diff --git a/auth/import_users.go b/auth/import_users.go index b036aad3..6de0c37b 100644 --- a/auth/import_users.go +++ b/auth/import_users.go @@ -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. diff --git a/auth/user_mgt_test.go b/auth/user_mgt_test.go index f6552d17..1e4a4646 100644 --- a/auth/user_mgt_test.go +++ b/auth/user_mgt_test.go @@ -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 diff --git a/firebase.go b/firebase.go index c4fa02e9..72aeb568 100644 --- a/firebase.go +++ b/firebase.go @@ -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"