diff --git a/lib/access_token_request.dart b/lib/access_token_request.dart new file mode 100644 index 0000000..03ee6f2 --- /dev/null +++ b/lib/access_token_request.dart @@ -0,0 +1,23 @@ +class AccessTokenRequest { + final String code; + final String clientId; + final String redirectUri; + final String tokenUrl; + final String? clientSecret; + final String? codeVerifier; + List? scopes; + Map? customParams; + dynamic httpClient; + + AccessTokenRequest({ + required this.code, + required this.clientId, + required this.redirectUri, + required this.tokenUrl, + this.clientSecret, + this.codeVerifier, + this.scopes, + this.customParams, + this.httpClient, + }); +} diff --git a/lib/oauth2_client.dart b/lib/oauth2_client.dart index a4e7489..500e337 100644 --- a/lib/oauth2_client.dart +++ b/lib/oauth2_client.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'package:flutter/services.dart'; import 'package:http/http.dart' as http; import 'package:oauth2_client/access_token_response.dart'; +import 'package:oauth2_client/access_token_request.dart'; import 'package:oauth2_client/authorization_response.dart'; import 'package:oauth2_client/oauth2_response.dart'; import 'package:oauth2_client/src/oauth2_utils.dart'; @@ -128,6 +129,61 @@ class OAuth2Client { } } + Future getTokenRequestWithAuthCodeFlow({ + required String clientId, + List? scopes, + String? clientSecret, + bool enablePKCE = true, + bool enableState = true, + String? state, + String? codeVerifier, + Function? afterAuthorizationCodeCb, + Map? authCodeParams, + Map? accessTokenParams, + httpClient, + BaseWebAuth? webAuthClient, + Map? webAuthOpts, + }) async { + String? codeChallenge; + + if (enablePKCE) { + codeVerifier ??= randomAlphaNumeric(80); + + codeChallenge = OAuth2Utils.generateCodeChallenge(codeVerifier); + } + + try { + final authResp = await requestAuthorization( + webAuthClient: webAuthClient, + clientId: clientId, + scopes: scopes, + codeChallenge: codeChallenge, + enableState: enableState, + state: state, + webAuthOpts: webAuthOpts, + ); + + if (authResp.isAccessGranted()) { + if (afterAuthorizationCodeCb != null) { + afterAuthorizationCodeCb(authResp); + } + + return AccessTokenRequest( + code: authResp.code!, + clientId: clientId, + scopes: scopes, + tokenUrl: tokenUrl, + redirectUri: redirectUri, + codeVerifier: codeVerifier, + customParams: accessTokenParams, + ); + } + } catch (e) { + return null; + } + return null; + } + /// Requests an Access Token to the OAuth2 endpoint using the Authorization Code Flow. Future getTokenWithAuthCodeFlow( {required String clientId, @@ -145,40 +201,25 @@ class OAuth2Client { Map? webAuthOpts}) async { AccessTokenResponse? tknResp; - String? codeChallenge; - - if (enablePKCE) { - codeVerifier ??= randomAlphaNumeric(80); - - codeChallenge = OAuth2Utils.generateCodeChallenge(codeVerifier); - } - try { - var authResp = await requestAuthorization( - webAuthClient: webAuthClient, - clientId: clientId, - scopes: scopes, - codeChallenge: codeChallenge, - enableState: enableState, - state: state, - customParams: authCodeParams, - webAuthOpts: webAuthOpts); - - if (authResp.isAccessGranted()) { - if (afterAuthorizationCodeCb != null) { - afterAuthorizationCodeCb(authResp); - } - - tknResp = await requestAccessToken( - httpClient: httpClient, - //If the authorization request was successfull, the code must be set - //otherwise an exception is raised in the OAuth2Response constructor - code: authResp.code!, - clientId: clientId, - scopes: scopes, - clientSecret: clientSecret, - codeVerifier: codeVerifier, - customParams: accessTokenParams); + final tknReq = await getTokenRequestWithAuthCodeFlow( + clientId: clientId, + scopes: scopes, + clientSecret: clientSecret, + enablePKCE: enablePKCE, + enableState: enableState, + state: state, + codeVerifier: codeVerifier, + afterAuthorizationCodeCb: afterAuthorizationCodeCb, + authCodeParams: authCodeParams, + accessTokenParams: accessTokenParams, + httpClient: httpClient, + webAuthClient: webAuthClient, + webAuthOpts: webAuthOpts, + ); + + if (tknReq != null) { + tknResp = await requestAccessToken(tknReq); } else { tknResp = AccessTokenResponse.errorResponse(); } @@ -247,29 +288,24 @@ class OAuth2Client { } /// Requests and Access Token using the provided Authorization [code]. - Future requestAccessToken( - {required String code, - required String clientId, - String? clientSecret, - String? codeVerifier, - List? scopes, - Map? customParams, - httpClient}) async { + Future requestAccessToken(AccessTokenRequest req) async { final params = getTokenUrlParams( - code: code, - redirectUri: redirectUri, - codeVerifier: codeVerifier, - customParams: customParams); + code: req.code, + redirectUri: redirectUri, + codeVerifier: req.codeVerifier, + customParams: req.customParams, + ); var response = await _performAuthorizedRequest( - url: tokenUrl, - clientId: clientId, - clientSecret: clientSecret, - params: params, - headers: _accessTokenRequestHeaders, - httpClient: httpClient); - - return http2TokenResponse(response, requestedScopes: scopes); + url: tokenUrl, + clientId: req.clientId, + clientSecret: req.clientSecret, + params: params, + headers: _accessTokenRequestHeaders, + httpClient: req.httpClient, + ); + + return http2TokenResponse(response, requestedScopes: req.scopes); } /// Refreshes an Access Token issuing a refresh_token grant to the OAuth2 server. diff --git a/test/oauth2_client_test.dart b/test/oauth2_client_test.dart index 8661a1f..55eca50 100644 --- a/test/oauth2_client_test.dart +++ b/test/oauth2_client_test.dart @@ -2,6 +2,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:http/http.dart' as http; +import 'package:oauth2_client/access_token_request.dart'; import 'package:oauth2_client/access_token_response.dart'; import 'package:oauth2_client/oauth2_client.dart'; import 'package:oauth2_client/src/oauth2_utils.dart'; @@ -94,10 +95,15 @@ void main() { 200)); final tknResponse = await oauth2Client.requestAccessToken( - httpClient: httpClient, + AccessTokenRequest( code: authCode, + tokenUrl: tokenUrl, clientId: clientId, - codeVerifier: codeVerifier); + redirectUri: redirectUri, + httpClient: httpClient, + codeVerifier: codeVerifier, + ), + ); expect( verify(httpClient.post(Uri.parse(tokenUrl), @@ -135,10 +141,15 @@ void main() { 200)); final tknResponse = await oauth2Client.requestAccessToken( - httpClient: httpClient, + AccessTokenRequest( code: authCode, + tokenUrl: tokenUrl, clientId: clientId, - codeVerifier: codeVerifier); + redirectUri: redirectUri, + httpClient: httpClient, + codeVerifier: codeVerifier, + ), + ); expect( verify(httpClient.post(Uri.parse(tokenUrl), @@ -203,11 +214,15 @@ void main() { .thenAnswer((_) async => http.Response('', 404)); final tknResponse = await oauth2Client.requestAccessToken( - httpClient: httpClient, + AccessTokenRequest( code: authCode, + tokenUrl: tokenUrl, clientId: clientId, - // clientSecret: clientSecret, - codeVerifier: codeVerifier); + redirectUri: redirectUri, + httpClient: httpClient, + codeVerifier: codeVerifier, + ), + ); expect(tknResponse.isValid(), false); }); diff --git a/test/oauth2_client_test.mocks.dart b/test/oauth2_client_test.mocks.dart index e3a4009..e7f5b3a 100644 --- a/test/oauth2_client_test.mocks.dart +++ b/test/oauth2_client_test.mocks.dart @@ -1,18 +1,17 @@ -// Mocks generated by Mockito 5.0.17 from annotations +// Mocks generated by Mockito 5.3.1 from annotations // in oauth2_client/test/oauth2_client_test.dart. // Do not manually edit this file. -import 'dart:async' as _i5; -import 'dart:convert' as _i7; -import 'dart:typed_data' as _i8; +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i4; +import 'dart:convert' as _i5; +import 'dart:typed_data' as _i6; -import 'package:http/src/base_request.dart' as _i9; -import 'package:http/src/client.dart' as _i6; -import 'package:http/src/response.dart' as _i2; -import 'package:http/src/streamed_response.dart' as _i3; +import 'package:http/http.dart' as _i2; import 'package:mockito/mockito.dart' as _i1; -import 'package:oauth2_client/src/base_web_auth.dart' as _i4; +import 'package:oauth2_client/src/base_web_auth.dart' as _i3; +// ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters // ignore_for_file: comment_references @@ -21,112 +20,275 @@ import 'package:oauth2_client/src/base_web_auth.dart' as _i4; // ignore_for_file: prefer_const_constructors // ignore_for_file: unnecessary_parenthesis // ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class -class _FakeResponse_0 extends _i1.Fake implements _i2.Response {} +class _FakeResponse_0 extends _i1.SmartFake implements _i2.Response { + _FakeResponse_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeStreamedResponse_1 extends _i1.Fake implements _i3.StreamedResponse { +class _FakeStreamedResponse_1 extends _i1.SmartFake + implements _i2.StreamedResponse { + _FakeStreamedResponse_1( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); } /// A class which mocks [BaseWebAuth]. /// /// See the documentation for Mockito's code generation for more information. -class MockBaseWebAuth extends _i1.Mock implements _i4.BaseWebAuth { +class MockBaseWebAuth extends _i1.Mock implements _i3.BaseWebAuth { MockBaseWebAuth() { _i1.throwOnMissingStub(this); } @override - _i5.Future authenticate( - {String? callbackUrlScheme, - String? url, - String? redirectUrl, - Map? opts}) => + _i4.Future authenticate({ + required String? callbackUrlScheme, + required String? url, + required String? redirectUrl, + Map? opts, + }) => (super.noSuchMethod( - Invocation.method(#authenticate, [], { + Invocation.method( + #authenticate, + [], + { #callbackUrlScheme: callbackUrlScheme, #url: url, #redirectUrl: redirectUrl, - #opts: opts - }), - returnValue: Future.value('')) as _i5.Future); + #opts: opts, + }, + ), + returnValue: _i4.Future.value(''), + ) as _i4.Future); } /// A class which mocks [Client]. /// /// See the documentation for Mockito's code generation for more information. -class MockClient extends _i1.Mock implements _i6.Client { +class MockClient extends _i1.Mock implements _i2.Client { MockClient() { _i1.throwOnMissingStub(this); } @override - _i5.Future<_i2.Response> head(Uri? url, {Map? headers}) => - (super.noSuchMethod(Invocation.method(#head, [url], {#headers: headers}), - returnValue: Future<_i2.Response>.value(_FakeResponse_0())) - as _i5.Future<_i2.Response>); + _i4.Future<_i2.Response> head( + Uri? url, { + Map? headers, + }) => + (super.noSuchMethod( + Invocation.method( + #head, + [url], + {#headers: headers}, + ), + returnValue: _i4.Future<_i2.Response>.value(_FakeResponse_0( + this, + Invocation.method( + #head, + [url], + {#headers: headers}, + ), + )), + ) as _i4.Future<_i2.Response>); @override - _i5.Future<_i2.Response> get(Uri? url, {Map? headers}) => - (super.noSuchMethod(Invocation.method(#get, [url], {#headers: headers}), - returnValue: Future<_i2.Response>.value(_FakeResponse_0())) - as _i5.Future<_i2.Response>); + _i4.Future<_i2.Response> get( + Uri? url, { + Map? headers, + }) => + (super.noSuchMethod( + Invocation.method( + #get, + [url], + {#headers: headers}, + ), + returnValue: _i4.Future<_i2.Response>.value(_FakeResponse_0( + this, + Invocation.method( + #get, + [url], + {#headers: headers}, + ), + )), + ) as _i4.Future<_i2.Response>); @override - _i5.Future<_i2.Response> post(Uri? url, - {Map? headers, - Object? body, - _i7.Encoding? encoding}) => + _i4.Future<_i2.Response> post( + Uri? url, { + Map? headers, + Object? body, + _i5.Encoding? encoding, + }) => (super.noSuchMethod( - Invocation.method(#post, [url], - {#headers: headers, #body: body, #encoding: encoding}), - returnValue: Future<_i2.Response>.value(_FakeResponse_0())) - as _i5.Future<_i2.Response>); + Invocation.method( + #post, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i4.Future<_i2.Response>.value(_FakeResponse_0( + this, + Invocation.method( + #post, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + )), + ) as _i4.Future<_i2.Response>); @override - _i5.Future<_i2.Response> put(Uri? url, - {Map? headers, - Object? body, - _i7.Encoding? encoding}) => + _i4.Future<_i2.Response> put( + Uri? url, { + Map? headers, + Object? body, + _i5.Encoding? encoding, + }) => (super.noSuchMethod( - Invocation.method(#put, [url], - {#headers: headers, #body: body, #encoding: encoding}), - returnValue: Future<_i2.Response>.value(_FakeResponse_0())) - as _i5.Future<_i2.Response>); + Invocation.method( + #put, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i4.Future<_i2.Response>.value(_FakeResponse_0( + this, + Invocation.method( + #put, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + )), + ) as _i4.Future<_i2.Response>); @override - _i5.Future<_i2.Response> patch(Uri? url, - {Map? headers, - Object? body, - _i7.Encoding? encoding}) => + _i4.Future<_i2.Response> patch( + Uri? url, { + Map? headers, + Object? body, + _i5.Encoding? encoding, + }) => (super.noSuchMethod( - Invocation.method(#patch, [url], - {#headers: headers, #body: body, #encoding: encoding}), - returnValue: Future<_i2.Response>.value(_FakeResponse_0())) - as _i5.Future<_i2.Response>); + Invocation.method( + #patch, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i4.Future<_i2.Response>.value(_FakeResponse_0( + this, + Invocation.method( + #patch, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + )), + ) as _i4.Future<_i2.Response>); @override - _i5.Future<_i2.Response> delete(Uri? url, - {Map? headers, - Object? body, - _i7.Encoding? encoding}) => + _i4.Future<_i2.Response> delete( + Uri? url, { + Map? headers, + Object? body, + _i5.Encoding? encoding, + }) => (super.noSuchMethod( - Invocation.method(#delete, [url], - {#headers: headers, #body: body, #encoding: encoding}), - returnValue: Future<_i2.Response>.value(_FakeResponse_0())) - as _i5.Future<_i2.Response>); + Invocation.method( + #delete, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i4.Future<_i2.Response>.value(_FakeResponse_0( + this, + Invocation.method( + #delete, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + )), + ) as _i4.Future<_i2.Response>); @override - _i5.Future read(Uri? url, {Map? headers}) => - (super.noSuchMethod(Invocation.method(#read, [url], {#headers: headers}), - returnValue: Future.value('')) as _i5.Future); + _i4.Future read( + Uri? url, { + Map? headers, + }) => + (super.noSuchMethod( + Invocation.method( + #read, + [url], + {#headers: headers}, + ), + returnValue: _i4.Future.value(''), + ) as _i4.Future); @override - _i5.Future<_i8.Uint8List> readBytes(Uri? url, - {Map? headers}) => + _i4.Future<_i6.Uint8List> readBytes( + Uri? url, { + Map? headers, + }) => (super.noSuchMethod( - Invocation.method(#readBytes, [url], {#headers: headers}), - returnValue: Future<_i8.Uint8List>.value(_i8.Uint8List(0))) - as _i5.Future<_i8.Uint8List>); + Invocation.method( + #readBytes, + [url], + {#headers: headers}, + ), + returnValue: _i4.Future<_i6.Uint8List>.value(_i6.Uint8List(0)), + ) as _i4.Future<_i6.Uint8List>); @override - _i5.Future<_i3.StreamedResponse> send(_i9.BaseRequest? request) => - (super.noSuchMethod(Invocation.method(#send, [request]), - returnValue: - Future<_i3.StreamedResponse>.value(_FakeStreamedResponse_1())) - as _i5.Future<_i3.StreamedResponse>); + _i4.Future<_i2.StreamedResponse> send(_i2.BaseRequest? request) => + (super.noSuchMethod( + Invocation.method( + #send, + [request], + ), + returnValue: + _i4.Future<_i2.StreamedResponse>.value(_FakeStreamedResponse_1( + this, + Invocation.method( + #send, + [request], + ), + )), + ) as _i4.Future<_i2.StreamedResponse>); @override - void close() => super.noSuchMethod(Invocation.method(#close, []), - returnValueForMissingStub: null); + void close() => super.noSuchMethod( + Invocation.method( + #close, + [], + ), + returnValueForMissingStub: null, + ); } diff --git a/test/oauth2_helper_test.mocks.dart b/test/oauth2_helper_test.mocks.dart index 767375e..250eb89 100644 --- a/test/oauth2_helper_test.mocks.dart +++ b/test/oauth2_helper_test.mocks.dart @@ -1,21 +1,24 @@ -// Mocks generated by Mockito 5.0.17 from annotations +// Mocks generated by Mockito 5.3.1 from annotations // in oauth2_client/test/oauth2_helper_test.dart. // Do not manually edit this file. +// ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i9; -import 'dart:convert' as _i10; -import 'dart:typed_data' as _i11; +import 'dart:convert' as _i11; +import 'dart:typed_data' as _i12; import 'package:http/http.dart' as _i6; import 'package:mockito/mockito.dart' as _i1; +import 'package:oauth2_client/access_token_request.dart' as _i10; import 'package:oauth2_client/access_token_response.dart' as _i3; import 'package:oauth2_client/authorization_response.dart' as _i4; import 'package:oauth2_client/oauth2_client.dart' as _i8; import 'package:oauth2_client/oauth2_response.dart' as _i5; import 'package:oauth2_client/src/base_storage.dart' as _i7; import 'package:oauth2_client/src/base_web_auth.dart' as _i2; -import 'package:oauth2_client/src/token_storage.dart' as _i12; +import 'package:oauth2_client/src/token_storage.dart' as _i13; +// ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters // ignore_for_file: comment_references @@ -24,23 +27,81 @@ import 'package:oauth2_client/src/token_storage.dart' as _i12; // ignore_for_file: prefer_const_constructors // ignore_for_file: unnecessary_parenthesis // ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class -class _FakeBaseWebAuth_0 extends _i1.Fake implements _i2.BaseWebAuth {} +class _FakeBaseWebAuth_0 extends _i1.SmartFake implements _i2.BaseWebAuth { + _FakeBaseWebAuth_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeAccessTokenResponse_1 extends _i1.Fake - implements _i3.AccessTokenResponse {} +class _FakeAccessTokenResponse_1 extends _i1.SmartFake + implements _i3.AccessTokenResponse { + _FakeAccessTokenResponse_1( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeAuthorizationResponse_2 extends _i1.Fake - implements _i4.AuthorizationResponse {} +class _FakeAuthorizationResponse_2 extends _i1.SmartFake + implements _i4.AuthorizationResponse { + _FakeAuthorizationResponse_2( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeOAuth2Response_3 extends _i1.Fake implements _i5.OAuth2Response {} +class _FakeOAuth2Response_3 extends _i1.SmartFake + implements _i5.OAuth2Response { + _FakeOAuth2Response_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeResponse_4 extends _i1.Fake implements _i6.Response {} +class _FakeResponse_4 extends _i1.SmartFake implements _i6.Response { + _FakeResponse_4( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeStreamedResponse_5 extends _i1.Fake implements _i6.StreamedResponse { +class _FakeStreamedResponse_5 extends _i1.SmartFake + implements _i6.StreamedResponse { + _FakeStreamedResponse_5( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); } -class _FakeBaseStorage_6 extends _i1.Fake implements _i7.BaseStorage {} +class _FakeBaseStorage_6 extends _i1.SmartFake implements _i7.BaseStorage { + _FakeBaseStorage_6( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} /// A class which mocks [OAuth2Client]. /// @@ -51,272 +112,503 @@ class MockOAuth2Client extends _i1.Mock implements _i8.OAuth2Client { } @override - String get redirectUri => - (super.noSuchMethod(Invocation.getter(#redirectUri), returnValue: '') - as String); + String get redirectUri => (super.noSuchMethod( + Invocation.getter(#redirectUri), + returnValue: '', + ) as String); @override - set redirectUri(String? _redirectUri) => - super.noSuchMethod(Invocation.setter(#redirectUri, _redirectUri), - returnValueForMissingStub: null); + set redirectUri(String? _redirectUri) => super.noSuchMethod( + Invocation.setter( + #redirectUri, + _redirectUri, + ), + returnValueForMissingStub: null, + ); @override - String get customUriScheme => - (super.noSuchMethod(Invocation.getter(#customUriScheme), returnValue: '') - as String); + String get customUriScheme => (super.noSuchMethod( + Invocation.getter(#customUriScheme), + returnValue: '', + ) as String); @override - set customUriScheme(String? _customUriScheme) => - super.noSuchMethod(Invocation.setter(#customUriScheme, _customUriScheme), - returnValueForMissingStub: null); + set customUriScheme(String? _customUriScheme) => super.noSuchMethod( + Invocation.setter( + #customUriScheme, + _customUriScheme, + ), + returnValueForMissingStub: null, + ); @override - String get tokenUrl => - (super.noSuchMethod(Invocation.getter(#tokenUrl), returnValue: '') - as String); + String get tokenUrl => (super.noSuchMethod( + Invocation.getter(#tokenUrl), + returnValue: '', + ) as String); @override - set tokenUrl(String? _tokenUrl) => - super.noSuchMethod(Invocation.setter(#tokenUrl, _tokenUrl), - returnValueForMissingStub: null); + set tokenUrl(String? _tokenUrl) => super.noSuchMethod( + Invocation.setter( + #tokenUrl, + _tokenUrl, + ), + returnValueForMissingStub: null, + ); @override - set refreshUrl(String? _refreshUrl) => - super.noSuchMethod(Invocation.setter(#refreshUrl, _refreshUrl), - returnValueForMissingStub: null); + set refreshUrl(String? _refreshUrl) => super.noSuchMethod( + Invocation.setter( + #refreshUrl, + _refreshUrl, + ), + returnValueForMissingStub: null, + ); @override - set revokeUrl(String? _revokeUrl) => - super.noSuchMethod(Invocation.setter(#revokeUrl, _revokeUrl), - returnValueForMissingStub: null); + set revokeUrl(String? _revokeUrl) => super.noSuchMethod( + Invocation.setter( + #revokeUrl, + _revokeUrl, + ), + returnValueForMissingStub: null, + ); @override - String get authorizeUrl => - (super.noSuchMethod(Invocation.getter(#authorizeUrl), returnValue: '') - as String); + String get authorizeUrl => (super.noSuchMethod( + Invocation.getter(#authorizeUrl), + returnValue: '', + ) as String); @override - set authorizeUrl(String? _authorizeUrl) => - super.noSuchMethod(Invocation.setter(#authorizeUrl, _authorizeUrl), - returnValueForMissingStub: null); + set authorizeUrl(String? _authorizeUrl) => super.noSuchMethod( + Invocation.setter( + #authorizeUrl, + _authorizeUrl, + ), + returnValueForMissingStub: null, + ); @override - String get scopeSeparator => - (super.noSuchMethod(Invocation.getter(#scopeSeparator), returnValue: '') - as String); + String get scopeSeparator => (super.noSuchMethod( + Invocation.getter(#scopeSeparator), + returnValue: '', + ) as String); @override - set scopeSeparator(String? _scopeSeparator) => - super.noSuchMethod(Invocation.setter(#scopeSeparator, _scopeSeparator), - returnValueForMissingStub: null); + set scopeSeparator(String? _scopeSeparator) => super.noSuchMethod( + Invocation.setter( + #scopeSeparator, + _scopeSeparator, + ), + returnValueForMissingStub: null, + ); @override - _i2.BaseWebAuth get webAuthClient => - (super.noSuchMethod(Invocation.getter(#webAuthClient), - returnValue: _FakeBaseWebAuth_0()) as _i2.BaseWebAuth); + _i2.BaseWebAuth get webAuthClient => (super.noSuchMethod( + Invocation.getter(#webAuthClient), + returnValue: _FakeBaseWebAuth_0( + this, + Invocation.getter(#webAuthClient), + ), + ) as _i2.BaseWebAuth); @override - set webAuthClient(_i2.BaseWebAuth? _webAuthClient) => - super.noSuchMethod(Invocation.setter(#webAuthClient, _webAuthClient), - returnValueForMissingStub: null); + set webAuthClient(_i2.BaseWebAuth? _webAuthClient) => super.noSuchMethod( + Invocation.setter( + #webAuthClient, + _webAuthClient, + ), + returnValueForMissingStub: null, + ); @override _i8.CredentialsLocation get credentialsLocation => (super.noSuchMethod( - Invocation.getter(#credentialsLocation), - returnValue: _i8.CredentialsLocation.HEADER) as _i8.CredentialsLocation); + Invocation.getter(#credentialsLocation), + returnValue: _i8.CredentialsLocation.HEADER, + ) as _i8.CredentialsLocation); @override set credentialsLocation(_i8.CredentialsLocation? _credentialsLocation) => super.noSuchMethod( - Invocation.setter(#credentialsLocation, _credentialsLocation), - returnValueForMissingStub: null); + Invocation.setter( + #credentialsLocation, + _credentialsLocation, + ), + returnValueForMissingStub: null, + ); @override set accessTokenRequestHeaders(Map? headers) => - super.noSuchMethod(Invocation.setter(#accessTokenRequestHeaders, headers), - returnValueForMissingStub: null); - @override - _i9.Future<_i3.AccessTokenResponse> getTokenWithImplicitGrantFlow( - {String? clientId, - List? scopes, - bool? enableState = true, - String? state, - dynamic httpClient, - _i2.BaseWebAuth? webAuthClient, - Map? webAuthOpts, - Map? customParams}) => + super.noSuchMethod( + Invocation.setter( + #accessTokenRequestHeaders, + headers, + ), + returnValueForMissingStub: null, + ); + @override + _i9.Future<_i3.AccessTokenResponse> getTokenWithImplicitGrantFlow({ + required String? clientId, + List? scopes, + bool? enableState = true, + String? state, + dynamic httpClient, + _i2.BaseWebAuth? webAuthClient, + Map? webAuthOpts, + Map? customParams, + }) => + (super.noSuchMethod( + Invocation.method( + #getTokenWithImplicitGrantFlow, + [], + { + #clientId: clientId, + #scopes: scopes, + #enableState: enableState, + #state: state, + #httpClient: httpClient, + #webAuthClient: webAuthClient, + #webAuthOpts: webAuthOpts, + #customParams: customParams, + }, + ), + returnValue: _i9.Future<_i3.AccessTokenResponse>.value( + _FakeAccessTokenResponse_1( + this, + Invocation.method( + #getTokenWithImplicitGrantFlow, + [], + { + #clientId: clientId, + #scopes: scopes, + #enableState: enableState, + #state: state, + #httpClient: httpClient, + #webAuthClient: webAuthClient, + #webAuthOpts: webAuthOpts, + #customParams: customParams, + }, + ), + )), + ) as _i9.Future<_i3.AccessTokenResponse>); + @override + _i9.Future<_i10.AccessTokenRequest?> getTokenRequestWithAuthCodeFlow({ + required String? clientId, + List? scopes, + String? clientSecret, + bool? enablePKCE = true, + bool? enableState = true, + String? state, + String? codeVerifier, + Function? afterAuthorizationCodeCb, + Map? authCodeParams, + Map? accessTokenParams, + dynamic httpClient, + _i2.BaseWebAuth? webAuthClient, + Map? webAuthOpts, + }) => (super.noSuchMethod( - Invocation.method(#getTokenWithImplicitGrantFlow, [], { - #clientId: clientId, - #scopes: scopes, - #enableState: enableState, - #state: state, - #httpClient: httpClient, - #webAuthClient: webAuthClient, - #webAuthOpts: webAuthOpts, - #customParams: customParams - }), - returnValue: Future<_i3.AccessTokenResponse>.value( - _FakeAccessTokenResponse_1())) - as _i9.Future<_i3.AccessTokenResponse>); - @override - _i9.Future<_i3.AccessTokenResponse> getTokenWithAuthCodeFlow( - {String? clientId, - List? scopes, - String? clientSecret, - bool? enablePKCE = true, - bool? enableState = true, - String? state, - String? codeVerifier, - Function? afterAuthorizationCodeCb, - Map? authCodeParams, - Map? accessTokenParams, - dynamic httpClient, - _i2.BaseWebAuth? webAuthClient, - Map? webAuthOpts}) => + Invocation.method( + #getTokenRequestWithAuthCodeFlow, + [], + { + #clientId: clientId, + #scopes: scopes, + #clientSecret: clientSecret, + #enablePKCE: enablePKCE, + #enableState: enableState, + #state: state, + #codeVerifier: codeVerifier, + #afterAuthorizationCodeCb: afterAuthorizationCodeCb, + #authCodeParams: authCodeParams, + #accessTokenParams: accessTokenParams, + #httpClient: httpClient, + #webAuthClient: webAuthClient, + #webAuthOpts: webAuthOpts, + }, + ), + returnValue: _i9.Future<_i10.AccessTokenRequest?>.value(), + ) as _i9.Future<_i10.AccessTokenRequest?>); + @override + _i9.Future<_i3.AccessTokenResponse> getTokenWithAuthCodeFlow({ + required String? clientId, + List? scopes, + String? clientSecret, + bool? enablePKCE = true, + bool? enableState = true, + String? state, + String? codeVerifier, + Function? afterAuthorizationCodeCb, + Map? authCodeParams, + Map? accessTokenParams, + dynamic httpClient, + _i2.BaseWebAuth? webAuthClient, + Map? webAuthOpts, + }) => (super.noSuchMethod( - Invocation.method(#getTokenWithAuthCodeFlow, [], { - #clientId: clientId, - #scopes: scopes, - #clientSecret: clientSecret, - #enablePKCE: enablePKCE, - #enableState: enableState, - #state: state, - #codeVerifier: codeVerifier, - #afterAuthorizationCodeCb: afterAuthorizationCodeCb, - #authCodeParams: authCodeParams, - #accessTokenParams: accessTokenParams, - #httpClient: httpClient, - #webAuthClient: webAuthClient, - #webAuthOpts: webAuthOpts - }), - returnValue: Future<_i3.AccessTokenResponse>.value( - _FakeAccessTokenResponse_1())) - as _i9.Future<_i3.AccessTokenResponse>); - @override - _i9.Future<_i3.AccessTokenResponse> getTokenWithClientCredentialsFlow( - {String? clientId, - String? clientSecret, - List? scopes, - dynamic httpClient}) => + Invocation.method( + #getTokenWithAuthCodeFlow, + [], + { + #clientId: clientId, + #scopes: scopes, + #clientSecret: clientSecret, + #enablePKCE: enablePKCE, + #enableState: enableState, + #state: state, + #codeVerifier: codeVerifier, + #afterAuthorizationCodeCb: afterAuthorizationCodeCb, + #authCodeParams: authCodeParams, + #accessTokenParams: accessTokenParams, + #httpClient: httpClient, + #webAuthClient: webAuthClient, + #webAuthOpts: webAuthOpts, + }, + ), + returnValue: _i9.Future<_i3.AccessTokenResponse>.value( + _FakeAccessTokenResponse_1( + this, + Invocation.method( + #getTokenWithAuthCodeFlow, + [], + { + #clientId: clientId, + #scopes: scopes, + #clientSecret: clientSecret, + #enablePKCE: enablePKCE, + #enableState: enableState, + #state: state, + #codeVerifier: codeVerifier, + #afterAuthorizationCodeCb: afterAuthorizationCodeCb, + #authCodeParams: authCodeParams, + #accessTokenParams: accessTokenParams, + #httpClient: httpClient, + #webAuthClient: webAuthClient, + #webAuthOpts: webAuthOpts, + }, + ), + )), + ) as _i9.Future<_i3.AccessTokenResponse>); + @override + _i9.Future<_i3.AccessTokenResponse> getTokenWithClientCredentialsFlow({ + required String? clientId, + required String? clientSecret, + List? scopes, + dynamic httpClient, + }) => (super.noSuchMethod( - Invocation.method(#getTokenWithClientCredentialsFlow, [], { - #clientId: clientId, - #clientSecret: clientSecret, - #scopes: scopes, - #httpClient: httpClient - }), - returnValue: Future<_i3.AccessTokenResponse>.value( - _FakeAccessTokenResponse_1())) - as _i9.Future<_i3.AccessTokenResponse>); - @override - _i9.Future<_i4.AuthorizationResponse> requestAuthorization( - {String? clientId, - List? scopes, - String? codeChallenge, - bool? enableState = true, - String? state, - Map? customParams, - _i2.BaseWebAuth? webAuthClient, - Map? webAuthOpts}) => + Invocation.method( + #getTokenWithClientCredentialsFlow, + [], + { + #clientId: clientId, + #clientSecret: clientSecret, + #scopes: scopes, + #httpClient: httpClient, + }, + ), + returnValue: _i9.Future<_i3.AccessTokenResponse>.value( + _FakeAccessTokenResponse_1( + this, + Invocation.method( + #getTokenWithClientCredentialsFlow, + [], + { + #clientId: clientId, + #clientSecret: clientSecret, + #scopes: scopes, + #httpClient: httpClient, + }, + ), + )), + ) as _i9.Future<_i3.AccessTokenResponse>); + @override + _i9.Future<_i4.AuthorizationResponse> requestAuthorization({ + required String? clientId, + List? scopes, + String? codeChallenge, + bool? enableState = true, + String? state, + Map? customParams, + _i2.BaseWebAuth? webAuthClient, + Map? webAuthOpts, + }) => (super.noSuchMethod( - Invocation.method(#requestAuthorization, [], { - #clientId: clientId, - #scopes: scopes, - #codeChallenge: codeChallenge, - #enableState: enableState, - #state: state, - #customParams: customParams, - #webAuthClient: webAuthClient, - #webAuthOpts: webAuthOpts - }), - returnValue: Future<_i4.AuthorizationResponse>.value( - _FakeAuthorizationResponse_2())) - as _i9.Future<_i4.AuthorizationResponse>); + Invocation.method( + #requestAuthorization, + [], + { + #clientId: clientId, + #scopes: scopes, + #codeChallenge: codeChallenge, + #enableState: enableState, + #state: state, + #customParams: customParams, + #webAuthClient: webAuthClient, + #webAuthOpts: webAuthOpts, + }, + ), + returnValue: _i9.Future<_i4.AuthorizationResponse>.value( + _FakeAuthorizationResponse_2( + this, + Invocation.method( + #requestAuthorization, + [], + { + #clientId: clientId, + #scopes: scopes, + #codeChallenge: codeChallenge, + #enableState: enableState, + #state: state, + #customParams: customParams, + #webAuthClient: webAuthClient, + #webAuthOpts: webAuthOpts, + }, + ), + )), + ) as _i9.Future<_i4.AuthorizationResponse>); @override _i9.Future<_i3.AccessTokenResponse> requestAccessToken( - {String? code, - String? clientId, - String? clientSecret, - String? codeVerifier, - List? scopes, - Map? customParams, - dynamic httpClient}) => + _i10.AccessTokenRequest? req) => (super.noSuchMethod( - Invocation.method(#requestAccessToken, [], { - #code: code, - #clientId: clientId, - #clientSecret: clientSecret, - #codeVerifier: codeVerifier, - #scopes: scopes, - #customParams: customParams, - #httpClient: httpClient - }), - returnValue: Future<_i3.AccessTokenResponse>.value( - _FakeAccessTokenResponse_1())) - as _i9.Future<_i3.AccessTokenResponse>); - @override - _i9.Future<_i3.AccessTokenResponse> refreshToken(String? refreshToken, - {dynamic httpClient, - String? clientId, - String? clientSecret, - List? scopes}) => + Invocation.method( + #requestAccessToken, + [req], + ), + returnValue: _i9.Future<_i3.AccessTokenResponse>.value( + _FakeAccessTokenResponse_1( + this, + Invocation.method( + #requestAccessToken, + [req], + ), + )), + ) as _i9.Future<_i3.AccessTokenResponse>); + @override + _i9.Future<_i3.AccessTokenResponse> refreshToken( + String? refreshToken, { + dynamic httpClient, + required String? clientId, + String? clientSecret, + List? scopes, + }) => (super.noSuchMethod( - Invocation.method(#refreshToken, [ - refreshToken - ], { - #httpClient: httpClient, - #clientId: clientId, - #clientSecret: clientSecret, - #scopes: scopes - }), - returnValue: Future<_i3.AccessTokenResponse>.value( - _FakeAccessTokenResponse_1())) - as _i9.Future<_i3.AccessTokenResponse>); - @override - _i9.Future<_i5.OAuth2Response> revokeToken(_i3.AccessTokenResponse? tknResp, - {String? clientId, String? clientSecret, dynamic httpClient}) => + Invocation.method( + #refreshToken, + [refreshToken], + { + #httpClient: httpClient, + #clientId: clientId, + #clientSecret: clientSecret, + #scopes: scopes, + }, + ), + returnValue: _i9.Future<_i3.AccessTokenResponse>.value( + _FakeAccessTokenResponse_1( + this, + Invocation.method( + #refreshToken, + [refreshToken], + { + #httpClient: httpClient, + #clientId: clientId, + #clientSecret: clientSecret, + #scopes: scopes, + }, + ), + )), + ) as _i9.Future<_i3.AccessTokenResponse>); + @override + _i9.Future<_i5.OAuth2Response> revokeToken( + _i3.AccessTokenResponse? tknResp, { + String? clientId, + String? clientSecret, + dynamic httpClient, + }) => (super.noSuchMethod( - Invocation.method(#revokeToken, [ - tknResp - ], { - #clientId: clientId, - #clientSecret: clientSecret, - #httpClient: httpClient - }), - returnValue: - Future<_i5.OAuth2Response>.value(_FakeOAuth2Response_3())) - as _i9.Future<_i5.OAuth2Response>); + Invocation.method( + #revokeToken, + [tknResp], + { + #clientId: clientId, + #clientSecret: clientSecret, + #httpClient: httpClient, + }, + ), + returnValue: _i9.Future<_i5.OAuth2Response>.value(_FakeOAuth2Response_3( + this, + Invocation.method( + #revokeToken, + [tknResp], + { + #clientId: clientId, + #clientSecret: clientSecret, + #httpClient: httpClient, + }, + ), + )), + ) as _i9.Future<_i5.OAuth2Response>); @override _i9.Future<_i5.OAuth2Response> revokeAccessToken( - _i3.AccessTokenResponse? tknResp, - {String? clientId, - String? clientSecret, - dynamic httpClient}) => + _i3.AccessTokenResponse? tknResp, { + String? clientId, + String? clientSecret, + dynamic httpClient, + }) => (super.noSuchMethod( - Invocation.method(#revokeAccessToken, [ - tknResp - ], { - #clientId: clientId, - #clientSecret: clientSecret, - #httpClient: httpClient - }), - returnValue: - Future<_i5.OAuth2Response>.value(_FakeOAuth2Response_3())) - as _i9.Future<_i5.OAuth2Response>); + Invocation.method( + #revokeAccessToken, + [tknResp], + { + #clientId: clientId, + #clientSecret: clientSecret, + #httpClient: httpClient, + }, + ), + returnValue: _i9.Future<_i5.OAuth2Response>.value(_FakeOAuth2Response_3( + this, + Invocation.method( + #revokeAccessToken, + [tknResp], + { + #clientId: clientId, + #clientSecret: clientSecret, + #httpClient: httpClient, + }, + ), + )), + ) as _i9.Future<_i5.OAuth2Response>); @override _i9.Future<_i5.OAuth2Response> revokeRefreshToken( - _i3.AccessTokenResponse? tknResp, - {String? clientId, - String? clientSecret, - dynamic httpClient}) => + _i3.AccessTokenResponse? tknResp, { + String? clientId, + String? clientSecret, + dynamic httpClient, + }) => (super.noSuchMethod( - Invocation.method(#revokeRefreshToken, [ - tknResp - ], { - #clientId: clientId, - #clientSecret: clientSecret, - #httpClient: httpClient - }), - returnValue: - Future<_i5.OAuth2Response>.value(_FakeOAuth2Response_3())) - as _i9.Future<_i5.OAuth2Response>); - @override - String getAuthorizeUrl( - {String? clientId, - String? responseType = r'code', - String? redirectUri, - List? scopes, - bool? enableState = true, - String? state, - String? codeChallenge, - Map? customParams}) => + Invocation.method( + #revokeRefreshToken, + [tknResp], + { + #clientId: clientId, + #clientSecret: clientSecret, + #httpClient: httpClient, + }, + ), + returnValue: _i9.Future<_i5.OAuth2Response>.value(_FakeOAuth2Response_3( + this, + Invocation.method( + #revokeRefreshToken, + [tknResp], + { + #clientId: clientId, + #clientSecret: clientSecret, + #httpClient: httpClient, + }, + ), + )), + ) as _i9.Future<_i5.OAuth2Response>); + @override + String getAuthorizeUrl({ + required String? clientId, + String? responseType = r'code', + String? redirectUri, + List? scopes, + bool? enableState = true, + String? state, + String? codeChallenge, + Map? customParams, + }) => (super.noSuchMethod( - Invocation.method(#getAuthorizeUrl, [], { + Invocation.method( + #getAuthorizeUrl, + [], + { #clientId: clientId, #responseType: responseType, #redirectUri: redirectUri, @@ -324,48 +616,85 @@ class MockOAuth2Client extends _i1.Mock implements _i8.OAuth2Client { #enableState: enableState, #state: state, #codeChallenge: codeChallenge, - #customParams: customParams - }), - returnValue: '') as String); - @override - Map getTokenUrlParams( - {String? code, - String? redirectUri, - String? codeVerifier, - Map? customParams}) => + #customParams: customParams, + }, + ), + returnValue: '', + ) as String); + @override + Map getTokenUrlParams({ + required String? code, + String? redirectUri, + String? codeVerifier, + Map? customParams, + }) => (super.noSuchMethod( - Invocation.method(#getTokenUrlParams, [], { + Invocation.method( + #getTokenUrlParams, + [], + { #code: code, #redirectUri: redirectUri, #codeVerifier: codeVerifier, - #customParams: customParams - }), - returnValue: {}) as Map); + #customParams: customParams, + }, + ), + returnValue: {}, + ) as Map); @override - Map getAuthorizationHeader( - {String? clientId, String? clientSecret}) => + Map getAuthorizationHeader({ + required String? clientId, + String? clientSecret, + }) => (super.noSuchMethod( - Invocation.method(#getAuthorizationHeader, [], - {#clientId: clientId, #clientSecret: clientSecret}), - returnValue: {}) as Map); + Invocation.method( + #getAuthorizationHeader, + [], + { + #clientId: clientId, + #clientSecret: clientSecret, + }, + ), + returnValue: {}, + ) as Map); @override - Map getRefreshUrlParams({String? refreshToken}) => + Map getRefreshUrlParams({required String? refreshToken}) => (super.noSuchMethod( - Invocation.method( - #getRefreshUrlParams, [], {#refreshToken: refreshToken}), - returnValue: {}) as Map); + Invocation.method( + #getRefreshUrlParams, + [], + {#refreshToken: refreshToken}, + ), + returnValue: {}, + ) as Map); @override - _i3.AccessTokenResponse http2TokenResponse(_i6.Response? response, - {List? requestedScopes}) => + _i3.AccessTokenResponse http2TokenResponse( + _i6.Response? response, { + List? requestedScopes, + }) => (super.noSuchMethod( - Invocation.method(#http2TokenResponse, [response], - {#requestedScopes: requestedScopes}), - returnValue: _FakeAccessTokenResponse_1()) - as _i3.AccessTokenResponse); - @override - String serializeScopes(List? scopes) => - (super.noSuchMethod(Invocation.method(#serializeScopes, [scopes]), - returnValue: '') as String); + Invocation.method( + #http2TokenResponse, + [response], + {#requestedScopes: requestedScopes}, + ), + returnValue: _FakeAccessTokenResponse_1( + this, + Invocation.method( + #http2TokenResponse, + [response], + {#requestedScopes: requestedScopes}, + ), + ), + ) as _i3.AccessTokenResponse); + @override + String serializeScopes(List? scopes) => (super.noSuchMethod( + Invocation.method( + #serializeScopes, + [scopes], + ), + returnValue: '', + ) as String); } /// A class which mocks [Client]. @@ -377,136 +706,324 @@ class MockClient extends _i1.Mock implements _i6.Client { } @override - _i9.Future<_i6.Response> head(Uri? url, {Map? headers}) => - (super.noSuchMethod(Invocation.method(#head, [url], {#headers: headers}), - returnValue: Future<_i6.Response>.value(_FakeResponse_4())) - as _i9.Future<_i6.Response>); + _i9.Future<_i6.Response> head( + Uri? url, { + Map? headers, + }) => + (super.noSuchMethod( + Invocation.method( + #head, + [url], + {#headers: headers}, + ), + returnValue: _i9.Future<_i6.Response>.value(_FakeResponse_4( + this, + Invocation.method( + #head, + [url], + {#headers: headers}, + ), + )), + ) as _i9.Future<_i6.Response>); @override - _i9.Future<_i6.Response> get(Uri? url, {Map? headers}) => - (super.noSuchMethod(Invocation.method(#get, [url], {#headers: headers}), - returnValue: Future<_i6.Response>.value(_FakeResponse_4())) - as _i9.Future<_i6.Response>); + _i9.Future<_i6.Response> get( + Uri? url, { + Map? headers, + }) => + (super.noSuchMethod( + Invocation.method( + #get, + [url], + {#headers: headers}, + ), + returnValue: _i9.Future<_i6.Response>.value(_FakeResponse_4( + this, + Invocation.method( + #get, + [url], + {#headers: headers}, + ), + )), + ) as _i9.Future<_i6.Response>); @override - _i9.Future<_i6.Response> post(Uri? url, - {Map? headers, - Object? body, - _i10.Encoding? encoding}) => + _i9.Future<_i6.Response> post( + Uri? url, { + Map? headers, + Object? body, + _i11.Encoding? encoding, + }) => (super.noSuchMethod( - Invocation.method(#post, [url], - {#headers: headers, #body: body, #encoding: encoding}), - returnValue: Future<_i6.Response>.value(_FakeResponse_4())) - as _i9.Future<_i6.Response>); - @override - _i9.Future<_i6.Response> put(Uri? url, - {Map? headers, - Object? body, - _i10.Encoding? encoding}) => + Invocation.method( + #post, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i9.Future<_i6.Response>.value(_FakeResponse_4( + this, + Invocation.method( + #post, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + )), + ) as _i9.Future<_i6.Response>); + @override + _i9.Future<_i6.Response> put( + Uri? url, { + Map? headers, + Object? body, + _i11.Encoding? encoding, + }) => (super.noSuchMethod( - Invocation.method(#put, [url], - {#headers: headers, #body: body, #encoding: encoding}), - returnValue: Future<_i6.Response>.value(_FakeResponse_4())) - as _i9.Future<_i6.Response>); - @override - _i9.Future<_i6.Response> patch(Uri? url, - {Map? headers, - Object? body, - _i10.Encoding? encoding}) => + Invocation.method( + #put, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i9.Future<_i6.Response>.value(_FakeResponse_4( + this, + Invocation.method( + #put, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + )), + ) as _i9.Future<_i6.Response>); + @override + _i9.Future<_i6.Response> patch( + Uri? url, { + Map? headers, + Object? body, + _i11.Encoding? encoding, + }) => (super.noSuchMethod( - Invocation.method(#patch, [url], - {#headers: headers, #body: body, #encoding: encoding}), - returnValue: Future<_i6.Response>.value(_FakeResponse_4())) - as _i9.Future<_i6.Response>); - @override - _i9.Future<_i6.Response> delete(Uri? url, - {Map? headers, - Object? body, - _i10.Encoding? encoding}) => + Invocation.method( + #patch, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i9.Future<_i6.Response>.value(_FakeResponse_4( + this, + Invocation.method( + #patch, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + )), + ) as _i9.Future<_i6.Response>); + @override + _i9.Future<_i6.Response> delete( + Uri? url, { + Map? headers, + Object? body, + _i11.Encoding? encoding, + }) => (super.noSuchMethod( - Invocation.method(#delete, [url], - {#headers: headers, #body: body, #encoding: encoding}), - returnValue: Future<_i6.Response>.value(_FakeResponse_4())) - as _i9.Future<_i6.Response>); + Invocation.method( + #delete, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i9.Future<_i6.Response>.value(_FakeResponse_4( + this, + Invocation.method( + #delete, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + )), + ) as _i9.Future<_i6.Response>); @override - _i9.Future read(Uri? url, {Map? headers}) => - (super.noSuchMethod(Invocation.method(#read, [url], {#headers: headers}), - returnValue: Future.value('')) as _i9.Future); + _i9.Future read( + Uri? url, { + Map? headers, + }) => + (super.noSuchMethod( + Invocation.method( + #read, + [url], + {#headers: headers}, + ), + returnValue: _i9.Future.value(''), + ) as _i9.Future); @override - _i9.Future<_i11.Uint8List> readBytes(Uri? url, - {Map? headers}) => + _i9.Future<_i12.Uint8List> readBytes( + Uri? url, { + Map? headers, + }) => (super.noSuchMethod( - Invocation.method(#readBytes, [url], {#headers: headers}), - returnValue: Future<_i11.Uint8List>.value(_i11.Uint8List(0))) - as _i9.Future<_i11.Uint8List>); + Invocation.method( + #readBytes, + [url], + {#headers: headers}, + ), + returnValue: _i9.Future<_i12.Uint8List>.value(_i12.Uint8List(0)), + ) as _i9.Future<_i12.Uint8List>); @override _i9.Future<_i6.StreamedResponse> send(_i6.BaseRequest? request) => - (super.noSuchMethod(Invocation.method(#send, [request]), - returnValue: - Future<_i6.StreamedResponse>.value(_FakeStreamedResponse_5())) - as _i9.Future<_i6.StreamedResponse>); + (super.noSuchMethod( + Invocation.method( + #send, + [request], + ), + returnValue: + _i9.Future<_i6.StreamedResponse>.value(_FakeStreamedResponse_5( + this, + Invocation.method( + #send, + [request], + ), + )), + ) as _i9.Future<_i6.StreamedResponse>); @override - void close() => super.noSuchMethod(Invocation.method(#close, []), - returnValueForMissingStub: null); + void close() => super.noSuchMethod( + Invocation.method( + #close, + [], + ), + returnValueForMissingStub: null, + ); } /// A class which mocks [TokenStorage]. /// /// See the documentation for Mockito's code generation for more information. -class MockTokenStorage extends _i1.Mock implements _i12.TokenStorage { +class MockTokenStorage extends _i1.Mock implements _i13.TokenStorage { MockTokenStorage() { _i1.throwOnMissingStub(this); } @override - String get key => - (super.noSuchMethod(Invocation.getter(#key), returnValue: '') as String); + String get key => (super.noSuchMethod( + Invocation.getter(#key), + returnValue: '', + ) as String); @override - set key(String? _key) => super.noSuchMethod(Invocation.setter(#key, _key), - returnValueForMissingStub: null); + set key(String? _key) => super.noSuchMethod( + Invocation.setter( + #key, + _key, + ), + returnValueForMissingStub: null, + ); @override - _i7.BaseStorage get storage => - (super.noSuchMethod(Invocation.getter(#storage), - returnValue: _FakeBaseStorage_6()) as _i7.BaseStorage); + _i7.BaseStorage get storage => (super.noSuchMethod( + Invocation.getter(#storage), + returnValue: _FakeBaseStorage_6( + this, + Invocation.getter(#storage), + ), + ) as _i7.BaseStorage); @override - set storage(_i7.BaseStorage? _storage) => - super.noSuchMethod(Invocation.setter(#storage, _storage), - returnValueForMissingStub: null); + set storage(_i7.BaseStorage? _storage) => super.noSuchMethod( + Invocation.setter( + #storage, + _storage, + ), + returnValueForMissingStub: null, + ); @override _i9.Future<_i3.AccessTokenResponse?> getToken(List? scopes) => - (super.noSuchMethod(Invocation.method(#getToken, [scopes]), - returnValue: Future<_i3.AccessTokenResponse?>.value()) - as _i9.Future<_i3.AccessTokenResponse?>); + (super.noSuchMethod( + Invocation.method( + #getToken, + [scopes], + ), + returnValue: _i9.Future<_i3.AccessTokenResponse?>.value(), + ) as _i9.Future<_i3.AccessTokenResponse?>); @override _i9.Future addToken(_i3.AccessTokenResponse? tknResp) => - (super.noSuchMethod(Invocation.method(#addToken, [tknResp]), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i9.Future); + (super.noSuchMethod( + Invocation.method( + #addToken, + [tknResp], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override _i9.Future>> insertToken( _i3.AccessTokenResponse? tknResp) => - (super.noSuchMethod(Invocation.method(#insertToken, [tknResp]), - returnValue: Future>>.value( - >{})) - as _i9.Future>>); - @override - _i9.Future deleteToken(List? scopes) => - (super.noSuchMethod(Invocation.method(#deleteToken, [scopes]), - returnValue: Future.value(false)) as _i9.Future); - @override - _i9.Future deleteAllTokens() => - (super.noSuchMethod(Invocation.method(#deleteAllTokens, []), - returnValue: Future.value(false)) as _i9.Future); - @override - List clearScopes(List? scopes) => - (super.noSuchMethod(Invocation.method(#clearScopes, [scopes]), - returnValue: []) as List); - @override - List getSortedScopes(List? scopes) => - (super.noSuchMethod(Invocation.method(#getSortedScopes, [scopes]), - returnValue: []) as List); - @override - String getScopeKey(List? scope) => - (super.noSuchMethod(Invocation.method(#getScopeKey, [scope]), - returnValue: '') as String); + (super.noSuchMethod( + Invocation.method( + #insertToken, + [tknResp], + ), + returnValue: _i9.Future>>.value( + >{}), + ) as _i9.Future>>); + @override + _i9.Future deleteToken(List? scopes) => (super.noSuchMethod( + Invocation.method( + #deleteToken, + [scopes], + ), + returnValue: _i9.Future.value(false), + ) as _i9.Future); + @override + _i9.Future deleteAllTokens() => (super.noSuchMethod( + Invocation.method( + #deleteAllTokens, + [], + ), + returnValue: _i9.Future.value(false), + ) as _i9.Future); + @override + List clearScopes(List? scopes) => (super.noSuchMethod( + Invocation.method( + #clearScopes, + [scopes], + ), + returnValue: [], + ) as List); + @override + List getSortedScopes(List? scopes) => (super.noSuchMethod( + Invocation.method( + #getSortedScopes, + [scopes], + ), + returnValue: [], + ) as List); + @override + String getScopeKey(List? scope) => (super.noSuchMethod( + Invocation.method( + #getScopeKey, + [scope], + ), + returnValue: '', + ) as String); } /// A class which mocks [BaseStorage]. @@ -518,12 +1035,27 @@ class MockBaseStorage extends _i1.Mock implements _i7.BaseStorage { } @override - _i9.Future read(String? key) => - (super.noSuchMethod(Invocation.method(#read, [key]), - returnValue: Future.value()) as _i9.Future); + _i9.Future read(String? key) => (super.noSuchMethod( + Invocation.method( + #read, + [key], + ), + returnValue: _i9.Future.value(), + ) as _i9.Future); @override - _i9.Future write(String? key, String? value) => - (super.noSuchMethod(Invocation.method(#write, [key, value]), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i9.Future); + _i9.Future write( + String? key, + String? value, + ) => + (super.noSuchMethod( + Invocation.method( + #write, + [ + key, + value, + ], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); } diff --git a/test/token_storage_test.mocks.dart b/test/token_storage_test.mocks.dart index bb9cac2..dd76eb6 100644 --- a/test/token_storage_test.mocks.dart +++ b/test/token_storage_test.mocks.dart @@ -1,12 +1,14 @@ -// Mocks generated by Mockito 5.0.17 from annotations +// Mocks generated by Mockito 5.3.1 from annotations // in oauth2_client/test/token_storage_test.dart. // Do not manually edit this file. +// ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i3; import 'package:mockito/mockito.dart' as _i1; import 'package:oauth2_client/src/secure_storage.dart' as _i2; +// ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters // ignore_for_file: comment_references @@ -15,6 +17,7 @@ import 'package:oauth2_client/src/secure_storage.dart' as _i2; // ignore_for_file: prefer_const_constructors // ignore_for_file: unnecessary_parenthesis // ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class /// A class which mocks [SecureStorage]. /// @@ -25,12 +28,27 @@ class MockSecureStorage extends _i1.Mock implements _i2.SecureStorage { } @override - _i3.Future read(String? key) => - (super.noSuchMethod(Invocation.method(#read, [key]), - returnValue: Future.value()) as _i3.Future); + _i3.Future read(String? key) => (super.noSuchMethod( + Invocation.method( + #read, + [key], + ), + returnValue: _i3.Future.value(), + ) as _i3.Future); @override - _i3.Future write(String? key, String? value) => - (super.noSuchMethod(Invocation.method(#write, [key, value]), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i3.Future); + _i3.Future write( + String? key, + String? value, + ) => + (super.noSuchMethod( + Invocation.method( + #write, + [ + key, + value, + ], + ), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) as _i3.Future); }