Beispiel #1
0
        public void DeleteEntriesForSubject_RetrieveAllEntries()
        {
            AclManagerBase manager = MockAclManager();

            Assert.IsTrue(manager.StoreEntry("Res", "Action", "U.User", Value.Grant), "StoreEntry should return true");
            Assert.IsTrue(manager.StoreEntry("Res", "Action", "G.Group", Value.Deny), "StoreEntry should return true");
            Assert.IsTrue(manager.StoreEntry("Res2", "Action2", "G.Group2", Value.Grant), "StoreEntry should return true");
            Assert.IsTrue(manager.StoreEntry("Res2", "Action3", "G.Group2", Value.Deny), "StoreEntry should return true");

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

            Assert.IsFalse(manager.DeleteEntriesForSubject("I.Inexistent"), "DeleteEntriesForSubject should return false");

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

            Assert.IsTrue(manager.DeleteEntriesForSubject("G.Group2"), "DeleteEntriesForSubject should return true");

            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("Res", "Action", "G.Group", Value.Deny), allEntries[0]);
            AssertAclEntriesAreEqual(new AclEntry("Res", "Action", "U.User", Value.Grant), allEntries[1]);
        }
        public void DeleteEntriesForSubject_Subject_Empty()
        {
            AclManagerBase manager = MockAclManager();
            var            ex      = Assert.Throws <ArgumentException>(() => manager.DeleteEntriesForSubject(""));

            Assert.Equal("Subject cannot be empty.\r\nParameter name: subject", ex.Message);
        }
        public void DeleteEntriesForSubject_Subject_Null()
        {
            AclManagerBase manager = MockAclManager();
            var            ex      = Assert.Throws <ArgumentNullException>(() => manager.DeleteEntriesForSubject(null));

            Assert.Equal("Value cannot be null.\r\nParameter name: subject", ex.Message);
        }
Beispiel #4
0
 public void DeleteEntriesForSubject_InvalidSubject_ShouldThrowArgumentException(string s)
 {
     Assert.Throws <ArgumentException>(() =>
     {
         AclManagerBase manager = MockAclManager();
         manager.DeleteEntriesForSubject(s);
     });
 }
Beispiel #5
0
        public void Event_AclChanged_DeleteEntriesForSubject()
        {
            AclManagerBase manager = MockAclManager();

            AclEntry entry = new AclEntry("Res", "Action", "U.User", Value.Grant);

            manager.StoreEntry(entry.Resource, entry.Action, entry.Subject, entry.Value);
            manager.StoreEntry("Res2", "Action", "G.Group", Value.Deny);

            bool invokedDelete = false;

            manager.AclChanged += delegate(object sender, AclChangedEventArgs e) {
                invokedDelete = true;
                Assert.AreEqual(1, e.Entries.Length, "Wrong entry count");
                AssertAclEntriesAreEqual(entry, e.Entries[0]);
                Assert.AreEqual(Change.EntryDeleted, e.Change, "Wrong change");
            };

            manager.DeleteEntriesForSubject(entry.Subject);

            Assert.IsTrue(invokedDelete, "Delete event not invoked");
        }
Beispiel #6
0
        public void DeleteEntriesForSubject_InvalidSubject(string s)
        {
            AclManagerBase manager = MockAclManager( );

            manager.DeleteEntriesForSubject(s);
        }