Skip to content

Commit

Permalink
fix: fixed how wrapped KsqlTopicAuthorizationException error messages…
Browse files Browse the repository at this point in the history
… are displayed
  • Loading branch information
stevenpyzhang committed Aug 22, 2019
1 parent abe410a commit fc893d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ public static Response accessDenied(final String msg) {
.build();
}

public static Response accessDeniedFromKafka(final Exception error) {
public static Response accessDeniedFromKafka(final Throwable t) {
return Response
.status(FORBIDDEN)
.entity(new KsqlErrorMessage(ERROR_CODE_FORBIDDEN_KAFKA_ACCESS, error.getMessage()))
.entity(new KsqlErrorMessage(ERROR_CODE_FORBIDDEN_KAFKA_ACCESS, t))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ public void shouldReturnForbiddenKafkaAccessIfKsqlTopicAuthorizationException()
@Test
public void shouldReturnForbiddenKafkaAccessIfRootCauseKsqlTopicAuthorizationException() {
// Given:
doThrow(new KsqlException("", new KsqlTopicAuthorizationException(
doThrow(new KsqlException("Could not delete the corresponding kafka topic: topic", new KsqlTopicAuthorizationException(
AclOperation.DELETE,
Collections.singleton("topic")))).when(topicAccessValidator).validate(any(), any(), any());

Expand All @@ -676,6 +676,9 @@ public void shouldReturnForbiddenKafkaAccessIfRootCauseKsqlTopicAuthorizationExc
// Then:
assertThat(result, is(instanceOf(KsqlErrorMessage.class)));
assertThat(result.getErrorCode(), is(Errors.ERROR_CODE_FORBIDDEN_KAFKA_ACCESS));
assertThat(result.getMessage(), is(
"Could not delete the corresponding kafka topic: topic\n" +
"Caused by: Authorization denied to Delete on topic(s): [topic]"));
}

@Test
Expand Down

0 comments on commit fc893d7

Please sign in to comment.