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
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,13 @@ void ExternalAccountCredentials::HttpFetchBody::OnHttpResponse(
absl::string_view response_body(self->response_.body,
self->response_.body_length);
if (self->response_.status != 200) {
grpc_status_code status_code = grpc_http2_status_to_grpc_status(self->response_.status);
grpc_status_code status_code =
grpc_http2_status_to_grpc_status(self->response_.status);
if (status_code != GRPC_STATUS_UNAVAILABLE) {
status_code = GRPC_STATUS_UNAUTHENTICATED;
}
self->Finish(absl::Status(static_cast<absl::StatusCode>(status_code),
self->Finish(absl::Status(
static_cast<absl::StatusCode>(status_code),
absl::StrCat("Call to HTTP server ended with status ",
self->response_.status, " [", response_body, "]")));
return;
Expand Down
9 changes: 4 additions & 5 deletions test/core/credentials/call/call_credentials_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2404,8 +2404,7 @@ int external_account_creds_httpcli_post_failure_token_exchange_bad_request(
absl::string_view /*body*/, Timestamp /*deadline*/, grpc_closure* on_done,
grpc_http_response* response) {
if (uri.path() == "/token") {
*response = http_response(400,
"");
*response = http_response(400, "");
} else if (uri.path() == "/service_account_impersonation") {
*response = http_response(
200,
Expand Down Expand Up @@ -3297,8 +3296,7 @@ TEST_F(ExternalAccountCredentialsTest,
HttpRequest::SetOverride(nullptr, nullptr, nullptr);
}

TEST_F(ExternalAccountCredentialsTest,
FailureTokenExchangeResponseNotOk) {
TEST_F(ExternalAccountCredentialsTest, FailureTokenExchangeResponseNotOk) {
ExecCtx exec_ctx;
Json credential_source = Json::FromString("");
TestExternalAccountCredentials::ServiceAccountImpersonation
Expand All @@ -3325,7 +3323,8 @@ TEST_F(ExternalAccountCredentialsTest,
external_account_creds_httpcli_post_failure_token_exchange_bad_request,
httpcli_put_should_not_be_called);
grpc_error_handle expected_error = absl::UnauthenticatedError(
"error fetching oauth2 token: Call to HTTP server ended with status 400 []");
"error fetching oauth2 token: Call to HTTP server ended with status 400 "
"[]");
auto state = RequestMetadataState::NewInstance(expected_error, {});
state->RunRequestMetadataTest(creds.get(), kTestUrlScheme, kTestAuthority,
kTestPath);
Expand Down