@@ -55,6 +55,7 @@ describe('auth() -> emailLink Provider', function () {
55
55
await sendSignInLinkToEmail ( auth , email , actionCodeSettings ) ;
56
56
const oobInfo = await getLastOob ( email ) ;
57
57
oobInfo . oobLink . should . containEql ( encodeURIComponent ( continueUrl ) ) ;
58
+ console . error ( 'the oobLink was: ' + oobInfo . oobLink ) ;
58
59
const signInResponse = await signInUser ( oobInfo . oobLink ) ;
59
60
signInResponse . should . containEql ( continueUrl ) ;
60
61
signInResponse . should . containEql ( oobInfo . oobCode ) ;
@@ -96,9 +97,53 @@ describe('auth() -> emailLink Provider', function () {
96
97
} ) ;
97
98
} ) ;
98
99
99
- // FOR MANUAL TESTING ONLY
100
- xdescribe ( 'signInWithEmailLink' , function ( ) {
101
- it ( 'should signIn' , async function ( ) {
100
+ describe ( 'signInWithEmailLink' , function ( ) {
101
+ it . only ( 'sign in via email does not crash with missing apiKey' , async function ( ) {
102
+ const { getAuth, sendSignInLinkToEmail, signInWithEmailLink } = authModular ;
103
+
104
+ const auth = getAuth ( ) ;
105
+ const random = Utils . randString ( 12 , '#aa' ) ;
106
+ const email = `${ random } @${ random } .com` ;
107
+ const continueUrl = `http://${ Platform . android ? '10.0.2.2' : '127.0.0.1' } :8081/authLinkFoo?bar=${ random } ` ;
108
+ const actionCodeSettings = {
109
+ url : continueUrl ,
110
+ handleCodeInApp : true ,
111
+ iOS : {
112
+ bundleId : 'com.testing' ,
113
+ } ,
114
+ android : {
115
+ packageName : 'com.testing' ,
116
+ installApp : true ,
117
+ minimumVersion : '12' ,
118
+ } ,
119
+ } ;
120
+ await sendSignInLinkToEmail ( auth , email , actionCodeSettings ) ;
121
+ const oobInfo = await getLastOob ( email ) ;
122
+ oobInfo . oobLink . should . containEql ( encodeURIComponent ( continueUrl ) ) ;
123
+
124
+ // Specifically remove the apiKey param. Android requires it and needs
125
+ // specific error handling or it crashes, See #8360
126
+ let linkNoApiKey = oobInfo . oobLink . replace ( '&apiKey=fake-api-key' , '' ) ;
127
+ try {
128
+ const signInResponse = await signInWithEmailLink ( auth , email , linkNoApiKey ) ;
129
+ if ( Platform . OS === 'android' ) {
130
+ throw new Error ( 'Should have rejected on Android' ) ;
131
+ } else {
132
+ signInResponse . user . email . should . equal ( email ) ;
133
+ auth . currentUser . email . should . equal ( email ) ;
134
+ }
135
+ } catch ( e ) {
136
+ if ( Platform . OS === 'android' ) {
137
+ e . message . should . containEql ( 'Given link is not a valid email link' ) ;
138
+ } else {
139
+ // all non-android platforms should have been fine without apiKey
140
+ throw e ;
141
+ }
142
+ }
143
+ } ) ;
144
+
145
+ // FOR MANUAL TESTING ONLY
146
+ xit ( 'should signIn' , async function ( ) {
102
147
const auth = getAuth ( ) ;
103
148
const email = 'MANUAL TEST EMAIL HERE' ;
104
149
const emailLink = 'MANUAL TEST CODE HERE' ;
0 commit comments