Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose http status code in OAuth2ServiceException #1251

Merged
merged 1 commit into from
Aug 3, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ public OAuth2ServiceException(String message, Integer httpStatusCode) {
super(message);
this.httpStatusCode = httpStatusCode != null ? httpStatusCode : 0;
}

/**
* Returns the HTTP status code of the failed OAuth2 service request or
* {@code 0} e.g. in case the service wasn't called at all.
*
* @return status code or 0
*/
public Integer getHttpStatusCode() {
return httpStatusCode;
}

/**
* Creates an exception.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public void retrieveEndpoints_errorOccurs_throwsServiceException() throws IOExce
assertThatThrownBy(this::retrieveEndpoints)
.isInstanceOf(OAuth2ServiceException.class)
.hasMessageContaining(errorMessage)
.extracting("httpStatusCode").isEqualTo(0);
.extracting(OAuth2ServiceException.class::cast)
.extracting(OAuth2ServiceException::getHttpStatusCode).isEqualTo(0);
}

@Test
Expand Down
Loading