-
Notifications
You must be signed in to change notification settings - Fork 246
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
base: dev
Are you sure you want to change the base?
Changes from 15 commits
54b8114
cef91ac
77177c7
a957589
eb0d2a0
05378ef
4121c50
928b104
02cde4f
6b40682
e60757f
bb055ed
e8dfc32
23a1f17
1d24577
f9dc53b
12a4788
4cf413a
54af579
981442d
61c6c04
32af2b8
02300a8
74c9bd5
37c7936
bef15cf
b28ccfb
b04387e
c348341
da18d13
77f51b8
147a277
e5a5134
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,24 +111,30 @@ 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 := []bool{true, false} | ||
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. I'm wondering if we can make this a list of testActionCodeSettings and testActionCodeSettingsMap instead, so we also test the "unset" case. Added some sample here, to illustrate what i mean.. (I did not verify that this compiles)
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. Done |
||
testActionCodeSettingsCustom, testActionCodeSettingsMapCustom := getCopiesOfTestSettings(testActionCodeSettings, | ||
testActionCodeSettingsMap) | ||
for _, returnOobLink := range cases { | ||
testActionCodeSettingsCustom.ReturnOobLink = 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) | ||
} | ||
} | ||
} | ||
|
||
|
@@ -158,24 +164,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.ReturnOobLink = 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 +216,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.ReturnOobLink = 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 +350,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, | ||
ReturnOobLink: testSettings.ReturnOobLink, | ||
} | ||
testActionCodeSettingsMapCustom := map[string]interface{}{} | ||
for k, v := range testSettingsMap { | ||
testActionCodeSettingsMapCustom[k] = v | ||
} | ||
return testActionCodeSettingsCustom, testActionCodeSettingsMapCustom | ||
} |
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.
API Review feedback was to rename this variable to
SendEmailLink
in order to maintain the default value false for booleanThere 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.
@Dal-Papa Would you be able to make this change, please?
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.
As you want but that will break the override that was happening on the key name due to the
toMap
function...