3 // - CAS unit tests for System.Web.SessionState.StateRuntime
6 // Sebastien Pouliot <sebastien@ximian.com>
8 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using NUnit.Framework;
33 using System.Reflection;
34 using System.Security;
35 using System.Security.Permissions;
37 using System.Web.SessionState;
39 namespace MonoCasTests.System.Web.SessionState {
41 // note: the execution order (not user controlable) is very important
42 // for the tests to execute properly. However the tests are protected
43 // not to report errors if the order isn't repected.
47 public class StateRuntimeCas : AspNetHostingMinimal {
49 private StateRuntime runtime;
52 public void FixtureSetUp ()
55 // ensure that the static ctor has been called
56 runtime = new StateRuntime ();
63 [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
64 [ExpectedException (typeof (SecurityException))]
65 public void Constructor_Deny_UnmanagedCode ()
70 catch (TypeInitializationException) {
71 Assert.Ignore ("fails on MS");
76 [AspNetHostingPermission (SecurityAction.Deny, Level = AspNetHostingPermissionLevel.Minimal)]
78 [ExpectedException (typeof (SecurityException))]
80 public void Constructor_Deny_Minimal ()
85 catch (TypeInitializationException) {
86 Assert.Ignore ("fails on MS");
92 [AspNetHostingPermission (SecurityAction.PermitOnly, Level = AspNetHostingPermissionLevel.Minimal)]
94 [SecurityPermission (SecurityAction.PermitOnly, UnmanagedCode = true)]
95 public void Constructor_PermitOnly_UnmanagedCodeMinimal ()
100 catch (TypeInitializationException) {
101 Assert.Ignore ("fails on MS");
106 [AspNetHostingPermission (SecurityAction.PermitOnly, Level = AspNetHostingPermissionLevel.Medium)]
107 public void ProcessRequest9_PermitOnly_Medium ()
110 Assert.Ignore ("impossible to instantiate under MS");
113 runtime.ProcessRequest (IntPtr.Zero, 0, null, 0, 0, 0, 0, 0, IntPtr.Zero);
115 catch (NullReferenceException) {
118 catch (DllNotFoundException) {
121 catch (NotImplementedException) {
127 [AspNetHostingPermission (SecurityAction.Deny, Level = AspNetHostingPermissionLevel.Medium)]
128 [ExpectedException (typeof (SecurityException))]
129 public void ProcessRequest9_Deny_Medium ()
132 Assert.Ignore ("impossible to instantiate under MS");
134 runtime.ProcessRequest (IntPtr.Zero, 0, null, 0, 0, 0, 0, 0, IntPtr.Zero);
138 [AspNetHostingPermission (SecurityAction.PermitOnly, Level = AspNetHostingPermissionLevel.Medium)]
139 public void ProcessRequest10_PermitOnly_Medium ()
142 Assert.Ignore ("impossible to instantiate under MS");
145 runtime.ProcessRequest (IntPtr.Zero, 0, null, 0, 0, 0, 0, 0, 0, IntPtr.Zero);
147 catch (DllNotFoundException) {
150 catch (NotImplementedException) {
156 [AspNetHostingPermission (SecurityAction.Deny, Level = AspNetHostingPermissionLevel.Medium)]
157 [ExpectedException (typeof (SecurityException))]
158 public void ProcessRequest10_Deny_Medium ()
161 Assert.Ignore ("impossible to instantiate under MS");
163 runtime.ProcessRequest (IntPtr.Zero, 0, null, 0, 0, 0, 0, 0, 0, IntPtr.Zero);
168 [SecurityPermission (SecurityAction.PermitOnly, UnmanagedCode = true)]
169 [Category ("NotDotNet")] // freeze
170 public void StopProcessing_PermitOnly_UnmanagedCode ()
173 Assert.Ignore ("impossible to instantiate under MS");
176 runtime.StopProcessing ();
178 catch (SecurityException se) {
179 Console.WriteLine (se);
181 catch (NotImplementedException) {
187 [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
188 [ExpectedException (typeof (SecurityException))]
189 public void StopProcessing_Deny_UnmanagedCode ()
192 Assert.Ignore ("may not be possible to instantiate under MS (run-order)");
194 runtime.StopProcessing ();
199 [SecurityPermission (SecurityAction.Assert, UnmanagedCode = true)]
200 public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
203 return base.CreateControl (action, level);
205 catch (TypeInitializationException) {
206 // ctor can't be called more than once (else it throws TIE)
211 public override Type Type {
212 get { return typeof (StateRuntime); }