Skip to content

Commit 5789faf

Browse files
authored
Merge pull request #1 from DutchCodingCompany/feature/upgrade-to-chopper-6.1.3
update Chopper
2 parents aa13e42 + f5e6842 commit 5789faf

File tree

4 files changed

+13
-24
lines changed

4 files changed

+13
-24
lines changed

example/oauth_chopper_example.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void main() {
1717

1818
/// Add the oauth authenticator and interceptor to the chopper client.
1919
final chopperClient = ChopperClient(
20-
baseUrl: 'https://example.com',
20+
baseUrl: Uri(host: 'https://example.com'),
2121
authenticator: oauthChopper.authenticator(),
2222
interceptors: [
2323
oauthChopper.interceptor,

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ environment:
77
sdk: '>=2.17.0 <3.0.0'
88

99
dependencies:
10-
chopper: ^5.0.0
10+
chopper: ^6.1.3
1111
oauth2: ^2.0.0
1212

1313
dev_dependencies:

test/oauth_authenticator_test.dart

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ void main() {
2222
expiration: DateTime(2022, 9, 1),
2323
),
2424
);
25-
final testRequest = Request('GET', 'test', 'test');
26-
final unauthorizedResponse =
27-
Response(http.Response('body', HttpStatus.unauthorized), 'body');
28-
final authorizedResponse =
29-
Response(http.Response('body', HttpStatus.accepted), 'body');
25+
final testRequest = Request('GET', Uri(host: 'test'), Uri(host: 'test'));
26+
final unauthorizedResponse = Response(http.Response('body', HttpStatus.unauthorized), 'body');
27+
final authorizedResponse = Response(http.Response('body', HttpStatus.accepted), 'body');
3028

3129
test('only refresh on unauthorized and token', () async {
3230
// arrange
@@ -36,8 +34,7 @@ void main() {
3634
final expected = {'Authorization': 'Bearer token'};
3735

3836
// act
39-
final result =
40-
await authenticator.authenticate(testRequest, unauthorizedResponse);
37+
final result = await authenticator.authenticate(testRequest, unauthorizedResponse);
4138

4239
// assert
4340
verify(mockOAuthChopper.refresh()).called(1);
@@ -51,8 +48,7 @@ void main() {
5148
final authenticator = OAuthAuthenticator(mockOAuthChopper, null);
5249

5350
// act
54-
final result =
55-
await authenticator.authenticate(testRequest, authorizedResponse);
51+
final result = await authenticator.authenticate(testRequest, authorizedResponse);
5652

5753
// assert
5854
verifyNever(mockOAuthChopper.refresh());
@@ -66,8 +62,7 @@ void main() {
6662
final authenticator = OAuthAuthenticator(mockOAuthChopper, null);
6763

6864
// act
69-
final result =
70-
await authenticator.authenticate(testRequest, unauthorizedResponse);
65+
final result = await authenticator.authenticate(testRequest, unauthorizedResponse);
7166

7267
// assert
7368
verifyNever(mockOAuthChopper.refresh());
@@ -81,8 +76,7 @@ void main() {
8176
final authenticator = OAuthAuthenticator(mockOAuthChopper, null);
8277

8378
// act
84-
final result =
85-
await authenticator.authenticate(testRequest, unauthorizedResponse);
79+
final result = await authenticator.authenticate(testRequest, unauthorizedResponse);
8680

8781
// assert
8882
verify(mockOAuthChopper.refresh()).called(1);
@@ -97,23 +91,18 @@ void main() {
9791

9892
// act
9993
// assert
100-
expect(
101-
() async =>
102-
await authenticator.authenticate(testRequest, unauthorizedResponse),
103-
throwsFormatException);
94+
expect(() async => await authenticator.authenticate(testRequest, unauthorizedResponse), throwsFormatException);
10495
});
10596

10697
test("Exception not thrown if onError is supplied", () async {
10798
// arrange
10899
FormatException? result;
109100
when(mockOAuthChopper.refresh()).thenThrow(FormatException('failed'));
110101
when(mockOAuthChopper.token).thenAnswer((_) async => testToken);
111-
final authenticator = OAuthAuthenticator(
112-
mockOAuthChopper, (e, s) => result = e as FormatException);
102+
final authenticator = OAuthAuthenticator(mockOAuthChopper, (e, s) => result = e as FormatException);
113103

114104
// act
115-
final responseResult =
116-
await authenticator.authenticate(testRequest, unauthorizedResponse);
105+
final responseResult = await authenticator.authenticate(testRequest, unauthorizedResponse);
117106

118107
// assert
119108
expect(result?.message, 'failed');

test/oauth_interceptor_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void main() {
2020
),
2121
);
2222

23-
final testRequest = Request('GET', 'test', 'test');
23+
final testRequest = Request('GET', Uri(host: 'test'), Uri(host: 'test'));
2424

2525
test('HeaderInterceptor adds available token to headers', () async {
2626
// arrange

0 commit comments

Comments
 (0)