public class ForbiddenException extends ClientErrorException
final List<SphereScope> scopes = singletonList(SphereProjectScope.VIEW_PRODUCTS);
ApiClientFixtures.withApiClient(client(), scopes, apiClient -> {
final SphereClientConfig clientConfig = toSphereClientConfig(getSphereClientConfig(), apiClient);
try (final SphereClient client = SphereClientFactory.of(IntegrationTest::newHttpClient)
.createClient(clientConfig)) {
assertThatThrownBy(() -> {
final CustomerQuery request = CustomerQuery.of();
SphereClientUtils.blockingWait(client.execute(request), 5, SECONDS);
})
.as("since the allowed scope is only to view products, customer data should not be loadable")
.isInstanceOf(ForbiddenException.class);
}
});
See the test code.
httpResponse
Constructor and Description |
---|
ForbiddenException() |
ForbiddenException(String message) |
ForbiddenException(String message,
Throwable cause) |
getJsonBody, getStatusCode
addNote, getAdditionalNotes, getHttpResponse, getMessage, getProjectKey, getSphereRequest, httpSummary, setHttpRequest, setProjectKey, setSphereRequest, setUnderlyingHttpResponse
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString