Merge pull request #186 from letsencrypt/formatting_script
Enforce `go fmt` is clean in the test run.
This commit is contained in:
commit
7c7aa9feb4
|
|
@ -7,16 +7,16 @@ package ca
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/x509"
|
||||
"crypto"
|
||||
"crypto/x509"
|
||||
"encoding/asn1"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
"os"
|
||||
|
||||
apisign "github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/cloudflare/cfssl/api/sign"
|
||||
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/cloudflare/cfssl/auth"
|
||||
|
|
@ -260,7 +260,6 @@ func TestMain(m *testing.M) {
|
|||
caCertPEM, _ := ioutil.ReadFile(caCertFile)
|
||||
caCert, _ := helpers.ParseCertificatePEM(caCertPEM)
|
||||
|
||||
|
||||
// Create an online CFSSL instance
|
||||
// This is designed to mimic what LE plans to do
|
||||
authHandler, _ := auth.New(authKey, nil)
|
||||
|
|
@ -330,7 +329,6 @@ func setup(t *testing.T) (cadb core.CertificateAuthorityDatabase, storageAuthori
|
|||
ssa.InitTables()
|
||||
storageAuthority = ssa
|
||||
|
||||
|
||||
cadb, _ = NewMockCertificateAuthorityDatabase()
|
||||
|
||||
// Create a CA
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@ import (
|
|||
_ "github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/cloudflare/cfssl/cmd/cfssl"
|
||||
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/codegangsta/cli"
|
||||
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/streadway/amqp"
|
||||
"github.com/letsencrypt/boulder/ca"
|
||||
blog "github.com/letsencrypt/boulder/log"
|
||||
"github.com/letsencrypt/boulder/rpc"
|
||||
"github.com/letsencrypt/boulder/ca"
|
||||
)
|
||||
|
||||
// Config stores configuration parameters that applications
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"crypto/x509"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
jose "github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/square/go-jose"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
|
@ -288,7 +288,7 @@ type Authorization struct {
|
|||
|
||||
// Fields of this type get encoded and decoded JOSE-style, in base64url encoding
|
||||
// with stripped padding.
|
||||
type JsonBuffer []byte;
|
||||
type JsonBuffer []byte
|
||||
|
||||
// Url-safe base64 encode that strips padding
|
||||
func base64URLEncode(data []byte) string {
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
blog "github.com/letsencrypt/boulder/log"
|
||||
jose "github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/square/go-jose"
|
||||
blog "github.com/letsencrypt/boulder/log"
|
||||
"hash"
|
||||
"io"
|
||||
"math/big"
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"fmt"
|
||||
"github.com/letsencrypt/boulder/test"
|
||||
"math"
|
||||
"math/big"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// challenges.go
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/letsencrypt/boulder/core"
|
||||
jose "github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/square/go-jose"
|
||||
"github.com/letsencrypt/boulder/core"
|
||||
blog "github.com/letsencrypt/boulder/log"
|
||||
"github.com/letsencrypt/boulder/policy"
|
||||
)
|
||||
|
|
@ -216,7 +216,6 @@ func (ra *RegistrationAuthorityImpl) NewCertificate(req core.CertificateRequest,
|
|||
}
|
||||
logEvent.VerificationMethods = verificationMethods
|
||||
|
||||
|
||||
// Validate that authorization key is authorized for all domains
|
||||
names := csr.DNSNames
|
||||
if len(csr.Subject.CommonName) > 0 {
|
||||
|
|
@ -283,7 +282,7 @@ func (ra *RegistrationAuthorityImpl) UpdateAuthorization(base core.Authorization
|
|||
|
||||
func (ra *RegistrationAuthorityImpl) RevokeCertificate(cert x509.Certificate) error {
|
||||
serialString := core.SerialToString(cert.SerialNumber)
|
||||
err := ra.CA.RevokeCertificate(serialString);
|
||||
err := ra.CA.RevokeCertificate(serialString)
|
||||
|
||||
// AUDIT[ Revocation Requests ] 4e85d791-09c0-4ab3-a837-d3d67e945134
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ import (
|
|||
|
||||
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/cloudflare/cfssl/signer/local"
|
||||
_ "github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/mattn/go-sqlite3"
|
||||
jose "github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/square/go-jose"
|
||||
"github.com/letsencrypt/boulder/ca"
|
||||
"github.com/letsencrypt/boulder/core"
|
||||
jose "github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/square/go-jose"
|
||||
"github.com/letsencrypt/boulder/policy"
|
||||
"github.com/letsencrypt/boulder/sa"
|
||||
"github.com/letsencrypt/boulder/test"
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
|
||||
jose "github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/square/go-jose"
|
||||
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/streadway/amqp"
|
||||
"github.com/letsencrypt/boulder/core"
|
||||
jose "github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/square/go-jose"
|
||||
blog "github.com/letsencrypt/boulder/log"
|
||||
)
|
||||
|
||||
|
|
@ -88,7 +88,6 @@ func errorCondition(method string, err error, obj interface{}) {
|
|||
log.Audit(fmt.Sprintf("Error condition. method: %s err: %s data: %+v", method, err, obj))
|
||||
}
|
||||
|
||||
|
||||
func NewRegistrationAuthorityServer(serverQueue string, channel *amqp.Channel, impl core.RegistrationAuthority) (*AmqpRPCServer, error) {
|
||||
log := blog.GetAuditLogger()
|
||||
rpc := NewAmqpRPCServer(serverQueue, channel)
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ import (
|
|||
|
||||
gorp "github.com/letsencrypt/boulder/Godeps/_workspace/src/gopkg.in/gorp.v1"
|
||||
|
||||
"github.com/letsencrypt/boulder/core"
|
||||
jose "github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/square/go-jose"
|
||||
"github.com/letsencrypt/boulder/core"
|
||||
blog "github.com/letsencrypt/boulder/log"
|
||||
)
|
||||
|
||||
|
|
@ -293,19 +293,19 @@ func statusIsPending(status core.AcmeStatus) bool {
|
|||
return status == core.StatusPending || status == core.StatusProcessing || status == core.StatusUnknown
|
||||
}
|
||||
|
||||
func existingPending(tx *gorp.Transaction, id string) (bool) {
|
||||
func existingPending(tx *gorp.Transaction, id string) bool {
|
||||
var count int64
|
||||
_ = tx.SelectOne(&count, "SELECT count(*) FROM pending_authz WHERE id = :id", map[string]interface{}{"id": id})
|
||||
return count > 0
|
||||
}
|
||||
|
||||
func existingFinal(tx *gorp.Transaction, id string) (bool) {
|
||||
func existingFinal(tx *gorp.Transaction, id string) bool {
|
||||
var count int64
|
||||
_ = tx.SelectOne(&count, "SELECT count(*) FROM authz WHERE id = :id", map[string]interface{}{"id": id})
|
||||
return count > 0
|
||||
}
|
||||
|
||||
func existingRegistration(tx *gorp.Transaction, id int64) (bool) {
|
||||
func existingRegistration(tx *gorp.Transaction, id int64) bool {
|
||||
var count int64
|
||||
_ = tx.SelectOne(&count, "SELECT count(*) FROM registrations WHERE id = :id", map[string]interface{}{"id": id})
|
||||
return count > 0
|
||||
|
|
@ -717,4 +717,3 @@ func (ssa *SQLStorageAuthority) AlreadyDeniedCSR(names []string) (already bool,
|
|||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,24 +6,24 @@
|
|||
package sa
|
||||
|
||||
import (
|
||||
"crypto/x509"
|
||||
"crypto/x509/pkix"
|
||||
"crypto/rand"
|
||||
"crypto/rsa"
|
||||
"crypto/x509"
|
||||
"crypto/x509/pkix"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
_ "github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/mattn/go-sqlite3"
|
||||
"github.com/letsencrypt/boulder/core"
|
||||
jose "github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/square/go-jose"
|
||||
"github.com/letsencrypt/boulder/core"
|
||||
"github.com/letsencrypt/boulder/test"
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func initSA(t *testing.T) (*SQLStorageAuthority) {
|
||||
func initSA(t *testing.T) *SQLStorageAuthority {
|
||||
sa, err := NewSQLStorageAuthority("sqlite3", ":memory:")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create SA")
|
||||
|
|
@ -109,7 +109,6 @@ func TestAddAuthorization(t *testing.T) {
|
|||
combos := make([][]int, 1)
|
||||
combos[0] = []int{0, 1}
|
||||
|
||||
|
||||
newPa := core.Authorization{ID: paID, Identifier: core.AcmeIdentifier{Type: core.IdentifierDNS, Value: "wut.com"}, RegistrationID: 0, Status: core.StatusPending, Expires: time.Now().AddDate(0, 0, 1), Challenges: []core.Challenge{chall}, Combinations: combos, Contact: []core.AcmeURL{u}}
|
||||
err = sa.UpdatePendingAuthorization(newPa)
|
||||
test.AssertNotError(t, err, "Couldn't update pending authorization with ID "+paID)
|
||||
|
|
|
|||
11
test.sh
11
test.sh
|
|
@ -63,4 +63,15 @@ else
|
|||
run go test ${dirlist}
|
||||
fi
|
||||
|
||||
echo "Checking for unformatted files:"
|
||||
unformatted=$(find . -name "*.go" -not -path "./Godeps/*" -print | xargs -n1 gofmt -l)
|
||||
if [ "x${unformatted}" != "x" ] ; then
|
||||
echo "Unformatted files found; setting failure state."
|
||||
echo "Please run 'go fmt' on each of these files and amend your commit to continue."
|
||||
FAILURE=1
|
||||
for f in ${unformatted}; do
|
||||
echo "- ${f}"
|
||||
done
|
||||
fi
|
||||
|
||||
exit ${FAILURE}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ func NewValidationAuthorityImpl(tm bool) ValidationAuthorityImpl {
|
|||
|
||||
// Validation methods
|
||||
|
||||
func (va ValidationAuthorityImpl) validateSimpleHTTPS(identifier core.AcmeIdentifier, input core.Challenge) (core.Challenge) {
|
||||
func (va ValidationAuthorityImpl) validateSimpleHTTPS(identifier core.AcmeIdentifier, input core.Challenge) core.Challenge {
|
||||
challenge := input
|
||||
|
||||
if len(challenge.Path) == 0 {
|
||||
|
|
@ -105,7 +105,7 @@ func (va ValidationAuthorityImpl) validateSimpleHTTPS(identifier core.AcmeIdenti
|
|||
return challenge
|
||||
}
|
||||
|
||||
func (va ValidationAuthorityImpl) validateDvsni(identifier core.AcmeIdentifier, input core.Challenge) (core.Challenge) {
|
||||
func (va ValidationAuthorityImpl) validateDvsni(identifier core.AcmeIdentifier, input core.Challenge) core.Challenge {
|
||||
challenge := input
|
||||
|
||||
if identifier.Type != "dns" {
|
||||
|
|
|
|||
|
|
@ -6,24 +6,24 @@
|
|||
package va
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"net"
|
||||
"net/http"
|
||||
"fmt"
|
||||
"strings"
|
||||
"math/big"
|
||||
"crypto/rand"
|
||||
"crypto/rsa"
|
||||
"crypto/sha256"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"crypto/x509/pkix"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"net"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
jose "github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/square/go-jose"
|
||||
"github.com/letsencrypt/boulder/core"
|
||||
"github.com/letsencrypt/boulder/test"
|
||||
jose "github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/square/go-jose"
|
||||
)
|
||||
|
||||
func bigIntFromB64(b64 string) *big.Int {
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
package wfe
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"bytes"
|
||||
"crypto/x509"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
|
@ -219,7 +219,7 @@ func (wfe *WebFrontEndImpl) sendError(response http.ResponseWriter, details stri
|
|||
problemDoc = []byte("{\"detail\": \"Problem marshalling error message.\"}")
|
||||
}
|
||||
|
||||
switch(problem.Type) {
|
||||
switch problem.Type {
|
||||
case ServerInternalProblem:
|
||||
// AUDIT[ Error Conditions ] 9cc4d537-8534-4970-8665-4b382abe82f3
|
||||
wfe.log.Audit(fmt.Sprintf("Internal error - %s - %s", details, debug))
|
||||
|
|
@ -305,7 +305,6 @@ func (wfe *WebFrontEndImpl) NewAuthorization(response http.ResponseWriter, reque
|
|||
return
|
||||
}
|
||||
|
||||
|
||||
var init core.Authorization
|
||||
if err = json.Unmarshal(body, &init); err != nil {
|
||||
wfe.sendError(response, "Error unmarshaling JSON", err, http.StatusBadRequest)
|
||||
|
|
@ -433,7 +432,6 @@ func (wfe *WebFrontEndImpl) NewCertificate(response http.ResponseWriter, request
|
|||
return
|
||||
}
|
||||
|
||||
|
||||
var init core.CertificateRequest
|
||||
if err = json.Unmarshal(body, &init); err != nil {
|
||||
fmt.Println(err)
|
||||
|
|
@ -512,7 +510,6 @@ func (wfe *WebFrontEndImpl) Challenge(authz core.Authorization, response http.Re
|
|||
return
|
||||
}
|
||||
|
||||
|
||||
var challengeResponse core.Challenge
|
||||
if err = json.Unmarshal(body, &challengeResponse); err != nil {
|
||||
wfe.sendError(response, "Error unmarshaling authorization", err, http.StatusBadRequest)
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ import (
|
|||
|
||||
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/cactus/go-statsd-client/statsd"
|
||||
|
||||
"github.com/letsencrypt/boulder/core"
|
||||
jose "github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/square/go-jose"
|
||||
"github.com/letsencrypt/boulder/core"
|
||||
|
||||
"github.com/letsencrypt/boulder/ra"
|
||||
"github.com/letsencrypt/boulder/test"
|
||||
|
|
@ -78,11 +78,11 @@ eROL1ve1vmQF3kjrMPhhK2kr6qdWnTE5XlPllVSZFQenSTzj98AO
|
|||
)
|
||||
|
||||
func (sa *MockSA) GetRegistration(id int64) (core.Registration, error) {
|
||||
if (id == 100) {
|
||||
if id == 100 {
|
||||
// Tag meaning "Missing"
|
||||
return core.Registration{}, errors.New("missing")
|
||||
}
|
||||
if (id == 101) {
|
||||
if id == 101 {
|
||||
// Tag meaning "Malformed"
|
||||
return core.Registration{}, nil
|
||||
}
|
||||
|
|
@ -100,11 +100,11 @@ func (sa *MockSA) GetRegistrationByKey(jwk jose.JsonWebKey) (core.Registration,
|
|||
test1KeyPublic.UnmarshalJSON([]byte(test1KeyPublicJSON))
|
||||
test2KeyPublic.UnmarshalJSON([]byte(test2KeyPublicJSON))
|
||||
|
||||
if (core.KeyDigestEquals(jwk, test1KeyPublic)) {
|
||||
if core.KeyDigestEquals(jwk, test1KeyPublic) {
|
||||
return core.Registration{Key: jwk}, nil
|
||||
}
|
||||
|
||||
if (core.KeyDigestEquals(jwk, test2KeyPublic)) {
|
||||
if core.KeyDigestEquals(jwk, test2KeyPublic) {
|
||||
// No key found
|
||||
return core.Registration{}, sql.ErrNoRows
|
||||
}
|
||||
|
|
@ -570,7 +570,6 @@ func TestAuthorization(t *testing.T) {
|
|||
responseWriter.Body.String(),
|
||||
"{\"type\":\"urn:acme:error:malformed\",\"detail\":\"Unable to read/verify body\"}")
|
||||
|
||||
|
||||
responseWriter.Body.Reset()
|
||||
wfe.NewAuthorization(responseWriter, &http.Request{
|
||||
Method: "POST",
|
||||
|
|
|
|||
Loading…
Reference in New Issue