|
|
|
@ -428,8 +428,8 @@ class check_channel_oauth2 final : public grpc_channel_credentials { |
|
|
|
|
grpc_core::RefCountedPtr<grpc_channel_security_connector> |
|
|
|
|
create_security_connector( |
|
|
|
|
grpc_core::RefCountedPtr<grpc_call_credentials> call_creds, |
|
|
|
|
const char* target, const grpc_channel_args* args, |
|
|
|
|
grpc_channel_args** new_args) override { |
|
|
|
|
const char* /*target*/, const grpc_channel_args* /*args*/, |
|
|
|
|
grpc_channel_args** /*new_args*/) override { |
|
|
|
|
GPR_ASSERT(strcmp(type(), "mock") == 0); |
|
|
|
|
GPR_ASSERT(call_creds != nullptr); |
|
|
|
|
GPR_ASSERT(strcmp(call_creds->type(), GRPC_CALL_CREDENTIALS_TYPE_OAUTH2) == |
|
|
|
@ -501,8 +501,8 @@ class check_channel_oauth2_google_iam final : public grpc_channel_credentials { |
|
|
|
|
grpc_core::RefCountedPtr<grpc_channel_security_connector> |
|
|
|
|
create_security_connector( |
|
|
|
|
grpc_core::RefCountedPtr<grpc_call_credentials> call_creds, |
|
|
|
|
const char* target, const grpc_channel_args* args, |
|
|
|
|
grpc_channel_args** new_args) override { |
|
|
|
|
const char* /*target*/, const grpc_channel_args* /*args*/, |
|
|
|
|
grpc_channel_args** /*new_args*/) override { |
|
|
|
|
GPR_ASSERT(strcmp(type(), "mock") == 0); |
|
|
|
|
GPR_ASSERT(call_creds != nullptr); |
|
|
|
|
GPR_ASSERT( |
|
|
|
@ -560,7 +560,7 @@ static void validate_compute_engine_http_request( |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int compute_engine_httpcli_get_success_override( |
|
|
|
|
const grpc_httpcli_request* request, grpc_millis deadline, |
|
|
|
|
const grpc_httpcli_request* request, grpc_millis /*deadline*/, |
|
|
|
|
grpc_closure* on_done, grpc_httpcli_response* response) { |
|
|
|
|
validate_compute_engine_http_request(request); |
|
|
|
|
*response = http_response(200, valid_oauth2_json_response); |
|
|
|
@ -569,7 +569,7 @@ static int compute_engine_httpcli_get_success_override( |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int compute_engine_httpcli_get_failure_override( |
|
|
|
|
const grpc_httpcli_request* request, grpc_millis deadline, |
|
|
|
|
const grpc_httpcli_request* request, grpc_millis /*deadline*/, |
|
|
|
|
grpc_closure* on_done, grpc_httpcli_response* response) { |
|
|
|
|
validate_compute_engine_http_request(request); |
|
|
|
|
*response = http_response(403, "Not Authorized."); |
|
|
|
@ -578,17 +578,16 @@ static int compute_engine_httpcli_get_failure_override( |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int httpcli_post_should_not_be_called( |
|
|
|
|
const grpc_httpcli_request* request, const char* body_bytes, |
|
|
|
|
size_t body_size, grpc_millis deadline, grpc_closure* on_done, |
|
|
|
|
grpc_httpcli_response* response) { |
|
|
|
|
const grpc_httpcli_request* /*request*/, const char* /*body_bytes*/, |
|
|
|
|
size_t /*body_size*/, grpc_millis /*deadline*/, grpc_closure* /*on_done*/, |
|
|
|
|
grpc_httpcli_response* /*response*/) { |
|
|
|
|
GPR_ASSERT("HTTP POST should not be called" == nullptr); |
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int httpcli_get_should_not_be_called(const grpc_httpcli_request* request, |
|
|
|
|
grpc_millis deadline, |
|
|
|
|
grpc_closure* on_done, |
|
|
|
|
grpc_httpcli_response* response) { |
|
|
|
|
static int httpcli_get_should_not_be_called( |
|
|
|
|
const grpc_httpcli_request* /*request*/, grpc_millis /*deadline*/, |
|
|
|
|
grpc_closure* /*on_done*/, grpc_httpcli_response* /*response*/) { |
|
|
|
|
GPR_ASSERT("HTTP GET should not be called" == nullptr); |
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
@ -664,7 +663,7 @@ static void validate_refresh_token_http_request( |
|
|
|
|
|
|
|
|
|
static int refresh_token_httpcli_post_success( |
|
|
|
|
const grpc_httpcli_request* request, const char* body, size_t body_size, |
|
|
|
|
grpc_millis deadline, grpc_closure* on_done, |
|
|
|
|
grpc_millis /*deadline*/, grpc_closure* on_done, |
|
|
|
|
grpc_httpcli_response* response) { |
|
|
|
|
validate_refresh_token_http_request(request, body, body_size); |
|
|
|
|
*response = http_response(200, valid_oauth2_json_response); |
|
|
|
@ -672,9 +671,10 @@ static int refresh_token_httpcli_post_success( |
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int token_httpcli_post_failure(const grpc_httpcli_request* request, |
|
|
|
|
const char* body, size_t body_size, |
|
|
|
|
grpc_millis deadline, |
|
|
|
|
static int token_httpcli_post_failure(const grpc_httpcli_request* /*request*/, |
|
|
|
|
const char* /*body*/, |
|
|
|
|
size_t /*body_size*/, |
|
|
|
|
grpc_millis /*deadline*/, |
|
|
|
|
grpc_closure* on_done, |
|
|
|
|
grpc_httpcli_response* response) { |
|
|
|
|
*response = http_response(403, "Not Authorized."); |
|
|
|
@ -876,7 +876,7 @@ static void validate_sts_token_http_request(const grpc_httpcli_request* request, |
|
|
|
|
|
|
|
|
|
static int sts_token_httpcli_post_success(const grpc_httpcli_request* request, |
|
|
|
|
const char* body, size_t body_size, |
|
|
|
|
grpc_millis deadline, |
|
|
|
|
grpc_millis /*deadline*/, |
|
|
|
|
grpc_closure* on_done, |
|
|
|
|
grpc_httpcli_response* response) { |
|
|
|
|
validate_sts_token_http_request(request, body, body_size); |
|
|
|
@ -1021,7 +1021,7 @@ static void validate_jwt_encode_and_sign_params( |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static char* encode_and_sign_jwt_success(const grpc_auth_json_key* json_key, |
|
|
|
|
const char* audience, |
|
|
|
|
const char* /*audience*/, |
|
|
|
|
gpr_timespec token_lifetime, |
|
|
|
|
const char* scope) { |
|
|
|
|
validate_jwt_encode_and_sign_params(json_key, scope, token_lifetime); |
|
|
|
@ -1029,7 +1029,7 @@ static char* encode_and_sign_jwt_success(const grpc_auth_json_key* json_key, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static char* encode_and_sign_jwt_failure(const grpc_auth_json_key* json_key, |
|
|
|
|
const char* audience, |
|
|
|
|
const char* /*audience*/, |
|
|
|
|
gpr_timespec token_lifetime, |
|
|
|
|
const char* scope) { |
|
|
|
|
validate_jwt_encode_and_sign_params(json_key, scope, token_lifetime); |
|
|
|
@ -1037,8 +1037,8 @@ static char* encode_and_sign_jwt_failure(const grpc_auth_json_key* json_key, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static char* encode_and_sign_jwt_should_not_be_called( |
|
|
|
|
const grpc_auth_json_key* json_key, const char* audience, |
|
|
|
|
gpr_timespec token_lifetime, const char* scope) { |
|
|
|
|
const grpc_auth_json_key* /*json_key*/, const char* /*audience*/, |
|
|
|
|
gpr_timespec /*token_lifetime*/, const char* /*scope*/) { |
|
|
|
|
GPR_ASSERT("grpc_jwt_encode_and_sign should not be called" == nullptr); |
|
|
|
|
return nullptr; |
|
|
|
|
} |
|
|
|
@ -1204,7 +1204,7 @@ static void test_google_default_creds_refresh_token(void) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int default_creds_metadata_server_detection_httpcli_get_success_override( |
|
|
|
|
const grpc_httpcli_request* request, grpc_millis deadline, |
|
|
|
|
const grpc_httpcli_request* request, grpc_millis /*deadline*/, |
|
|
|
|
grpc_closure* on_done, grpc_httpcli_response* response) { |
|
|
|
|
*response = http_response(200, ""); |
|
|
|
|
grpc_http_header* headers = |
|
|
|
@ -1300,7 +1300,7 @@ static void test_google_default_creds_non_gce(void) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int default_creds_gce_detection_httpcli_get_failure_override( |
|
|
|
|
const grpc_httpcli_request* request, grpc_millis deadline, |
|
|
|
|
const grpc_httpcli_request* request, grpc_millis /*deadline*/, |
|
|
|
|
grpc_closure* on_done, grpc_httpcli_response* response) { |
|
|
|
|
/* No magic header. */ |
|
|
|
|
GPR_ASSERT(strcmp(request->http.path, "/") == 0); |
|
|
|
@ -1342,10 +1342,10 @@ static const expected_md plugin_md[] = {{"foo", "bar"}, {"hi", "there"}}; |
|
|
|
|
|
|
|
|
|
static int plugin_get_metadata_success( |
|
|
|
|
void* state, grpc_auth_metadata_context context, |
|
|
|
|
grpc_credentials_plugin_metadata_cb cb, void* user_data, |
|
|
|
|
grpc_credentials_plugin_metadata_cb /*cb*/, void* /*user_data*/, |
|
|
|
|
grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], |
|
|
|
|
size_t* num_creds_md, grpc_status_code* status, |
|
|
|
|
const char** error_details) { |
|
|
|
|
size_t* num_creds_md, grpc_status_code* /*status*/, |
|
|
|
|
const char** /*error_details*/) { |
|
|
|
|
GPR_ASSERT(strcmp(context.service_url, test_service_url) == 0); |
|
|
|
|
GPR_ASSERT(strcmp(context.method_name, test_method) == 0); |
|
|
|
|
GPR_ASSERT(context.channel_auth_context == nullptr); |
|
|
|
@ -1367,9 +1367,9 @@ static const char* plugin_error_details = "Could not get metadata for plugin."; |
|
|
|
|
|
|
|
|
|
static int plugin_get_metadata_failure( |
|
|
|
|
void* state, grpc_auth_metadata_context context, |
|
|
|
|
grpc_credentials_plugin_metadata_cb cb, void* user_data, |
|
|
|
|
grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], |
|
|
|
|
size_t* num_creds_md, grpc_status_code* status, |
|
|
|
|
grpc_credentials_plugin_metadata_cb /*cb*/, void* /*user_data*/, |
|
|
|
|
grpc_metadata /*creds_md*/[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], |
|
|
|
|
size_t* /*num_creds_md*/, grpc_status_code* status, |
|
|
|
|
const char** error_details) { |
|
|
|
|
GPR_ASSERT(strcmp(context.service_url, test_service_url) == 0); |
|
|
|
|
GPR_ASSERT(strcmp(context.method_name, test_method) == 0); |
|
|
|
|