pull/106/head
max furman 5 years ago
parent 81093c3080
commit fe7973c060

@ -49,6 +49,8 @@ linters:
- misspell - misspell
- ineffassign - ineffassign
- deadcode - deadcode
- staticcheck
- unused
run: run:
skip-dirs: skip-dirs:
@ -60,10 +62,9 @@ issues:
- declaration of "err" shadows declaration at line - declaration of "err" shadows declaration at line
- should have a package comment, unless it's in another file for this package - should have a package comment, unless it's in another file for this package
- error strings should not be capitalized or end with punctuation or a newline - error strings should not be capitalized or end with punctuation or a newline
- declaration of "authz" shadows declaration at line
# golangci.com configuration # golangci.com configuration
# https://github.com/golangci/golangci/wiki/Configuration # https://github.com/golangci/golangci/wiki/Configuration
service: service:
golangci-lint-version: 1.17.x # use the fixed version to not introduce new linters unexpectedly golangci-lint-version: 1.18.x # use the fixed version to not introduce new linters unexpectedly
prepare: prepare:
- echo "here I can run custom commands, but no preparation needed for this repo" - echo "here I can run custom commands, but no preparation needed for this repo"

@ -214,18 +214,18 @@ func (a *Authority) FinalizeOrder(p provisioner.Interface, accID, orderID string
// GetAuthz retrieves and attempts to update the status on an ACME authz // GetAuthz retrieves and attempts to update the status on an ACME authz
// before returning. // before returning.
func (a *Authority) GetAuthz(p provisioner.Interface, accID, authzID string) (*Authz, error) { func (a *Authority) GetAuthz(p provisioner.Interface, accID, authzID string) (*Authz, error) {
authz, err := getAuthz(a.db, authzID) az, err := getAuthz(a.db, authzID)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if accID != authz.getAccountID() { if accID != az.getAccountID() {
return nil, UnauthorizedErr(errors.New("account does not own authz")) return nil, UnauthorizedErr(errors.New("account does not own authz"))
} }
authz, err = authz.updateStatus(a.db) az, err = az.updateStatus(a.db)
if err != nil { if err != nil {
return nil, Wrap(err, "error updating authz status") return nil, Wrap(err, "error updating authz status")
} }
return authz.toACME(a.db, a.dir, p) return az.toACME(a.db, a.dir, p)
} }
// ValidateChallenge attempts to validate the challenge. // ValidateChallenge attempts to validate the challenge.

@ -195,13 +195,6 @@ func (ba *baseAuthz) clone() *baseAuthz {
return &u return &u
} }
func (ba *baseAuthz) storeAndReturnError(db nosql.DB, err *Error) error {
clone := ba.clone()
clone.Error = err
clone.save(db, ba)
return err
}
func (ba *baseAuthz) parent() authz { func (ba *baseAuthz) parent() authz {
return &dnsAuthz{ba} return &dnsAuthz{ba}
} }

@ -16,9 +16,6 @@ func TestDirectoryGetLink(t *testing.T) {
prov := newProv() prov := newProv()
provID := URLSafeProvisionerName(prov) provID := URLSafeProvisionerName(prov)
type newTest struct {
actual, expected string
}
assert.Equals(t, dir.getLink(NewNonceLink, provID, true), fmt.Sprintf("https://ca.smallstep.com/acme/%s/new-nonce", provID)) assert.Equals(t, dir.getLink(NewNonceLink, provID, true), fmt.Sprintf("https://ca.smallstep.com/acme/%s/new-nonce", provID))
assert.Equals(t, dir.getLink(NewNonceLink, provID, false), fmt.Sprintf("/%s/new-nonce", provID)) assert.Equals(t, dir.getLink(NewNonceLink, provID, false), fmt.Sprintf("/%s/new-nonce", provID))

@ -74,7 +74,6 @@ func Test_caHandler_Revoke(t *testing.T) {
input string input string
auth Authority auth Authority
tls *tls.ConnectionState tls *tls.ConnectionState
err error
statusCode int statusCode int
expected []byte expected []byte
} }

@ -260,13 +260,6 @@ func Test_caHandler_SignSSH(t *testing.T) {
}) })
assert.FatalError(t, err) assert.FatalError(t, err)
type fields struct {
Authority Authority
}
type args struct {
w http.ResponseWriter
r *http.Request
}
tests := []struct { tests := []struct {
name string name string
req []byte req []byte

@ -26,7 +26,6 @@ type Authority struct {
intermediateIdentity *x509util.Identity intermediateIdentity *x509util.Identity
sshCAUserCertSignKey crypto.Signer sshCAUserCertSignKey crypto.Signer
sshCAHostCertSignKey crypto.Signer sshCAHostCertSignKey crypto.Signer
validateOnce bool
certificates *sync.Map certificates *sync.Map
startTime time.Time startTime time.Time
provisioners *provisioner.Collection provisioners *provisioner.Collection

@ -8,7 +8,7 @@ import (
type MockAuthDB struct { type MockAuthDB struct {
err error err error
ret1, ret2 interface{} ret1 interface{}
init func(*db.Config) (db.AuthDB, error) init func(*db.Config) (db.AuthDB, error)
isRevoked func(string) (bool, error) isRevoked func(string) (bool, error)
revoke func(rci *db.RevokedCertificateInfo) error revoke func(rci *db.RevokedCertificateInfo) error

@ -248,10 +248,6 @@ func TestTimeDuration_Unix(t *testing.T) {
func TestTimeDuration_String(t *testing.T) { func TestTimeDuration_String(t *testing.T) {
tm, fn := mockNow() tm, fn := mockNow()
defer fn() defer fn()
type fields struct {
t time.Time
d time.Duration
}
tests := []struct { tests := []struct {
name string name string
timeDuration *TimeDuration timeDuration *TimeDuration

@ -212,7 +212,6 @@ type RevokeOptions struct {
MTLS bool MTLS bool
Crt *x509.Certificate Crt *x509.Certificate
OTT string OTT string
errCtxt map[string]interface{}
} }
// Revoke revokes a certificate. // Revoke revokes a certificate.

@ -22,7 +22,6 @@ import (
func TestNewACMEClient(t *testing.T) { func TestNewACMEClient(t *testing.T) {
type test struct { type test struct {
endpoint string
ops []ClientOption ops []ClientOption
r1, r2 interface{} r1, r2 interface{}
rc1, rc2 int rc1, rc2 int
@ -357,8 +356,6 @@ func TestACMEClient_post(t *testing.T) {
func TestACMEClient_NewOrder(t *testing.T) { func TestACMEClient_NewOrder(t *testing.T) {
type test struct { type test struct {
payload []byte
jwk *jose.JSONWebKey
ops []withHeaderOption ops []withHeaderOption
r1, r2 interface{} r1, r2 interface{}
rc1, rc2 int rc1, rc2 int

@ -570,8 +570,8 @@ func TestBootstrapListener(t *testing.T) {
return return
} }
wg := new(sync.WaitGroup) wg := new(sync.WaitGroup)
wg.Add(1)
go func() { go func() {
wg.Add(1)
http.Serve(lis, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { http.Serve(lis, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("ok")) w.Write([]byte("ok"))
})) }))

@ -63,12 +63,11 @@ func WithDatabase(db db.AuthDB) Option {
// CA is the type used to build the complete certificate authority. It builds // CA is the type used to build the complete certificate authority. It builds
// the HTTP server, set ups the middlewares and the HTTP handlers. // the HTTP server, set ups the middlewares and the HTTP handlers.
type CA struct { type CA struct {
auth *authority.Authority auth *authority.Authority
acmeAuth *acme.Authority config *authority.Config
config *authority.Config srv *server.Server
srv *server.Server opts *options
opts *options renewer *TLSRenewer
renewer *TLSRenewer
} }
// New creates and initializes the CA with the given configuration and options. // New creates and initializes the CA with the given configuration and options.

@ -2,6 +2,7 @@ package logging
import ( import (
"bufio" "bufio"
"context"
"net" "net"
"net/http" "net/http"
) )
@ -30,7 +31,7 @@ func NewResponseLogger(w http.ResponseWriter) ResponseLogger {
func wrapLogger(w http.ResponseWriter) (rw ResponseLogger) { func wrapLogger(w http.ResponseWriter) (rw ResponseLogger) {
rw = &rwDefault{w, 200, 0, nil} rw = &rwDefault{w, 200, 0, nil}
if c, ok := w.(http.CloseNotifier); ok { if c, ok := w.(context.Context); ok {
rw = &rwCloseNotifier{rw, c} rw = &rwCloseNotifier{rw, c}
} }
if f, ok := w.(http.Flusher); ok { if f, ok := w.(http.Flusher); ok {
@ -90,11 +91,11 @@ func (r *rwDefault) WithFields(fields map[string]interface{}) {
type rwCloseNotifier struct { type rwCloseNotifier struct {
ResponseLogger ResponseLogger
c http.CloseNotifier ctx context.Context
} }
func (r *rwCloseNotifier) CloseNotify() <-chan bool { func (r *rwCloseNotifier) Done() <-chan struct{} {
return r.CloseNotify() return r.Done()
} }
type rwFlusher struct { type rwFlusher struct {

Loading…
Cancel
Save