@@ -29,6 +29,7 @@ const (
29
29
testActionLink = "https://test.link"
30
30
testActionLinkFormat = `{"oobLink": %q}`
31
31
32
+ testNewEmail = "[email protected] "
32
33
)
33
34
34
35
var testActionLinkResponse = []byte (fmt .Sprintf (testActionLinkFormat , testActionLink ))
@@ -309,6 +310,55 @@ func TestEmailVerificationLinkError(t *testing.T) {
309
310
}
310
311
}
311
312
313
+ func TestVerifyAndChangeEmailLink (t * testing.T ) {
314
+ s := echoServer (testActionLinkResponse , t )
315
+ defer s .Close ()
316
+
317
+ link , err := s .Client .VerifyAndChangeEmailLink (context .Background (), testEmail , testNewEmail )
318
+ if err != nil {
319
+ t .Fatal (err )
320
+ }
321
+ if link != testActionLink {
322
+ t .Errorf ("TestVerifyAndChangeEmailLink() = %q; want = %q" , link , testActionLink )
323
+ }
324
+
325
+ want := map [string ]interface {}{
326
+ "requestType" : "VERIFY_AND_CHANGE_EMAIL" ,
327
+ "email" : testEmail ,
328
+ "returnOobLink" : true ,
329
+ "newEmail" : testNewEmail ,
330
+ }
331
+ if err := checkActionLinkRequest (want , s ); err != nil {
332
+ t .Fatalf ("TestVerifyAndChangeEmailLink() %v" , err )
333
+ }
334
+ }
335
+
336
+ func TestVerifyAndChangeEmailLinkWithSettings (t * testing.T ) {
337
+ s := echoServer (testActionLinkResponse , t )
338
+ defer s .Close ()
339
+
340
+ link , err := s .Client .VerifyAndChangeEmailLinkWithSettings (context .Background (), testEmail , testNewEmail , testActionCodeSettings )
341
+ if err != nil {
342
+ t .Fatal (err )
343
+ }
344
+ if link != testActionLink {
345
+ t .Errorf ("VerifyAndChangeEmailLinkWithSettings() = %q; want = %q" , link , testActionLink )
346
+ }
347
+
348
+ want := map [string ]interface {}{
349
+ "requestType" : "VERIFY_AND_CHANGE_EMAIL" ,
350
+ "email" : testEmail ,
351
+ "returnOobLink" : true ,
352
+ "newEmail" : testNewEmail ,
353
+ }
354
+ for k , v := range testActionCodeSettingsMap {
355
+ want [k ] = v
356
+ }
357
+ if err := checkActionLinkRequest (want , s ); err != nil {
358
+ t .Fatalf ("VerifyAndChangeEmailLinkWithSettings() %v" , err )
359
+ }
360
+ }
361
+
312
362
func checkActionLinkRequest (want map [string ]interface {}, s * mockAuthServer ) error {
313
363
wantURL := "/projects/mock-project-id/accounts:sendOobCode"
314
364
return checkActionLinkRequestWithURL (want , wantURL , s )
0 commit comments