From e19497a9d5e50ce47fb4bc0046aa6b239a15549d Mon Sep 17 00:00:00 2001 From: Stanley Cheung <stanleycheung@google.com> Date: Tue, 5 May 2015 09:31:23 -0700 Subject: [PATCH] add php compute_engine_creds auth interop test --- src/php/tests/interop/interop_client.php | 24 +++++++++++++++++- tools/gce_setup/grpc_docker.sh | 31 ++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/src/php/tests/interop/interop_client.php b/src/php/tests/interop/interop_client.php index 22f85aa322..98a367a905 100755 --- a/src/php/tests/interop/interop_client.php +++ b/src/php/tests/interop/interop_client.php @@ -125,6 +125,24 @@ function serviceAccountCreds($stub, $args) { 'invalid oauth scope returned'); } +/** + * Run the compute engine credentials auth test. + * Has not been run from gcloud as of 2015-05-05 + * @param $stub Stub object that has service methods + * @param $args array command line args + */ +function computeEngineCreds($stub, $args) { + if (!array_key_exists('oauth_scope', $args)) { + throw new Exception('Missing oauth scope'); + } + if (!array_key_exists('default_service_account', $args)) { + throw new Exception('Missing default_service_account'); + } + $result = performLargeUnary($stub, $fillUsername=true, $fillOauthScope=true); + hardAssert($args['default_service_account'] == $result->getUsername(), + 'invalid email returned'); +} + /** * Run the client_streaming test. * Passes when run against the Node server as of 2015-04-30 @@ -240,7 +258,8 @@ function cancelAfterFirstResponse($stub) { } $args = getopt('', array('server_host:', 'server_port:', 'test_case:', - 'server_host_override:', 'oauth_scope:')); + 'server_host_override:', 'oauth_scope:', + 'default_service_account:')); if (!array_key_exists('server_host', $args) || !array_key_exists('server_port', $args) || !array_key_exists('test_case', $args)) { @@ -301,6 +320,9 @@ switch ($args['test_case']) { case 'service_account_creds': serviceAccountCreds($stub, $args); break; + case 'compute_engine_creds': + computeEngineCreds($stub, $args); + break; default: exit(1); } diff --git a/tools/gce_setup/grpc_docker.sh b/tools/gce_setup/grpc_docker.sh index 8b5d5eae50..ecce0e2983 100755 --- a/tools/gce_setup/grpc_docker.sh +++ b/tools/gce_setup/grpc_docker.sh @@ -1250,6 +1250,37 @@ grpc_interop_gen_php_cmd() { echo $the_cmd } +# constructs the full dockerized php service_account auth interop test cmd. +# +# call-seq: +# flags= .... # generic flags to include the command +# cmd=$($grpc_gen_test_cmd $flags) +grpc_cloud_prod_auth_service_account_creds_gen_php_cmd() { + local env_flag="-e SSL_CERT_FILE=/cacerts/roots.pem " + env_flag+="-e GOOGLE_APPLICATION_CREDENTIALS=/service_account/stubbyCloudTestingTest-7dd63462c60c.json " + local cmd_prefix="sudo docker run $env_flag grpc/php"; + local test_script="/var/local/git/grpc/src/php/bin/interop_client.sh"; + local gfe_flags=$(_grpc_prod_gfe_flags); + local added_gfe_flags=$(_grpc_default_creds_test_flags) + local the_cmd="$cmd_prefix $test_script $gfe_flags $added_gfe_flags $@"; + echo $the_cmd +} + +# constructs the full dockerized php compute_engine auth interop test cmd. +# +# call-seq: +# flags= .... # generic flags to include the command +# cmd=$($grpc_gen_test_cmd $flags) +grpc_cloud_prod_auth_compute_engine_creds_gen_php_cmd() { + local env_flag="-e SSL_CERT_FILE=/cacerts/roots.pem " + local cmd_prefix="sudo docker run $env_flag grpc/php"; + local test_script="/var/local/git/grpc/src/php/bin/interop_client.sh"; + local gfe_flags=$(_grpc_prod_gfe_flags); + local added_gfe_flags=$(_grpc_gce_test_flags) + local the_cmd="$cmd_prefix $test_script $gfe_flags $added_gfe_flags $@"; + echo $the_cmd +} + # constructs the full dockerized node interop test cmd. # # call-seq: -- GitLab