diff options
author | Jan Tattermusch <jtattermusch@users.noreply.github.com> | 2016-03-11 14:47:07 -0800 |
---|---|---|
committer | Jan Tattermusch <jtattermusch@users.noreply.github.com> | 2016-03-11 14:47:07 -0800 |
commit | 52676ba0c250f55828f9b590c0e215ec18a9344c (patch) | |
tree | 4138d2fda2bac9430632bdb53cbd02e1366291d2 /test/core/security | |
parent | 4d52cca1ef29837c7610e31897240b6f4abd6991 (diff) | |
parent | aad4156a0ba79d963bfa3cd37e48a1074f956809 (diff) |
Merge pull request #5694 from nicolasnoble/pre-0.13.1-downmerge
Pre 0.13.1 downmerge
Diffstat (limited to 'test/core/security')
-rw-r--r-- | test/core/security/b64_test.c (renamed from test/core/security/base64_test.c) | 4 | ||||
-rw-r--r-- | test/core/security/create_jwt.c | 2 | ||||
-rw-r--r-- | test/core/security/credentials_test.c | 17 | ||||
-rw-r--r-- | test/core/security/fetch_oauth2.c | 4 | ||||
-rw-r--r-- | test/core/security/json_token_test.c | 7 | ||||
-rw-r--r-- | test/core/security/jwt_verifier_test.c | 2 | ||||
-rw-r--r-- | test/core/security/oauth2_utils.c | 27 | ||||
-rw-r--r-- | test/core/security/print_google_default_creds_token.c | 38 | ||||
-rw-r--r-- | test/core/security/secure_endpoint_test.c | 26 | ||||
-rw-r--r-- | test/core/security/security_connector_test.c | 15 | ||||
-rw-r--r-- | test/core/security/verify_jwt.c | 33 |
11 files changed, 96 insertions, 79 deletions
diff --git a/test/core/security/base64_test.c b/test/core/security/b64_test.c index e656d4c947..772514e1fd 100644 --- a/test/core/security/base64_test.c +++ b/test/core/security/b64_test.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ * */ -#include "src/core/security/base64.h" +#include "src/core/security/b64.h" #include <string.h> diff --git a/test/core/security/create_jwt.c b/test/core/security/create_jwt.c index 237dc9aa3e..4c0cf436ee 100644 --- a/test/core/security/create_jwt.c +++ b/test/core/security/create_jwt.c @@ -36,7 +36,7 @@ #include "src/core/security/credentials.h" #include "src/core/security/json_token.h" -#include "src/core/support/file.h" +#include "src/core/support/load_file.h" #include <grpc/support/alloc.h> #include <grpc/support/cmdline.h> diff --git a/test/core/security/credentials_test.c b/test/core/security/credentials_test.c index 8a210bb3c3..98133ef5e5 100644 --- a/test/core/security/credentials_test.c +++ b/test/core/security/credentials_test.c @@ -32,25 +32,24 @@ */ #include <grpc/support/port_platform.h> + #include "src/core/security/credentials.h" +#include <openssl/rsa.h> #include <stdlib.h> #include <string.h> -#include "src/core/httpcli/httpcli.h" -#include "src/core/security/json_token.h" -#include "src/core/support/env.h" -#include "src/core/support/file.h" -#include "src/core/support/string.h" - -#include "test/core/util/test_config.h" - #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> #include <grpc/support/time.h> -#include <openssl/rsa.h> +#include "src/core/httpcli/httpcli.h" +#include "src/core/security/json_token.h" +#include "src/core/support/env.h" +#include "src/core/support/tmpfile.h" +#include "src/core/support/string.h" +#include "test/core/util/test_config.h" /* -- Mock channel credentials. -- */ diff --git a/test/core/security/fetch_oauth2.c b/test/core/security/fetch_oauth2.c index ee1178cbdd..87b54f1a0c 100644 --- a/test/core/security/fetch_oauth2.c +++ b/test/core/security/fetch_oauth2.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -43,7 +43,7 @@ #include <grpc/support/sync.h> #include "src/core/security/credentials.h" -#include "src/core/support/file.h" +#include "src/core/support/load_file.h" #include "test/core/security/oauth2_utils.h" static grpc_call_credentials *create_refresh_token_creds( diff --git a/test/core/security/json_token_test.c b/test/core/security/json_token_test.c index 7c01a9ce5c..4d80c16fb9 100644 --- a/test/core/security/json_token_test.c +++ b/test/core/security/json_token_test.c @@ -33,16 +33,17 @@ #include "src/core/security/json_token.h" +#include <openssl/evp.h> #include <string.h> -#include "src/core/security/base64.h" #include <grpc/grpc_security.h> #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/slice.h> -#include "test/core/util/test_config.h" + #include "src/core/json/json.h" -#include <openssl/evp.h> +#include "src/core/security/b64.h" +#include "test/core/util/test_config.h" /* This JSON key was generated with the GCE console and revoked immediately. The identifiers have been changed as well. diff --git a/test/core/security/jwt_verifier_test.c b/test/core/security/jwt_verifier_test.c index f396398cef..f6ec9e12ef 100644 --- a/test/core/security/jwt_verifier_test.c +++ b/test/core/security/jwt_verifier_test.c @@ -36,7 +36,7 @@ #include <string.h> #include "src/core/httpcli/httpcli.h" -#include "src/core/security/base64.h" +#include "src/core/security/b64.h" #include "src/core/security/json_token.h" #include "test/core/util/test_config.h" diff --git a/test/core/security/oauth2_utils.c b/test/core/security/oauth2_utils.c index 55ac31e62c..9b70afffe1 100644 --- a/test/core/security/oauth2_utils.c +++ b/test/core/security/oauth2_utils.c @@ -45,7 +45,8 @@ #include "src/core/security/credentials.h" typedef struct { - grpc_pollset pollset; + gpr_mu *mu; + grpc_pollset *pollset; int is_done; char *token; } oauth2_request; @@ -66,11 +67,11 @@ static void on_oauth2_response(grpc_exec_ctx *exec_ctx, void *user_data, GPR_SLICE_LENGTH(token_slice)); token[GPR_SLICE_LENGTH(token_slice)] = '\0'; } - gpr_mu_lock(GRPC_POLLSET_MU(&request->pollset)); + gpr_mu_lock(request->mu); request->is_done = 1; request->token = token; - grpc_pollset_kick(&request->pollset, NULL); - gpr_mu_unlock(GRPC_POLLSET_MU(&request->pollset)); + grpc_pollset_kick(request->pollset, NULL); + gpr_mu_unlock(request->mu); } static void do_nothing(grpc_exec_ctx *exec_ctx, void *unused, bool success) {} @@ -82,28 +83,30 @@ char *grpc_test_fetch_oauth2_token_with_credentials( grpc_closure do_nothing_closure; grpc_auth_metadata_context null_ctx = {"", "", NULL, NULL}; - grpc_pollset_init(&request.pollset); + request.pollset = gpr_malloc(grpc_pollset_size()); + grpc_pollset_init(request.pollset, &request.mu); request.is_done = 0; grpc_closure_init(&do_nothing_closure, do_nothing, NULL); - grpc_call_credentials_get_request_metadata(&exec_ctx, creds, &request.pollset, + grpc_call_credentials_get_request_metadata(&exec_ctx, creds, request.pollset, null_ctx, on_oauth2_response, &request); grpc_exec_ctx_finish(&exec_ctx); - gpr_mu_lock(GRPC_POLLSET_MU(&request.pollset)); + gpr_mu_lock(request.mu); while (!request.is_done) { - grpc_pollset_worker worker; - grpc_pollset_work(&exec_ctx, &request.pollset, &worker, + grpc_pollset_worker *worker = NULL; + grpc_pollset_work(&exec_ctx, request.pollset, &worker, gpr_now(GPR_CLOCK_MONOTONIC), gpr_inf_future(GPR_CLOCK_MONOTONIC)); } - gpr_mu_unlock(GRPC_POLLSET_MU(&request.pollset)); + gpr_mu_unlock(request.mu); - grpc_pollset_shutdown(&exec_ctx, &request.pollset, &do_nothing_closure); + grpc_pollset_shutdown(&exec_ctx, request.pollset, &do_nothing_closure); grpc_exec_ctx_finish(&exec_ctx); - grpc_pollset_destroy(&request.pollset); + grpc_pollset_destroy(request.pollset); + gpr_free(request.pollset); return request.token; } diff --git a/test/core/security/print_google_default_creds_token.c b/test/core/security/print_google_default_creds_token.c index 50fe61c996..09673f362c 100644 --- a/test/core/security/print_google_default_creds_token.c +++ b/test/core/security/print_google_default_creds_token.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,8 +34,6 @@ #include <stdio.h> #include <string.h> -#include "src/core/security/credentials.h" -#include "src/core/support/string.h" #include <grpc/grpc.h> #include <grpc/grpc_security.h> #include <grpc/support/alloc.h> @@ -44,8 +42,12 @@ #include <grpc/support/slice.h> #include <grpc/support/sync.h> +#include "src/core/security/credentials.h" +#include "src/core/support/string.h" + typedef struct { - grpc_pollset pollset; + gpr_mu *mu; + grpc_pollset *pollset; int is_done; } synchronizer; @@ -62,10 +64,10 @@ static void on_metadata_response(grpc_exec_ctx *exec_ctx, void *user_data, printf("\nGot token: %s\n\n", token); gpr_free(token); } - gpr_mu_lock(GRPC_POLLSET_MU(&sync->pollset)); + gpr_mu_lock(sync->mu); sync->is_done = 1; - grpc_pollset_kick(&sync->pollset, NULL); - gpr_mu_unlock(GRPC_POLLSET_MU(&sync->pollset)); + grpc_pollset_kick(sync->pollset, NULL); + gpr_mu_unlock(sync->mu); } int main(int argc, char **argv) { @@ -91,26 +93,30 @@ int main(int argc, char **argv) { goto end; } - grpc_pollset_init(&sync.pollset); + sync.pollset = gpr_malloc(grpc_pollset_size()); + grpc_pollset_init(sync.pollset, &sync.mu); sync.is_done = 0; grpc_call_credentials_get_request_metadata( &exec_ctx, ((grpc_composite_channel_credentials *)creds)->call_creds, - &sync.pollset, context, on_metadata_response, &sync); + sync.pollset, context, on_metadata_response, &sync); - gpr_mu_lock(GRPC_POLLSET_MU(&sync.pollset)); + gpr_mu_lock(sync.mu); while (!sync.is_done) { - grpc_pollset_worker worker; - grpc_pollset_work(&exec_ctx, &sync.pollset, &worker, + grpc_pollset_worker *worker = NULL; + grpc_pollset_work(&exec_ctx, sync.pollset, &worker, gpr_now(GPR_CLOCK_MONOTONIC), gpr_inf_future(GPR_CLOCK_MONOTONIC)); - gpr_mu_unlock(GRPC_POLLSET_MU(&sync.pollset)); - grpc_exec_ctx_finish(&exec_ctx); - gpr_mu_lock(GRPC_POLLSET_MU(&sync.pollset)); + gpr_mu_unlock(sync.mu); + grpc_exec_ctx_flush(&exec_ctx); + gpr_mu_lock(sync.mu); } - gpr_mu_unlock(GRPC_POLLSET_MU(&sync.pollset)); + gpr_mu_unlock(sync.mu); + + grpc_exec_ctx_finish(&exec_ctx); grpc_channel_credentials_release(creds); + gpr_free(sync.pollset); end: gpr_cmdline_destroy(cl); diff --git a/test/core/security/secure_endpoint_test.c b/test/core/security/secure_endpoint_test.c index fb4bd30e2d..0e8c38a53e 100644 --- a/test/core/security/secure_endpoint_test.c +++ b/test/core/security/secure_endpoint_test.c @@ -36,16 +36,17 @@ #include <fcntl.h> #include <sys/types.h> -#include "src/core/security/secure_endpoint.h" -#include "src/core/iomgr/endpoint_pair.h" -#include "src/core/iomgr/iomgr.h" #include <grpc/grpc.h> #include <grpc/support/alloc.h> #include <grpc/support/log.h> -#include "test/core/util/test_config.h" +#include "src/core/iomgr/endpoint_pair.h" +#include "src/core/iomgr/iomgr.h" +#include "src/core/security/secure_endpoint.h" #include "src/core/tsi/fake_transport_security.h" +#include "test/core/util/test_config.h" -static grpc_pollset g_pollset; +static gpr_mu *g_mu; +static grpc_pollset *g_pollset; static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair( size_t slice_size, gpr_slice *leftover_slices, size_t leftover_nslices) { @@ -56,8 +57,8 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair( grpc_endpoint_pair tcp; tcp = grpc_iomgr_create_endpoint_pair("fixture", slice_size); - grpc_endpoint_add_to_pollset(&exec_ctx, tcp.client, &g_pollset); - grpc_endpoint_add_to_pollset(&exec_ctx, tcp.server, &g_pollset); + grpc_endpoint_add_to_pollset(&exec_ctx, tcp.client, g_pollset); + grpc_endpoint_add_to_pollset(&exec_ctx, tcp.server, g_pollset); if (leftover_nslices == 0) { f.client_ep = @@ -181,13 +182,16 @@ int main(int argc, char **argv) { grpc_test_init(argc, argv); grpc_init(); - grpc_pollset_init(&g_pollset); - grpc_endpoint_tests(configs[0], &g_pollset); + g_pollset = gpr_malloc(grpc_pollset_size()); + grpc_pollset_init(g_pollset, &g_mu); + grpc_endpoint_tests(configs[0], g_pollset, g_mu); test_leftover(configs[1], 1); - grpc_closure_init(&destroyed, destroy_pollset, &g_pollset); - grpc_pollset_shutdown(&exec_ctx, &g_pollset, &destroyed); + grpc_closure_init(&destroyed, destroy_pollset, g_pollset); + grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed); grpc_exec_ctx_finish(&exec_ctx); grpc_shutdown(); + gpr_free(g_pollset); + return 0; } diff --git a/test/core/security/security_connector_test.c b/test/core/security/security_connector_test.c index ee5435f01d..420e3a4c52 100644 --- a/test/core/security/security_connector_test.c +++ b/test/core/security/security_connector_test.c @@ -34,22 +34,21 @@ #include <stdio.h> #include <string.h> +#include <grpc/grpc_security.h> +#include <grpc/support/alloc.h> +#include <grpc/support/log.h> +#include <grpc/support/string_util.h> +#include <grpc/support/useful.h> + #include "src/core/security/security_connector.h" #include "src/core/security/security_context.h" #include "src/core/support/env.h" -#include "src/core/support/file.h" +#include "src/core/support/tmpfile.h" #include "src/core/support/string.h" #include "src/core/tsi/ssl_transport_security.h" #include "src/core/tsi/transport_security.h" #include "test/core/util/test_config.h" -#include <grpc/grpc_security.h> - -#include <grpc/support/alloc.h> -#include <grpc/support/log.h> -#include <grpc/support/string_util.h> -#include <grpc/support/useful.h> - static int check_transport_security_type(const grpc_auth_context *ctx) { grpc_auth_property_iterator it = grpc_auth_context_find_properties_by_name( ctx, GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME); diff --git a/test/core/security/verify_jwt.c b/test/core/security/verify_jwt.c index 378a37f26c..eb86589681 100644 --- a/test/core/security/verify_jwt.c +++ b/test/core/security/verify_jwt.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,7 +34,6 @@ #include <stdio.h> #include <string.h> -#include "src/core/security/jwt_verifier.h" #include <grpc/grpc.h> #include <grpc/grpc_security.h> #include <grpc/support/alloc.h> @@ -43,8 +42,11 @@ #include <grpc/support/slice.h> #include <grpc/support/sync.h> +#include "src/core/security/jwt_verifier.h" + typedef struct { - grpc_pollset pollset; + grpc_pollset *pollset; + gpr_mu *mu; int is_done; int success; } synchronizer; @@ -77,10 +79,10 @@ static void on_jwt_verification_done(void *user_data, grpc_jwt_verifier_status_to_string(status)); } - gpr_mu_lock(GRPC_POLLSET_MU(&sync->pollset)); + gpr_mu_lock(sync->mu); sync->is_done = 1; - grpc_pollset_kick(&sync->pollset, NULL); - gpr_mu_unlock(GRPC_POLLSET_MU(&sync->pollset)); + grpc_pollset_kick(sync->pollset, NULL); + gpr_mu_unlock(sync->mu); } int main(int argc, char **argv) { @@ -103,23 +105,26 @@ int main(int argc, char **argv) { grpc_init(); - grpc_pollset_init(&sync.pollset); + sync.pollset = gpr_malloc(grpc_pollset_size()); + grpc_pollset_init(sync.pollset, &sync.mu); sync.is_done = 0; - grpc_jwt_verifier_verify(&exec_ctx, verifier, &sync.pollset, jwt, aud, + grpc_jwt_verifier_verify(&exec_ctx, verifier, sync.pollset, jwt, aud, on_jwt_verification_done, &sync); - gpr_mu_lock(GRPC_POLLSET_MU(&sync.pollset)); + gpr_mu_lock(sync.mu); while (!sync.is_done) { - grpc_pollset_worker worker; - grpc_pollset_work(&exec_ctx, &sync.pollset, &worker, + grpc_pollset_worker *worker = NULL; + grpc_pollset_work(&exec_ctx, sync.pollset, &worker, gpr_now(GPR_CLOCK_MONOTONIC), gpr_inf_future(GPR_CLOCK_MONOTONIC)); - gpr_mu_unlock(GRPC_POLLSET_MU(&sync.pollset)); + gpr_mu_unlock(sync.mu); grpc_exec_ctx_finish(&exec_ctx); - gpr_mu_lock(GRPC_POLLSET_MU(&sync.pollset)); + gpr_mu_lock(sync.mu); } - gpr_mu_unlock(GRPC_POLLSET_MU(&sync.pollset)); + gpr_mu_unlock(sync.mu); + + gpr_free(sync.pollset); grpc_jwt_verifier_destroy(verifier); gpr_cmdline_destroy(cl); |