3
0

Migrate gplus -> google

This commit is contained in:
Tomaž Jerman
2019-08-20 10:33:00 +02:00
parent a133c97c77
commit 7a8212b879
6 changed files with 14 additions and 14 deletions

View File

@@ -141,7 +141,7 @@ func authAddExternals(ctx context.Context, cmd *cobra.Command, c *cli.Config) (e
kinds = []string{
"github",
"facebook",
"gplus",
"google",
"linkedin",
"oidc",
}

View File

@@ -8,7 +8,7 @@ import (
"github.com/markbates/goth/gothic"
"github.com/markbates/goth/providers/facebook"
"github.com/markbates/goth/providers/github"
"github.com/markbates/goth/providers/gplus"
"github.com/markbates/goth/providers/google"
"github.com/markbates/goth/providers/linkedin"
"github.com/markbates/goth/providers/openidConnect"
"go.uber.org/zap"
@@ -97,8 +97,8 @@ func setupGothProviders(as service.AuthSettings) {
provider = github.New(pc.Key, pc.Secret, pc.RedirectUrl, scopes...)
case "facebook":
provider = facebook.New(pc.Key, pc.Secret, pc.RedirectUrl, scopes...)
case "gplus":
provider = gplus.New(pc.Key, pc.Secret, pc.RedirectUrl, scopes...)
case "google":
provider = google.New(pc.Key, pc.Secret, pc.RedirectUrl, scopes...)
case "linkedin":
provider = linkedin.New(pc.Key, pc.Secret, pc.RedirectUrl, scopes...)
}

View File

@@ -30,7 +30,7 @@ func TestCredentials(t *testing.T) {
cc := types.CredentialsSet{
&types.Credentials{OwnerID: 10000, Kind: "li", Credentials: "linkedin-profile-id"},
&types.Credentials{OwnerID: 10000, Kind: "g+", Credentials: "gplus-profile-id"},
&types.Credentials{OwnerID: 10000, Kind: "google", Credentials: "google-profile-id"},
&types.Credentials{OwnerID: 20000, Kind: "fb", Credentials: "facebook-profile-id"},
}

View File

@@ -106,7 +106,7 @@ func (as *AuthSettings) parseExternalProviders(kv intset.KV) (map[string]AuthSet
ep = map[string]AuthSettingsExternalAuthProvider{
"github": {},
"facebook": {},
"gplus": {},
"google": {},
"linkedin": {},
}
@@ -202,7 +202,7 @@ func (as AuthSettings) Format() map[string]interface{} {
label = "Crust Unify"
case "facebook":
label = "Facebook"
case "gplus":
case "google":
label = "Google"
case "linkedin":
label = "LinkedIn"

View File

@@ -26,7 +26,7 @@ func Test_extractProviders(t *testing.T) {
wantProviders: map[string]AuthSettingsExternalAuthProvider{
"github": AuthSettingsExternalAuthProvider{},
"linkedin": AuthSettingsExternalAuthProvider{},
"gplus": AuthSettingsExternalAuthProvider{},
"google": AuthSettingsExternalAuthProvider{},
"facebook": AuthSettingsExternalAuthProvider{},
},
},
@@ -69,7 +69,7 @@ func Test_extractProviders(t *testing.T) {
"openid-connect.baz": AuthSettingsExternalAuthProvider{},
"github": AuthSettingsExternalAuthProvider{},
"linkedin": AuthSettingsExternalAuthProvider{},
"gplus": AuthSettingsExternalAuthProvider{},
"google": AuthSettingsExternalAuthProvider{},
"facebook": AuthSettingsExternalAuthProvider{
Enabled: true,
Secret: "fb-secret",

View File

@@ -47,11 +47,11 @@ func TestAuth_External_Existing(t *testing.T) {
var c = &types.Credentials{ID: 200000, OwnerID: u.ID}
// Profile to be used. make sure email matches
var p = goth.User{UserID: "some-profile-id", Provider: "gplus", Email: u.Email}
var p = goth.User{UserID: "some-profile-id", Provider: "google", Email: u.Email}
crdRpoMock := repomock.NewMockCredentialsRepository(mockCtrl)
crdRpoMock.EXPECT().
FindByCredentials("gplus", p.UserID).
FindByCredentials("google", p.UserID).
Times(1).
Return(types.CredentialsSet{c}, nil)
@@ -80,16 +80,16 @@ func TestAuth_External_NonExisting(t *testing.T) {
var u = &types.User{ID: 300000, Email: "foo@example.tld"}
var c = &types.Credentials{ID: 200000, OwnerID: u.ID}
var p = goth.User{UserID: "some-profile-id", Provider: "gplus", Email: u.Email}
var p = goth.User{UserID: "some-profile-id", Provider: "google", Email: u.Email}
crdRpoMock := repomock.NewMockCredentialsRepository(mockCtrl)
crdRpoMock.EXPECT().
FindByCredentials("gplus", p.UserID).
FindByCredentials("google", p.UserID).
Times(1).
Return(types.CredentialsSet{}, nil)
crdRpoMock.EXPECT().
Create(&types.Credentials{Kind: "gplus", OwnerID: u.ID, Credentials: p.UserID}).
Create(&types.Credentials{Kind: "google", OwnerID: u.ID, Credentials: p.UserID}).
Times(1).
Return(c, nil)