use of org.apache.cxf.jaxrs.provider.json.JsonMapObjectProvider in project cxf by apache.
the class OIDCDynamicRegistrationTest method testGetClientRegNotAvail.
@org.junit.Test
public void testGetClientRegNotAvail() throws Exception {
URL busFile = OIDCDynamicRegistrationTest.class.getResource("client.xml");
String address = "https://localhost:" + DYNREG_SERVER.getPort() + "/services/dynamic/register";
WebClient wc = WebClient.create(address, Collections.singletonList(new JsonMapObjectProvider()), busFile.toString());
Response r = wc.accept("application/json").path("some-client-id").get();
assertEquals(401, r.getStatus());
}
use of org.apache.cxf.jaxrs.provider.json.JsonMapObjectProvider in project cxf by apache.
the class OIDCDynamicRegistrationTest method testUpdateClient.
@org.junit.Test
public void testUpdateClient() throws Exception {
URL busFile = OIDCDynamicRegistrationTest.class.getResource("client.xml");
String address = "https://localhost:" + DYNREG_SERVER.getPort() + "/services/dynamicWithAt/register";
WebClient wc = WebClient.create(address, Collections.singletonList(new JsonMapObjectProvider()), busFile.toString()).accept("application/json").type("application/json").authorization(new ClientAccessToken(OAuthConstants.BEARER_AUTHORIZATION_SCHEME, ACCESS_TOKEN));
final ClientRegistration reg = newClientRegistrationCodeGrant();
final ClientRegistrationResponse clientRegistrationResponse = wc.post(reg, ClientRegistrationResponse.class);
final String regAccessToken = clientRegistrationResponse.getRegistrationAccessToken();
assertNotNull(regAccessToken);
reg.setScope(OidcUtils.getEmailScope());
final ClientRegistration updatedClientRegistration = wc.path(clientRegistrationResponse.getClientId()).authorization(new ClientAccessToken(OAuthConstants.BEARER_AUTHORIZATION_SCHEME, regAccessToken)).put(reg, ClientRegistration.class);
assertEquals(OidcUtils.getEmailScope(), updatedClientRegistration.getScope());
// https://tools.ietf.org/html/rfc7592#section-2.2
assertNull(updatedClientRegistration.getProperty("registration_access_token"));
assertNull(updatedClientRegistration.getProperty("registration_client_uri"));
assertNull(updatedClientRegistration.getProperty("client_secret_expires_at"));
assertNull(updatedClientRegistration.getProperty("client_id_issued_at"));
wc.authorization(null);
assertEquals(Status.UNAUTHORIZED.getStatusCode(), wc.put(reg).getStatus());
assertEquals(Status.UNAUTHORIZED.getStatusCode(), wc.delete().getStatus());
wc.authorization(new ClientAccessToken(OAuthConstants.BEARER_AUTHORIZATION_SCHEME, regAccessToken));
assertEquals(200, wc.delete().getStatus());
}
Aggregations