IamSecurityContextFactory extends AbstractSecurityContextFactory { @Override protected boolean isValid() { GatewayIdentity identity = getIdentitySafe(); String userArn = identity.getUserArn(); String user = identity.getUser(); if (userArn == null) { LOG.debug("userArn may not be null"); return false; } else if (user == null) { LOG.debug("user may not be null"); return false; } else { return true; } } protected  IamSecurityContextFactory(@Nonnull GatewayRequest request);   }
@Test public void isValid_NoUserArnAndUserAndCallerGiven_ShouldNotBeValid() { GatewayRequest request = createRequestMock("accessKey", null, null, null); assertFalse(createSecurityContextFactory(request).isValid()); }
@Test public void isValid_NoUserArnAndCallerGiven_ShouldNotBeValid() { GatewayRequest request = createRequestMock("accessKey", null, "user", null); assertFalse(createSecurityContextFactory(request).isValid()); }
@Test public void isValid_NoUserAndCallerGiven_ShouldNotBeValid() { GatewayRequest request = createRequestMock("accessKey", "userArn", null, null); assertFalse(createSecurityContextFactory(request).isValid()); }
@Test public void isValid_NoUserAndUserrGiven_ShouldNotBeValid() { GatewayRequest request = createRequestMock("accessKey", null, null, "caller"); assertFalse(createSecurityContextFactory(request).isValid()); }
@Test public void isValid_UserArnAndUserAndCallerGiven_ShouldBeValid() { GatewayRequest request = createRequestMock("accessKey", "userArn", "user", "caller"); assertTrue(createSecurityContextFactory(request).isValid()); }