@Test public void testCreateExternalGroupMapUsingNameAlreadyExists() throws Exception { String displayName = "internal.read"; String externalGroup = "cn=developers,ou=scopes,dc=test,dc=com"; ResultActions result = createGroup(null, displayName, externalGroup); //we don't throw in JdbcScimGroupExternalMembershipManager.java //result.andExpect(status().isConflict()); result.andExpect(status().isCreated()); }
@Test public void createServiceProvider() throws Exception { performCreateServiceProvider() .andExpect(status().isCreated()); }
@Test void testCreateClientWithJwtBearerGrant() throws Exception { String id = new RandomValueStringGenerator().generate(); ClientDetails client = createBaseClient(id, SECRET, Collections.singletonList(GRANT_TYPE_JWT_BEARER), null, Collections.singletonList(id + ".read")); MockHttpServletRequestBuilder createClientPost = post("/oauth/clients") .header("Authorization", "Bearer " + adminToken) .accept(APPLICATION_JSON) .contentType(APPLICATION_JSON) .content(JsonUtils.writeValueAsString(client)); mockMvc.perform(createClientPost).andExpect(status().isCreated()).andReturn(); verify(mockApplicationEventPublisher, times(1)).publishEvent(abstractUaaEventCaptor.capture()); }
@Test void userEndpointCreateAllowed_For_Origin_LDAP() throws Exception { MockMvcUtils.setDisableInternalUserManagement(true, webApplicationContext); ResultActions result = createUser(OriginKeys.LDAP); result.andExpect(status().isCreated()); }
private ClientDetails createClientAdminsClient(String token) throws Exception { List<String> scopes = Arrays.asList("oauth.approvals", "clients.admin"); BaseClientDetails client = createBaseClient(null, SECRET, Arrays.asList("password", "client_credentials"), scopes, scopes); MockHttpServletRequestBuilder createClientPost = post("/oauth/clients") .header("Authorization", "Bearer " + token) .accept(APPLICATION_JSON) .contentType(APPLICATION_JSON) .content(JsonUtils.writeValueAsString(client)); mockMvc.perform(createClientPost).andExpect(status().isCreated()); return getClient(client.getClientId()); }
private ClientDetails createReadWriteClient(String token) throws Exception { List<String> scopes = Arrays.asList("oauth.approvals", "clients.read", "clients.write"); BaseClientDetails client = createBaseClient(null, SECRET, Arrays.asList("password", "client_credentials"), scopes, scopes); MockHttpServletRequestBuilder createClientPost = post("/oauth/clients") .header("Authorization", "Bearer " + token) .accept(APPLICATION_JSON) .contentType(APPLICATION_JSON) .content(JsonUtils.writeValueAsString(client)); mockMvc.perform(createClientPost).andExpect(status().isCreated()); return getClient(client.getClientId()); }
private ClientDetails createAdminClient(String token) throws Exception { List<String> scopes = Arrays.asList("uaa.admin", "oauth.approvals", "clients.read", "clients.write"); BaseClientDetails client = createBaseClient(null, SECRET, Arrays.asList("password", "client_credentials"), scopes, scopes); MockHttpServletRequestBuilder createClientPost = post("/oauth/clients") .header("Authorization", "Bearer " + token) .accept(APPLICATION_JSON) .contentType(APPLICATION_JSON) .content(JsonUtils.writeValueAsString(client)); mockMvc.perform(createClientPost).andExpect(status().isCreated()); return getClient(client.getClientId()); }
private ClientDetails createApprovalsLoginClient(String token) throws Exception { List<String> scopes = Arrays.asList("uaa.admin", "oauth.approvals", "oauth.login"); BaseClientDetails client = createBaseClient(null, SECRET, Arrays.asList("password", "client_credentials"), scopes, scopes); MockHttpServletRequestBuilder createClientPost = post("/oauth/clients") .header("Authorization", "Bearer " + token) .accept(APPLICATION_JSON) .contentType(APPLICATION_JSON) .content(JsonUtils.writeValueAsString(client)); mockMvc.perform(createClientPost).andExpect(status().isCreated()); return getClient(client.getClientId()); }
private BaseClientDetails createClient(List<String> authorities) throws Exception { String clientId = generator.generate().toLowerCase(); List<String> scopes = Arrays.asList("foo", "bar", "oauth.approvals"); ClientDetailsModification client = createBaseClient(clientId, SECRET, Collections.singleton("client_credentials"), authorities, scopes); MockHttpServletRequestBuilder createClientPost = post("/oauth/clients") .header("Authorization", "Bearer " + adminUserToken) .accept(APPLICATION_JSON) .contentType(APPLICATION_JSON) .content(JsonUtils.writeValueAsString(client)); ResultActions createResult = mockMvc.perform(createClientPost).andExpect(status().isCreated()); return JsonUtils.readValue(createResult.andReturn().getResponse().getContentAsString(), BaseClientDetails.class); }
private ResultActions createClientHelper() throws Exception { return mockMvc.perform(post("/oauth/clients") .header("Authorization", "Bearer " + clientAdminToken) .contentType(APPLICATION_JSON) .accept(APPLICATION_JSON) .content(writeValueAsString( createBasicClientWithAdditionalInformation(Arrays.asList("clients.read", "clients.write")) ))) .andExpect(status().isCreated()); }
private void postUserAndExpectSame(String userJson) throws Exception { mockMvc.perform( post("/user") .contentType(MediaType.APPLICATION_JSON_UTF8) .content(userJson) ).andExpect(status().isCreated()).andExpect(content().json(userJson)); } }
private ResultActions createScimGroupHelper(ScimGroup scimGroup) throws Exception { MockHttpServletRequestBuilder post = post("/Groups") .header("Authorization", "Bearer " + scimWriteToken) .contentType(APPLICATION_JSON) .content(serializeWithoutMeta(scimGroup)); return mockMvc.perform(post).andExpect(status().isCreated()); }
@Test public void duplicateServiceProvider_isConflict() throws Exception { performCreateServiceProvider() .andExpect(status().isCreated()); performCreateServiceProvider() .andExpect(status().isConflict()); }
private String requestExpiringCode(String email, String token) throws Exception { MockHttpServletRequestBuilder resetPasswordPost = post("/password_resets") .accept(APPLICATION_JSON_VALUE) .contentType(MediaType.APPLICATION_JSON) .header("Authorization", "Bearer " + token) .content(email); MvcResult mvcResult = mockMvc.perform(resetPasswordPost) .andExpect(status().isCreated()).andReturn(); return JsonUtils.readValue(mvcResult.getResponse().getContentAsString(), new TypeReference<Map<String, String>>() { }).get("code"); }
@Test void test_InZone_ClientWrite_Using_ZonesDotAdmin() throws Exception { String subdomain = generator.generate(); MockMvcUtils.IdentityZoneCreationResult result = MockMvcUtils.createOtherIdentityZoneAndReturnResult(subdomain, mockMvc, webApplicationContext, null); String clientId = generator.generate(); BaseClientDetails client = new BaseClientDetails(clientId, "", "openid", GRANT_TYPE_AUTHORIZATION_CODE, "", "http://some.redirect.url.com"); client.setClientSecret("secret"); MockMvcUtils.createClient(mockMvc, result.getZoneAdminToken(), client, result.getIdentityZone(), status().isCreated()); }
public static IdentityZone createZoneUsingWebRequest(MockMvc mockMvc, String accessToken) throws Exception { final String zoneId = new RandomValueStringGenerator(12).generate().toLowerCase(); IdentityZone identityZone = MultitenancyFixture.identityZone(zoneId, zoneId); MvcResult result = mockMvc.perform(post("/identity-zones") .header("Authorization", "Bearer " + accessToken) .contentType(APPLICATION_JSON) .content(JsonUtils.writeValueAsString(identityZone))) .andExpect(status().isCreated()).andReturn(); return JsonUtils.readValue(result.getResponse().getContentAsString(), IdentityZone.class); }
protected ClientDetails createClient(String token, String id, String clientSecret, Collection<String> grantTypes) throws Exception { BaseClientDetails client = createBaseClient(id, clientSecret, grantTypes); MockHttpServletRequestBuilder createClientPost = post("/oauth/clients") .header("Authorization", "Bearer " + token) .accept(APPLICATION_JSON) .contentType(APPLICATION_JSON) .content(toString(client)); mockMvc.perform(createClientPost).andExpect(status().isCreated()); return getClient(client.getClientId()); }
protected ClientDetails createClient(String token, String id, String clientSecret, Collection<String> grantTypes) throws Exception { BaseClientDetails client = createBaseClient(id, clientSecret, grantTypes); MockHttpServletRequestBuilder createClientPost = post("/oauth/clients") .header("Authorization", "Bearer " + token) .accept(APPLICATION_JSON) .contentType(APPLICATION_JSON) .content(JsonUtils.writeValueAsString(client)); mockMvc.perform(createClientPost).andExpect(status().isCreated()); return getClient(client.getClientId()); }
@Test void test_InZone_ClientWrite_Success_with_Complex_Secret_Policy() throws Exception { String subdomain = generator.generate(); MockMvcUtils.IdentityZoneCreationResult result = MockMvcUtils.createOtherIdentityZoneAndReturnResult(subdomain, mockMvc, webApplicationContext, null); result.getIdentityZone().getConfig().setClientSecretPolicy(new ClientSecretPolicy(6, 255, 1, 1, 1, 1, 6)); MockMvcUtils.setZoneConfiguration(webApplicationContext, result.getIdentityZone().getId(), result.getIdentityZone().getConfig()); String clientId = generator.generate(); BaseClientDetails client = new BaseClientDetails(clientId, "", "openid", GRANT_TYPE_AUTHORIZATION_CODE, "", "http://sample.redirect"); client.setClientSecret("Secret1@"); MockMvcUtils.createClient(mockMvc, result.getZoneAdminToken(), client, result.getIdentityZone(), status().isCreated()); }