@@ -236,6 +236,70 @@ describe('auth() -> Providers', function () {
236236 'At least one of ID token and access token must be non-null' ,
237237 ) ;
238238 } ) ;
239+
240+ it ( 'should accept id-token-only credentials (Credential Manager)' , function ( ) {
241+ const { GoogleAuthProvider } = authModular ;
242+
243+ const token = 'google-id-token-only' ;
244+ const credential = GoogleAuthProvider . credential ( token , null ) ;
245+ credential . providerId . should . equal ( 'google.com' ) ;
246+ credential . signInMethod . should . equal ( 'google.com' ) ;
247+ credential . token . should . equal ( token ) ;
248+ credential . secret . should . equal ( '' ) ;
249+ credential . idToken . should . equal ( token ) ;
250+ should . equal ( credential . accessToken , undefined ) ;
251+ } ) ;
252+
253+ it ( 'should accept access-token-only credentials' , function ( ) {
254+ const { GoogleAuthProvider } = authModular ;
255+
256+ const accessToken = 'google-access-token-only' ;
257+ const credential = GoogleAuthProvider . credential ( null , accessToken ) ;
258+ credential . providerId . should . equal ( 'google.com' ) ;
259+ credential . signInMethod . should . equal ( 'google.com' ) ;
260+ credential . token . should . equal ( '' ) ;
261+ credential . secret . should . equal ( accessToken ) ;
262+ credential . accessToken . should . equal ( accessToken ) ;
263+ should . equal ( credential . idToken , undefined ) ;
264+ } ) ;
265+
266+ it ( 'should reach Android native signInWithCredential for id-token-only Google credentials' , async function ( ) {
267+ if ( ! Platform . android ) {
268+ this . skip ( ) ;
269+ }
270+ const { getApp } = modular ;
271+ const { GoogleAuthProvider, signInWithCredential, getAuth } = authModular ;
272+ const defaultAuth = getAuth ( getApp ( ) ) ;
273+ const credential = GoogleAuthProvider . credential ( 'google-id-token-only-e2e' , null ) ;
274+
275+ try {
276+ await signInWithCredential ( defaultAuth , credential ) ;
277+ throw new Error ( 'Did not error.' ) ;
278+ } catch ( error ) {
279+ error . code . should . be . a . String ( ) ;
280+ error . code . should . not . equal ( 'auth/unknown' ) ;
281+ String ( error . message ) . should . not . match ( / a c c e s s T o k e n c a n n o t b e e m p t y / i) ;
282+ }
283+ } ) ;
284+
285+ it ( 'should reach Android native signInWithCredential for access-token-only Google credentials' , async function ( ) {
286+ if ( ! Platform . android ) {
287+ this . skip ( ) ;
288+ }
289+ const { getApp } = modular ;
290+ const { GoogleAuthProvider, signInWithCredential, getAuth } = authModular ;
291+ const defaultAuth = getAuth ( getApp ( ) ) ;
292+ const credential = GoogleAuthProvider . credential ( null , 'google-access-token-only-e2e' ) ;
293+
294+ try {
295+ await signInWithCredential ( defaultAuth , credential ) ;
296+ throw new Error ( 'Did not error.' ) ;
297+ } catch ( error ) {
298+ error . code . should . be . a . String ( ) ;
299+ error . code . should . not . equal ( 'auth/unknown' ) ;
300+ String ( error . message ) . should . not . match ( / i d T o k e n c a n n o t b e e m p t y / i) ;
301+ }
302+ } ) ;
239303 } ) ;
240304
241305 describe ( 'GOOGLE_SIGN_IN_METHOD' , function ( ) {
0 commit comments