Exemplo n.º 1
0
        public void Delete_LoadData()
        {
            IAclManager manager = MockAclManager();

            AclStorer storer = new AclStorer(manager, testFile);

            manager.StoreEntry("Res1", "Action1", "U.User", Value.Grant);
            manager.StoreEntry("Res2", "Action2", "G.Group", Value.Deny);
            manager.StoreEntry("Res3", "Action1", "U.User", Value.Grant);
            manager.StoreEntry("Res3", "Action2", "G.Group", Value.Deny);

            manager.DeleteEntriesForResource("Res3");

            storer.Dispose();
            storer = null;

            manager = MockAclManager();

            storer = new AclStorer(manager, testFile);
            storer.LoadData();

            Assert.AreEqual(2, manager.TotalEntries, "Wrong entry count");

            AclEntry[] allEntries = manager.RetrieveAllEntries();
            Assert.AreEqual(2, allEntries.Length, "Wrong entry count");

            Array.Sort(allEntries, delegate(AclEntry x, AclEntry y) { return(x.Subject.CompareTo(y.Subject)); });
            AssertAclEntriesAreEqual(new AclEntry("Res2", "Action2", "G.Group", Value.Deny), allEntries[0]);
            AssertAclEntriesAreEqual(new AclEntry("Res1", "Action1", "U.User", Value.Grant), allEntries[1]);
        }
Exemplo n.º 2
0
        public void Overwrite_LoadData()
        {
            IAclManager manager = MockAclManager();

            AclStorer storer = new AclStorer(manager, testFile);

            manager.StoreEntry("Res1", "Action1", "U.User", Value.Grant);
            manager.StoreEntry("Res2", "Action2", "G.Group", Value.Grant);
            manager.StoreEntry("Res2", "Action2", "G.Group", Value.Deny); // Overwrite

            storer.Dispose();
            storer = null;

            manager = MockAclManager();

            storer = new AclStorer(manager, testFile);
            storer.LoadData();

            Assert.AreEqual(2, manager.TotalEntries, "Wrong entry count");

            AclEntry[] allEntries = manager.RetrieveAllEntries();
            Assert.AreEqual(2, allEntries.Length, "Wrong entry count");

            Array.Sort(allEntries, delegate(AclEntry x, AclEntry y) { return x.Subject.CompareTo(y.Subject); });
            AssertAclEntriesAreEqual(new AclEntry("Res2", "Action2", "G.Group", Value.Deny), allEntries[0]);
            AssertAclEntriesAreEqual(new AclEntry("Res1", "Action1", "U.User", Value.Grant), allEntries[1]);
        }
Exemplo n.º 3
0
        public void Constructor()
        {
            IAclManager manager = MockAclManager();

            AclStorer storer = new AclStorer(manager, testFile);
            Assert.AreSame(manager, storer.AclManager, "Wrong ACL Manager instance");
        }
Exemplo n.º 4
0
 public void Constructor_InvalidFile_ShouldThrowArgumentException(string f)
 {
     Assert.Throws <ArgumentException>(() =>
     {
         AclStorer storer = new AclStorer(MockAclManager(), f);
     });
 }
Exemplo n.º 5
0
 public void Constructor_NullAclManager()
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         AclStorer storer = new AclStorer(null, testFile);
     });
 }
Exemplo n.º 6
0
        public void Constructor()
        {
            IAclManager manager = MockAclManager();

            AclStorer storer = new AclStorer(manager, testFile);

            Assert.AreSame(manager, storer.AclManager, "Wrong ACL Manager instance");
        }
Exemplo n.º 7
0
 public void Constructor_InvalidFile(string f)
 {
     AclStorer storer = new AclStorer(MockAclManager(), f);
 }
Exemplo n.º 8
0
 public void Constructor_NullAclManager()
 {
     AclStorer storer = new AclStorer(null, testFile);
 }
Exemplo n.º 9
0
 public void Constructor_NullAclManager()
 {
     AclStorer storer = new AclStorer(null, testFile);
 }
Exemplo n.º 10
0
 public void Constructor_InvalidFile(string f)
 {
     AclStorer storer = new AclStorer(MockAclManager(), f);
 }