@Test public void requestClientRegistrationFail3() throws Exception { showTitle("requestClientRegistrationFail3"); RegisterClient registerClient = new RegisterClient(registrationEndpoint); RegisterResponse response = registerClient.execRegister(ApplicationType.WEB, "oxAuth test app", Arrays.asList("https://client.example.com/cb#fail_fragment")); showClient(registerClient); assertEquals(response.getStatus(), 400, "Unexpected response code: " + response.getEntity()); assertNotNull(response.getEntity(), "The entity is null"); assertNotNull(response.getErrorType(), "The error type is null"); assertNotNull(response.getErrorDescription(), "The error description is null"); }
@Test public void requestClientRegistrationFail2() throws Exception { showTitle("requestClientRegistrationFail2"); RegisterClient registerClient = new RegisterClient(registrationEndpoint); RegisterResponse response = registerClient.execRegister(ApplicationType.WEB, "oxAuth test app", null); // Missing redirect URIs showClient(registerClient); assertEquals(response.getStatus(), 400, "Unexpected response code: " + response.getEntity()); assertNotNull(response.getEntity(), "The entity is null"); assertNotNull(response.getErrorType(), "The error type is null"); assertNotNull(response.getErrorDescription(), "The error description is null"); }
@Test public void requestClientRegistrationFail1() throws Exception { showTitle("requestClientRegistrationFail1"); RegisterClient registerClient = new RegisterClient(registrationEndpoint); RegisterResponse response = registerClient.execRegister(null, null, null); showClient(registerClient); assertEquals(response.getStatus(), 400, "Unexpected response code: " + response.getEntity()); assertNotNull(response.getEntity(), "The entity is null"); assertNotNull(response.getErrorType(), "The error type is null"); assertNotNull(response.getErrorDescription(), "The error description is null"); }
@Test public void requestClientAssociateInBlackList() throws Exception { showTitle("requestClientAssociateInBlackList"); final String redirectUris = "https://www.attacker.com"; RegisterClient registerClient = new RegisterClient(registrationEndpoint); RegisterResponse response = registerClient.execRegister(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); showClient(registerClient); assertEquals(response.getStatus(), 400, "Unexpected response code: " + response.getEntity()); assertNotNull(response.getEntity(), "The entity is null"); assertNotNull(response.getErrorType(), "The error type is null"); assertNotNull(response.getErrorDescription(), "The error description is null"); }
/** * Fail: Register a client with Application Type <code>web</code> and Redirect URI with the schema HTTP. */ @Test public void applicationTypeWebFail1() throws Exception { showTitle("applicationTypeWebFail1"); final String redirectUris = "http://client.example.com/cb"; RegisterClient registerClient = new RegisterClient(registrationEndpoint); RegisterResponse registerResponse = registerClient.execRegister(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); showClient(registerClient); assertEquals(registerResponse.getStatus(), 400, "Unexpected response code: " + registerResponse.getEntity()); assertNotNull(registerResponse.getEntity(), "The entity is null"); assertNotNull(registerResponse.getErrorType(), "The error type is null"); assertNotNull(registerResponse.getErrorDescription(), "The error description is null"); }
/** * Fail: Register a client with Application Type <code>native</code> and Redirect URI with the schema HTTPS. */ @Test(enabled = false) //allowed to register redirect_uris with custom schema to conform "OAuth 2.0 for Native Apps" spec public void applicationTypeNativeFail1() throws Exception { showTitle("applicationTypeNativeFail1"); final String redirectUris = "https://client.example.com/cb"; RegisterClient registerClient = new RegisterClient(registrationEndpoint); RegisterResponse registerResponse = registerClient.execRegister(ApplicationType.NATIVE, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); showClient(registerClient); assertEquals(registerResponse.getStatus(), 400, "Unexpected response code: " + registerResponse.getEntity()); assertNotNull(registerResponse.getEntity(), "The entity is null"); assertNotNull(registerResponse.getErrorType(), "The error type is null"); assertNotNull(registerResponse.getErrorDescription(), "The error description is null"); }
/** * Fail: Register a client with Application Type <code>native</code> and Redirect URI with the host different than localhost. */ @Parameters({"redirectUris"}) @Test(enabled = false) //allowed to register redirect_uris with custom schema to conform "OAuth 2.0 for Native Apps" spec public void applicationTypeNativeFail2(final String redirectUris) throws Exception { showTitle("applicationTypeNativeFail2"); RegisterClient registerClient = new RegisterClient(registrationEndpoint); RegisterResponse registerResponse = registerClient.execRegister(ApplicationType.NATIVE, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); showClient(registerClient); assertEquals(registerResponse.getStatus(), 400, "Unexpected response code: " + registerResponse.getEntity()); assertNotNull(registerResponse.getEntity(), "The entity is null"); assertNotNull(registerResponse.getErrorType(), "The error type is null"); assertNotNull(registerResponse.getErrorDescription(), "The error description is null"); } }
@Parameters({"redirectUris"}) @Test(invocationCount = 1000, threadPoolSize = 100) public void registerClient(final String redirectUris) throws Exception { showTitle("requestClientAssociate1"); RegisterClient registerClient = new RegisterClient(registrationEndpoint); RegisterResponse response = registerClient.execRegister(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); showClient(registerClient); assertEquals(response.getStatus(), 200, "Unexpected response code: " + response.getEntity()); assertNotNull(response.getClientId()); assertNotNull(response.getClientSecret()); assertNotNull(response.getRegistrationAccessToken()); assertNotNull(response.getClientSecretExpiresAt()); RegisterRequest readClientRequest = new RegisterRequest(response.getRegistrationAccessToken()); RegisterClient readClient = new RegisterClient(response.getRegistrationClientUri()); readClient.setRequest(readClientRequest); RegisterResponse readClientResponse = readClient.exec(); showClient(readClient); assertEquals(readClientResponse.getStatus(), 200, "Unexpected response code: " + readClientResponse.getEntity()); assertNotNull(readClientResponse.getClientId()); assertNotNull(readClientResponse.getClientSecret()); assertNotNull(readClientResponse.getClientIdIssuedAt()); assertNotNull(readClientResponse.getClientSecretExpiresAt()); } }