Skip to content

Commit 05378ef

Browse files
Merge dev into master
2 parents eb0d2a0 + b4f2d40 commit 05378ef

File tree

4 files changed

+26
-19
lines changed

4 files changed

+26
-19
lines changed

auth/user_mgt.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,15 +609,22 @@ func (c *baseClient) GetUserByPhoneNumber(ctx context.Context, phone string) (*U
609609
})
610610
}
611611

612-
// GetUserByProviderID gets the user data for the user corresponding to a given provider ID.
612+
// GetUserByProviderID is an alias for GetUserByProviderUID.
613+
//
614+
// Deprecated. Use GetUserByProviderUID instead.
615+
func (c *baseClient) GetUserByProviderID(ctx context.Context, providerID string, providerUID string) (*UserRecord, error) {
616+
return c.GetUserByProviderUID(ctx, providerID, providerUID)
617+
}
618+
619+
// GetUserByProviderUID gets the user data for the user corresponding to a given provider ID.
613620
//
614621
// See
615-
// [Retrieve user data](https://firebase.google.com/docs/auth/admin/manage-users#retrieve_user_data)
622+
// https://firebase.google.com/docs/auth/admin/manage-users#retrieve_user_data
616623
// for code samples and detailed documentation.
617624
//
618625
// `providerID` indicates the provider, such as 'google.com' for the Google provider.
619626
// `providerUID` is the user identifier for the given provider.
620-
func (c *baseClient) GetUserByProviderID(ctx context.Context, providerID string, providerUID string) (*UserRecord, error) {
627+
func (c *baseClient) GetUserByProviderUID(ctx context.Context, providerID string, providerUID string) (*UserRecord, error) {
621628
// Although we don't really advertise it, we want to also handle non-federated
622629
// IDPs with this call. So if we detect one of them, we'll reroute this
623630
// request appropriately.

auth/user_mgt_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ func TestGetUserByProviderIDNotFound(t *testing.T) {
146146
s := echoServer(mockUsers, t)
147147
defer s.Close()
148148

149-
userRecord, err := s.Client.GetUserByProviderID(context.Background(), "google.com", "google_uid1")
149+
userRecord, err := s.Client.GetUserByProviderUID(context.Background(), "google.com", "google_uid1")
150150
want := "cannot find user from providerID: { google.com, google_uid1 }"
151151
if userRecord != nil || err == nil || err.Error() != want || !IsUserNotFound(err) {
152-
t.Errorf("GetUserByProviderID() = (%v, %q); want = (nil, %q)", userRecord, err, want)
152+
t.Errorf("GetUserByProviderUID() = (%v, %q); want = (nil, %q)", userRecord, err, want)
153153
}
154154
}
155155

@@ -182,19 +182,19 @@ func TestGetUserByProviderId(t *testing.T) {
182182
for _, tc := range cases {
183183
t.Run(tc.providerID+":"+tc.providerUID, func(t *testing.T) {
184184

185-
_, err := s.Client.GetUserByProviderID(context.Background(), tc.providerID, tc.providerUID)
185+
_, err := s.Client.GetUserByProviderUID(context.Background(), tc.providerID, tc.providerUID)
186186
if err != nil {
187-
t.Fatalf("GetUserByProviderID() = %q", err)
187+
t.Fatalf("GetUserByProviderUID() = %q", err)
188188
}
189189

190190
got := string(s.Rbody)
191191
if got != tc.want {
192-
t.Errorf("GetUserByProviderID() Req = %v; want = %v", got, tc.want)
192+
t.Errorf("GetUserByProviderUID() Req = %v; want = %v", got, tc.want)
193193
}
194194

195195
wantPath := "/projects/mock-project-id/accounts:lookup"
196196
if s.Req[0].RequestURI != wantPath {
197-
t.Errorf("GetUserByProviderID() URL = %q; want = %q", s.Req[0].RequestURI, wantPath)
197+
t.Errorf("GetUserByProviderUID() URL = %q; want = %q", s.Req[0].RequestURI, wantPath)
198198
}
199199
})
200200
}
@@ -220,16 +220,16 @@ func TestInvalidGetUser(t *testing.T) {
220220
t.Errorf("GetUserPhoneNumber('') = (%v, %v); want = (nil, error)", user, err)
221221
}
222222

223-
userRecord, err := client.GetUserByProviderID(context.Background(), "", "google_uid1")
223+
userRecord, err := client.GetUserByProviderUID(context.Background(), "", "google_uid1")
224224
want := "providerID must be a non-empty string"
225225
if userRecord != nil || err == nil || err.Error() != want {
226-
t.Errorf("GetUserByProviderID() = (%v, %q); want = (nil, %q)", userRecord, err, want)
226+
t.Errorf("GetUserByProviderUID() = (%v, %q); want = (nil, %q)", userRecord, err, want)
227227
}
228228

229-
userRecord, err = client.GetUserByProviderID(context.Background(), "google.com", "")
229+
userRecord, err = client.GetUserByProviderUID(context.Background(), "google.com", "")
230230
want = "providerUID must be a non-empty string"
231231
if userRecord != nil || err == nil || err.Error() != want {
232-
t.Errorf("GetUserByProviderID() = (%v, %q); want = (nil, %q)", userRecord, err, want)
232+
t.Errorf("GetUserByProviderUID() = (%v, %q); want = (nil, %q)", userRecord, err, want)
233233
}
234234
}
235235

firebase.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import (
3838
var defaultAuthOverrides = make(map[string]interface{})
3939

4040
// Version of the Firebase Go Admin SDK.
41-
const Version = "4.3.0"
41+
const Version = "4.4.0"
4242

4343
// firebaseEnvName is the name of the environment variable with the Config.
4444
const firebaseEnvName = "FIREBASE_CONFIG"

integration/auth/user_mgt_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func TestGetUser(t *testing.T) {
8080
}
8181
}
8282

83-
func TestGetUserByProviderID(t *testing.T) {
83+
func TestGetUserByProviderUID(t *testing.T) {
8484
// TODO(rsgowman): Once we can link a provider id with a user, just do that
8585
// here instead of importing a new user.
8686
importUserUID := randomUID()
@@ -98,13 +98,13 @@ func TestGetUserByProviderID(t *testing.T) {
9898
importUser(t, importUserUID, userToImport)
9999
defer deleteUser(importUserUID)
100100

101-
userRecord, err := client.GetUserByProviderID(context.Background(), "google.com", providerUID)
101+
userRecord, err := client.GetUserByProviderUID(context.Background(), "google.com", providerUID)
102102
if err != nil {
103-
t.Fatalf("GetUserByProviderID() = %q", err)
103+
t.Fatalf("GetUserByProviderUID() = %q", err)
104104
}
105105

106106
if userRecord.UID != importUserUID {
107-
t.Errorf("GetUserByProviderID().UID = %v; want = %v", userRecord.UID, importUserUID)
107+
t.Errorf("GetUserByProviderUID().UID = %v; want = %v", userRecord.UID, importUserUID)
108108
}
109109
}
110110

@@ -124,7 +124,7 @@ func TestGetNonExistingUser(t *testing.T) {
124124
t.Errorf("GetUser(non.existing) = (%v, %v); want = (nil, error)", user, err)
125125
}
126126

127-
user, err = client.GetUserByProviderID(context.Background(), "google.com", "a-uid-that-doesnt-exist")
127+
user, err = client.GetUserByProviderUID(context.Background(), "google.com", "a-uid-that-doesnt-exist")
128128
if user != nil || !auth.IsUserNotFound(err) {
129129
t.Errorf("GetUser(non.existing) = (%v, %v); want = (nil, error)", user, err)
130130
}

0 commit comments

Comments
 (0)