@@ -1071,6 +1071,108 @@ void main() {
1071
1071
expect (result, null );
1072
1072
});
1073
1073
1074
+ test ('does not return cached token from authn after signOut' , () async {
1075
+ const List <String > scopes = < String > ['a' , 'b' ];
1076
+ const String accessToken = 'accessToken' ;
1077
+ const String serverAuthCode = 'authCode' ;
1078
+ final UserData userData = UserData (
1079
+ displayName: _testUser.displayName,
1080
+ email: _testUser.email,
1081
+ userId: _testUser.id,
1082
+ photoUrl: _testUser.photoUrl,
1083
+ idToken: '' ,
1084
+ );
1085
+ when (mockApi.signIn (scopes, null )).thenAnswer (
1086
+ (_) async => SignInResult (
1087
+ success: SignInSuccess (
1088
+ user: userData,
1089
+ accessToken: accessToken,
1090
+ serverAuthCode: serverAuthCode,
1091
+ grantedScopes: < String > [],
1092
+ ),
1093
+ ),
1094
+ );
1095
+ when (mockApi.getRefreshedAuthorizationTokens (userData.userId)).thenAnswer (
1096
+ (_) async => SignInResult (
1097
+ success: SignInSuccess (
1098
+ user: userData,
1099
+ accessToken: accessToken,
1100
+ // serverAuthCode will always be null for getRefreshedAuthorizationTokens.
1101
+ grantedScopes: scopes,
1102
+ ),
1103
+ ),
1104
+ );
1105
+
1106
+ await googleSignIn.authenticate (
1107
+ const AuthenticateParameters (scopeHint: scopes),
1108
+ );
1109
+ await googleSignIn.signOut (const SignOutParams ());
1110
+ final ServerAuthorizationTokenData ? result = await googleSignIn
1111
+ .serverAuthorizationTokensForScopes (
1112
+ ServerAuthorizationTokensForScopesParameters (
1113
+ request: AuthorizationRequestDetails (
1114
+ scopes: scopes,
1115
+ userId: userData.userId,
1116
+ email: userData.email,
1117
+ promptIfUnauthorized: false ,
1118
+ ),
1119
+ ),
1120
+ );
1121
+
1122
+ expect (result, null );
1123
+ });
1124
+
1125
+ test ('does not return cached token from authn after disconnect' , () async {
1126
+ const List <String > scopes = < String > ['a' , 'b' ];
1127
+ const String accessToken = 'accessToken' ;
1128
+ const String serverAuthCode = 'authCode' ;
1129
+ final UserData userData = UserData (
1130
+ displayName: _testUser.displayName,
1131
+ email: _testUser.email,
1132
+ userId: _testUser.id,
1133
+ photoUrl: _testUser.photoUrl,
1134
+ idToken: '' ,
1135
+ );
1136
+ when (mockApi.signIn (scopes, null )).thenAnswer (
1137
+ (_) async => SignInResult (
1138
+ success: SignInSuccess (
1139
+ user: userData,
1140
+ accessToken: accessToken,
1141
+ serverAuthCode: serverAuthCode,
1142
+ grantedScopes: < String > [],
1143
+ ),
1144
+ ),
1145
+ );
1146
+ when (mockApi.getRefreshedAuthorizationTokens (userData.userId)).thenAnswer (
1147
+ (_) async => SignInResult (
1148
+ success: SignInSuccess (
1149
+ user: userData,
1150
+ accessToken: accessToken,
1151
+ // serverAuthCode will always be null for getRefreshedAuthorizationTokens.
1152
+ grantedScopes: scopes,
1153
+ ),
1154
+ ),
1155
+ );
1156
+
1157
+ await googleSignIn.authenticate (
1158
+ const AuthenticateParameters (scopeHint: scopes),
1159
+ );
1160
+ await googleSignIn.disconnect (const DisconnectParams ());
1161
+ final ServerAuthorizationTokenData ? result = await googleSignIn
1162
+ .serverAuthorizationTokensForScopes (
1163
+ ServerAuthorizationTokensForScopesParameters (
1164
+ request: AuthorizationRequestDetails (
1165
+ scopes: scopes,
1166
+ userId: userData.userId,
1167
+ email: userData.email,
1168
+ promptIfUnauthorized: false ,
1169
+ ),
1170
+ ),
1171
+ );
1172
+
1173
+ expect (result, null );
1174
+ });
1175
+
1074
1176
test (
1075
1177
'passes returned data to caller when calling addScopes without cache' ,
1076
1178
() async {
0 commit comments