Add tests for the OpenID's id_token
diff --git a/test/handle_access_token_response_test.dart b/test/handle_access_token_response_test.dart
index fd4b1a7..1ab3239 100644
--- a/test/handle_access_token_response_test.dart
+++ b/test/handle_access_token_response_test.dart
@@ -259,4 +259,36 @@
expect(credentials.scopes, equals(['scope1', 'scope2']));
});
});
+
+ group('a success response with id_token', () {
+ oauth2.Credentials handleSuccess(
+ {String contentType = "application/json",
+ accessToken = 'access token',
+ tokenType = 'bearer',
+ expiresIn,
+ refreshToken,
+ idToken = 'decode me',
+ scope}) {
+ return handle(new http.Response(
+ jsonEncode({
+ 'access_token': accessToken,
+ 'token_type': tokenType,
+ 'expires_in': expiresIn,
+ 'refresh_token': refreshToken,
+ 'id_token': idToken,
+ 'scope': scope
+ }),
+ 200,
+ headers: {'content-type': contentType}));
+ }
+
+ test('with a non-string id token throws a FormatException', () {
+ expect(() => handleSuccess(idToken: 12), throwsFormatException);
+ });
+
+ test('with a id token sets the id token', () {
+ var credentials = handleSuccess(idToken: "decode me");
+ expect(credentials.idToken, equals("decode me"));
+ });
+ });
}