-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TF-2965 Add retry capability for OIDC check request
- Loading branch information
1 parent
8221c2e
commit 8aa62b7
Showing
11 changed files
with
192 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
enum LoginFormType { | ||
none, | ||
retry, | ||
baseUrlForm, | ||
credentialForm, | ||
passwordForm, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
lib/features/login/presentation/widgets/try_again_button.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'package:core/presentation/extensions/color_extension.dart'; | ||
import 'package:core/presentation/utils/responsive_utils.dart'; | ||
import 'package:core/presentation/views/button/tmail_button_widget.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; | ||
|
||
class TryAgainButton extends StatelessWidget { | ||
const TryAgainButton({ | ||
super.key, | ||
required this.onRetry, | ||
required this.responsiveUtils, | ||
}); | ||
|
||
final VoidCallback onRetry; | ||
final ResponsiveUtils responsiveUtils; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return TMailButtonWidget.fromText( | ||
text: AppLocalizations.of(context).tryAgain, | ||
textStyle: const TextStyle(fontSize: 16, color: Colors.white), | ||
backgroundColor: AppColor.primaryColor, | ||
onTapActionCallback: onRetry, | ||
borderRadius: 10, | ||
margin: const EdgeInsetsDirectional.only(bottom: 16, start: 24, end: 24), | ||
width: responsiveUtils.getDeviceWidth(context), | ||
textAlign: TextAlign.center, | ||
padding: const EdgeInsets.symmetric(vertical: 12), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
test/features/login/data/network/oidc_http_client_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import 'package:core/data/network/dio_client.dart'; | ||
import 'package:dio/dio.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:mockito/annotations.dart'; | ||
import 'package:mockito/mockito.dart'; | ||
import 'package:model/oidc/request/oidc_request.dart'; | ||
import 'package:tmail_ui_user/features/login/data/network/oidc_error.dart'; | ||
import 'package:tmail_ui_user/features/login/data/network/oidc_http_client.dart'; | ||
|
||
import 'oidc_http_client_test.mocks.dart'; | ||
|
||
@GenerateNiceMocks([MockSpec<DioClient>()]) | ||
void main() { | ||
final dioClient = MockDioClient(); | ||
final oidcHttpClient = OIDCHttpClient(dioClient); | ||
final requestOptions = RequestOptions(); | ||
final oidcRequest = OIDCRequest(baseUrl: '', resourceUrl: ''); | ||
|
||
group('oidc http client test:', () { | ||
test( | ||
'should throw CanNotFoundOIDCLinks ' | ||
'when checkOIDCIsAvailable() is called ' | ||
'and dioClient throw DioError ' | ||
'and status code is 404', | ||
() { | ||
// arrange | ||
when(dioClient.get(any)).thenThrow(DioError( | ||
requestOptions: requestOptions, | ||
response: Response(requestOptions: requestOptions, statusCode: 404))); | ||
|
||
// assert | ||
expect( | ||
() => oidcHttpClient.checkOIDCIsAvailable(oidcRequest), | ||
throwsA(isA<CanNotFoundOIDCLinks>())); | ||
}); | ||
|
||
test( | ||
'should throw CanRetryOIDCException ' | ||
'when checkOIDCIsAvailable() is called ' | ||
'and dioClient throw DioError ' | ||
'and status code is not 404', | ||
() { | ||
// arrange | ||
when(dioClient.get(any)).thenThrow(DioError( | ||
requestOptions: requestOptions, | ||
response: Response(requestOptions: requestOptions, statusCode: 403))); | ||
|
||
// assert | ||
expect( | ||
() => oidcHttpClient.checkOIDCIsAvailable(oidcRequest), | ||
throwsA(isA<CanRetryOIDCException>())); | ||
}); | ||
|
||
test( | ||
'should throw CanRetryOIDCException ' | ||
'when checkOIDCIsAvailable() is called ' | ||
'and dioClient throw exception that is not DioError', | ||
() { | ||
// arrange | ||
when(dioClient.get(any)).thenThrow(Exception()); | ||
|
||
// assert | ||
expect( | ||
() => oidcHttpClient.checkOIDCIsAvailable(oidcRequest), | ||
throwsA(isA<CanRetryOIDCException>())); | ||
}); | ||
}); | ||
} |