Migrate gplus -> google
This commit is contained in:
@@ -141,7 +141,7 @@ func authAddExternals(ctx context.Context, cmd *cobra.Command, c *cli.Config) (e
|
||||
kinds = []string{
|
||||
"github",
|
||||
"facebook",
|
||||
"gplus",
|
||||
"google",
|
||||
"linkedin",
|
||||
"oidc",
|
||||
}
|
||||
|
||||
6
system/internal/auth/external/goth.go
vendored
6
system/internal/auth/external/goth.go
vendored
@@ -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...)
|
||||
}
|
||||
|
||||
@@ -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"},
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user