|
1 |
| -import 'package:app_links/app_links.dart'; |
2 | 1 | import 'package:flutter_test/flutter_test.dart';
|
3 | 2 | import 'package:supabase_flutter/supabase_flutter.dart';
|
4 | 3 |
|
@@ -79,13 +78,14 @@ void main() {
|
79 | 78 | authOptions: FlutterAuthClientOptions(
|
80 | 79 | localStorage: MockExpiredStorage(),
|
81 | 80 | pkceAsyncStorage: MockAsyncStorage(),
|
| 81 | + autoRefreshToken: false, |
82 | 82 | ),
|
83 | 83 | );
|
84 | 84 | });
|
85 | 85 |
|
86 |
| - test('initial session contains the error', () async { |
| 86 | + test('emits exception when no auto refresh', () async { |
87 | 87 | // Give it a delay to wait for recoverSession to throw
|
88 |
| - await Future.delayed(const Duration(milliseconds: 10)); |
| 88 | + await Future.delayed(const Duration(milliseconds: 100)); |
89 | 89 |
|
90 | 90 | await expectLater(Supabase.instance.client.auth.onAuthStateChange,
|
91 | 91 | emitsError(isA<AuthException>()));
|
@@ -113,65 +113,6 @@ void main() {
|
113 | 113 | });
|
114 | 114 | });
|
115 | 115 |
|
116 |
| - group('Deep Link with PKCE code', () { |
117 |
| - late final PkceHttpClient pkceHttpClient; |
118 |
| - late final bool mockEventChannel; |
119 |
| - |
120 |
| - /// Check if the current version of AppLinks uses an explicit call to get |
121 |
| - /// the initial link. This is only the case before version 6.0.0, where we |
122 |
| - /// can find the getInitialAppLink function. |
123 |
| - /// |
124 |
| - /// CI pipeline is set so that it tests both app_links newer and older than v6.0.0 |
125 |
| - bool appLinksExposesInitialLinkInStream() { |
126 |
| - try { |
127 |
| - // before app_links 6.0.0 |
128 |
| - (AppLinks() as dynamic).getInitialAppLink; |
129 |
| - return false; |
130 |
| - } on NoSuchMethodError catch (_) { |
131 |
| - return true; |
132 |
| - } |
133 |
| - } |
134 |
| - |
135 |
| - setUp(() async { |
136 |
| - pkceHttpClient = PkceHttpClient(); |
137 |
| - |
138 |
| - // Add initial deep link with a `code` parameter, use method channel if |
139 |
| - // we are in a version of AppLinks that use the explcit method for |
140 |
| - // getting the initial link. Otherwise we want to mock the event channel |
141 |
| - // and put the initial link there. |
142 |
| - mockEventChannel = appLinksExposesInitialLinkInStream(); |
143 |
| - mockAppLink( |
144 |
| - mockMethodChannel: !mockEventChannel, |
145 |
| - mockEventChannel: mockEventChannel, |
146 |
| - initialLink: 'com.supabase://callback/?code=my-code-verifier', |
147 |
| - ); |
148 |
| - await Supabase.initialize( |
149 |
| - url: supabaseUrl, |
150 |
| - anonKey: supabaseKey, |
151 |
| - debug: false, |
152 |
| - httpClient: pkceHttpClient, |
153 |
| - authOptions: FlutterAuthClientOptions( |
154 |
| - localStorage: MockEmptyLocalStorage(), |
155 |
| - pkceAsyncStorage: MockAsyncStorage() |
156 |
| - ..setItem( |
157 |
| - key: 'supabase.auth.token-code-verifier', |
158 |
| - value: 'raw-code-verifier'), |
159 |
| - ), |
160 |
| - ); |
161 |
| - }); |
162 |
| - |
163 |
| - test( |
164 |
| - 'Having `code` as the query parameter triggers `getSessionFromUrl` call on initialize', |
165 |
| - () async { |
166 |
| - // Wait for the initial app link to be handled, as this is an async |
167 |
| - // process when mocking the event channel. |
168 |
| - if (mockEventChannel) { |
169 |
| - await Future.delayed(const Duration(milliseconds: 500)); |
170 |
| - } |
171 |
| - expect(pkceHttpClient.requestCount, 1); |
172 |
| - expect(pkceHttpClient.lastRequestBody['auth_code'], 'my-code-verifier'); |
173 |
| - }); |
174 |
| - }); |
175 | 116 | group('EmptyLocalStorage', () {
|
176 | 117 | late EmptyLocalStorage localStorage;
|
177 | 118 |
|
|
0 commit comments