Skip to content
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 @@ -43,9 +43,7 @@ void GrpcClientImpl::check(RequestCallbacks& callbacks,

void GrpcClientImpl::onSuccess(std::unique_ptr<envoy::service::auth::v2::CheckResponse>&& response,
Tracing::Span& span) {
ASSERT(response->status().code() != Grpc::Status::GrpcStatus::Unknown);
ResponsePtr authz_response = std::make_unique<Response>(Response{});

if (response->status().code() == Grpc::Status::GrpcStatus::Ok) {
span.setTag(Constants::get().TraceStatus, Constants::get().TraceOk);
authz_response->status = CheckStatus::OK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,30 @@ TEST_P(ExtAuthzGrpcClientTest, AuthorizationDenied) {
client_->onSuccess(std::move(check_response), span_);
}

// Test the client when a gRPC status code unknown is received from the authorization server.
TEST_P(ExtAuthzGrpcClientTest, AuthorizationDeniedGrpcUnknownStatus) {
initialize(GetParam());

auto check_response = std::make_unique<envoy::service::auth::v2::CheckResponse>();
auto status = check_response->mutable_status();
status->set_code(Grpc::Status::GrpcStatus::Unknown);
auto authz_response = Response{};
authz_response.status = CheckStatus::Denied;

envoy::service::auth::v2::CheckRequest request;
expectCallSend(request);
client_->check(request_callbacks_, request, Tracing::NullSpan::instance());

Http::HeaderMapImpl headers;
client_->onCreateInitialMetadata(headers);
EXPECT_EQ(nullptr, headers.RequestId());
EXPECT_CALL(span_, setTag("ext_authz_status", "ext_authz_unauthorized"));
EXPECT_CALL(request_callbacks_, onComplete_(WhenDynamicCastTo<ResponsePtr&>(
AuthzResponseNoAttributes(authz_response))));

client_->onSuccess(std::move(check_response), span_);
}

// Test the client when a denied response with additional HTTP attributes is received.
TEST_P(ExtAuthzGrpcClientTest, AuthorizationDeniedWithAllAttributes) {
initialize(GetParam());
Expand Down