/// <exception cref="System.IO.IOException"/> public virtual void TestReadCorrectlyRestrictedWithSecurity() { SecureIOUtils.OpenForRead(testFilePathIs, realOwner, realGroup).Close(); SecureIOUtils.OpenFSDataInputStream(testFilePathFadis, realOwner, realGroup).Close (); SecureIOUtils.OpenForRandomRead(testFilePathRaf, "r", realOwner, realGroup).Close (); }
// expected /// <exception cref="System.IO.IOException"/> public virtual void TestCreateForWrite() { try { SecureIOUtils.CreateForWrite(testFilePathIs, 0x1ff); NUnit.Framework.Assert.Fail("Was able to create file at " + testFilePathIs); } catch (SecureIOUtils.AlreadyExistsException) { } }
/// <exception cref="System.IO.IOException"/> public virtual void TestReadIncorrectlyRestrictedWithSecurity() { // this will only run if libs are available Assume.AssumeTrue(NativeIO.IsAvailable()); System.Console.Out.WriteLine("Running test with native libs..."); string invalidUser = "******"; // We need to make sure that forceSecure.. call works only if // the file belongs to expectedOwner. // InputStream try { SecureIOUtils.ForceSecureOpenForRead(testFilePathIs, invalidUser, realGroup).Close (); NUnit.Framework.Assert.Fail("Didn't throw expection for wrong user ownership!"); } catch (IOException) { } // expected // FSDataInputStream try { SecureIOUtils.ForceSecureOpenFSDataInputStream(testFilePathFadis, invalidUser, realGroup ).Close(); NUnit.Framework.Assert.Fail("Didn't throw expection for wrong user ownership!"); } catch (IOException) { } // expected // RandomAccessFile try { SecureIOUtils.ForceSecureOpenForRandomRead(testFilePathRaf, "r", invalidUser, realGroup ).Close(); NUnit.Framework.Assert.Fail("Didn't throw expection for wrong user ownership!"); } catch (IOException) { } }
/// <exception cref="System.IO.IOException"/> public virtual void TestReadUnrestricted() { SecureIOUtils.OpenForRead(testFilePathIs, null, null).Close(); SecureIOUtils.OpenFSDataInputStream(testFilePathFadis, null, null).Close(); SecureIOUtils.OpenForRandomRead(testFilePathRaf, "r", null, null).Close(); }