Skip to content

Commit

Permalink
Merge dev into master
Browse files Browse the repository at this point in the history
  • Loading branch information
google-oss-bot authored Jan 20, 2022
2 parents 6b40682 + 8a5d6de commit e60757f
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 4 deletions.
6 changes: 3 additions & 3 deletions auth/import_users.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ func (u *UserToImport) set(key string, value interface{}) *UserToImport {
type UserProvider struct {
UID string `json:"rawId"`
ProviderID string `json:"providerId"`
Email string `json:"email"`
DisplayName string `json:"displayName"`
PhotoURL string `json:"photoUrl"`
Email string `json:"email,omitempty"`
DisplayName string `json:"displayName,omitempty"`
PhotoURL string `json:"photoUrl,omitempty"`
}

// ProviderData setter.
Expand Down
56 changes: 56 additions & 0 deletions auth/user_mgt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,62 @@ func TestSetCustomUserClaims(t *testing.T) {
}
}

func TestUserProvider(t *testing.T) {
cases := []struct {
provider *UserProvider
want map[string]interface{}
}{
{
provider: &UserProvider{UID: "test", ProviderID: "google.com"},
want: map[string]interface{}{"rawId": "test", "providerId": "google.com"},
},
{
provider: &UserProvider{
UID: "test",
ProviderID: "google.com",
DisplayName: "Test User",
},
want: map[string]interface{}{
"rawId": "test",
"providerId": "google.com",
"displayName": "Test User",
},
},
{
provider: &UserProvider{
UID: "test",
ProviderID: "google.com",
DisplayName: "Test User",
Email: "test@example.com",
PhotoURL: "https://test.com/user.png",
},
want: map[string]interface{}{
"rawId": "test",
"providerId": "google.com",
"displayName": "Test User",
"email": "test@example.com",
"photoUrl": "https://test.com/user.png",
},
},
}

for idx, tc := range cases {
b, err := json.Marshal(tc.provider)
if err != nil {
t.Fatal(err)
}

var got map[string]interface{}
if err := json.Unmarshal(b, &got); err != nil {
t.Fatal(err)
}

if !reflect.DeepEqual(got, tc.want) {
t.Errorf("[%d] UserProvider = %#v; want = %#v", idx, got, tc.want)
}
}
}

func TestUserToImport(t *testing.T) {
cases := []struct {
user *UserToImport
Expand Down
2 changes: 1 addition & 1 deletion firebase.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
var defaultAuthOverrides = make(map[string]interface{})

// Version of the Firebase Go Admin SDK.
const Version = "4.7.0"
const Version = "4.7.1"

// firebaseEnvName is the name of the environment variable with the Config.
const firebaseEnvName = "FIREBASE_CONFIG"
Expand Down

0 comments on commit e60757f

Please sign in to comment.