CognitoUserPoolSecurityContextFactory extends AbstractSecurityContextFactory { @Override protected boolean isApplicable() { return getRawClaimsSafe() != null; } protected  CognitoUserPoolSecurityContextFactory(@Nonnull GatewayRequest request);   }
@Test public void isApplicable_NoContextGiven_ShouldNotBeApplicable() { GatewayRequest request = mock(GatewayRequest.class); assertFalse(createSecurityContextFactory(request).isApplicable()); }
@Test public void isApplicable_NoAuthorizerGiven_ShouldNotBeApplicable() { GatewayRequestContext context = mock(GatewayRequestContext.class); when(context.getAuthorizer()).thenReturn(null); GatewayRequest request = mock(GatewayRequest.class); when(request.getRequestContext()).thenReturn(context); assertFalse(createSecurityContextFactory(request).isApplicable()); }
@Test public void isApplicable_NoClaimsGiven_ShouldNotBeApplicable() { GatewayRequestContext context = mock(GatewayRequestContext.class); when(context.getAuthorizer()).thenReturn(Collections.emptyMap()); GatewayRequest request = mock(GatewayRequest.class); when(request.getRequestContext()).thenReturn(context); assertFalse(createSecurityContextFactory(request).isApplicable()); }
@Test public void isApplicable_InvalidClaimsGiven_ShouldBeApplicable() { GatewayRequest request = createRequestMock(null, null); assertTrue(createSecurityContextFactory(request).isApplicable()); }
@Test public void isApplicable_ValidClaimsGiven_ShouldBeApplicable() { GatewayRequest request = createRequestMock("subClaim", null); assertTrue(createSecurityContextFactory(request).isApplicable()); }