Skip to content

Commit aea0dc3

Browse files
authored
Merge branch 'master' into secrets
2 parents ca9ff0b + 0b0f351 commit aea0dc3

File tree

20 files changed

+77
-71
lines changed

20 files changed

+77
-71
lines changed

acme/api/eab.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func validateEABJWS(ctx context.Context, jws *jose.JSONWebSignature) (string, *a
129129
keyID := header.KeyID
130130
nonce := header.Nonce
131131

132-
if !(algorithm == jose.HS256 || algorithm == jose.HS384 || algorithm == jose.HS512) {
132+
if algorithm != jose.HS256 && algorithm != jose.HS384 && algorithm != jose.HS512 {
133133
return "", acme.NewError(acme.ErrorMalformedType, "'alg' field set to invalid algorithm '%s'", algorithm)
134134
}
135135

api/sshRenew.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ type SSHRenewRequest struct {
2121

2222
// Validate validates the SSHSignRequest.
2323
func (s *SSHRenewRequest) Validate() error {
24-
switch {
25-
case s.OTT == "":
24+
switch s.OTT {
25+
case "":
2626
return errs.BadRequest("missing or empty ott")
2727
default:
2828
return nil

authority/provisioner/acme.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
// ACMEChallenge represents the supported acme challenges.
1818
type ACMEChallenge string
1919

20-
//nolint:stylecheck,revive // better names
20+
//nolint:staticcheck,revive // better names
2121
const (
2222
// HTTP_01 is the http-01 ACME challenge.
2323
HTTP_01 ACMEChallenge = "http-01"

authority/provisioner/utils_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,10 +1042,12 @@ func generateAzureToken(sub, iss, aud, tenantID, subscriptionID, resourceGroup,
10421042
if err != nil {
10431043
return "", err
10441044
}
1045+
10451046
var xmsMirID string
1046-
if resourceType == "vm" {
1047+
switch resourceType {
1048+
case "vm":
10471049
xmsMirID = fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/virtualMachines/%s", subscriptionID, resourceGroup, resourceName)
1048-
} else if resourceType == "uai" {
1050+
case "uai":
10491051
xmsMirID = fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ManagedIdentity/userAssignedIdentities/%s", subscriptionID, resourceGroup, resourceName)
10501052
}
10511053

authority/tls.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ func (a *Authority) Revoke(ctx context.Context, revokeOpts *RevokeOptions) error
610610
}
611611

612612
// If not mTLS nor ACME, then get the TokenID of the token.
613-
if !(revokeOpts.MTLS || revokeOpts.ACME) {
613+
if !revokeOpts.MTLS && !revokeOpts.ACME {
614614
token, err := jose.ParseSigned(revokeOpts.OTT)
615615
if err != nil {
616616
return errs.Wrap(http.StatusUnauthorized, err, "authority.Revoke; error parsing token", opts...)

ca/acmeClient_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ func TestNewACMEClient(t *testing.T) {
112112
i := 0
113113
srv.Config.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
114114
assert.Equals(t, "step-http-client/1.0", r.Header.Get("User-Agent")) // check default User-Agent header
115-
switch {
116-
case i == 0:
115+
switch i {
116+
case 0:
117117
render.JSONStatus(w, r, tc.r1, tc.rc1)
118118
i++
119-
case i == 1:
119+
case 1:
120120
w.Header().Set("Replay-Nonce", "abc123")
121121
render.JSONStatus(w, r, []byte{}, 200)
122122
i++

cas/stepcas/issuer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ func validateX5CIssuer(iss *apiv1.CertificateIssuer) error {
9191
// not given, then it will download it from the CA. If the password is not set
9292
// it will be prompted.
9393
func validateJWKIssuer(iss *apiv1.CertificateIssuer) error {
94-
switch {
95-
case iss.Provisioner == "":
94+
switch iss.Provisioner {
95+
case "":
9696
return errors.New("stepCAS `certificateIssuer.provisioner` cannot be empty")
9797
default:
9898
return nil

cas/stepcas/stepcas_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,13 @@ func testCAHelper(t *testing.T) (*url.URL, *ca.Client) {
130130
_ = json.NewDecoder(r.Body).Decode(v)
131131
}
132132
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
133-
switch {
134-
case r.RequestURI == "/root/"+testRootFingerprint:
133+
switch r.RequestURI {
134+
case "/root/" + testRootFingerprint:
135135
w.WriteHeader(http.StatusOK)
136136
writeJSON(w, api.RootResponse{
137137
RootPEM: api.NewCertificate(testRootCrt),
138138
})
139-
case r.RequestURI == "/sign":
139+
case "/sign":
140140
var msg api.SignRequest
141141
parseJSON(r, &msg)
142142
if msg.CsrPEM.DNSNames[0] == "fail.doe.org" {
@@ -148,7 +148,7 @@ func testCAHelper(t *testing.T) (*url.URL, *ca.Client) {
148148
writeJSON(w, api.SignResponse{
149149
CertChainPEM: []api.Certificate{api.NewCertificate(testCrt), api.NewCertificate(testIssCrt)},
150150
})
151-
case r.RequestURI == "/renew":
151+
case "/renew":
152152
if r.Header.Get("Authorization") == "Bearer fail" {
153153
w.WriteHeader(http.StatusBadRequest)
154154
fmt.Fprintf(w, `{"error":"fail","message":"fail"}`)
@@ -158,7 +158,7 @@ func testCAHelper(t *testing.T) (*url.URL, *ca.Client) {
158158
writeJSON(w, api.SignResponse{
159159
CertChainPEM: []api.Certificate{api.NewCertificate(testCrt), api.NewCertificate(testIssCrt)},
160160
})
161-
case r.RequestURI == "/revoke":
161+
case "/revoke":
162162
var msg api.RevokeRequest
163163
parseJSON(r, &msg)
164164
if msg.Serial == "fail" {
@@ -170,7 +170,7 @@ func testCAHelper(t *testing.T) (*url.URL, *ca.Client) {
170170
writeJSON(w, api.RevokeResponse{
171171
Status: "ok",
172172
})
173-
case r.RequestURI == "/provisioners":
173+
case "/provisioners":
174174
w.WriteHeader(http.StatusOK)
175175
writeJSON(w, api.ProvisionersResponse{
176176
NextCursor: "cursor",
@@ -188,7 +188,7 @@ func testCAHelper(t *testing.T) (*url.URL, *ca.Client) {
188188
},
189189
},
190190
})
191-
case r.RequestURI == "/provisioners?cursor=cursor":
191+
case "/provisioners?cursor=cursor":
192192
w.WriteHeader(http.StatusOK)
193193
writeJSON(w, api.ProvisionersResponse{})
194194
default:

cas/vaultcas/auth/approle/approle_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ func testCAHelper(t *testing.T) (*url.URL, *vault.Client) {
1616
t.Helper()
1717

1818
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
19-
switch {
20-
case r.RequestURI == "/v1/auth/approle/login":
19+
switch r.RequestURI {
20+
case "/v1/auth/approle/login":
2121
w.WriteHeader(http.StatusOK)
2222
fmt.Fprintf(w, `{
2323
"auth": {
2424
"client_token": "hvs.0000"
2525
}
2626
}`)
27-
case r.RequestURI == "/v1/auth/custom-approle/login":
27+
case "/v1/auth/custom-approle/login":
2828
w.WriteHeader(http.StatusOK)
2929
fmt.Fprintf(w, `{
3030
"auth": {

cas/vaultcas/auth/aws/aws_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ func testCAHelper(t *testing.T) (*url.URL, *vault.Client) {
1616
t.Helper()
1717

1818
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
19-
switch {
20-
case r.RequestURI == "/v1/auth/aws/login":
19+
switch r.RequestURI {
20+
case "/v1/auth/aws/login":
2121
w.WriteHeader(http.StatusOK)
2222
fmt.Fprintf(w, `{
2323
"auth": {
2424
"client_token": "hvs.0000"
2525
}
2626
}`)
27-
case r.RequestURI == "/v1/auth/custom-aws/login":
27+
case "/v1/auth/custom-aws/login":
2828
w.WriteHeader(http.StatusOK)
2929
fmt.Fprintf(w, `{
3030
"auth": {

0 commit comments

Comments
 (0)