aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/security
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-09-29 11:18:26 -0700
committerGravatar Craig Tiller <ctiller@google.com>2017-09-29 11:18:26 -0700
commit1e868f0f9539925e51aa52269c848082d23b7c4e (patch)
tree49fd965a5f58e2605864df54a1d70621367eee36 /test/core/security
parent710334577ce1b2de94f656ec0762eeba6effd29b (diff)
parent903f06fe3f8b1b971f1b633dff45488ca68c6708 (diff)
Merge github.com:grpc/grpc into flowctl+millis
Diffstat (limited to 'test/core/security')
-rw-r--r--test/core/security/credentials_test.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/test/core/security/credentials_test.c b/test/core/security/credentials_test.c
index fa8f1089c3..34f310142c 100644
--- a/test/core/security/credentials_test.c
+++ b/test/core/security/credentials_test.c
@@ -1035,39 +1035,46 @@ typedef enum {
static const expected_md plugin_md[] = {{"foo", "bar"}, {"hi", "there"}};
-static void plugin_get_metadata_success(void *state,
- grpc_auth_metadata_context context,
- grpc_credentials_plugin_metadata_cb cb,
- void *user_data) {
- size_t i;
- grpc_metadata md[GPR_ARRAY_SIZE(plugin_md)];
- plugin_state *s = (plugin_state *)state;
+static int plugin_get_metadata_success(
+ 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,
+ 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 == NULL);
GPR_ASSERT(context.reserved == NULL);
+ GPR_ASSERT(GPR_ARRAY_SIZE(plugin_md) <
+ GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX);
+ plugin_state *s = (plugin_state *)state;
*s = PLUGIN_GET_METADATA_CALLED_STATE;
- for (i = 0; i < GPR_ARRAY_SIZE(plugin_md); i++) {
- memset(&md[i], 0, sizeof(grpc_metadata));
- md[i].key = grpc_slice_from_copied_string(plugin_md[i].key);
- md[i].value = grpc_slice_from_copied_string(plugin_md[i].value);
+ for (size_t i = 0; i < GPR_ARRAY_SIZE(plugin_md); ++i) {
+ memset(&creds_md[i], 0, sizeof(grpc_metadata));
+ creds_md[i].key = grpc_slice_from_copied_string(plugin_md[i].key);
+ creds_md[i].value = grpc_slice_from_copied_string(plugin_md[i].value);
}
- cb(user_data, md, GPR_ARRAY_SIZE(md), GRPC_STATUS_OK, NULL);
+ *num_creds_md = GPR_ARRAY_SIZE(plugin_md);
+ return true; // Synchronous return.
}
static const char *plugin_error_details = "Could not get metadata for plugin.";
-static void plugin_get_metadata_failure(void *state,
- grpc_auth_metadata_context context,
- grpc_credentials_plugin_metadata_cb cb,
- void *user_data) {
- plugin_state *s = (plugin_state *)state;
+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,
+ 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 == NULL);
GPR_ASSERT(context.reserved == NULL);
+ plugin_state *s = (plugin_state *)state;
*s = PLUGIN_GET_METADATA_CALLED_STATE;
- cb(user_data, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, plugin_error_details);
+ *status = GRPC_STATUS_UNAUTHENTICATED;
+ *error_details = gpr_strdup(plugin_error_details);
+ return true; // Synchronous return.
}
static void plugin_destroy(void *state) {