public void CheckCanAccessExternalArea_ReturnsFalse_WhenUserHasNoClaims() { // Arrange WeeeContext weeeContext = A.Fake <WeeeContext>(); ClaimsPrincipal principal = new ClaimsPrincipal(); IUserContext userContext = A.Fake <IUserContext>(); A.CallTo(() => userContext.Principal).Returns(principal); WeeeAuthorization authorization = new WeeeAuthorization(weeeContext, userContext); // Act bool result = authorization.CheckCanAccessExternalArea(); // Assert Assert.Equal(false, result); }
public void CheckCanAccessExternalArea_ReturnsTrue_WhenUserHasRequiredClaim() { // Arrange WeeeContext weeeContext = A.Fake <WeeeContext>(); ClaimsIdentity identity = new ClaimsIdentity(); identity.AddClaim(new Claim(ClaimTypes.AuthenticationMethod, Claims.CanAccessExternalArea)); ClaimsPrincipal principal = new ClaimsPrincipal(identity); IUserContext userContext = A.Fake <IUserContext>(); A.CallTo(() => userContext.Principal).Returns(principal); WeeeAuthorization authorization = new WeeeAuthorization(weeeContext, userContext); // Act bool result = authorization.CheckCanAccessExternalArea(); // Assert Assert.Equal(true, result); }
public void CheckCanAccessExternalArea_ReturnsTrue_WhenUserHasRequiredClaim() { // Arrange WeeeContext weeeContext = A.Fake<WeeeContext>(); ClaimsIdentity identity = new ClaimsIdentity(); identity.AddClaim(new Claim(ClaimTypes.AuthenticationMethod, Claims.CanAccessExternalArea)); ClaimsPrincipal principal = new ClaimsPrincipal(identity); IUserContext userContext = A.Fake<IUserContext>(); A.CallTo(() => userContext.Principal).Returns(principal); WeeeAuthorization authorization = new WeeeAuthorization(weeeContext, userContext); // Act bool result = authorization.CheckCanAccessExternalArea(); // Assert Assert.Equal(true, result); }
public void CheckCanAccessExternalArea_ReturnsFalse_WhenUserHasNoClaims() { // Arrange WeeeContext weeeContext = A.Fake<WeeeContext>(); ClaimsPrincipal principal = new ClaimsPrincipal(); IUserContext userContext = A.Fake<IUserContext>(); A.CallTo(() => userContext.Principal).Returns(principal); WeeeAuthorization authorization = new WeeeAuthorization(weeeContext, userContext); // Act bool result = authorization.CheckCanAccessExternalArea(); // Assert Assert.Equal(false, result); }