From d0f8758fa9cb055e9da7b46f73bd3d150dbbc0ad Mon Sep 17 00:00:00 2001 From: rsgowman Date: Wed, 24 Mar 2021 17:20:21 -0400 Subject: [PATCH 1/2] GetUserByProviderID -> GetUserByProviderUID (#425) Fix incorrect method name. The old one has been left as a (deprecated) alias. --- auth/user_mgt.go | 13 ++++++++++--- auth/user_mgt_test.go | 20 ++++++++++---------- integration/auth/user_mgt_test.go | 10 +++++----- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/auth/user_mgt.go b/auth/user_mgt.go index e4ada620..c44e15ae 100644 --- a/auth/user_mgt.go +++ b/auth/user_mgt.go @@ -609,15 +609,22 @@ func (c *baseClient) GetUserByPhoneNumber(ctx context.Context, phone string) (*U }) } -// GetUserByProviderID gets the user data for the user corresponding to a given provider ID. +// GetUserByProviderID is an alias for GetUserByProviderUID. +// +// Deprecated. Use GetUserByProviderUID instead. +func (c *baseClient) GetUserByProviderID(ctx context.Context, providerID string, providerUID string) (*UserRecord, error) { + return c.GetUserByProviderUID(ctx, providerID, providerUID) +} + +// GetUserByProviderUID gets the user data for the user corresponding to a given provider ID. // // See -// [Retrieve user data](https://firebase.google.com/docs/auth/admin/manage-users#retrieve_user_data) +// https://firebase.google.com/docs/auth/admin/manage-users#retrieve_user_data // for code samples and detailed documentation. // // `providerID` indicates the provider, such as 'google.com' for the Google provider. // `providerUID` is the user identifier for the given provider. -func (c *baseClient) GetUserByProviderID(ctx context.Context, providerID string, providerUID string) (*UserRecord, error) { +func (c *baseClient) GetUserByProviderUID(ctx context.Context, providerID string, providerUID string) (*UserRecord, error) { // Although we don't really advertise it, we want to also handle non-federated // IDPs with this call. So if we detect one of them, we'll reroute this // request appropriately. diff --git a/auth/user_mgt_test.go b/auth/user_mgt_test.go index 32b2e726..78ad58d8 100644 --- a/auth/user_mgt_test.go +++ b/auth/user_mgt_test.go @@ -146,10 +146,10 @@ func TestGetUserByProviderIDNotFound(t *testing.T) { s := echoServer(mockUsers, t) defer s.Close() - userRecord, err := s.Client.GetUserByProviderID(context.Background(), "google.com", "google_uid1") + userRecord, err := s.Client.GetUserByProviderUID(context.Background(), "google.com", "google_uid1") want := "cannot find user from providerID: { google.com, google_uid1 }" if userRecord != nil || err == nil || err.Error() != want || !IsUserNotFound(err) { - t.Errorf("GetUserByProviderID() = (%v, %q); want = (nil, %q)", userRecord, err, want) + t.Errorf("GetUserByProviderUID() = (%v, %q); want = (nil, %q)", userRecord, err, want) } } @@ -182,19 +182,19 @@ func TestGetUserByProviderId(t *testing.T) { for _, tc := range cases { t.Run(tc.providerID+":"+tc.providerUID, func(t *testing.T) { - _, err := s.Client.GetUserByProviderID(context.Background(), tc.providerID, tc.providerUID) + _, err := s.Client.GetUserByProviderUID(context.Background(), tc.providerID, tc.providerUID) if err != nil { - t.Fatalf("GetUserByProviderID() = %q", err) + t.Fatalf("GetUserByProviderUID() = %q", err) } got := string(s.Rbody) if got != tc.want { - t.Errorf("GetUserByProviderID() Req = %v; want = %v", got, tc.want) + t.Errorf("GetUserByProviderUID() Req = %v; want = %v", got, tc.want) } wantPath := "/projects/mock-project-id/accounts:lookup" if s.Req[0].RequestURI != wantPath { - t.Errorf("GetUserByProviderID() URL = %q; want = %q", s.Req[0].RequestURI, wantPath) + t.Errorf("GetUserByProviderUID() URL = %q; want = %q", s.Req[0].RequestURI, wantPath) } }) } @@ -220,16 +220,16 @@ func TestInvalidGetUser(t *testing.T) { t.Errorf("GetUserPhoneNumber('') = (%v, %v); want = (nil, error)", user, err) } - userRecord, err := client.GetUserByProviderID(context.Background(), "", "google_uid1") + userRecord, err := client.GetUserByProviderUID(context.Background(), "", "google_uid1") want := "providerID must be a non-empty string" if userRecord != nil || err == nil || err.Error() != want { - t.Errorf("GetUserByProviderID() = (%v, %q); want = (nil, %q)", userRecord, err, want) + t.Errorf("GetUserByProviderUID() = (%v, %q); want = (nil, %q)", userRecord, err, want) } - userRecord, err = client.GetUserByProviderID(context.Background(), "google.com", "") + userRecord, err = client.GetUserByProviderUID(context.Background(), "google.com", "") want = "providerUID must be a non-empty string" if userRecord != nil || err == nil || err.Error() != want { - t.Errorf("GetUserByProviderID() = (%v, %q); want = (nil, %q)", userRecord, err, want) + t.Errorf("GetUserByProviderUID() = (%v, %q); want = (nil, %q)", userRecord, err, want) } } diff --git a/integration/auth/user_mgt_test.go b/integration/auth/user_mgt_test.go index 13a27ddf..c32f6d3e 100644 --- a/integration/auth/user_mgt_test.go +++ b/integration/auth/user_mgt_test.go @@ -80,7 +80,7 @@ func TestGetUser(t *testing.T) { } } -func TestGetUserByProviderID(t *testing.T) { +func TestGetUserByProviderUID(t *testing.T) { // TODO(rsgowman): Once we can link a provider id with a user, just do that // here instead of importing a new user. importUserUID := randomUID() @@ -98,13 +98,13 @@ func TestGetUserByProviderID(t *testing.T) { importUser(t, importUserUID, userToImport) defer deleteUser(importUserUID) - userRecord, err := client.GetUserByProviderID(context.Background(), "google.com", providerUID) + userRecord, err := client.GetUserByProviderUID(context.Background(), "google.com", providerUID) if err != nil { - t.Fatalf("GetUserByProviderID() = %q", err) + t.Fatalf("GetUserByProviderUID() = %q", err) } if userRecord.UID != importUserUID { - t.Errorf("GetUserByProviderID().UID = %v; want = %v", userRecord.UID, importUserUID) + t.Errorf("GetUserByProviderUID().UID = %v; want = %v", userRecord.UID, importUserUID) } } @@ -124,7 +124,7 @@ func TestGetNonExistingUser(t *testing.T) { t.Errorf("GetUser(non.existing) = (%v, %v); want = (nil, error)", user, err) } - user, err = client.GetUserByProviderID(context.Background(), "google.com", "a-uid-that-doesnt-exist") + user, err = client.GetUserByProviderUID(context.Background(), "google.com", "a-uid-that-doesnt-exist") if user != nil || !auth.IsUserNotFound(err) { t.Errorf("GetUser(non.existing) = (%v, %v); want = (nil, error)", user, err) } From b4f2d4002ae4192eea8272be857ae9c4fa2f4846 Mon Sep 17 00:00:00 2001 From: Hiranya Jayathilaka Date: Mon, 29 Mar 2021 10:20:44 -0700 Subject: [PATCH 2/2] [chore] Release 4.4.0 (#430) --- firebase.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firebase.go b/firebase.go index 68e0fdc7..e825f759 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.3.0" +const Version = "4.4.0" // firebaseEnvName is the name of the environment variable with the Config. const firebaseEnvName = "FIREBASE_CONFIG"