public void AllActionsValidForResources(CRN resource, ResourceAction action)
        {
            // Arrange
            var storage           = new MockResourceStorage().Setup();
            var resourceValidator = new ResourceValidator(storage);

            // Act
            var result = resourceValidator.Validate(resource, action);

            // Assert
            result.IsValid.Should().BeTrue();
        }
        public void AllResourcesAreValid(Resource resource)
        {
            // Arrange
            var storage           = new MockResourceStorage().Setup();
            var resourceValidator = new ResourceValidator(storage);

            // Act
            var result = resourceValidator.Validate(resource.Identifier);

            // Assert
            result.IsValid.Should().BeTrue();
        }
        public void AllResourcesAreInvalid(CRN resource)
        {
            // Arrange
            var storage           = new MockResourceStorage().Setup();
            var resourceValidator = new ResourceValidator(storage);

            // Act
            var result = resourceValidator.Validate(resource);

            // Assert
            result.IsValid.Should().BeFalse();
        }
        public void FindResourcesByWildcard(CRN resource, IEnumerable <Resource> expectedResources)
        {
            // Arrange
            var storage        = new MockResourceStorage().Setup();
            var resourceFinder = new ResourceFinder(storage);

            // Act
            var result = resourceFinder.Find(resource);

            // Assert
            result.Should().BeEquivalentTo(expectedResources);
        }
        public void ResourceNotFound(CRN rn)
        {
            // Arrange
            var storage        = new MockResourceStorage().Setup();
            var resourceFinder = new ResourceFinder(storage);

            // Act
            var result = resourceFinder.Find(rn);

            // Assert
            result.Should().BeEmpty();
        }
        public void FindSpecificResource(CRN rn)
        {
            // Arrange
            var storage        = new MockResourceStorage().Setup();
            var resourceFinder = new ResourceFinder(storage);

            // Act
            var result = resourceFinder.Find(rn);

            // Assert
            result.Should().ContainSingle(r => r.Identifier == rn);
        }
Beispiel #7
0
        IPermissionValidator GetValidator()
        {
            var resourceStorage     = new MockResourceStorage().Setup();
            var permissionStorage   = new MockPermissionGrantStorage().Setup();
            var resourceFinder      = new ResourceFinder(resourceStorage);
            var resourceValidator   = new ResourceValidator(resourceStorage);
            var permissionFinder    = new PermissionGrantFinder(permissionStorage);
            var dataProviderStorage = new MockDataProviderStorage().Setup();
            var principalStorage    = new MockPrincipalStorage().Setup();
            var policyApplicator    = new DataProviderPolicyApplicator(dataProviderStorage, principalStorage);

            return(new PermissionValidator(resourceValidator, resourceFinder, permissionFinder, policyApplicator));
        }
        public PermissionGrantManagerTests()
        {
            var dataProviderStorage    = new MockDataProviderStorage().Setup();
            var principalStorage       = new MockPrincipalStorage().Setup();
            var applicator             = new DataProviderPolicyApplicator(dataProviderStorage, principalStorage);
            var permissionGrantStorage = new MockPermissionGrantStorage().Setup();
            var permissionGrantFinder  = new PermissionGrantFinder(permissionGrantStorage);
            var resourceStorage        = new MockResourceStorage().Setup();
            var resourceValidator      = new ResourceValidator(resourceStorage);
            var resourceFinder         = new ResourceFinder(resourceStorage);
            var validator = new PermissionValidator(resourceValidator, resourceFinder, permissionGrantFinder, applicator);

            this.manager = new PermissionGrantManager(applicator, permissionGrantStorage, validator, resourceStorage);
        }