@@ -23,8 +23,10 @@ void main() {
23
23
),
24
24
);
25
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' );
26
+ final unauthorizedResponse =
27
+ Response (http.Response ('body' , HttpStatus .unauthorized), 'body' );
28
+ final authorizedResponse =
29
+ Response (http.Response ('body' , HttpStatus .accepted), 'body' );
28
30
29
31
test ('only refresh on unauthorized and token' , () async {
30
32
// arrange
@@ -34,7 +36,8 @@ void main() {
34
36
final expected = {'Authorization' : 'Bearer token' };
35
37
36
38
// act
37
- final result = await authenticator.authenticate (testRequest, unauthorizedResponse);
39
+ final result =
40
+ await authenticator.authenticate (testRequest, unauthorizedResponse);
38
41
39
42
// assert
40
43
verify (mockOAuthChopper.refresh ()).called (1 );
@@ -48,7 +51,8 @@ void main() {
48
51
final authenticator = OAuthAuthenticator (mockOAuthChopper, null );
49
52
50
53
// act
51
- final result = await authenticator.authenticate (testRequest, authorizedResponse);
54
+ final result =
55
+ await authenticator.authenticate (testRequest, authorizedResponse);
52
56
53
57
// assert
54
58
verifyNever (mockOAuthChopper.refresh ());
@@ -62,7 +66,8 @@ void main() {
62
66
final authenticator = OAuthAuthenticator (mockOAuthChopper, null );
63
67
64
68
// act
65
- final result = await authenticator.authenticate (testRequest, unauthorizedResponse);
69
+ final result =
70
+ await authenticator.authenticate (testRequest, unauthorizedResponse);
66
71
67
72
// assert
68
73
verifyNever (mockOAuthChopper.refresh ());
@@ -76,7 +81,8 @@ void main() {
76
81
final authenticator = OAuthAuthenticator (mockOAuthChopper, null );
77
82
78
83
// act
79
- final result = await authenticator.authenticate (testRequest, unauthorizedResponse);
84
+ final result =
85
+ await authenticator.authenticate (testRequest, unauthorizedResponse);
80
86
81
87
// assert
82
88
verify (mockOAuthChopper.refresh ()).called (1 );
@@ -91,18 +97,23 @@ void main() {
91
97
92
98
// act
93
99
// assert
94
- expect (() async => await authenticator.authenticate (testRequest, unauthorizedResponse), throwsFormatException);
100
+ expect (
101
+ () async =>
102
+ await authenticator.authenticate (testRequest, unauthorizedResponse),
103
+ throwsFormatException);
95
104
});
96
105
97
106
test ("Exception not thrown if onError is supplied" , () async {
98
107
// arrange
99
108
FormatException ? result;
100
109
when (mockOAuthChopper.refresh ()).thenThrow (FormatException ('failed' ));
101
110
when (mockOAuthChopper.token).thenAnswer ((_) async => testToken);
102
- final authenticator = OAuthAuthenticator (mockOAuthChopper, (e, s) => result = e as FormatException );
111
+ final authenticator = OAuthAuthenticator (
112
+ mockOAuthChopper, (e, s) => result = e as FormatException );
103
113
104
114
// act
105
- final responseResult = await authenticator.authenticate (testRequest, unauthorizedResponse);
115
+ final responseResult =
116
+ await authenticator.authenticate (testRequest, unauthorizedResponse);
106
117
107
118
// assert
108
119
expect (result? .message, 'failed' );
0 commit comments