use of org.cloudfoundry.identity.uaa.zone.IdentityZoneProvisioning in project uaa by cloudfoundry.
the class TokenMvcMockTests method testDefaultZone_Jwt_Revocable.
@Test
void testDefaultZone_Jwt_Revocable() throws Exception {
IdentityZoneProvisioning zoneProvisioning = webApplicationContext.getBean(IdentityZoneProvisioning.class);
IdentityZone defaultZone = zoneProvisioning.retrieve(IdentityZone.getUaaZoneId());
try {
defaultZone.getConfig().getTokenPolicy().setJwtRevocable(true);
zoneProvisioning.update(defaultZone);
Map<String, String> parameters = new HashedMap();
Map<String, Object> tokenResponse = testRevocablePasswordGrantTokenForDefaultZone(parameters);
validateRevocableJwtToken(tokenResponse, defaultZone);
} finally {
defaultZone.getConfig().getTokenPolicy().setJwtRevocable(false);
zoneProvisioning.update(defaultZone);
}
}
use of org.cloudfoundry.identity.uaa.zone.IdentityZoneProvisioning in project uaa by cloudfoundry.
the class TokenMvcMockTests method testNonDefaultZone_Jwt_Revocable.
@Test
void testNonDefaultZone_Jwt_Revocable() throws Exception {
String username = generator.generate() + "@test.org";
String subdomain = "testzone" + generator.generate();
String clientId = "testclient" + generator.generate();
createNonDefaultZone(username, subdomain, clientId);
IdentityZoneProvisioning zoneProvisioning = webApplicationContext.getBean(IdentityZoneProvisioning.class);
IdentityZone defaultZone = zoneProvisioning.retrieveBySubdomain(subdomain);
try {
defaultZone.getConfig().getTokenPolicy().setJwtRevocable(true);
zoneProvisioning.update(defaultZone);
MockHttpServletRequestBuilder post = post("/oauth/token").with(httpBasic(clientId, SECRET)).header("Host", subdomain + ".localhost").param("username", username).param("password", "secret").param(OAuth2Utils.GRANT_TYPE, "password").param(OAuth2Utils.CLIENT_ID, clientId);
Map<String, Object> tokenResponse = JsonUtils.readValue(mockMvc.perform(post).andDo(print()).andExpect(status().isOk()).andReturn().getResponse().getContentAsString(), new TypeReference<Map<String, Object>>() {
});
validateRevocableJwtToken(tokenResponse, defaultZone);
} finally {
defaultZone.getConfig().getTokenPolicy().setJwtRevocable(false);
zoneProvisioning.update(defaultZone);
}
}
use of org.cloudfoundry.identity.uaa.zone.IdentityZoneProvisioning in project uaa by cloudfoundry.
the class MockMvcUtils method getZoneConfiguration.
public static IdentityZoneConfiguration getZoneConfiguration(ApplicationContext context, String zoneId) {
IdentityZoneProvisioning provisioning = context.getBean(IdentityZoneProvisioning.class);
IdentityZone uaaZone = provisioning.retrieve(zoneId);
return uaaZone.getConfig();
}
use of org.cloudfoundry.identity.uaa.zone.IdentityZoneProvisioning in project uaa by cloudfoundry.
the class MockMvcUtils method setZoneConfiguration.
public static void setZoneConfiguration(ApplicationContext context, String zoneId, IdentityZoneConfiguration configuration) {
IdentityZoneProvisioning provisioning = context.getBean(IdentityZoneProvisioning.class);
IdentityZone uaaZone = provisioning.retrieve(zoneId);
uaaZone.setConfig(configuration);
provisioning.update(uaaZone);
}
use of org.cloudfoundry.identity.uaa.zone.IdentityZoneProvisioning in project uaa by cloudfoundry.
the class KeyInfoServiceTests method configureDefaultZoneKeys.
private void configureDefaultZoneKeys(Map<String, String> keys) {
IdentityZoneHolder.clear();
IdentityZoneProvisioning provisioning = mock(IdentityZoneProvisioning.class);
IdentityZoneHolder.setProvisioning(provisioning);
IdentityZone zone = IdentityZone.getUaa();
IdentityZoneConfiguration config = new IdentityZoneConfiguration();
TokenPolicy tokenPolicy = new TokenPolicy();
tokenPolicy.setKeys(keys);
config.setTokenPolicy(tokenPolicy);
zone.setConfig(config);
when(provisioning.retrieve("uaa")).thenReturn(zone);
}
Aggregations