Exemple #1
0
    $update_metadata = function ($metadata, $authUri = null, ClientInterface $client = null) use($token) {
        $metadata_copy = $metadata;
        $metadata_copy[CredentialsLoader::AUTH_METADATA_KEY] = [sprintf('%s %s', $token['token_type'], $token['access_token'])];
        return $metadata_copy;
    };
    $opts['update_metadata'] = $update_metadata;
}
$stub = new grpc\testing\TestServiceClient($server_address, $opts);
echo "Connecting to {$server_address}\n";
echo "Running test case {$test_case}\n";
switch ($test_case) {
    case 'empty_unary':
        emptyUnary($stub);
        break;
    case 'large_unary':
        largeUnary($stub);
        break;
    case 'client_streaming':
        clientStreaming($stub);
        break;
    case 'server_streaming':
        serverStreaming($stub);
        break;
    case 'ping_pong':
        pingPong($stub);
        break;
    case 'empty_stream':
        emptyStream($stub);
        break;
    case 'cancel_after_begin':
        cancelAfterBegin($stub);
Exemple #2
0
function interop_main($args, $stub = false)
{
    if (!$stub) {
        $stub = _makeStub($args);
    }
    $test_case = $args['test_case'];
    echo "Running test case {$test_case}\n";
    switch ($test_case) {
        case 'empty_unary':
            emptyUnary($stub);
            break;
        case 'large_unary':
            largeUnary($stub);
            break;
        case 'client_streaming':
            clientStreaming($stub);
            break;
        case 'server_streaming':
            serverStreaming($stub);
            break;
        case 'ping_pong':
            pingPong($stub);
            break;
        case 'empty_stream':
            emptyStream($stub);
            break;
        case 'cancel_after_begin':
            cancelAfterBegin($stub);
            break;
        case 'cancel_after_first_response':
            cancelAfterFirstResponse($stub);
            break;
        case 'timeout_on_sleeping_server':
            timeoutOnSleepingServer($stub);
            break;
        case 'custom_metadata':
            customMetadata($stub);
            break;
        case 'status_code_and_message':
            statusCodeAndMessage($stub);
            break;
        case 'unimplemented_method':
            unimplementedMethod($stub);
            break;
        case 'service_account_creds':
            serviceAccountCreds($stub, $args);
            break;
        case 'compute_engine_creds':
            computeEngineCreds($stub, $args);
            break;
        case 'jwt_token_creds':
            jwtTokenCreds($stub, $args);
            break;
        case 'oauth2_auth_token':
            oauth2AuthToken($stub, $args);
            break;
        case 'per_rpc_creds':
            perRpcCreds($stub, $args);
            break;
        default:
            echo "Unsupported test case {$test_case}\n";
            exit(1);
    }
    return $stub;
}