/** * Run the per_rpc_creds auth test. * @param $stub Stub object that has service methods * @param $args array command line args */ function perRpcCreds($stub, $args) { $jsonKey = json_decode(file_get_contents(getenv(CredentialsLoader::ENV_VAR)), true); $auth_credentials = ApplicationDefaultCredentials::getCredentials($args['oauth_scope']); $token = $auth_credentials->fetchAuthToken(); $metadata = array(CredentialsLoader::AUTH_METADATA_KEY => array(sprintf("%s %s", $token['token_type'], $token['access_token']))); $result = performLargeUnary($stub, $fillUsername = true, $fillOauthScope = true, $metadata); hardAssert($result->getUsername() == $jsonKey['client_email'], 'invalid email returned'); }
/** * Run the per_rpc_creds auth test. * * @param $stub Stub object that has service methods * @param $args array command line args */ function perRpcCreds($stub, $args) { $jsonKey = json_decode(file_get_contents(getenv(CredentialsLoader::ENV_VAR)), true); $result = performLargeUnary($stub, $fillUsername = true, $fillOauthScope = true, 'updateAuthMetadataCallback'); hardAssert($result->getUsername() == $jsonKey['client_email'], 'invalid email returned'); }
/** * Run the jwt token credentials auth test. * Passes when run against the cloud server as of 2015-05-12 * @param $stub Stub object that has service methods * @param $args array command line args */ function jwtTokenCreds($stub, $args) { $jsonKey = json_decode(file_get_contents(getenv(Google\Auth\CredentialsLoader::ENV_VAR)), true); $result = performLargeUnary($stub, $fillUsername = true, $fillOauthScope = true); hardAssert($result->getUsername() == $jsonKey['client_email'], 'invalid email returned'); }