AutoRefreshingClient should close underlying client by default (#253)
Co-authored-by: Kevin Moore <kevmoo@users.noreply.github.com>
diff --git a/README.md b/README.md
index c740a9c..12b6385 100644
--- a/README.md
+++ b/README.md
@@ -476,6 +476,19 @@
The following notes for those who are contributing to this package.
If you are only using this package, you can skip this section.
+If you are only making changes to `googleapis_auth`, then you only need to run
+tests for that package and can skip the remainder of this section. Specifically,
+before submitting a pull request:
+
+ ```console
+ $ pushd googleapis_auth
+ $ pub get
+ $ pub run test
+ $ dart format . --fix
+ $ popd
+ ```
+Otherwise...
+
* Clone this package and run `pub upgrade` from the `generator` directory.
```console
@@ -544,5 +557,3 @@
<a href="http://developers.google.com/products/">developers' products page</a>.
Find the product you're interested in on that page and follow the link.
Be sure to look the API reference docs for Dart as some of the Dart APIs have quirks.
-
-
diff --git a/googleapis_auth/lib/src/auth_http_utils.dart b/googleapis_auth/lib/src/auth_http_utils.dart
index 42572db..1d00763 100644
--- a/googleapis_auth/lib/src/auth_http_utils.dart
+++ b/googleapis_auth/lib/src/auth_http_utils.dart
@@ -90,7 +90,7 @@
Client client,
this.clientId,
this.credentials, {
- bool closeUnderlyingClient = false,
+ bool closeUnderlyingClient = true,
this.quotaProject,
}) : assert(credentials.accessToken.type == 'Bearer'),
assert(credentials.refreshToken != null),
diff --git a/googleapis_auth/test/adc_test.dart b/googleapis_auth/test/adc_test.dart
index efd7ea5..48555ad 100644
--- a/googleapis_auth/test/adc_test.dart
+++ b/googleapis_auth/test/adc_test.dart
@@ -50,7 +50,7 @@
return Response('hello world', 200);
}
return Response('bad', 404);
- }, expectClose: false),
+ }),
);
expect(c.credentials.accessToken.data, equals('atoken'));
@@ -104,7 +104,7 @@
return Response('hello world', 200);
}
return Response('bad', 404);
- }, expectClose: false),
+ }),
);
expect(c.credentials.accessToken.data, equals('atoken'));
diff --git a/googleapis_auth/test/oauth2_test.dart b/googleapis_auth/test/oauth2_test.dart
index d1b8355..ce1583c 100644
--- a/googleapis_auth/test/oauth2_test.dart
+++ b/googleapis_auth/test/oauth2_test.dart
@@ -325,19 +325,17 @@
final client = autoRefreshingClient(
clientId,
credentials,
- mockClient(
- expectAsync1((request) {
- if (serverInvocation++ == 0) {
- // This should be a refresh request.
- expect(request.headers['foo'], isNull);
- return successfulRefresh(request);
- } else {
- // This is the real request.
- expect(request.headers['foo'], equals('bar'));
- return Future.value(Response('', 200));
- }
- }, count: 2),
- expectClose: false));
+ mockClient(expectAsync1((request) {
+ if (serverInvocation++ == 0) {
+ // This should be a refresh request.
+ expect(request.headers['foo'], isNull);
+ return successfulRefresh(request);
+ } else {
+ // This is the real request.
+ expect(request.headers['foo'], equals('bar'));
+ return Future.value(Response('', 200));
+ }
+ }, count: 2)));
expect(client.credentials, equals(credentials));
var executed = false;