-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(auth): Add returnOobLink to the ActionCodeSettings #502
Open
Dal-Papa
wants to merge
33
commits into
firebase:dev
Choose a base branch
from
Dal-Papa:master
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
54b8114
Merge dev into master
google-oss-bot cef91ac
Merge dev into master
google-oss-bot 77177c7
Merge dev into master
google-oss-bot a957589
Merge dev into master
google-oss-bot eb0d2a0
Merge dev into master
google-oss-bot 05378ef
Merge dev into master
google-oss-bot 4121c50
Merge dev into master
google-oss-bot 928b104
Merge dev into master
google-oss-bot 02cde4f
Merge dev into master
google-oss-bot 6b40682
Merge dev into master
google-oss-bot e60757f
Merge dev into master
google-oss-bot bb055ed
Merge dev into master
google-oss-bot e8dfc32
Add returnOobLink to the ActionCodeSettings
Dal-Papa 23a1f17
Merge dev into master
google-oss-bot 1d24577
Merge dev into master
google-oss-bot f9dc53b
Merge remote-tracking branch 'upstream/dev'
Dal-Papa 12a4788
Fix all tests with both returnOobLink cases
Dal-Papa 4cf413a
Change `ReturnOobLink` into `SendEmailLink`
Dal-Papa 54af579
Avoid name conflict with url package
Dal-Papa 981442d
Add an unset test case and a comment
Dal-Papa 61c6c04
Merge dev into master
google-oss-bot 32af2b8
[chore] Release 4.12.0 (#561)
lahirumaramba 02300a8
Revert "[chore] Release 4.12.0 (#561)" (#565)
lahirumaramba 74c9bd5
Merge dev into master
google-oss-bot 37c7936
Merge dev into master
google-oss-bot bef15cf
Merge remote-tracking branch 'fruitz-fork/master'
Dal-Papa b28ccfb
Merge remote-tracking branch 'upstream/dev'
Dal-Papa b04387e
Merge dev into master
google-oss-bot c348341
Merge remote-tracking branch 'upstream/master'
Dal-Papa da18d13
Fix comment
Dal-Papa 77f51b8
Merge branch 'dev'
Dal-Papa 147a277
Merge branch 'dev'
Dal-Papa e5a5134
Resolve conflicts on tests
Dal-Papa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ import ( | |
"fmt" | ||
"net/http" | ||
"reflect" | ||
"strconv" | ||
"testing" | ||
|
||
"firebase.google.com/go/v4/errorutils" | ||
|
@@ -98,9 +99,8 @@ func TestEmailVerificationLink(t *testing.T) { | |
} | ||
|
||
want := map[string]interface{}{ | ||
"requestType": "VERIFY_EMAIL", | ||
"email": testEmail, | ||
"returnOobLink": true, | ||
"requestType": "VERIFY_EMAIL", | ||
"email": testEmail, | ||
} | ||
if err := checkActionLinkRequest(want, s); err != nil { | ||
t.Fatalf("EmailVerificationLink() %v", err) | ||
|
@@ -111,24 +111,32 @@ func TestEmailVerificationLinkWithSettings(t *testing.T) { | |
s := echoServer(testActionLinkResponse, t) | ||
defer s.Close() | ||
|
||
link, err := s.Client.EmailVerificationLinkWithSettings(context.Background(), testEmail, testActionCodeSettings) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if link != testActionLink { | ||
t.Errorf("EmailVerificationLinkWithSettings() = %q; want = %q", link, testActionLink) | ||
} | ||
cases := []string{"true", "false", ""} | ||
testActionCodeSettingsCustom, testActionCodeSettingsMapCustom := getCopiesOfTestSettings(testActionCodeSettings, | ||
testActionCodeSettingsMap) | ||
for _, caseStr := range cases { | ||
if returnOobLink, err := strconv.ParseBool(caseStr); err == nil { | ||
testActionCodeSettingsCustom.SendEmailLink = !returnOobLink | ||
testActionCodeSettingsMapCustom["returnOobLink"] = returnOobLink | ||
} | ||
link, err := s.Client.EmailVerificationLinkWithSettings(context.Background(), testEmail, testActionCodeSettingsCustom) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if link != testActionLink { | ||
t.Errorf("EmailVerificationLinkWithSettings() = %q; want = %q", link, testActionLink) | ||
} | ||
|
||
want := map[string]interface{}{ | ||
"requestType": "VERIFY_EMAIL", | ||
"email": testEmail, | ||
"returnOobLink": true, | ||
} | ||
for k, v := range testActionCodeSettingsMap { | ||
want[k] = v | ||
} | ||
if err := checkActionLinkRequest(want, s); err != nil { | ||
t.Fatalf("EmailVerificationLinkWithSettings() %v", err) | ||
want := map[string]interface{}{ | ||
"requestType": "VERIFY_EMAIL", | ||
"email": testEmail, | ||
} | ||
for k, v := range testActionCodeSettingsMapCustom { | ||
want[k] = v | ||
} | ||
if err := checkActionLinkRequest(want, s); err != nil { | ||
t.Fatalf("EmailVerificationLinkWithSettings() %v", err) | ||
} | ||
} | ||
} | ||
|
||
|
@@ -145,9 +153,8 @@ func TestPasswordResetLink(t *testing.T) { | |
} | ||
|
||
want := map[string]interface{}{ | ||
"requestType": "PASSWORD_RESET", | ||
"email": testEmail, | ||
"returnOobLink": true, | ||
"requestType": "PASSWORD_RESET", | ||
"email": testEmail, | ||
} | ||
if err := checkActionLinkRequest(want, s); err != nil { | ||
t.Fatalf("PasswordResetLink() %v", err) | ||
|
@@ -158,24 +165,30 @@ func TestPasswordResetLinkWithSettings(t *testing.T) { | |
s := echoServer(testActionLinkResponse, t) | ||
defer s.Close() | ||
|
||
link, err := s.Client.PasswordResetLinkWithSettings(context.Background(), testEmail, testActionCodeSettings) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if link != testActionLink { | ||
t.Errorf("PasswordResetLinkWithSettings() = %q; want = %q", link, testActionLink) | ||
} | ||
cases := []bool{true, false} | ||
testActionCodeSettingsCustom, testActionCodeSettingsMapCustom := getCopiesOfTestSettings(testActionCodeSettings, | ||
testActionCodeSettingsMap) | ||
for _, returnOobLink := range cases { | ||
testActionCodeSettingsCustom.SendEmailLink = !returnOobLink | ||
testActionCodeSettingsMapCustom["returnOobLink"] = returnOobLink | ||
link, err := s.Client.PasswordResetLinkWithSettings(context.Background(), testEmail, testActionCodeSettingsCustom) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if link != testActionLink { | ||
t.Errorf("PasswordResetLinkWithSettings() = %q; want = %q", link, testActionLink) | ||
} | ||
|
||
want := map[string]interface{}{ | ||
"requestType": "PASSWORD_RESET", | ||
"email": testEmail, | ||
"returnOobLink": true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's make sure we keep the current SDK behaviour intact. When |
||
} | ||
for k, v := range testActionCodeSettingsMap { | ||
want[k] = v | ||
} | ||
if err := checkActionLinkRequest(want, s); err != nil { | ||
t.Fatalf("PasswordResetLinkWithSettings() %v", err) | ||
want := map[string]interface{}{ | ||
"requestType": "PASSWORD_RESET", | ||
"email": testEmail, | ||
} | ||
for k, v := range testActionCodeSettingsMapCustom { | ||
want[k] = v | ||
} | ||
if err := checkActionLinkRequest(want, s); err != nil { | ||
t.Fatalf("PasswordResetLinkWithSettings() %v", err) | ||
} | ||
} | ||
} | ||
|
||
|
@@ -204,24 +217,29 @@ func TestEmailSignInLink(t *testing.T) { | |
s := echoServer(testActionLinkResponse, t) | ||
defer s.Close() | ||
|
||
link, err := s.Client.EmailSignInLink(context.Background(), testEmail, testActionCodeSettings) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if link != testActionLink { | ||
t.Errorf("EmailSignInLink() = %q; want = %q", link, testActionLink) | ||
} | ||
|
||
want := map[string]interface{}{ | ||
"requestType": "EMAIL_SIGNIN", | ||
"email": testEmail, | ||
"returnOobLink": true, | ||
} | ||
for k, v := range testActionCodeSettingsMap { | ||
want[k] = v | ||
} | ||
if err := checkActionLinkRequest(want, s); err != nil { | ||
t.Fatalf("EmailSignInLink() %v", err) | ||
cases := []bool{true, false} | ||
testActionCodeSettingsCustom, testActionCodeSettingsMapCustom := getCopiesOfTestSettings(testActionCodeSettings, | ||
testActionCodeSettingsMap) | ||
for _, returnOobLink := range cases { | ||
testActionCodeSettingsCustom.SendEmailLink = !returnOobLink | ||
testActionCodeSettingsMapCustom["returnOobLink"] = returnOobLink | ||
link, err := s.Client.EmailSignInLink(context.Background(), testEmail, testActionCodeSettingsCustom) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if link != testActionLink { | ||
t.Errorf("EmailSignInLink() = %q; want = %q", link, testActionLink) | ||
} | ||
want := map[string]interface{}{ | ||
"requestType": "EMAIL_SIGNIN", | ||
"email": testEmail, | ||
} | ||
for k, v := range testActionCodeSettingsMapCustom { | ||
want[k] = v | ||
} | ||
if err := checkActionLinkRequest(want, s); err != nil { | ||
t.Fatalf("EmailSignInLink() %v", err) | ||
} | ||
} | ||
} | ||
|
||
|
@@ -333,3 +351,22 @@ func checkActionLinkRequestWithURL(want map[string]interface{}, wantURL string, | |
} | ||
return nil | ||
} | ||
|
||
func getCopiesOfTestSettings(testSettings *ActionCodeSettings, | ||
testSettingsMap map[string]interface{}) (*ActionCodeSettings, map[string]interface{}) { | ||
testActionCodeSettingsCustom := &ActionCodeSettings{ | ||
URL: testSettings.URL, | ||
HandleCodeInApp: testSettings.HandleCodeInApp, | ||
IOSBundleID: testSettings.IOSBundleID, | ||
AndroidPackageName: testSettings.AndroidPackageName, | ||
AndroidMinimumVersion: testSettings.AndroidMinimumVersion, | ||
AndroidInstallApp: testSettings.AndroidInstallApp, | ||
DynamicLinkDomain: testSettings.DynamicLinkDomain, | ||
SendEmailLink: testSettings.SendEmailLink, | ||
} | ||
testActionCodeSettingsMapCustom := map[string]interface{}{} | ||
for k, v := range testSettingsMap { | ||
testActionCodeSettingsMapCustom[k] = v | ||
} | ||
return testActionCodeSettingsCustom, testActionCodeSettingsMapCustom | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a comment here like : "Since SendEmailLink defaults to true, we will always set "returnOobLink" to false by default, this means no email is sent out in the defautl case".
And we can remove the
"returnOobLink" : true
setting in line 121?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this after several weeks - can you remind me how SendEmailLink defaults to true? I think the comment should be:
"Since SendEmailLink defaults to false, we will always set "returnOobLink" to true by default, this means no email is sent out in the default case".
Apologies for the mistake in my earlier comment.