Beispiel #1
0
        public async Task GetAuthorizationResult_WhenTheUserInRoleIsNotSupportConsole_ThenAuthorizedTheUser()
        {
            //Act
            var authorizationResult = await SutDefaultAuthorizationHandler.GetAuthorizationResult(Options, AuthorizationContext);

            //Assert
            authorizationResult.IsAuthorized.Should().Be(true);
        }
Beispiel #2
0
        public void GetAuthorizationResult_WhenTheUserIsConsoleUser_ThenAllowTheUserToViewTeamPage(string role)
        {
            //Arrange
            AuthorizationContextTestsFixture.SetData(_testAuthorizationResource.Value, role);

            //Act
            AuthorizationContextTestsFixture.AuthorizationContext.ToString();

            //Assert
            var authorizationResult = SutDefaultAuthorizationHandler.GetAuthorizationResult(Options, AuthorizationContextTestsFixture.AuthorizationContext);

            authorizationResult.Result.IsAuthorized.Should().Be(true);
        }
Beispiel #3
0
        public void GetAuthorizationResult_WhenTheUserInRoleINotSupportConsoleAndClaimsSet_ThenAuthorizedTheUser()
        {
            //Arrange
            AuthorizationContextTestsFixture.SetDataNotSupportConsoleUser();

            //Act
            AuthorizationContextTestsFixture.AuthorizationContext.ToString();

            //Assert
            var authorizationResult = SutDefaultAuthorizationHandler.GetAuthorizationResult(Options, AuthorizationContextTestsFixture.AuthorizationContext);

            authorizationResult.Result.IsAuthorized.Should().Be(true);
        }
Beispiel #4
0
        public void GetAuthorizationResult_WhenTheUserInRoleIsSupportConsoleAndResourceNotSet_ThenAuthorizedTheUser(string role)
        {
            //Arrange
            AuthorizationContextTestsFixture.SetDataSupportConsoleUserNoResource(role);

            _mockAuthenticationService.Setup(m => m.HasClaim(ClaimsIdentity.DefaultRoleClaimType, role)).Returns(true);

            //Act
            AuthorizationContextTestsFixture.AuthorizationContext.ToString();

            //Assert
            var authorizationResult = SutDefaultAuthorizationHandler.GetAuthorizationResult(Options, AuthorizationContextTestsFixture.AuthorizationContext);

            authorizationResult.Result.IsAuthorized.Should().Be(false);
        }