Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions library/java/net/openid/appauth/AuthorizationService.java
Original file line number Diff line number Diff line change
Expand Up @@ -653,9 +653,9 @@ protected void onPostExecute(JSONObject json) {
return;
} catch (RegistrationResponse.MissingArgumentException ex) {
Logger.errorWithStack(ex, "Malformed registration response");
mException = AuthorizationException.fromTemplate(
mCallback.onRegistrationRequestCompleted(null, AuthorizationException.fromTemplate(
GeneralErrors.INVALID_REGISTRATION_RESPONSE,
ex);
ex));
return;
}
Logger.debug("Dynamic registration with %s completed",
Expand Down
16 changes: 16 additions & 0 deletions library/javatests/net/openid/appauth/AuthorizationServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ public class AuthorizationServiceTest {
+ " \"application_type\": " + RegistrationRequest.APPLICATION_TYPE_NATIVE + "\n"
+ "}";

private static final String INVALID_REGISTRATION_RESPONSE_JSON = "{\n"
+ " \"client_id\": \"" + TEST_CLIENT_ID + "\",\n"
+ " \"client_secret\": \"" + TEST_CLIENT_SECRET + "\",\n"
+ " \"application_type\": " + RegistrationRequest.APPLICATION_TYPE_NATIVE + "\n"
+ "}";

private static final String INVALID_GRANT_RESPONSE_JSON = "{\n"
+ " \"error\": \"invalid_grant\",\n"
+ " \"error_description\": \"invalid_grant description\"\n"
Expand Down Expand Up @@ -410,6 +416,16 @@ public void testRegistrationRequest_IoException() throws Exception {
assertEquals(GeneralErrors.NETWORK_ERROR, mRegistrationCallback.error);
}

@Test
public void testRegistrationRequest_MissingArgumentException() throws Exception {
InputStream is = new ByteArrayInputStream(INVALID_REGISTRATION_RESPONSE_JSON.getBytes());
when(mHttpConnection.getInputStream()).thenReturn(is);
mService.performRegistrationRequest(getTestRegistrationRequest(), mRegistrationCallback);
mRegistrationCallback.waitForCallback();
assertNotNull(mRegistrationCallback.error);
assertEquals(GeneralErrors.INVALID_REGISTRATION_RESPONSE, mRegistrationCallback.error);
}

@Test(expected = IllegalStateException.class)
public void testTokenRequest_afterDispose() throws Exception {
mService.dispose();
Expand Down