forked from mystiq/dex
Fix whitespace
This commit is contained in:
parent
9bd5ae5197
commit
f141f2133b
19 changed files with 0 additions and 33 deletions
|
@ -18,7 +18,6 @@ linters:
|
||||||
# TODO: fix me
|
# TODO: fix me
|
||||||
- unparam
|
- unparam
|
||||||
- golint
|
- golint
|
||||||
- whitespace
|
|
||||||
- goconst
|
- goconst
|
||||||
- unconvert
|
- unconvert
|
||||||
- bodyclose
|
- bodyclose
|
||||||
|
|
|
@ -211,5 +211,4 @@ logger:
|
||||||
if diff := pretty.Compare(c, want); diff != "" {
|
if diff := pretty.Compare(c, want); diff != "" {
|
||||||
t.Errorf("got!=want: %s", diff)
|
t.Errorf("got!=want: %s", diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,7 +182,6 @@ func serve(cmd *cobra.Command, args []string) error {
|
||||||
return fmt.Errorf("failed to initialize storage connectors: %v", err)
|
return fmt.Errorf("failed to initialize storage connectors: %v", err)
|
||||||
}
|
}
|
||||||
storageConnectors[i] = conn
|
storageConnectors[i] = conn
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.EnablePasswordDB {
|
if c.EnablePasswordDB {
|
||||||
|
|
|
@ -41,7 +41,6 @@ type Config struct {
|
||||||
|
|
||||||
// Open returns a strategy for logging in through Bitbucket.
|
// Open returns a strategy for logging in through Bitbucket.
|
||||||
func (c *Config) Open(id string, logger log.Logger) (connector.Connector, error) {
|
func (c *Config) Open(id string, logger log.Logger) (connector.Connector, error) {
|
||||||
|
|
||||||
b := bitbucketConnector{
|
b := bitbucketConnector{
|
||||||
redirectURI: c.RedirectURI,
|
redirectURI: c.RedirectURI,
|
||||||
teams: c.Teams,
|
teams: c.Teams,
|
||||||
|
@ -373,7 +372,6 @@ type userTeamsResponse struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *bitbucketConnector) userTeams(ctx context.Context, client *http.Client) ([]string, error) {
|
func (b *bitbucketConnector) userTeams(ctx context.Context, client *http.Client) ([]string, error) {
|
||||||
|
|
||||||
var teams []string
|
var teams []string
|
||||||
apiURL := b.apiURL + "/teams?role=member"
|
apiURL := b.apiURL + "/teams?role=member"
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestUserGroups(t *testing.T) {
|
func TestUserGroups(t *testing.T) {
|
||||||
|
|
||||||
teamsResponse := userTeamsResponse{
|
teamsResponse := userTeamsResponse{
|
||||||
pagedResponse: pagedResponse{
|
pagedResponse: pagedResponse{
|
||||||
Size: 3,
|
Size: 3,
|
||||||
|
@ -46,7 +45,6 @@ func TestUserGroups(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUserWithoutTeams(t *testing.T) {
|
func TestUserWithoutTeams(t *testing.T) {
|
||||||
|
|
||||||
s := newTestServer(map[string]interface{}{
|
s := newTestServer(map[string]interface{}{
|
||||||
"/teams?role=member": userTeamsResponse{},
|
"/teams?role=member": userTeamsResponse{},
|
||||||
})
|
})
|
||||||
|
@ -61,7 +59,6 @@ func TestUserWithoutTeams(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUsernameIncludedInFederatedIdentity(t *testing.T) {
|
func TestUsernameIncludedInFederatedIdentity(t *testing.T) {
|
||||||
|
|
||||||
s := newTestServer(map[string]interface{}{
|
s := newTestServer(map[string]interface{}{
|
||||||
"/user": user{Username: "some-login"},
|
"/user": user{Username: "some-login"},
|
||||||
"/user/emails": userEmailResponse{
|
"/user/emails": userEmailResponse{
|
||||||
|
|
|
@ -67,7 +67,6 @@ type Org struct {
|
||||||
|
|
||||||
// Open returns a strategy for logging in through GitHub.
|
// Open returns a strategy for logging in through GitHub.
|
||||||
func (c *Config) Open(id string, logger log.Logger) (connector.Connector, error) {
|
func (c *Config) Open(id string, logger log.Logger) (connector.Connector, error) {
|
||||||
|
|
||||||
if c.Org != "" {
|
if c.Org != "" {
|
||||||
// Return error if both 'org' and 'orgs' fields are used.
|
// Return error if both 'org' and 'orgs' fields are used.
|
||||||
if len(c.Orgs) > 0 {
|
if len(c.Orgs) > 0 {
|
||||||
|
@ -107,7 +106,6 @@ func (c *Config) Open(id string, logger log.Logger) (connector.Connector, error)
|
||||||
if g.httpClient, err = newHTTPClient(g.rootCA); err != nil {
|
if g.httpClient, err = newHTTPClient(g.rootCA); err != nil {
|
||||||
return nil, fmt.Errorf("failed to create HTTP client: %v", err)
|
return nil, fmt.Errorf("failed to create HTTP client: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
g.loadAllGroups = c.LoadAllGroups
|
g.loadAllGroups = c.LoadAllGroups
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,6 @@ func TestUserGroupsWithTeamNameAndSlugFieldConfig(t *testing.T) {
|
||||||
|
|
||||||
// tests that the users login is used as their username when they have no username set
|
// tests that the users login is used as their username when they have no username set
|
||||||
func TestUsernameIncludedInFederatedIdentity(t *testing.T) {
|
func TestUsernameIncludedInFederatedIdentity(t *testing.T) {
|
||||||
|
|
||||||
s := newTestServer(map[string]testResponse{
|
s := newTestServer(map[string]testResponse{
|
||||||
"/user": {data: user{Login: "some-login", ID: 12345678}},
|
"/user": {data: user{Login: "some-login", ID: 12345678}},
|
||||||
"/user/emails": {data: []userEmail{{
|
"/user/emails": {data: []userEmail{{
|
||||||
|
@ -168,7 +167,6 @@ func TestUsernameIncludedInFederatedIdentity(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoginUsedAsIDWhenConfigured(t *testing.T) {
|
func TestLoginUsedAsIDWhenConfigured(t *testing.T) {
|
||||||
|
|
||||||
s := newTestServer(map[string]testResponse{
|
s := newTestServer(map[string]testResponse{
|
||||||
"/user": {data: user{Login: "some-login", ID: 12345678, Name: "Joe Bloggs"}},
|
"/user": {data: user{Login: "some-login", ID: 12345678, Name: "Joe Bloggs"}},
|
||||||
"/user/emails": {data: []userEmail{{
|
"/user/emails": {data: []userEmail{{
|
||||||
|
|
|
@ -65,7 +65,6 @@ func TestUserGroupsWithoutOrgs(t *testing.T) {
|
||||||
|
|
||||||
// tests that the email is used as their username when they have no username set
|
// tests that the email is used as their username when they have no username set
|
||||||
func TestUsernameIncludedInFederatedIdentity(t *testing.T) {
|
func TestUsernameIncludedInFederatedIdentity(t *testing.T) {
|
||||||
|
|
||||||
s := newTestServer(map[string]interface{}{
|
s := newTestServer(map[string]interface{}{
|
||||||
"/api/v4/user": gitlabUser{Email: "some@email.com", ID: 12345678},
|
"/api/v4/user": gitlabUser{Email: "some@email.com", ID: 12345678},
|
||||||
"/oauth/token": map[string]interface{}{
|
"/oauth/token": map[string]interface{}{
|
||||||
|
@ -102,7 +101,6 @@ func TestUsernameIncludedInFederatedIdentity(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoginUsedAsIDWhenConfigured(t *testing.T) {
|
func TestLoginUsedAsIDWhenConfigured(t *testing.T) {
|
||||||
|
|
||||||
s := newTestServer(map[string]interface{}{
|
s := newTestServer(map[string]interface{}{
|
||||||
"/api/v4/user": gitlabUser{Email: "some@email.com", ID: 12345678, Name: "Joe Bloggs", Username: "joebloggs"},
|
"/api/v4/user": gitlabUser{Email: "some@email.com", ID: 12345678, Name: "Joe Bloggs", Username: "joebloggs"},
|
||||||
"/oauth/token": map[string]interface{}{
|
"/oauth/token": map[string]interface{}{
|
||||||
|
@ -130,7 +128,6 @@ func TestLoginUsedAsIDWhenConfigured(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoginWithTeamWhitelisted(t *testing.T) {
|
func TestLoginWithTeamWhitelisted(t *testing.T) {
|
||||||
|
|
||||||
s := newTestServer(map[string]interface{}{
|
s := newTestServer(map[string]interface{}{
|
||||||
"/api/v4/user": gitlabUser{Email: "some@email.com", ID: 12345678, Name: "Joe Bloggs"},
|
"/api/v4/user": gitlabUser{Email: "some@email.com", ID: 12345678, Name: "Joe Bloggs"},
|
||||||
"/oauth/token": map[string]interface{}{
|
"/oauth/token": map[string]interface{}{
|
||||||
|
@ -158,7 +155,6 @@ func TestLoginWithTeamWhitelisted(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoginWithTeamNonWhitelisted(t *testing.T) {
|
func TestLoginWithTeamNonWhitelisted(t *testing.T) {
|
||||||
|
|
||||||
s := newTestServer(map[string]interface{}{
|
s := newTestServer(map[string]interface{}{
|
||||||
"/api/v4/user": gitlabUser{Email: "some@email.com", ID: 12345678, Name: "Joe Bloggs", Username: "joebloggs"},
|
"/api/v4/user": gitlabUser{Email: "some@email.com", ID: 12345678, Name: "Joe Bloggs", Username: "joebloggs"},
|
||||||
"/oauth/token": map[string]interface{}{
|
"/oauth/token": map[string]interface{}{
|
||||||
|
|
|
@ -150,7 +150,6 @@ func (p *conn) Prompt() string { return "username" }
|
||||||
|
|
||||||
func (p *conn) Refresh(
|
func (p *conn) Refresh(
|
||||||
ctx context.Context, scopes connector.Scopes, identity connector.Identity) (connector.Identity, error) {
|
ctx context.Context, scopes connector.Scopes, identity connector.Identity) (connector.Identity, error) {
|
||||||
|
|
||||||
token, err := p.getAdminToken(ctx)
|
token, err := p.getAdminToken(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return identity, fmt.Errorf("keystone: failed to obtain admin token: %v", err)
|
return identity, fmt.Errorf("keystone: failed to obtain admin token: %v", err)
|
||||||
|
|
|
@ -189,7 +189,6 @@ func (c *Config) OpenConnector(logger log.Logger) (interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Config) openConnector(logger log.Logger) (*ldapConnector, error) {
|
func (c *Config) openConnector(logger log.Logger) (*ldapConnector, error) {
|
||||||
|
|
||||||
requiredFields := []struct {
|
requiredFields := []struct {
|
||||||
name string
|
name string
|
||||||
val string
|
val string
|
||||||
|
@ -365,7 +364,6 @@ func (c *ldapConnector) identityFromEntry(user ldap.Entry) (ident connector.Iden
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ldapConnector) userEntry(conn *ldap.Conn, username string) (user ldap.Entry, found bool, err error) {
|
func (c *ldapConnector) userEntry(conn *ldap.Conn, username string) (user ldap.Entry, found bool, err error) {
|
||||||
|
|
||||||
filter := fmt.Sprintf("(%s=%s)", c.UserSearch.Username, ldap.EscapeFilter(username))
|
filter := fmt.Sprintf("(%s=%s)", c.UserSearch.Username, ldap.EscapeFilter(username))
|
||||||
if c.UserSearch.Filter != "" {
|
if c.UserSearch.Filter != "" {
|
||||||
filter = fmt.Sprintf("(&%s%s)", c.UserSearch.Filter, filter)
|
filter = fmt.Sprintf("(&%s%s)", c.UserSearch.Filter, filter)
|
||||||
|
|
|
@ -249,7 +249,6 @@ type provider struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *provider) POSTData(s connector.Scopes, id string) (action, value string, err error) {
|
func (p *provider) POSTData(s connector.Scopes, id string) (action, value string, err error) {
|
||||||
|
|
||||||
r := &authnRequest{
|
r := &authnRequest{
|
||||||
ProtocolBinding: bindingPOST,
|
ProtocolBinding: bindingPOST,
|
||||||
ID: id,
|
ID: id,
|
||||||
|
|
|
@ -218,7 +218,6 @@ func (d dexAPI) DeletePassword(ctx context.Context, req *api.DeletePasswordReq)
|
||||||
return nil, fmt.Errorf("delete password: %v", err)
|
return nil, fmt.Errorf("delete password: %v", err)
|
||||||
}
|
}
|
||||||
return &api.DeletePasswordResp{}, nil
|
return &api.DeletePasswordResp{}, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d dexAPI) GetVersion(ctx context.Context, req *api.VersionReq) (*api.VersionResp, error) {
|
func (d dexAPI) GetVersion(ctx context.Context, req *api.VersionReq) (*api.VersionResp, error) {
|
||||||
|
@ -248,7 +247,6 @@ func (d dexAPI) ListPasswords(ctx context.Context, req *api.ListPasswordReq) (*a
|
||||||
return &api.ListPasswordResp{
|
return &api.ListPasswordResp{
|
||||||
Passwords: passwords,
|
Passwords: passwords,
|
||||||
}, nil
|
}, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d dexAPI) VerifyPassword(ctx context.Context, req *api.VerifyPasswordReq) (*api.VerifyPasswordResp, error) {
|
func (d dexAPI) VerifyPassword(ctx context.Context, req *api.VerifyPasswordReq) (*api.VerifyPasswordResp, error) {
|
||||||
|
|
|
@ -167,7 +167,6 @@ func TestPassword(t *testing.T) {
|
||||||
if _, err := client.DeletePassword(ctx, &deleteReq); err != nil {
|
if _, err := client.DeletePassword(ctx, &deleteReq); err != nil {
|
||||||
t.Fatalf("Unable to delete password: %v", err)
|
t.Fatalf("Unable to delete password: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensures checkCost returns expected values
|
// Ensures checkCost returns expected values
|
||||||
|
@ -495,7 +494,6 @@ func TestUpdateClient(t *testing.T) {
|
||||||
if tc.cleanup != nil {
|
if tc.cleanup != nil {
|
||||||
tc.cleanup(t, tc.req.Id)
|
tc.cleanup(t, tc.req.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -922,7 +922,6 @@ func (s *Server) handleAuthCode(w http.ResponseWriter, r *http.Request, client s
|
||||||
deleteToken = true
|
deleteToken = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.writeAccessToken(w, idToken, accessToken, refreshToken, expiry)
|
s.writeAccessToken(w, idToken, accessToken, refreshToken, expiry)
|
||||||
|
|
|
@ -24,7 +24,6 @@ func TestHandleHealth(t *testing.T) {
|
||||||
if rr.Code != http.StatusOK {
|
if rr.Code != http.StatusOK {
|
||||||
t.Errorf("expected 200 got %d", rr.Code)
|
t.Errorf("expected 200 got %d", rr.Code)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type badStorage struct {
|
type badStorage struct {
|
||||||
|
|
|
@ -799,7 +799,6 @@ func TestCrossClientScopes(t *testing.T) {
|
||||||
if !reflect.DeepEqual(idToken.Audience, expAudience) {
|
if !reflect.DeepEqual(idToken.Audience, expAudience) {
|
||||||
t.Errorf("expected audience %q, got %q", expAudience, idToken.Audience)
|
t.Errorf("expected audience %q, got %q", expAudience, idToken.Audience)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if gotState := q.Get("state"); gotState != state {
|
if gotState := q.Get("state"); gotState != state {
|
||||||
t.Errorf("state did not match, want=%q got=%q", state, gotState)
|
t.Errorf("state did not match, want=%q got=%q", state, gotState)
|
||||||
|
@ -921,7 +920,6 @@ func TestCrossClientScopesWithAzpInAudienceByDefault(t *testing.T) {
|
||||||
if !reflect.DeepEqual(idToken.Audience, expAudience) {
|
if !reflect.DeepEqual(idToken.Audience, expAudience) {
|
||||||
t.Errorf("expected audience %q, got %q", expAudience, idToken.Audience)
|
t.Errorf("expected audience %q, got %q", expAudience, idToken.Audience)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if gotState := q.Get("state"); gotState != state {
|
if gotState := q.Get("state"); gotState != state {
|
||||||
t.Errorf("state did not match, want=%q got=%q", state, gotState)
|
t.Errorf("state did not match, want=%q got=%q", state, gotState)
|
||||||
|
@ -1058,7 +1056,6 @@ func TestPasswordDB(t *testing.T) {
|
||||||
t.Errorf("%s: %s", tc.name, diff)
|
t.Errorf("%s: %s", tc.name, diff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPasswordDBUsernamePrompt(t *testing.T) {
|
func TestPasswordDBUsernamePrompt(t *testing.T) {
|
||||||
|
|
|
@ -176,7 +176,6 @@ func loadTemplates(c webConfig, templatesDir string) (*templates, error) {
|
||||||
//assetPath is static/main.css
|
//assetPath is static/main.css
|
||||||
//relativeURL("/dex", "/dex/auth", "static/main.css") = "../static/main.css"
|
//relativeURL("/dex", "/dex/auth", "static/main.css") = "../static/main.css"
|
||||||
func relativeURL(serverPath, reqPath, assetPath string) string {
|
func relativeURL(serverPath, reqPath, assetPath string) string {
|
||||||
|
|
||||||
splitPath := func(p string) []string {
|
splitPath := func(p string) []string {
|
||||||
res := []string{}
|
res := []string{}
|
||||||
parts := strings.Split(path.Clean(p), "/")
|
parts := strings.Split(path.Clean(p), "/")
|
||||||
|
|
|
@ -160,7 +160,6 @@ func testAuthRequestCRUD(t *testing.T, s storage.Storage) {
|
||||||
if err := s.DeleteAuthRequest(a2.ID); err != nil {
|
if err := s.DeleteAuthRequest(a2.ID); err != nil {
|
||||||
t.Fatalf("failed to delete auth request: %v", err)
|
t.Fatalf("failed to delete auth request: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAuthCodeCRUD(t *testing.T, s storage.Storage) {
|
func testAuthCodeCRUD(t *testing.T, s storage.Storage) {
|
||||||
|
@ -509,7 +508,6 @@ func testPasswordCRUD(t *testing.T, s storage.Storage) {
|
||||||
|
|
||||||
_, err = s.GetPassword(password1.Email)
|
_, err = s.GetPassword(password1.Email)
|
||||||
mustBeErrNotFound(t, "password", err)
|
mustBeErrNotFound(t, "password", err)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testOfflineSessionCRUD(t *testing.T, s storage.Storage) {
|
func testOfflineSessionCRUD(t *testing.T, s storage.Storage) {
|
||||||
|
|
|
@ -169,7 +169,6 @@ func (c *conn) UpdateAuthRequest(id string, updater func(a storage.AuthRequest)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conn) GetAuthRequest(id string) (storage.AuthRequest, error) {
|
func (c *conn) GetAuthRequest(id string) (storage.AuthRequest, error) {
|
||||||
|
|
Loading…
Reference in a new issue