use of org.apache.cxf.rs.security.oauth2.services.ClientRegistration in project cxf by apache.
the class OIDCDynamicRegistrationTest method testRegisterClientPasswordGrant.
@org.junit.Test
public void testRegisterClientPasswordGrant() throws Exception {
URL busFile = OIDCDynamicRegistrationTest.class.getResource("client.xml");
String address = "https://localhost:" + PORT + "/services/dynamicWithAt/register";
WebClient wc = WebClient.create(address, Collections.singletonList(new JsonMapObjectProvider()), busFile.toString());
wc.accept("application/json").type("application/json");
ClientRegistration reg = new ClientRegistration();
reg.setClientName("dynamic_client");
reg.setGrantTypes(Collections.singletonList(OAuthConstants.RESOURCE_OWNER_GRANT));
wc.authorization(new ClientAccessToken("Bearer", "123456789"));
ClientRegistrationResponse resp = wc.post(reg, ClientRegistrationResponse.class);
assertNotNull(resp.getClientId());
assertNotNull(resp.getClientSecret());
assertEquals(address + "/" + resp.getClientId(), resp.getRegistrationClientUri());
String regAccessToken = resp.getRegistrationAccessToken();
assertNotNull(regAccessToken);
wc.reset();
wc.path(resp.getClientId());
wc.authorization(new ClientAccessToken("Bearer", regAccessToken));
ClientRegistration clientRegResp = wc.get(ClientRegistration.class);
assertEquals("web", clientRegResp.getApplicationType());
assertEquals("dynamic_client", clientRegResp.getClientName());
assertEquals(Collections.singletonList(OAuthConstants.RESOURCE_OWNER_GRANT), clientRegResp.getGrantTypes());
assertNull(clientRegResp.getTokenEndpointAuthMethod());
assertNull(clientRegResp.getScope());
assertNull(clientRegResp.getRedirectUris());
assertEquals(200, wc.delete().getStatus());
}
Aggregations