-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added client-side interop tests. (#32)
- Loading branch information
1 parent
2f118ea
commit a9b919a
Showing
4 changed files
with
1,144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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----- |
Oops, something went wrong.