mirror of https://github.com/grpc/grpc-dart.git
Added client-side interop tests. (#32)
This commit is contained in:
parent
2f118ea043
commit
a9b919a5e9
|
@ -0,0 +1,99 @@
|
|||
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:args/args.dart';
|
||||
|
||||
import 'package:interop/src/client.dart';
|
||||
|
||||
const _serverHostArgument = 'server_host';
|
||||
const _serverHostOverrideArgument = 'server_host_override';
|
||||
const _serverPortArgument = 'server_port';
|
||||
const _testCaseArgument = 'test_case';
|
||||
const _useTLSArgument = 'use_tls';
|
||||
const _useTestCAArgument = 'use_test_ca';
|
||||
const _defaultServiceAccountArgument = 'default_service_account';
|
||||
const _oauthScopeArgument = 'oauth_scope';
|
||||
const _serviceAccountKeyFileArgument = 'service_account_key_file';
|
||||
|
||||
/// Clients implement test cases that test certain functionally. Each client is
|
||||
/// provided the test case it is expected to run as a command-line parameter.
|
||||
/// Names should be lowercase and without spaces.
|
||||
///
|
||||
/// Clients should accept these arguments:
|
||||
///
|
||||
/// * --server_host=HOSTNAME
|
||||
/// * The server host to connect to. For example, "localhost" or "127.0.0.1"
|
||||
/// * --server_host_override=HOSTNAME
|
||||
/// * The server host to claim to be connecting to, for use in TLS and
|
||||
/// HTTP/2 :authority header. If unspecified, the value of --server_host
|
||||
/// will be used
|
||||
/// * --server_port=PORT
|
||||
/// * The server port to connect to. For example, "8080"
|
||||
/// * --test_case=TESTCASE
|
||||
/// * The name of the test case to execute. For example, "empty_unary"
|
||||
/// * --use_tls=BOOLEAN
|
||||
/// * Whether to use a plaintext or encrypted connection
|
||||
/// * --use_test_ca=BOOLEAN
|
||||
/// * Whether to replace platform root CAs with ca.pem as the CA root
|
||||
/// * --default_service_account=ACCOUNT_EMAIL
|
||||
/// * Email of the GCE default service account.
|
||||
/// * --oauth_scope=SCOPE
|
||||
/// * OAuth scope. For example, "https://www.googleapis.com/auth/xapi.zoo"
|
||||
/// * --service_account_key_file=PATH
|
||||
/// * The path to the service account JSON key file generated from GCE
|
||||
/// developer console.
|
||||
///
|
||||
/// Clients must support TLS with ALPN. Clients must not disable certificate
|
||||
/// checking.
|
||||
Future<int> main(List<String> args) async {
|
||||
final argumentParser = new ArgParser();
|
||||
argumentParser.addOption(_serverHostArgument,
|
||||
help: 'The server host to connect to. For example, "localhost" or '
|
||||
'"127.0.0.1".');
|
||||
argumentParser.addOption(_serverHostOverrideArgument,
|
||||
help: 'The server host to claim to be connecting to, for use in TLS and '
|
||||
'HTTP/2 :authority header. If unspecified, the value of '
|
||||
'--server_host will be used.');
|
||||
argumentParser.addOption(_serverPortArgument,
|
||||
help: 'The server port to connect to. For example, "8080".');
|
||||
argumentParser.addOption(_testCaseArgument,
|
||||
help:
|
||||
'The name of the test case to execute. For example, "empty_unary".');
|
||||
argumentParser.addOption(_useTLSArgument,
|
||||
defaultsTo: 'false',
|
||||
help: 'Whether to use a plaintext or encrypted connection.');
|
||||
argumentParser.addOption(_useTestCAArgument,
|
||||
help: 'Whether to replace platform root CAs with ca.pem as the CA root.');
|
||||
argumentParser.addOption(_defaultServiceAccountArgument,
|
||||
help: 'Email of the GCE default service account.');
|
||||
argumentParser.addOption(_oauthScopeArgument,
|
||||
help: 'OAuth scope. For example, '
|
||||
'"https://www.googleapis.com/auth/xapi.zoo".');
|
||||
argumentParser.addOption(_serviceAccountKeyFileArgument,
|
||||
help: 'The path to the service account JSON key file generated from GCE '
|
||||
'developer console.');
|
||||
final arguments = argumentParser.parse(args);
|
||||
|
||||
final testClient = new Tester();
|
||||
|
||||
testClient.serverHost = arguments[_serverHostArgument];
|
||||
testClient.serverHostOverride = arguments[_serverHostOverrideArgument];
|
||||
testClient.serverPort = arguments[_serverPortArgument];
|
||||
testClient.testCase = arguments[_testCaseArgument];
|
||||
testClient.useTls = arguments[_useTLSArgument];
|
||||
testClient.useTestCA = arguments[_useTestCAArgument];
|
||||
testClient.defaultServiceAccount = arguments[_defaultServiceAccountArgument];
|
||||
testClient.oauthScope = arguments[_oauthScopeArgument];
|
||||
testClient.serviceAccountKeyFile = arguments[_serviceAccountKeyFileArgument];
|
||||
|
||||
if (!testClient.validate()) {
|
||||
print(argumentParser.usage);
|
||||
return -1;
|
||||
}
|
||||
await testClient.runTest();
|
||||
print('Passed.');
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
-----BEGIN CERTIFICATE-----
|
||||
MIICSjCCAbOgAwIBAgIJAJHGGR4dGioHMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV
|
||||
BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX
|
||||
aWRnaXRzIFB0eSBMdGQxDzANBgNVBAMTBnRlc3RjYTAeFw0xNDExMTEyMjMxMjla
|
||||
Fw0yNDExMDgyMjMxMjlaMFYxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0
|
||||
YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDzANBgNVBAMT
|
||||
BnRlc3RjYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwEDfBV5MYdlHVHJ7
|
||||
+L4nxrZy7mBfAVXpOc5vMYztssUI7mL2/iYujiIXM+weZYNTEpLdjyJdu7R5gGUu
|
||||
g1jSVK/EPHfc74O7AyZU34PNIP4Sh33N+/A5YexrNgJlPY+E3GdVYi4ldWJjgkAd
|
||||
Qah2PH5ACLrIIC6tRka9hcaBlIECAwEAAaMgMB4wDAYDVR0TBAUwAwEB/zAOBgNV
|
||||
HQ8BAf8EBAMCAgQwDQYJKoZIhvcNAQELBQADgYEAHzC7jdYlzAVmddi/gdAeKPau
|
||||
sPBG/C2HCWqHzpCUHcKuvMzDVkY/MP2o6JIW2DBbY64bO/FceExhjcykgaYtCH/m
|
||||
oIU63+CFOTtR7otyQAWHqXa7q4SbCDlG7DyRFxqG0txPtGvy12lgldA2+RgcigQG
|
||||
Dfcog5wrJytaQ6UA0wE=
|
||||
-----END CERTIFICATE-----
|
File diff suppressed because it is too large
Load Diff
|
@ -9,6 +9,7 @@ environment:
|
|||
dependencies:
|
||||
args: ^0.13.0
|
||||
async: ^1.13.3
|
||||
collection: ^1.14.2
|
||||
grpc:
|
||||
path: ../
|
||||
protobuf: ^0.5.4
|
||||
|
|
Loading…
Reference in New Issue