IamSecurityContextFactory extends AbstractSecurityContextFactory { @Override protected boolean isApplicable() { GatewayIdentity identity = getIdentitySafe(); if (identity == null) { return false; } return identity.getAccessKey() != null; } protected  IamSecurityContextFactory(@Nonnull GatewayRequest request);   }
@Test public void isApplicable_NoContextGiven_ShouldNotBeApplicable() { GatewayRequest request = mock(GatewayRequest.class); assertFalse(createSecurityContextFactory(request).isApplicable()); }
@Test public void isApplicable_NoIdentityGiven_ShouldNotBeApplicable() { GatewayRequest request = mock(GatewayRequest.class); GatewayRequestContext context = mock(GatewayRequestContext.class); when(request.getRequestContext()).thenReturn(context); assertFalse(createSecurityContextFactory(request).isApplicable()); }
@Test public void isApplicable_NoAccessKeyGiven_ShouldNotBeApplicable() { GatewayRequest request = createRequestMock(null, null, null, null); assertFalse(createSecurityContextFactory(request).isApplicable()); }
@Test public void isApplicable_AccessKeyGiven_ShouldBeApplicable() { GatewayRequest request = createRequestMock("accessKey", null, null, null); assertTrue(createSecurityContextFactory(request).isApplicable()); }