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;
export 'src/auth/auth_io.dart'
show
ComputeEngineAuthenticator,
ServiceAccountAuthenticator;
show ComputeEngineAuthenticator, ServiceAccountAuthenticator;
export 'src/client/call.dart' show CallOptions, ClientCall, MetadataProvider;
export 'src/client/client.dart' show Client;

View File

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

View File

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

View File

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

View File

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

View File

@ -50,7 +50,7 @@ class FixedConnectionClientChannel extends ClientChannelBase {
main() async {
test('client reconnects after the connection gets old', () async {
final grpc.Server server = grpc.Server([TestService()]);
await server.serve(port: 0);
await server.serve(address: 'localhost', port: 0);
final channel = FixedConnectionClientChannel(Http2ClientConnection(
'localhost',
@ -75,7 +75,9 @@ main() async {
test('client reconnects when stream limit is used', () async {
final grpc.Server server = grpc.Server([TestService()]);
await server.serve(
port: 0, http2ServerSettings: ServerSettings(concurrentStreamLimit: 2));
address: 'localhost',
port: 0,
http2ServerSettings: ServerSettings(concurrentStreamLimit: 2));
final channel = FixedConnectionClientChannel(Http2ClientConnection(
'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/connection.dart';
import 'package:grpc/src/client/http2_connection.dart';
import 'package:http2/http2.dart';
import 'package:test/test.dart';
class TestClient extends Client {
@ -49,7 +48,7 @@ class FixedConnectionClientChannel extends ClientChannelBase {
main() async {
test('round trip insecure connection', () async {
final Server server = Server([TestService()]);
await server.serve(port: 0);
await server.serve(address: 'localhost', port: 0);
final channel = FixedConnectionClientChannel(Http2ClientConnection(
'localhost',
@ -64,6 +63,7 @@ main() async {
test('round trip secure connection', () async {
final Server server = Server([TestService()]);
await server.serve(
address: 'localhost',
port: 0,
security: ServerTlsCredentials(
certificate: File('test/data/localhost.crt').readAsBytesSync(),

View File

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