*: fix some lint issues
Mostly gathered these using golangci-lint's deadcode and ineffassign linters. Signed-off-by: Stephan Renatus <srenatus@chef.io>
This commit is contained in:
@@ -443,7 +443,7 @@ func (c *githubConnector) userOrgs(ctx context.Context, client *http.Client) ([]
|
||||
// userOrgTeams retrieves teams which current user belongs to.
|
||||
// Method returns a map where key is an org name and value list of teams under the org.
|
||||
func (c *githubConnector) userOrgTeams(ctx context.Context, client *http.Client) (map[string][]string, error) {
|
||||
groups := make(map[string][]string, 0)
|
||||
groups := make(map[string][]string)
|
||||
apiURL := c.apiURL + "/user/teams"
|
||||
for {
|
||||
// https://developer.github.com/v3/orgs/teams/#list-user-teams
|
||||
|
@@ -185,13 +185,11 @@ func TestLoginWithTeamNonWhitelisted(t *testing.T) {
|
||||
}
|
||||
|
||||
func newTestServer(responses map[string]interface{}) *httptest.Server {
|
||||
var s *httptest.Server
|
||||
s = httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
return httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
response := responses[r.RequestURI]
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(response)
|
||||
}))
|
||||
return s
|
||||
}
|
||||
|
||||
func newClient() *http.Client {
|
||||
|
@@ -241,6 +241,9 @@ func (p *conn) getUserGroups(ctx context.Context, userID string, token string) (
|
||||
// https://developer.openstack.org/api-ref/identity/v3/#list-groups-to-which-a-user-belongs
|
||||
groupsURL := p.Host + "/v3/users/" + userID + "/groups"
|
||||
req, err := http.NewRequest("GET", groupsURL, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Header.Set("X-Auth-Token", token)
|
||||
req = req.WithContext(ctx)
|
||||
resp, err := client.Do(req)
|
||||
|
@@ -148,7 +148,6 @@ type oidcConnector struct {
|
||||
redirectURI string
|
||||
oauth2Config *oauth2.Config
|
||||
verifier *oidc.IDTokenVerifier
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
logger log.Logger
|
||||
hostedDomains []string
|
||||
|
@@ -20,6 +20,7 @@ import (
|
||||
"github.com/russellhaering/goxmldsig/etreeutils"
|
||||
)
|
||||
|
||||
// nolint
|
||||
const (
|
||||
bindingRedirect = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
|
||||
bindingPOST = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
|
||||
|
@@ -424,14 +424,6 @@ func TestConfigCAData(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
defaultSSOIssuer = "http://www.okta.com/exk91cb99lKkKSYoy0h7"
|
||||
defaultRedirectURI = "http://localhost:5556/dex/callback"
|
||||
|
||||
// Response ID embedded in our testdata.
|
||||
testDataResponseID = "_fd1b3ef9-ec09-44a7-a66b-0d39c250f6a0"
|
||||
)
|
||||
|
||||
// Deprecated: Use testing framework established above.
|
||||
func runVerify(t *testing.T, ca string, resp string, shouldSucceed bool) {
|
||||
cert, err := loadCert(ca)
|
||||
@@ -458,27 +450,6 @@ func runVerify(t *testing.T, ca string, resp string, shouldSucceed bool) {
|
||||
}
|
||||
}
|
||||
|
||||
// Deprecated: Use testing framework established above.
|
||||
func newProvider(ssoIssuer string, redirectURI string) *provider {
|
||||
if ssoIssuer == "" {
|
||||
ssoIssuer = defaultSSOIssuer
|
||||
}
|
||||
if redirectURI == "" {
|
||||
redirectURI = defaultRedirectURI
|
||||
}
|
||||
now, _ := time.Parse(time.RFC3339, "2017-01-24T20:48:41Z")
|
||||
timeFunc := func() time.Time { return now }
|
||||
return &provider{
|
||||
ssoIssuer: ssoIssuer,
|
||||
ssoURL: "http://idp.org/saml/sso",
|
||||
now: timeFunc,
|
||||
usernameAttr: "user",
|
||||
emailAttr: "email",
|
||||
redirectURI: redirectURI,
|
||||
logger: logrus.New(),
|
||||
}
|
||||
}
|
||||
|
||||
func TestVerify(t *testing.T) {
|
||||
runVerify(t, "testdata/okta-ca.pem", "testdata/okta-resp.xml", true)
|
||||
}
|
||||
|
Reference in New Issue
Block a user