public void ThenReturnsFalseIfProviderUkprnNotInRoute( ProviderUkPrnRequirement requirement, AuthorizationFilterContext contextFilter, ProviderAuthorizationHandler handler) { //Assign var claim = new Claim(ProviderClaims.ProviderUkprn, "1234"); var claimsPrinciple = new ClaimsPrincipal(new[] { new ClaimsIdentity(new[] { claim }) }); var context = new AuthorizationHandlerContext(new[] { requirement }, claimsPrinciple, contextFilter); //Act var result = handler.IsProviderAuthorised(context); //Assert Assert.IsFalse(result); }
public void ThenReturnsFalseIfUserDoesNotHaveMatchingUkprnInClaim( ProviderUkPrnRequirement requirement, AuthorizationFilterContext contextFilter, ProviderAuthorizationHandler handler) { //Assign var claim = new Claim(ProviderClaims.ProviderUkprn, "5555"); var claimsPrinciple = new ClaimsPrincipal(new[] { new ClaimsIdentity(new[] { claim }) }); var context = new AuthorizationHandlerContext(new[] { requirement }, claimsPrinciple, contextFilter); var filter = context.Resource as AuthorizationFilterContext; filter.RouteData.Values.Add(RouteValues.UkPrn, 1234); //Act var result = handler.IsProviderAuthorised(context); //Assert Assert.IsFalse(result); }