New test.
[mono.git] / mono / tests / cas / linkdemand / noncas1.cs
1 using System;
2 using System.Security;
3 using System.Security.Permissions;
4 using System.Security.Principal;
5 using System.Threading;
6
7 [PrincipalPermission (SecurityAction.LinkDemand, Authenticated=false)]
8 public class LinkDemand {
9
10         static public int Test () 
11         {
12                 Console.WriteLine ("*0* [this should print]");
13                 return 0;
14         }
15 }
16
17 class LinkDemandTest {
18
19         static int Test ()
20         {
21                 GenericIdentity identity = new GenericIdentity ("me");
22                 string[] roles = new string [1] { "mono hacker" };
23                 Thread.CurrentPrincipal = new GenericPrincipal (identity, roles);
24
25                 return LinkDemand.Test ();
26         }
27
28         [STAThread]
29         static int Main (string[] args)
30         {
31                 try {
32                         return Test ();
33                 }
34                 catch (SecurityException se) {
35                         Console.WriteLine ("*1* Unexpected SecurityException\n{0}", se);
36                         return 1;
37                 }
38                 catch (Exception e) {
39                         Console.WriteLine ("*2* Unexpected Exception\n{0}", e);
40                         return 2;
41                 }
42         }
43 }
44