use of org.xdi.oxauth.client.RegisterClient in project oxAuth by GluuFederation.
the class ClientWhiteListBlackListRedirectUris method requestClientAssociate.
@Parameters({ "redirectUris", "sectorIdentifierUri" })
@Test
public void requestClientAssociate(final String redirectUris, final String sectorIdentifierUri) throws Exception {
showTitle("requestClientAssociate");
RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris));
registerRequest.setSectorIdentifierUri(sectorIdentifierUri);
RegisterClient registerClient = new RegisterClient(registrationEndpoint);
registerClient.setRequest(registerRequest);
registerClient.setExecutor(clientExecutor(true));
RegisterResponse response = registerClient.exec();
showClient(registerClient);
assertEquals(response.getStatus(), 200, "Unexpected response code: " + response.getEntity());
assertNotNull(response.getClientId());
assertNotNull(response.getClientSecret());
assertNotNull(response.getRegistrationAccessToken());
assertNotNull(response.getClientSecretExpiresAt());
assertNotNull(response.getClaims().get(SCOPES.toString()));
registrationAccessToken1 = response.getRegistrationAccessToken();
registrationClientUri1 = response.getRegistrationClientUri();
}
use of org.xdi.oxauth.client.RegisterClient in project oxAuth by GluuFederation.
the class RejectsSectorIdentifierNotContainingRegisteredRedirectUriValues method rejectsSectorIdentifierNotContainingRegisteredRedirectUriValues.
@Parameters({ "sectorIdentifierUri" })
@Test
public void rejectsSectorIdentifierNotContainingRegisteredRedirectUriValues(final String sectorIdentifierUri) throws Exception {
showTitle("OC5:FeatureTest-Rejects Sector Identifier Not Containing Registered redirect uri Values");
List<ResponseType> responseTypes = Arrays.asList(ResponseType.CODE);
RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList("https://not_registered"));
registerRequest.setSectorIdentifierUri(sectorIdentifierUri);
registerRequest.setResponseTypes(responseTypes);
RegisterClient registerClient = new RegisterClient(registrationEndpoint);
registerClient.setRequest(registerRequest);
RegisterResponse registerResponse = registerClient.exec();
showClient(registerClient);
assertEquals(registerResponse.getStatus(), 400, "Unexpected response code: " + registerResponse.getStatus());
assertNotNull(registerResponse.getErrorType(), "The error type is null");
assertNotNull(registerResponse.getErrorDescription(), "The error description is null");
}
use of org.xdi.oxauth.client.RegisterClient in project oxAuth by GluuFederation.
the class RegistrationRestWebServiceHttpTest method registerWithHttpFail.
@Parameters({ "redirectUris" })
@Test
public void registerWithHttpFail(final String redirectUris) throws Exception {
showTitle("registerWithHttpFail");
List<String> redirectUriList = Lists.newArrayList(StringUtils.spaceSeparatedToList(redirectUris));
// URI with HTTP schema
redirectUriList.add("http://www.example.com/cb");
RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth web test app with HTTP schema in URI", redirectUriList);
registerRequest.setSubjectType(SubjectType.PUBLIC);
RegisterClient registerClient = new RegisterClient(registrationEndpoint);
registerClient.setExecutor(clientExecutor(true));
registerClient.setRequest(registerRequest);
RegisterResponse response = registerClient.exec();
showClient(registerClient);
assertEquals(response.getStatus(), 400);
assertNotNull(response.getEntity());
assertNotNull(response.getErrorType());
assertNotNull(response.getErrorDescription());
}
use of org.xdi.oxauth.client.RegisterClient in project oxAuth by GluuFederation.
the class RegistrationRestWebServiceHttpTest method registerWithHttp2.
@Parameters({ "redirectUris" })
@Test
public void registerWithHttp2(final String redirectUris) throws Exception {
showTitle("registerWithHttp2");
List<String> redirectUriList = Lists.newArrayList(StringUtils.spaceSeparatedToList(redirectUris));
// URI with HTTP schema
redirectUriList.add("http://127.0.0.1/cb");
RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth web test app with HTTP schema in URI", redirectUriList);
registerRequest.setSubjectType(SubjectType.PUBLIC);
RegisterClient registerClient = new RegisterClient(registrationEndpoint);
registerClient.setExecutor(clientExecutor(true));
registerClient.setRequest(registerRequest);
RegisterResponse response = registerClient.exec();
showClient(registerClient);
assertEquals(response.getStatus(), 200, "Unexpected response code: " + response.getEntity());
assertNotNull(response.getClientId());
assertNotNull(response.getClientSecret());
assertNotNull(response.getRegistrationAccessToken());
assertNotNull(response.getClientSecretExpiresAt());
}
use of org.xdi.oxauth.client.RegisterClient in project oxAuth by GluuFederation.
the class RegistrationRestWebServiceHttpTest method requestClientRegistrationWithCustomAttributes.
@Parameters({ "redirectUris", "sectorIdentifierUri" })
@Test
public // is loaded by ldap server.
void requestClientRegistrationWithCustomAttributes(final String redirectUris, final String sectorIdentifierUri) throws Exception {
showTitle("requestClientRegistrationWithCustomAttributes");
final RegisterRequest request = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris));
// custom attribute must be declared in oxauth-config.xml in dynamic-registration-custom-attribute tag
request.addCustomAttribute("myCustomAttr1", "customAttrValue1");
request.addCustomAttribute("myCustomAttr2", "customAttrValue2");
request.setSectorIdentifierUri(sectorIdentifierUri);
final RegisterClient registerClient = new RegisterClient(registrationEndpoint);
registerClient.setRequest(request);
final RegisterResponse response = registerClient.exec();
showClient(registerClient);
assertEquals(response.getStatus(), 200, "Unexpected response code: " + response.getEntity());
assertNotNull(response.getClientId());
assertNotNull(response.getClientSecret());
assertNotNull(response.getRegistrationAccessToken());
assertNotNull(response.getClientSecretExpiresAt());
}
Aggregations