Merge pull request #3522 from henricm/fix-csharp-compiler-path-windows
[mono.git] / mcs / class / corlib / Test / System.Security.AccessControl / FileSecurityTest.cs
index 513bd0db1cbba3674a1b6707a961f6afa7ce4ed6..0723d17161109a03f0d53cf8cc7b7ff7a4527f79 100644 (file)
@@ -19,7 +19,7 @@ namespace MonoTests.System.Security.AccessControl
                {
                        FileSecurity security;
                        if (PlatformID.Win32NT != Environment.OSVersion.Platform) {
-                               Assert.Ignore (); return;
+                               Assert.Ignore ();
                        }
 
                        string path = Path.GetTempFileName ();
@@ -42,7 +42,7 @@ namespace MonoTests.System.Security.AccessControl
                {
                        FileSecurity security;
                        if (PlatformID.Win32NT != Environment.OSVersion.Platform) {
-                               Assert.Ignore (); return;
+                               Assert.Ignore ();
                        }
 
                        string path = Path.GetTempFileName ();
@@ -90,7 +90,7 @@ namespace MonoTests.System.Security.AccessControl
                {
                        FileSecurity security;
                        if (PlatformID.Win32NT != Environment.OSVersion.Platform) {
-                               Assert.Ignore (); return;
+                               Assert.Ignore ();
                        }
 
                        string path = Path.GetTempFileName ();
@@ -98,6 +98,13 @@ namespace MonoTests.System.Security.AccessControl
                                security = File.GetAccessControl (path);
                                security.SetOwner (new SecurityIdentifier ("WD"));
                                File.SetAccessControl (path, security);
+                               // If we don't get an InvalidOperationException it could be that we are running
+                               // with administrator privileges. Don't fail the test if that is the case.
+                               WindowsIdentity identity = WindowsIdentity.GetCurrent ();
+                               WindowsPrincipal principal = new WindowsPrincipal (identity);
+                               if (principal.IsInRole (WindowsBuiltInRole.Administrator)) {
+                                       Assert.Ignore ("Running as Administrator");
+                               }
                        } finally {
                                File.Delete (path);
                        }