Esempio n. 1
0
        public async Task WhenPassNullResource_AndHasNoPermissions_ShouldSucceed()
        {
            // Arrange
            string                      userId      = Guid.NewGuid().ToString();
            ClaimsPrincipal             principal   = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(Constants.ObjectIdentifierClaimType, userId) }));
            AuthorizationHandlerContext authContext = CreateAuthenticationContext(principal, SpecificationActionTypes.CanApproveFunding, null);

            AlwaysAllowedPermissionHandler authHandler = new AlwaysAllowedPermissionHandler();

            // Act
            await authHandler.HandleAsync(authContext);

            // Assert
            authContext.HasSucceeded.Should().BeTrue();
        }
Esempio n. 2
0
        public async Task WhenUserIsNotKnown_ShouldSucceed()
        {
            // Arrange
            ClaimsPrincipal principal = new ClaimsPrincipal(new ClaimsIdentity());
            ISpecificationAuthorizationEntity spec        = Substitute.For <ISpecificationAuthorizationEntity>();
            AuthorizationHandlerContext       authContext = CreateAuthenticationContext(principal, SpecificationActionTypes.CanApproveFunding, spec);

            AlwaysAllowedPermissionHandler authHandler = new AlwaysAllowedPermissionHandler();

            // Act
            await authHandler.HandleAsync(authContext);

            // Assert
            authContext.HasSucceeded.Should().BeTrue();
        }