forked from TrueCloudLab/certificates
wip
This commit is contained in:
parent
81093c3080
commit
fe7973c060
14 changed files with 19 additions and 45 deletions
|
@ -49,6 +49,8 @@ linters:
|
|||
- misspell
|
||||
- ineffassign
|
||||
- deadcode
|
||||
- staticcheck
|
||||
- unused
|
||||
|
||||
run:
|
||||
skip-dirs:
|
||||
|
@ -60,10 +62,9 @@ issues:
|
|||
- declaration of "err" shadows declaration at line
|
||||
- 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
|
||||
- declaration of "authz" shadows declaration at line
|
||||
# golangci.com configuration
|
||||
# https://github.com/golangci/golangci/wiki/Configuration
|
||||
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:
|
||||
- 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
|
||||
// before returning.
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
if accID != authz.getAccountID() {
|
||||
if accID != az.getAccountID() {
|
||||
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 {
|
||||
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.
|
||||
|
|
|
@ -195,13 +195,6 @@ func (ba *baseAuthz) clone() *baseAuthz {
|
|||
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 {
|
||||
return &dnsAuthz{ba}
|
||||
}
|
||||
|
|
|
@ -16,9 +16,6 @@ func TestDirectoryGetLink(t *testing.T) {
|
|||
prov := newProv()
|
||||
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, false), fmt.Sprintf("/%s/new-nonce", provID))
|
||||
|
||||
|
|
|
@ -74,7 +74,6 @@ func Test_caHandler_Revoke(t *testing.T) {
|
|||
input string
|
||||
auth Authority
|
||||
tls *tls.ConnectionState
|
||||
err error
|
||||
statusCode int
|
||||
expected []byte
|
||||
}
|
||||
|
|
|
@ -260,13 +260,6 @@ func Test_caHandler_SignSSH(t *testing.T) {
|
|||
})
|
||||
assert.FatalError(t, err)
|
||||
|
||||
type fields struct {
|
||||
Authority Authority
|
||||
}
|
||||
type args struct {
|
||||
w http.ResponseWriter
|
||||
r *http.Request
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
req []byte
|
||||
|
|
|
@ -26,7 +26,6 @@ type Authority struct {
|
|||
intermediateIdentity *x509util.Identity
|
||||
sshCAUserCertSignKey crypto.Signer
|
||||
sshCAHostCertSignKey crypto.Signer
|
||||
validateOnce bool
|
||||
certificates *sync.Map
|
||||
startTime time.Time
|
||||
provisioners *provisioner.Collection
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
type MockAuthDB struct {
|
||||
err error
|
||||
ret1, ret2 interface{}
|
||||
ret1 interface{}
|
||||
init func(*db.Config) (db.AuthDB, error)
|
||||
isRevoked func(string) (bool, error)
|
||||
revoke func(rci *db.RevokedCertificateInfo) error
|
||||
|
|
|
@ -248,10 +248,6 @@ func TestTimeDuration_Unix(t *testing.T) {
|
|||
func TestTimeDuration_String(t *testing.T) {
|
||||
tm, fn := mockNow()
|
||||
defer fn()
|
||||
type fields struct {
|
||||
t time.Time
|
||||
d time.Duration
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
timeDuration *TimeDuration
|
||||
|
|
|
@ -212,7 +212,6 @@ type RevokeOptions struct {
|
|||
MTLS bool
|
||||
Crt *x509.Certificate
|
||||
OTT string
|
||||
errCtxt map[string]interface{}
|
||||
}
|
||||
|
||||
// Revoke revokes a certificate.
|
||||
|
|
|
@ -22,7 +22,6 @@ import (
|
|||
|
||||
func TestNewACMEClient(t *testing.T) {
|
||||
type test struct {
|
||||
endpoint string
|
||||
ops []ClientOption
|
||||
r1, r2 interface{}
|
||||
rc1, rc2 int
|
||||
|
@ -357,8 +356,6 @@ func TestACMEClient_post(t *testing.T) {
|
|||
|
||||
func TestACMEClient_NewOrder(t *testing.T) {
|
||||
type test struct {
|
||||
payload []byte
|
||||
jwk *jose.JSONWebKey
|
||||
ops []withHeaderOption
|
||||
r1, r2 interface{}
|
||||
rc1, rc2 int
|
||||
|
|
|
@ -570,8 +570,8 @@ func TestBootstrapListener(t *testing.T) {
|
|||
return
|
||||
}
|
||||
wg := new(sync.WaitGroup)
|
||||
go func() {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
http.Serve(lis, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("ok"))
|
||||
}))
|
||||
|
|
1
ca/ca.go
1
ca/ca.go
|
@ -64,7 +64,6 @@ func WithDatabase(db db.AuthDB) Option {
|
|||
// the HTTP server, set ups the middlewares and the HTTP handlers.
|
||||
type CA struct {
|
||||
auth *authority.Authority
|
||||
acmeAuth *acme.Authority
|
||||
config *authority.Config
|
||||
srv *server.Server
|
||||
opts *options
|
||||
|
|
|
@ -2,6 +2,7 @@ package logging
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"net"
|
||||
"net/http"
|
||||
)
|
||||
|
@ -30,7 +31,7 @@ func NewResponseLogger(w http.ResponseWriter) ResponseLogger {
|
|||
|
||||
func wrapLogger(w http.ResponseWriter) (rw ResponseLogger) {
|
||||
rw = &rwDefault{w, 200, 0, nil}
|
||||
if c, ok := w.(http.CloseNotifier); ok {
|
||||
if c, ok := w.(context.Context); ok {
|
||||
rw = &rwCloseNotifier{rw, c}
|
||||
}
|
||||
if f, ok := w.(http.Flusher); ok {
|
||||
|
@ -90,11 +91,11 @@ func (r *rwDefault) WithFields(fields map[string]interface{}) {
|
|||
|
||||
type rwCloseNotifier struct {
|
||||
ResponseLogger
|
||||
c http.CloseNotifier
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
func (r *rwCloseNotifier) CloseNotify() <-chan bool {
|
||||
return r.CloseNotify()
|
||||
func (r *rwCloseNotifier) Done() <-chan struct{} {
|
||||
return r.Done()
|
||||
}
|
||||
|
||||
type rwFlusher struct {
|
||||
|
|
Loading…
Reference in a new issue