Add explicit 'localhost' to tests involving server (#242)

* Add explicit 'localhost' to tests involving server

* Bump version

* Clean up CHANGELOG

* Revert version bump.
This commit is contained in:
Nic Hite 2019-09-30 01:22:16 -07:00 committed by GitHub
parent 7af96e5ced
commit 7ed8b741cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 15 additions and 19 deletions

View File

@ -20,9 +20,7 @@ export 'src/auth/auth.dart'
JwtServiceAccountAuthenticator; JwtServiceAccountAuthenticator;
export 'src/auth/auth_io.dart' export 'src/auth/auth_io.dart'
show show ComputeEngineAuthenticator, ServiceAccountAuthenticator;
ComputeEngineAuthenticator,
ServiceAccountAuthenticator;
export 'src/client/call.dart' show CallOptions, ClientCall, MetadataProvider; export 'src/client/call.dart' show CallOptions, ClientCall, MetadataProvider;
export 'src/client/client.dart' show Client; export 'src/client/client.dart' show Client;

View File

@ -8,7 +8,7 @@ import 'auth.dart';
class ComputeEngineAuthenticator extends HttpBasedAuthenticator { class ComputeEngineAuthenticator extends HttpBasedAuthenticator {
Future<auth.AccessCredentials> obtainCredentialsWithClient( Future<auth.AccessCredentials> obtainCredentialsWithClient(
http.Client client, String uri) => http.Client client, String uri) =>
auth.obtainAccessCredentialsViaMetadataServer(client); auth.obtainAccessCredentialsViaMetadataServer(client);
} }
@ -27,7 +27,7 @@ class ServiceAccountAuthenticator extends HttpBasedAuthenticator {
String get projectId => _projectId; String get projectId => _projectId;
Future<auth.AccessCredentials> obtainCredentialsWithClient( Future<auth.AccessCredentials> obtainCredentialsWithClient(
http.Client client, String uri) => http.Client client, String uri) =>
auth.obtainAccessCredentialsViaServiceAccount( auth.obtainAccessCredentialsViaServiceAccount(
_serviceAccountCredentials, _scopes, client); _serviceAccountCredentials, _scopes, client);
} }

View File

@ -91,7 +91,6 @@ class RS256Signer {
} }
} }
class ASN1Parser { class ASN1Parser {
static const INTEGER_TAG = 0x02; static const INTEGER_TAG = 0x02;
static const OCTET_STRING_TAG = 0x04; static const OCTET_STRING_TAG = 0x04;
@ -222,7 +221,6 @@ class ASN1ObjectIdentifier extends ASN1Object {
class ASN1Null extends ASN1Object {} class ASN1Null extends ASN1Object {}
/// Represents integers obtained while creating a Public/Private key pair. /// Represents integers obtained while creating a Public/Private key pair.
class RSAPrivateKey { class RSAPrivateKey {
/// First prime number. /// First prime number.

View File

@ -130,7 +130,6 @@ class ClientCall<Q, R> implements Response {
return sanitizedMetadata; return sanitizedMetadata;
} }
// TODO(sigurdm): Find out why we do this. // TODO(sigurdm): Find out why we do this.
static String audiencePath(ClientMethod method) { static String audiencePath(ClientMethod method) {
final lastSlashPos = method.path.lastIndexOf('/'); final lastSlashPos = method.path.lastIndexOf('/');
@ -139,7 +138,6 @@ class ClientCall<Q, R> implements Response {
: method.path.substring(0, lastSlashPos); : method.path.substring(0, lastSlashPos);
} }
void onConnectionReady(ClientConnection connection) { void onConnectionReady(ClientConnection connection) {
if (isCancelled) return; if (isCancelled) return;
@ -149,8 +147,8 @@ class ClientCall<Q, R> implements Response {
final metadata = Map<String, String>.from(options.metadata); final metadata = Map<String, String>.from(options.metadata);
Future.forEach( Future.forEach(
options.metadataProviders, options.metadataProviders,
(provider) => provider( (provider) => provider(metadata,
metadata, '${connection.scheme}://${connection.authority}${audiencePath(_method)}')) '${connection.scheme}://${connection.authority}${audiencePath(_method)}'))
.then((_) => _sendRequest(connection, _sanitizeMetadata(metadata))) .then((_) => _sendRequest(connection, _sanitizeMetadata(metadata)))
.catchError(_onMetadataProviderError); .catchError(_onMetadataProviderError);
} }

View File

@ -48,9 +48,9 @@ class ChannelCredentials {
/// [certificates] is not provided, the default trust store is used. /// [certificates] is not provided, the default trust store is used.
const ChannelCredentials.secure( const ChannelCredentials.secure(
{List<int> certificates, {List<int> certificates,
String password, String password,
String authority, String authority,
BadCertificateHandler onBadCertificate}) BadCertificateHandler onBadCertificate})
: this._(true, certificates, password, authority, onBadCertificate); : this._(true, certificates, password, authority, onBadCertificate);
SecurityContext get securityContext { SecurityContext get securityContext {

View File

@ -50,7 +50,7 @@ class FixedConnectionClientChannel extends ClientChannelBase {
main() async { main() async {
test('client reconnects after the connection gets old', () async { test('client reconnects after the connection gets old', () async {
final grpc.Server server = grpc.Server([TestService()]); final grpc.Server server = grpc.Server([TestService()]);
await server.serve(port: 0); await server.serve(address: 'localhost', port: 0);
final channel = FixedConnectionClientChannel(Http2ClientConnection( final channel = FixedConnectionClientChannel(Http2ClientConnection(
'localhost', 'localhost',
@ -75,7 +75,9 @@ main() async {
test('client reconnects when stream limit is used', () async { test('client reconnects when stream limit is used', () async {
final grpc.Server server = grpc.Server([TestService()]); final grpc.Server server = grpc.Server([TestService()]);
await server.serve( await server.serve(
port: 0, http2ServerSettings: ServerSettings(concurrentStreamLimit: 2)); address: 'localhost',
port: 0,
http2ServerSettings: ServerSettings(concurrentStreamLimit: 2));
final channel = FixedConnectionClientChannel(Http2ClientConnection( final channel = FixedConnectionClientChannel(Http2ClientConnection(
'localhost', 'localhost',

View File

@ -6,7 +6,6 @@ import 'package:grpc/service_api.dart' as api;
import 'package:grpc/src/client/channel.dart' hide ClientChannel; import 'package:grpc/src/client/channel.dart' hide ClientChannel;
import 'package:grpc/src/client/connection.dart'; import 'package:grpc/src/client/connection.dart';
import 'package:grpc/src/client/http2_connection.dart'; import 'package:grpc/src/client/http2_connection.dart';
import 'package:http2/http2.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
class TestClient extends Client { class TestClient extends Client {
@ -49,7 +48,7 @@ class FixedConnectionClientChannel extends ClientChannelBase {
main() async { main() async {
test('round trip insecure connection', () async { test('round trip insecure connection', () async {
final Server server = Server([TestService()]); final Server server = Server([TestService()]);
await server.serve(port: 0); await server.serve(address: 'localhost', port: 0);
final channel = FixedConnectionClientChannel(Http2ClientConnection( final channel = FixedConnectionClientChannel(Http2ClientConnection(
'localhost', 'localhost',
@ -64,6 +63,7 @@ main() async {
test('round trip secure connection', () async { test('round trip secure connection', () async {
final Server server = Server([TestService()]); final Server server = Server([TestService()]);
await server.serve( await server.serve(
address: 'localhost',
port: 0, port: 0,
security: ServerTlsCredentials( security: ServerTlsCredentials(
certificate: File('test/data/localhost.crt').readAsBytesSync(), certificate: File('test/data/localhost.crt').readAsBytesSync(),

View File

@ -76,7 +76,7 @@ main() async {
server.shutdown(); server.shutdown();
}, reason: 'the producer should get cancelled')) }, reason: 'the producer should get cancelled'))
]); ]);
await server.serve(port: 0); await server.serve(address: 'localhost', port: 0);
final receivePort = ReceivePort(); final receivePort = ReceivePort();
Isolate.spawn( Isolate.spawn(
client, ClientData(port: server.port, sendPort: receivePort.sendPort)); client, ClientData(port: server.port, sendPort: receivePort.sendPort));