Пример #1
0
        public void RetrieveGrantsForDirectory_Sub_User()
        {
            var mocks      = new MockRepository();
            var prov       = mocks.DynamicMock <ISettingsStorageProviderV30>();
            var filesProv  = mocks.DynamicMock <IFilesStorageProviderV30>();
            var aclManager = mocks.DynamicMock <IAclManager>();

            Expect.Call(prov.AclManager).Return(aclManager).Repeat.Any();

            var dirName = Actions.ForDirectories.ResourceMasterPrefix +
                          AuthTools.GetDirectoryName(filesProv, "/Dir/Sub/");

            Expect.Call(aclManager.RetrieveEntriesForSubject("U.User")).Return(
                new[]
            {
                new AclEntry(dirName, Actions.ForDirectories.UploadFiles, "U.User", Value.Grant),
                new AclEntry(dirName, Actions.FullControl, "U.User", Value.Deny),
                new AclEntry("D." + AuthTools.GetDirectoryName(filesProv, "/"), Actions.ForDirectories.List,
                             "U.User", Value.Grant)
            });

            mocks.Replay(prov);
            mocks.Replay(aclManager);

            Collectors.SettingsProvider = prov;

            var grants =
                AuthReader.RetrieveGrantsForDirectory(
                    new UserInfo("User", "User", "*****@*****.**", true, DateTime.Now, null),
                    filesProv, "/Dir/Sub/");

            Assert.AreEqual(1, grants.Length, "Wrong grant count");
            Assert.AreEqual(Actions.ForDirectories.UploadFiles, grants[0], "Wrong grant");
        }
Пример #2
0
        public void RetrieveGrantsForDirectory_Group_InvalidDirectory(string d)
        {
            Collectors.SettingsProvider = MockProvider();

            var fProv = mocks.DynamicMock <IFilesStorageProviderV30>();

            mocks.Replay(fProv);
            AuthReader.RetrieveGrantsForDirectory(new UserGroup("Group", "Group", null), fProv, d);
        }
Пример #3
0
        public void RetrieveGrantsForDirectory_User_InvalidDirectory(string d)
        {
            Collectors.SettingsProvider = MockProvider();

            var fProv = mocks.DynamicMock <IFilesStorageProviderV30>();

            mocks.Replay(fProv);
            AuthReader.RetrieveGrantsForDirectory(
                new UserInfo("User", "User", "*****@*****.**", true, DateTime.Now, null), fProv, d);
        }