Skip to content

Commit

Permalink
Remove actual email value from the error message returned in validate…
Browse files Browse the repository at this point in the history
…Error()
  • Loading branch information
horai committed Sep 27, 2023
1 parent 5e861fd commit 691f78d
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 8 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/GitLink.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/firebase-admin-go.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion auth/user_mgt.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ func validateEmail(email string) error {
return fmt.Errorf("email must be a non-empty string")
}
if parts := strings.Split(email, "@"); len(parts) != 2 || parts[0] == "" || parts[1] == "" {
return fmt.Errorf("malformed email string: %q", email)
return fmt.Errorf("malformed email string")
}
return nil
}
Expand Down
14 changes: 7 additions & 7 deletions auth/user_mgt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ func TestGetUsersInvalidEmail(t *testing.T) {
getUsersResult, err := client.GetUsers(
context.Background(),
[]UserIdentifier{EmailIdentifier{"invalid email addr"}})
want := `malformed email string: "invalid email addr"`
want := `malformed email string`
if getUsersResult != nil || err == nil || err.Error() != want {
t.Errorf("GetUsers() = (%v, %q); want = (nil, %q)", getUsersResult, err, want)
}
Expand Down Expand Up @@ -632,16 +632,16 @@ func TestInvalidCreateUser(t *testing.T) {
"email must be a non-empty string",
}, {
(&UserToCreate{}).Email("a"),
`malformed email string: "a"`,
`malformed email string`,
}, {
(&UserToCreate{}).Email("a@"),
`malformed email string: "a@"`,
`malformed email string`,
}, {
(&UserToCreate{}).Email("@a"),
`malformed email string: "@a"`,
`malformed email string`,
}, {
(&UserToCreate{}).Email("a@a@a"),
`malformed email string: "a@a@a"`,
`malformed email string`,
}, {
(&UserToCreate{}).MFASettings(MultiFactorSettings{
EnrolledFactors: []*MultiFactorInfo{
Expand Down Expand Up @@ -861,7 +861,7 @@ func TestInvalidUpdateUser(t *testing.T) {
"email must be a non-empty string",
}, {
(&UserToUpdate{}).Email("invalid"),
`malformed email string: "invalid"`,
`malformed email string`,
}, {
(&UserToUpdate{}).PhoneNumber("1"),
"phone number must be a valid, E.164 compliant identifier",
Expand Down Expand Up @@ -1528,7 +1528,7 @@ func TestUserToImportError(t *testing.T) {
},
{
(&UserToImport{}).UID("test").Email("not-an-email"),
`malformed email string: "not-an-email"`,
`malformed email string`,
},
{
(&UserToImport{}).UID("test").PhoneNumber("not-a-phone"),
Expand Down

0 comments on commit 691f78d

Please sign in to comment.