Skip to content

Commit

Permalink
run gofmt -w -s
Browse files Browse the repository at this point in the history
Signed-off-by: Jessica Frazelle <acidburn@docker.com>
  • Loading branch information
jessfraz committed Feb 12, 2016
1 parent 3f3fa68 commit 29ae6fd
Show file tree
Hide file tree
Showing 24 changed files with 62 additions and 63 deletions.
8 changes: 4 additions & 4 deletions api/api_test.go
Expand Up @@ -16,8 +16,8 @@ const (

func simpleHandle(w http.ResponseWriter, r *http.Request) error {
_, _, err := ProcessRequestOneOf(r, [][]string{
[]string{"compliment"},
[]string{"critique"},
{"compliment"},
{"critique"},
})
if err != nil {
return err
Expand All @@ -29,8 +29,8 @@ func simpleHandle(w http.ResponseWriter, r *http.Request) error {

func cleverHandle(w http.ResponseWriter, r *http.Request) error {
_, matched, err := ProcessRequestFirstMatchOf(r, [][]string{
[]string{"compliment"},
[]string{"critique"},
{"compliment"},
{"critique"},
})
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions api/bundle/bundle.go
Expand Up @@ -35,8 +35,8 @@ func NewHandler(caBundleFile, intBundleFile string) (http.Handler, error) {
func (h *Handler) Handle(w http.ResponseWriter, r *http.Request) error {
blob, matched, err := api.ProcessRequestFirstMatchOf(r,
[][]string{
[]string{"certificate"},
[]string{"domain"},
{"certificate"},
{"domain"},
})
if err != nil {
log.Warningf("invalid request: %v", err)
Expand Down
4 changes: 2 additions & 2 deletions api/certinfo/certinfo.go
Expand Up @@ -24,8 +24,8 @@ func NewHandler() http.Handler {
func (h *Handler) Handle(w http.ResponseWriter, r *http.Request) (err error) {
blob, matched, err := api.ProcessRequestFirstMatchOf(r,
[][]string{
[]string{"certificate"},
[]string{"domain"},
{"certificate"},
{"domain"},
})
if err != nil {
log.Warningf("invalid request: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion api/client/client_test.go
Expand Up @@ -71,7 +71,7 @@ func TestDefaultAuthSign(t *testing.T) {
s := NewAuthServer(".X", testProvider)
testRequest := []byte(`testing 1 2 3`)
as, err := s.Sign(testRequest)
if as != nil || err == nil{
if as != nil || err == nil {
t.Fatal("expected error with auth sign function")
}
}
Expand Down
2 changes: 1 addition & 1 deletion api/generator/generator_test.go
Expand Up @@ -100,7 +100,7 @@ func TestNewCertGeneratorHandlerFromSigner(t *testing.T) {
var CAConfig = &config.Config{
Signing: &config.Signing{
Profiles: map[string]*config.SigningProfile{
"signature": &config.SigningProfile{
"signature": {
Usage: []string{"digital signature"},
Expiry: expiry,
},
Expand Down
2 changes: 1 addition & 1 deletion bundler/bundler.go
Expand Up @@ -478,7 +478,7 @@ func (b *Bundler) fetchIntermediates(certs []*x509.Certificate) (err error) {
name = constructCertFileName(cert)
}

chain = append([]*fetchedIntermediate{&fetchedIntermediate{cert, name}}, chain...)
chain = append([]*fetchedIntermediate{{cert, name}}, chain...)
seen[string(cert.Signature)] = true
}

Expand Down
2 changes: 1 addition & 1 deletion bundler/bundler_test.go
Expand Up @@ -300,7 +300,7 @@ func TestRebundleExpiring(t *testing.T) {
expiry := 1 * time.Hour
policy := &config.Signing{
Profiles: map[string]*config.SigningProfile{
"expireIn1Hour": &config.SigningProfile{
"expireIn1Hour": {
Usage: []string{"cert sign"},
Expiry: expiry,
CA: true,
Expand Down
2 changes: 1 addition & 1 deletion cli/ocspdump/ocspdump.go
Expand Up @@ -6,8 +6,8 @@ import (
"errors"
"fmt"

"github.com/cloudflare/cfssl/certdb/sql"
"github.com/cloudflare/cfssl/certdb/dbconf"
"github.com/cloudflare/cfssl/certdb/sql"
"github.com/cloudflare/cfssl/cli"
)

Expand Down
2 changes: 1 addition & 1 deletion cli/ocsprefresh/ocsprefresh.go
Expand Up @@ -5,8 +5,8 @@ import (
"errors"
"time"

"github.com/cloudflare/cfssl/certdb/sql"
"github.com/cloudflare/cfssl/certdb/dbconf"
"github.com/cloudflare/cfssl/certdb/sql"
"github.com/cloudflare/cfssl/cli"
"github.com/cloudflare/cfssl/helpers"
"github.com/cloudflare/cfssl/log"
Expand Down
2 changes: 1 addition & 1 deletion cli/revoke/revoke.go
Expand Up @@ -4,8 +4,8 @@ package revoke
import (
"errors"

"github.com/cloudflare/cfssl/certdb/sql"
"github.com/cloudflare/cfssl/certdb/dbconf"
"github.com/cloudflare/cfssl/certdb/sql"
"github.com/cloudflare/cfssl/cli"
"github.com/cloudflare/cfssl/log"
"github.com/cloudflare/cfssl/ocsp"
Expand Down
4 changes: 2 additions & 2 deletions crl/crl.go
Expand Up @@ -56,10 +56,10 @@ func NewCRLFromFile(serialList, issuerFile, keyFile []byte, expiryTime string) (
}
revokedCerts = append(revokedCerts, tempCert)
}

strPassword := os.Getenv("CFSSL_CA_PK_PASSWORD")
password := []byte(strPassword)
if (strPassword == "") {
if strPassword == "" {
password = nil
}

Expand Down
2 changes: 1 addition & 1 deletion helpers/helpers.go
Expand Up @@ -348,7 +348,7 @@ func GetKeyDERFromPEM(in []byte, password []byte) ([]byte, error) {
if keyDER != nil {
if procType, ok := keyDER.Headers["Proc-Type"]; ok {
if strings.Contains(procType, "ENCRYPTED") {
if (password != nil) {
if password != nil {
return x509.DecryptPEMBlock(keyDER, password)
}
return nil, cferr.New(cferr.PrivateKeyError, cferr.Encrypted)
Expand Down
4 changes: 2 additions & 2 deletions initca/initca_test.go
Expand Up @@ -180,11 +180,11 @@ var testValidations = []validation{
CN: "test CA",
}, true},
{&csr.CertificateRequest{
Names: []csr.Name{csr.Name{}},
Names: []csr.Name{{}},
}, false},
{&csr.CertificateRequest{
Names: []csr.Name{
csr.Name{O: "Example CA"},
{O: "Example CA"},
},
}, true},
}
Expand Down
10 changes: 5 additions & 5 deletions ocsp/config/config.go
Expand Up @@ -3,17 +3,17 @@
package config

import (
"time"
"github.com/cloudflare/cfssl/crypto/pkcs11key"
"time"
)

// Config contains configuration information required to set up an OCSP
// signer. If PKCS11.Module is non-empty, PKCS11 signing will be used.
// Otherwise signing from a key file will be used.
type Config struct {
CACertFile string
CACertFile string
ResponderCertFile string
KeyFile string
Interval time.Duration
PKCS11 pkcs11key.Config
KeyFile string
Interval time.Duration
PKCS11 pkcs11key.Config
}
2 changes: 1 addition & 1 deletion ocsp/pkcs11/pkcs11.go
Expand Up @@ -5,13 +5,13 @@
package pkcs11

import (
"io/ioutil"
"github.com/cloudflare/cfssl/crypto/pkcs11key"
"github.com/cloudflare/cfssl/errors"
"github.com/cloudflare/cfssl/helpers"
"github.com/cloudflare/cfssl/log"
"github.com/cloudflare/cfssl/ocsp"
ocspConfig "github.com/cloudflare/cfssl/ocsp/config"
"io/ioutil"
)

// Enabled is set to true if PKCS #11 support is present.
Expand Down
14 changes: 7 additions & 7 deletions ocsp/responder_test.go
Expand Up @@ -31,18 +31,18 @@ type testCase struct {

func TestOCSP(t *testing.T) {
cases := []testCase{
testCase{"OPTIONS", "/", http.StatusMethodNotAllowed},
testCase{"GET", "/", http.StatusBadRequest},
{"OPTIONS", "/", http.StatusMethodNotAllowed},
{"GET", "/", http.StatusBadRequest},
// Bad URL encoding
testCase{"GET", "%ZZFQwUjBQME4wTDAJBgUrDgMCGgUABBQ55F6w46hhx%2Fo6OXOHa%2BYfe32YhgQU%2B3hPEvlgFYMsnxd%2FNBmzLjbqQYkCEwD6Wh0MaVKu9gJ3By9DI%2F%2Fxsd4%3D", http.StatusBadRequest},
{"GET", "%ZZFQwUjBQME4wTDAJBgUrDgMCGgUABBQ55F6w46hhx%2Fo6OXOHa%2BYfe32YhgQU%2B3hPEvlgFYMsnxd%2FNBmzLjbqQYkCEwD6Wh0MaVKu9gJ3By9DI%2F%2Fxsd4%3D", http.StatusBadRequest},
// Bad URL encoding
testCase{"GET", "%%FQwUjBQME4wTDAJBgUrDgMCGgUABBQ55F6w46hhx%2Fo6OXOHa%2BYfe32YhgQU%2B3hPEvlgFYMsnxd%2FNBmzLjbqQYkCEwD6Wh0MaVKu9gJ3By9DI%2F%2Fxsd4%3D", http.StatusBadRequest},
{"GET", "%%FQwUjBQME4wTDAJBgUrDgMCGgUABBQ55F6w46hhx%2Fo6OXOHa%2BYfe32YhgQU%2B3hPEvlgFYMsnxd%2FNBmzLjbqQYkCEwD6Wh0MaVKu9gJ3By9DI%2F%2Fxsd4%3D", http.StatusBadRequest},
// Bad base64 encoding
testCase{"GET", "==MFQwUjBQME4wTDAJBgUrDgMCGgUABBQ55F6w46hhx%2Fo6OXOHa%2BYfe32YhgQU%2B3hPEvlgFYMsnxd%2FNBmzLjbqQYkCEwD6Wh0MaVKu9gJ3By9DI%2F%2Fxsd4%3D", http.StatusBadRequest},
{"GET", "==MFQwUjBQME4wTDAJBgUrDgMCGgUABBQ55F6w46hhx%2Fo6OXOHa%2BYfe32YhgQU%2B3hPEvlgFYMsnxd%2FNBmzLjbqQYkCEwD6Wh0MaVKu9gJ3By9DI%2F%2Fxsd4%3D", http.StatusBadRequest},
// Bad OCSP DER encoding
testCase{"GET", "AAAMFQwUjBQME4wTDAJBgUrDgMCGgUABBQ55F6w46hhx%2Fo6OXOHa%2BYfe32YhgQU%2B3hPEvlgFYMsnxd%2FNBmzLjbqQYkCEwD6Wh0MaVKu9gJ3By9DI%2F%2Fxsd4%3D", http.StatusBadRequest},
{"GET", "AAAMFQwUjBQME4wTDAJBgUrDgMCGgUABBQ55F6w46hhx%2Fo6OXOHa%2BYfe32YhgQU%2B3hPEvlgFYMsnxd%2FNBmzLjbqQYkCEwD6Wh0MaVKu9gJ3By9DI%2F%2Fxsd4%3D", http.StatusBadRequest},
// Good encoding all around, including a double slash
testCase{"GET", "MFQwUjBQME4wTDAJBgUrDgMCGgUABBQ55F6w46hhx%2Fo6OXOHa%2BYfe32YhgQU%2B3hPEvlgFYMsnxd%2FNBmzLjbqQYkCEwD6Wh0MaVKu9gJ3By9DI%2F%2Fxsd4%3D", http.StatusOK},
{"GET", "MFQwUjBQME4wTDAJBgUrDgMCGgUABBQ55F6w46hhx%2Fo6OXOHa%2BYfe32YhgQU%2B3hPEvlgFYMsnxd%2FNBmzLjbqQYkCEwD6Wh0MaVKu9gJ3By9DI%2F%2Fxsd4%3D", http.StatusOK},
}

responder := Responder{
Expand Down
1 change: 0 additions & 1 deletion ocsp/universal/universal.go
Expand Up @@ -14,4 +14,3 @@ func NewSignerFromConfig(cfg ocspConfig.Config) (ocsp.Signer, error) {
return ocsp.NewSignerFromFile(cfg.CACertFile, cfg.ResponderCertFile,
cfg.KeyFile, cfg.Interval)
}

2 changes: 1 addition & 1 deletion scan/tls_handshake.go
Expand Up @@ -306,7 +306,7 @@ func cipherSuiteScan(addr, hostname string) (grade Grade, output Output, err err
goto exists
}
}
cvList = append(cvList, cipherVersions{cipherID, []cipherDatum{cipherDatum{vers, supportedCurves}}})
cvList = append(cvList, cipherVersions{cipherID, []cipherDatum{{vers, supportedCurves}}})
exists:
ciphers = append(ciphers[:cipherIndex], ciphers[cipherIndex+1:]...)
}
Expand Down
20 changes: 10 additions & 10 deletions signer/local/local_test.go
Expand Up @@ -47,7 +47,7 @@ func TestNewSignerFromFilePolicy(t *testing.T) {
var CAConfig = &config.Config{
Signing: &config.Signing{
Profiles: map[string]*config.SigningProfile{
"signature": &config.SigningProfile{
"signature": {
Usage: []string{"digital signature"},
Expiry: expiry,
},
Expand All @@ -70,11 +70,11 @@ func TestNewSignerFromFileInvalidPolicy(t *testing.T) {
var invalidConfig = &config.Config{
Signing: &config.Signing{
Profiles: map[string]*config.SigningProfile{
"invalid": &config.SigningProfile{
"invalid": {
Usage: []string{"wiretapping"},
Expiry: expiry,
},
"empty": &config.SigningProfile{},
"empty": {},
},
Default: &config.SigningProfile{
Usage: []string{"digital signature"},
Expand All @@ -96,11 +96,11 @@ func TestNewSignerFromFileNoUsageInPolicy(t *testing.T) {
var invalidConfig = &config.Config{
Signing: &config.Signing{
Profiles: map[string]*config.SigningProfile{
"invalid": &config.SigningProfile{
"invalid": {
Usage: []string{},
Expiry: expiry,
},
"empty": &config.SigningProfile{},
"empty": {},
},
Default: &config.SigningProfile{
Usage: []string{"digital signature"},
Expand Down Expand Up @@ -642,8 +642,8 @@ func TestOverwriteHosts(t *testing.T) {

for _, hosts := range [][]string{
nil,
[]string{},
[]string{"127.0.0.1", "localhost", "xyz@example.com"},
{},
{"127.0.0.1", "localhost", "xyz@example.com"},
} {
request := signer.SignRequest{
Hosts: hosts,
Expand Down Expand Up @@ -914,7 +914,7 @@ func TestExtensionSign(t *testing.T) {
request := signer.SignRequest{
Request: string(csrPEM),
Extensions: []signer.Extension{
signer.Extension{ID: config.OID(asn1.ObjectIdentifier{1, 2, 3, 4})},
{ID: config.OID(asn1.ObjectIdentifier{1, 2, 3, 4})},
},
}

Expand All @@ -939,7 +939,7 @@ func TestExtensionSign(t *testing.T) {
request = signer.SignRequest{
Request: string(csrPEM),
Extensions: []signer.Extension{
signer.Extension{ID: config.OID(asn1.ObjectIdentifier{1, 2, 3, 5})},
{ID: config.OID(asn1.ObjectIdentifier{1, 2, 3, 5})},
},
}

Expand All @@ -955,7 +955,7 @@ func TestExtensionSign(t *testing.T) {
request = signer.SignRequest{
Request: string(csrPEM),
Extensions: []signer.Extension{
signer.Extension{
{
ID: config.OID(asn1.ObjectIdentifier{1, 2, 3, 4}),
Critical: false,
Value: extValueHex,
Expand Down
2 changes: 1 addition & 1 deletion signer/remote/remote_test.go
Expand Up @@ -230,7 +230,7 @@ func newHandler(t *testing.T, caFile, caKeyFile, op string) (http.Handler, error
var CAConfig = &config.Config{
Signing: &config.Signing{
Profiles: map[string]*config.SigningProfile{
"signature": &config.SigningProfile{
"signature": {
Usage: []string{"digital signature"},
Expiry: expiry,
},
Expand Down
8 changes: 4 additions & 4 deletions signer/signer_test.go
Expand Up @@ -50,7 +50,7 @@ func TestSplitHosts(t *testing.T) {
func TestAddPolicies(t *testing.T) {
var cert x509.Certificate
addPolicies(&cert, []config.CertificatePolicy{
config.CertificatePolicy{
{
ID: config.OID([]int{1, 2, 3, 4}),
},
})
Expand All @@ -75,14 +75,14 @@ func TestAddPolicies(t *testing.T) {
func TestAddPoliciesWithQualifiers(t *testing.T) {
var cert x509.Certificate
addPolicies(&cert, []config.CertificatePolicy{
config.CertificatePolicy{
{
ID: config.OID([]int{1, 2, 3, 4}),
Qualifiers: []config.CertificatePolicyQualifier{
config.CertificatePolicyQualifier{
{
Type: "id-qt-cps",
Value: "http://example.com/cps",
},
config.CertificatePolicyQualifier{
{
Type: "id-qt-unotice",
Value: "Do What Thou Wilt",
},
Expand Down
2 changes: 1 addition & 1 deletion transport/kp/key_provider_test.go
Expand Up @@ -18,7 +18,7 @@ var testIdentity = &core.Identity{
CN: "localhost test certificate",
},
Profiles: map[string]map[string]string{
"paths": map[string]string{
"paths": {
"private_key": testKey,
"certificate": testCert,
},
Expand Down
12 changes: 6 additions & 6 deletions transport/transport_test.go
Expand Up @@ -94,10 +94,10 @@ var (
CN: "localhost test certificate",
},
Roots: []*core.Root{
&core.Root{
{
Type: "system",
},
&core.Root{
{
Type: "cfssl",
Metadata: map[string]string{
"host": testRemote,
Expand All @@ -107,7 +107,7 @@ var (
},
},
Profiles: map[string]map[string]string{
"paths": map[string]string{
"paths": {
"private_key": testKey,
"certificate": testCert,
},
Expand Down Expand Up @@ -180,7 +180,7 @@ var (
Hosts: []string{"127.0.0.1"},
},
Profiles: map[string]map[string]string{
"paths": map[string]string{
"paths": {
"private_key": testLKey,
"certificate": testLCert,
},
Expand All @@ -191,10 +191,10 @@ var (
},
},
Roots: []*core.Root{
&core.Root{
{
Type: "system",
},
&core.Root{
{
Type: "cfssl",
Metadata: map[string]string{
"host": testRemote,
Expand Down

0 comments on commit 29ae6fd

Please sign in to comment.