@@ -1014,36 +1014,38 @@ void main() {
1014
1014
},
1015
1015
);
1016
1016
1017
- test ('does not return cached token from authn when user changes' , () async {
1017
+ test ('does not return cached token from authn if user changes' , () async {
1018
1018
const List <String > scopes = < String > ['a' , 'b' ];
1019
1019
const String accessToken = 'accessToken' ;
1020
1020
const String serverAuthCode = 'authCode' ;
1021
+ final UserData previousUser = UserData (
1022
+ displayName: 'Previous user' ,
1023
+
1024
+ userId: 'different_id' ,
1025
+ photoUrl: _testUser.photoUrl,
1026
+ idToken: '' ,
1027
+ );
1028
+ final UserData newUser = UserData (
1029
+ displayName: _testUser.displayName,
1030
+ email: _testUser.email,
1031
+ userId: _testUser.id,
1032
+ photoUrl: _testUser.photoUrl,
1033
+ idToken: '' ,
1034
+ );
1021
1035
when (mockApi.signIn (scopes, null )).thenAnswer (
1022
1036
(_) async => SignInResult (
1023
1037
success: SignInSuccess (
1024
- user: UserData (
1025
- displayName: 'Previous user' ,
1026
-
1027
- userId: 'different_id' ,
1028
- photoUrl: _testUser.photoUrl,
1029
- idToken: '' ,
1030
- ),
1038
+ user: previousUser,
1031
1039
accessToken: accessToken,
1032
1040
serverAuthCode: serverAuthCode,
1033
1041
grantedScopes: < String > [],
1034
1042
),
1035
1043
),
1036
1044
);
1037
- when (mockApi.getRefreshedAuthorizationTokens (_testUser.id )).thenAnswer (
1045
+ when (mockApi.getRefreshedAuthorizationTokens (newUser.userId )).thenAnswer (
1038
1046
(_) async => SignInResult (
1039
1047
success: SignInSuccess (
1040
- user: UserData (
1041
- displayName: _testUser.displayName,
1042
- email: _testUser.email,
1043
- userId: _testUser.id,
1044
- photoUrl: _testUser.photoUrl,
1045
- idToken: '' ,
1046
- ),
1048
+ user: newUser,
1047
1049
accessToken: accessToken,
1048
1050
// serverAuthCode will always be null for getRefreshedAuthorizationTokens.
1049
1051
grantedScopes: scopes,
@@ -1059,8 +1061,8 @@ void main() {
1059
1061
ServerAuthorizationTokensForScopesParameters (
1060
1062
request: AuthorizationRequestDetails (
1061
1063
scopes: scopes,
1062
- userId: _testUser.id ,
1063
- email: _testUser .email,
1064
+ userId: newUser.userId ,
1065
+ email: newUser .email,
1064
1066
promptIfUnauthorized: false ,
1065
1067
),
1066
1068
),
0 commit comments