gofmt code with -s (simplify) flag (#4763)

Found by golangci-lint's `gofmt` linter.
This commit is contained in:
Jacob Hoffman-Andrews 2020-04-08 17:25:35 -07:00 committed by GitHub
parent aa9ec70ef7
commit 72deb5b798
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 99 additions and 99 deletions

View File

@ -1216,11 +1216,11 @@ func TestIssuePrecertificateLinting(t *testing.T) {
ca.defaultIssuer.eeSigner = &linttrapSigner{
lintErr: &local.LintError{
ErrorResults: map[string]lint.LintResult{
"foobar": lint.LintResult{
"foobar": {
Status: lint.Error,
Details: "foobar is error",
},
"foobar2": lint.LintResult{
"foobar2": {
Status: lint.Warn,
Details: "foobar2 is warning",
},

View File

@ -56,7 +56,7 @@ func TestLoadCertificateChains(t *testing.T) {
{
Name: "AIA Issuer without chain files",
Input: map[string][]string{
"http://break.the.chain.com": []string{},
"http://break.the.chain.com": {},
},
ExpectedError: fmt.Errorf(
"CertificateChain entry for AIA issuer url \"http://break.the.chain.com\" " +
@ -65,7 +65,7 @@ func TestLoadCertificateChains(t *testing.T) {
{
Name: "Missing chain file",
Input: map[string][]string{
"http://where.is.my.mind": []string{"/tmp/does.not.exist.pem"},
"http://where.is.my.mind": {"/tmp/does.not.exist.pem"},
},
ExpectedError: fmt.Errorf("CertificateChain entry for AIA issuer url \"http://where.is.my.mind\" " +
"has an invalid chain file: \"/tmp/does.not.exist.pem\" - error reading " +
@ -74,7 +74,7 @@ func TestLoadCertificateChains(t *testing.T) {
{
Name: "PEM chain file with Windows CRLF line endings",
Input: map[string][]string{
"http://windows.sad.zone": []string{crlfPEM.Name()},
"http://windows.sad.zone": {crlfPEM.Name()},
},
ExpectedError: fmt.Errorf("CertificateChain entry for AIA issuer url \"http://windows.sad.zone\" "+
"has an invalid chain file: %q - contents had CRLF line endings", crlfPEM.Name()),
@ -82,7 +82,7 @@ func TestLoadCertificateChains(t *testing.T) {
{
Name: "Invalid PEM chain file",
Input: map[string][]string{
"http://ok.go": []string{invalidPEMFile.Name()},
"http://ok.go": {invalidPEMFile.Name()},
},
ExpectedError: fmt.Errorf(
"CertificateChain entry for AIA issuer url \"http://ok.go\" has an "+
@ -92,7 +92,7 @@ func TestLoadCertificateChains(t *testing.T) {
{
Name: "PEM chain file that isn't a cert",
Input: map[string][]string{
"http://not-a-cert.com": []string{"../../test/test-root.key"},
"http://not-a-cert.com": {"../../test/test-root.key"},
},
ExpectedError: fmt.Errorf(
"CertificateChain entry for AIA issuer url \"http://not-a-cert.com\" has " +
@ -102,7 +102,7 @@ func TestLoadCertificateChains(t *testing.T) {
{
Name: "PEM chain file with leftover bytes",
Input: map[string][]string{
"http://tasty.leftovers.com": []string{leftoverPEMFile.Name()},
"http://tasty.leftovers.com": {leftoverPEMFile.Name()},
},
ExpectedError: fmt.Errorf(
"CertificateChain entry for AIA issuer url \"http://tasty.leftovers.com\" "+
@ -115,7 +115,7 @@ func TestLoadCertificateChains(t *testing.T) {
{
Name: "One PEM file chain",
Input: map[string][]string{
"http://single-cert-chain.com": []string{"../../test/test-ca.pem"},
"http://single-cert-chain.com": {"../../test/test-ca.pem"},
},
ExpectedMap: map[string][]byte{
"http://single-cert-chain.com": []byte(fmt.Sprintf("\n%s", string(certBytesA))),
@ -124,7 +124,7 @@ func TestLoadCertificateChains(t *testing.T) {
{
Name: "Two PEM file chain",
Input: map[string][]string{
"http://two-cert-chain.com": []string{"../../test/test-ca.pem", "../../test/test-ca2.pem"},
"http://two-cert-chain.com": {"../../test/test-ca.pem", "../../test/test-ca2.pem"},
},
ExpectedMap: map[string][]byte{
"http://two-cert-chain.com": []byte(fmt.Sprintf("\n%s\n%s", string(certBytesA), string(certBytesB))),
@ -133,7 +133,7 @@ func TestLoadCertificateChains(t *testing.T) {
{
Name: "One PEM file chain, no trailing newline",
Input: map[string][]string{
"http://single-cert-chain.nonewline.com": []string{abruptPEM.Name()},
"http://single-cert-chain.nonewline.com": {abruptPEM.Name()},
},
ExpectedMap: map[string][]byte{
// NOTE(@cpu): There should be a trailing \n added by the WFE that we
@ -145,7 +145,7 @@ func TestLoadCertificateChains(t *testing.T) {
Name: "Two PEM file chain, don't require at least one chain",
AllowEmptyChain: true,
Input: map[string][]string{
"http://two-cert-chain.com": []string{"../../test/test-ca.pem", "../../test/test-ca2.pem"},
"http://two-cert-chain.com": {"../../test/test-ca.pem", "../../test/test-ca2.pem"},
},
ExpectedMap: map[string][]byte{
"http://two-cert-chain.com": []byte(fmt.Sprintf("\n%s\n%s", string(certBytesA), string(certBytesB))),
@ -155,14 +155,14 @@ func TestLoadCertificateChains(t *testing.T) {
Name: "Empty chain, don't require at least one chain",
AllowEmptyChain: true,
Input: map[string][]string{
"http://two-cert-chain.com": []string{},
"http://two-cert-chain.com": {},
},
ExpectedMap: map[string][]byte{},
},
{
Name: "Empty chain",
Input: map[string][]string{
"http://two-cert-chain.com": []string{},
"http://two-cert-chain.com": {},
},
ExpectedError: fmt.Errorf(
"CertificateChain entry for AIA issuer url %q has no chain "+

View File

@ -22,10 +22,10 @@ var stringToCurve = map[string]elliptic.Curve{
// curveToOIDDER maps the name of the curves to their DER encoded OIDs
var curveToOIDDER = map[string][]byte{
elliptic.P224().Params().Name: []byte{6, 5, 43, 129, 4, 0, 33},
elliptic.P256().Params().Name: []byte{6, 8, 42, 134, 72, 206, 61, 3, 1, 7},
elliptic.P384().Params().Name: []byte{6, 5, 43, 129, 4, 0, 34},
elliptic.P521().Params().Name: []byte{6, 5, 43, 129, 4, 0, 35},
elliptic.P224().Params().Name: {6, 5, 43, 129, 4, 0, 33},
elliptic.P256().Params().Name: {6, 8, 42, 134, 72, 206, 61, 3, 1, 7},
elliptic.P384().Params().Name: {6, 5, 43, 129, 4, 0, 34},
elliptic.P521().Params().Name: {6, 5, 43, 129, 4, 0, 35},
}
var curveToHash = map[elliptic.Curve]crypto.Hash{

View File

@ -210,7 +210,7 @@ var allowedExtensions = map[string]bool{
// For extensions that have a fixed value we check that it contains that value
var expectedExtensionContent = map[string][]byte{
"1.3.6.1.5.5.7.1.24": []byte{0x30, 0x03, 0x02, 0x01, 0x05}, // Must staple feature
"1.3.6.1.5.5.7.1.24": {0x30, 0x03, 0x02, 0x01, 0x05}, // Must staple feature
}
func (c *certChecker) checkCert(cert core.Certificate, ignoredLints map[string]bool) (problems []string) {

View File

@ -16,14 +16,14 @@ func TestWithSubErrors(t *testing.T) {
}
subErrs := []SubBoulderError{
SubBoulderError{
{
Identifier: identifier.DNSIdentifier("example.com"),
BoulderError: &BoulderError{
Type: RateLimit,
Detail: "everyone uses this example domain",
},
},
SubBoulderError{
{
Identifier: identifier.DNSIdentifier("what about example.com"),
BoulderError: &BoulderError{
Type: RateLimit,

View File

@ -102,7 +102,7 @@ func TestChallenge(t *testing.T) {
ip := net.ParseIP("1.1.1.1")
chall.ValidationRecord = []core.ValidationRecord{
core.ValidationRecord{
{
Hostname: "host",
Port: "2020",
AddressesResolved: []net.IP{ip},

View File

@ -94,7 +94,7 @@ func TestWithSubProblems(t *testing.T) {
HTTPStatus: statusTooManyRequests,
}
subProbs := []SubProblemDetails{
SubProblemDetails{
{
Identifier: identifier.DNSIdentifier("example.com"),
ProblemDetails: ProblemDetails{
Type: RateLimitedProblem,
@ -102,7 +102,7 @@ func TestWithSubProblems(t *testing.T) {
HTTPStatus: statusTooManyRequests,
},
},
SubProblemDetails{
{
Identifier: identifier.DNSIdentifier("what about example.com"),
ProblemDetails: ProblemDetails{
Type: MalformedProblem,

View File

@ -230,7 +230,7 @@ func (pub *Impl) SubmitToSingleCTWithResult(ctx context.Context, req *pubpb.Requ
return nil, err
}
chain := append([]ct.ASN1Cert{ct.ASN1Cert{Data: req.Der}}, pub.issuerBundle...)
chain := append([]ct.ASN1Cert{{Data: req.Der}}, pub.issuerBundle...)
// Add a log URL/pubkey to the cache, if already present the
// existing *Log will be returned, otherwise one will be constructed, added

View File

@ -252,7 +252,7 @@ func makePrecert(k *ecdsa.PrivateKey) ([]ct.ASN1Cert, []byte, error) {
if err != nil {
return nil, nil, err
}
return []ct.ASN1Cert{ct.ASN1Cert{Data: rootBytes}}, precert, err
return []ct.ASN1Cert{{Data: rootBytes}}, precert, err
}
func TestTimestampVerificationFuture(t *testing.T) {

View File

@ -1799,27 +1799,27 @@ func newMockSAWithRecentAndOlder(recent, older time.Time) *mockSAWithRecentAndOl
}
return &mockSAWithRecentAndOlder{
authzMap: map[string]*core.Authorization{
"recent.com": &core.Authorization{
"recent.com": {
Identifier: makeIdentifier("recent.com"),
Expires: &recent,
Challenges: []core.Challenge{{Status: core.StatusValid, Type: core.ChallengeTypeHTTP01}},
},
"older.com": &core.Authorization{
"older.com": {
Identifier: makeIdentifier("older.com"),
Expires: &older,
Challenges: []core.Challenge{{Status: core.StatusValid, Type: core.ChallengeTypeHTTP01}},
},
"older2.com": &core.Authorization{
"older2.com": {
Identifier: makeIdentifier("older2.com"),
Expires: &older,
Challenges: []core.Challenge{{Status: core.StatusValid, Type: core.ChallengeTypeHTTP01}},
},
"wildcard.com": &core.Authorization{
"wildcard.com": {
Identifier: makeIdentifier("wildcard.com"),
Expires: &older,
Challenges: []core.Challenge{{Status: core.StatusValid, Type: core.ChallengeTypeHTTP01}},
},
"*.wildcard.com": &core.Authorization{
"*.wildcard.com": {
Identifier: makeIdentifier("*.wildcard.com"),
Expires: &older,
Challenges: []core.Challenge{{Status: core.StatusValid, Type: core.ChallengeTypeHTTP01}},
@ -1924,7 +1924,7 @@ func TestRecheckCAAEmpty(t *testing.T) {
func makeHTTP01Authorization(domain string) *core.Authorization {
return &core.Authorization{
Identifier: identifier.ACMEIdentifier{Type: identifier.DNS, Value: domain},
Challenges: []core.Challenge{core.Challenge{Status: core.StatusValid, Type: core.ChallengeTypeHTTP01}},
Challenges: []core.Challenge{{Status: core.StatusValid, Type: core.ChallengeTypeHTTP01}},
}
}
@ -2290,7 +2290,7 @@ func (msa *mockSAUnsafeAuthzReuse) GetAuthorizations(
ctx context.Context,
req *sapb.GetAuthorizationsRequest) (*sapb.Authorizations, error) {
authzs := map[string]*core.Authorization{
"*.zombo.com": &core.Authorization{
"*.zombo.com": {
// A static fake ID we can check for in a unit test
ID: "bad-bad-not-good",
Identifier: identifier.DNSIdentifier("*.zombo.com"),
@ -2299,18 +2299,18 @@ func (msa *mockSAUnsafeAuthzReuse) GetAuthorizations(
Status: "valid",
Challenges: []core.Challenge{
// HTTP-01 challenge is valid
core.Challenge{
{
Type: core.ChallengeTypeHTTP01, // The dreaded HTTP-01! X__X
Status: core.StatusValid,
},
// DNS-01 challenge is pending
core.Challenge{
{
Type: core.ChallengeTypeDNS01,
Status: core.StatusPending,
},
},
},
"zombo.com": &core.Authorization{
"zombo.com": {
// A static fake ID we can check for in a unit test
ID: "reused-valid-authz",
Identifier: identifier.DNSIdentifier("zombo.com"),
@ -2319,12 +2319,12 @@ func (msa *mockSAUnsafeAuthzReuse) GetAuthorizations(
Status: "valid",
Challenges: []core.Challenge{
// HTTP-01 challenge is valid
core.Challenge{
{
Type: core.ChallengeTypeHTTP01,
Status: core.StatusValid,
},
// DNS-01 challenge is pending
core.Challenge{
{
Type: core.ChallengeTypeDNS01,
Status: core.StatusPending,
},
@ -2338,7 +2338,7 @@ func (msa *mockSAUnsafeAuthzReuse) GetAuthorizations2(
ctx context.Context,
req *sapb.GetAuthorizationsRequest) (*sapb.Authorizations, error) {
authzs := map[string]*core.Authorization{
"*.zombo.com": &core.Authorization{
"*.zombo.com": {
// A static fake ID we can check for in a unit test
ID: "1",
Identifier: identifier.DNSIdentifier("*.zombo.com"),
@ -2347,18 +2347,18 @@ func (msa *mockSAUnsafeAuthzReuse) GetAuthorizations2(
Status: "valid",
Challenges: []core.Challenge{
// HTTP-01 challenge is valid
core.Challenge{
{
Type: core.ChallengeTypeHTTP01, // The dreaded HTTP-01! X__X
Status: core.StatusValid,
},
// DNS-01 challenge is pending
core.Challenge{
{
Type: core.ChallengeTypeDNS01,
Status: core.StatusPending,
},
},
},
"zombo.com": &core.Authorization{
"zombo.com": {
// A static fake ID we can check for in a unit test
ID: "2",
Identifier: identifier.DNSIdentifier("zombo.com"),
@ -2367,12 +2367,12 @@ func (msa *mockSAUnsafeAuthzReuse) GetAuthorizations2(
Status: "valid",
Challenges: []core.Challenge{
// HTTP-01 challenge is valid
core.Challenge{
{
Type: core.ChallengeTypeHTTP01,
Status: core.StatusValid,
},
// DNS-01 challenge is pending
core.Challenge{
{
Type: core.ChallengeTypeDNS01,
Status: core.StatusPending,
},
@ -2641,7 +2641,7 @@ func (msa *mockSANearExpiredAuthz) GetAuthorizations(
ctx context.Context,
req *sapb.GetAuthorizationsRequest) (*sapb.Authorizations, error) {
authzs := map[string]*core.Authorization{
"zombo.com": &core.Authorization{
"zombo.com": {
// A static fake ID we can check for in a unit test
ID: "near-expired-authz",
Identifier: identifier.DNSIdentifier("zombo.com"),
@ -2649,7 +2649,7 @@ func (msa *mockSANearExpiredAuthz) GetAuthorizations(
Expires: &msa.expiry,
Status: "valid",
Challenges: []core.Challenge{
core.Challenge{
{
Type: core.ChallengeTypeHTTP01,
Status: core.StatusValid,
},
@ -2663,7 +2663,7 @@ func (msa *mockSANearExpiredAuthz) GetAuthorizations2(
ctx context.Context,
req *sapb.GetAuthorizationsRequest) (*sapb.Authorizations, error) {
authzs := map[string]*core.Authorization{
"zombo.com": &core.Authorization{
"zombo.com": {
// A static fake ID we can check for in a unit test
ID: "1",
Identifier: identifier.DNSIdentifier("zombo.com"),
@ -2671,7 +2671,7 @@ func (msa *mockSANearExpiredAuthz) GetAuthorizations2(
Expires: &msa.expiry,
Status: "valid",
Challenges: []core.Challenge{
core.Challenge{
{
Type: core.ChallengeTypeHTTP01,
Status: core.StatusValid,
},
@ -3387,7 +3387,7 @@ func TestPerformValidationBadChallengeType(t *testing.T) {
exp := fc.Now().Add(10 * time.Hour)
authz := core.Authorization{
Challenges: []core.Challenge{
core.Challenge{
{
Status: core.StatusValid,
Type: core.ChallengeTypeHTTP01},
},

View File

@ -76,22 +76,22 @@ func TestV2AuthzModel(t *testing.T) {
Status: &status,
Expires: &expires,
Challenges: []*corepb.Challenge{
&corepb.Challenge{
{
Type: &challType,
Status: &status,
Token: &token,
Validationrecords: []*corepb.ValidationRecord{
&corepb.ValidationRecord{
{
Hostname: &hostname,
Port: &port,
AddressUsed: []byte("1.2.3.4"),
Url: &url,
AddressesResolved: [][]byte{[]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4}},
AddressesTried: [][]byte{[]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4}},
AddressesResolved: [][]byte{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4}},
AddressesTried: [][]byte{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4}},
},
},
},
&corepb.Challenge{
{
Type: &challType2,
Status: &statusPending,
Token: &token,

View File

@ -749,7 +749,7 @@ func setupFQDNSets(t *testing.T, db *db.WrappedMap, fc clock.FakeClock) map[stri
testcases := map[string]fqdnTestcase{
// One test case with serial "a" issued now and expiring in two hours for
// namesA
"a": fqdnTestcase{
"a": {
Serial: "a",
Names: namesA,
ExpectedHash: expectedHashA,
@ -758,7 +758,7 @@ func setupFQDNSets(t *testing.T, db *db.WrappedMap, fc clock.FakeClock) map[stri
},
// One test case with serial "b", issued one hour from now and expiring in
// two hours, also for namesA
"b": fqdnTestcase{
"b": {
Serial: "b",
Names: namesA,
ExpectedHash: expectedHashA,
@ -767,7 +767,7 @@ func setupFQDNSets(t *testing.T, db *db.WrappedMap, fc clock.FakeClock) map[stri
},
// One test case with serial "c", issued one hour from now and expiring in
// two hours, for namesB
"c": fqdnTestcase{
"c": {
Serial: "c",
Names: namesB,
ExpectedHash: expectedHashB,
@ -776,7 +776,7 @@ func setupFQDNSets(t *testing.T, db *db.WrappedMap, fc clock.FakeClock) map[stri
},
// One test case with serial "d", issued five hours in the past and expiring
// in two hours from now, with namesC
"d": fqdnTestcase{
"d": {
Serial: "d",
Names: namesC,
ExpectedHash: expectedHashC,
@ -883,7 +883,7 @@ func TestGetNewIssuancesByFQDNSet(t *testing.T) {
// Calling getNewIssuancesByFQDNSet with FQDNSet hashes that don't exist
// should return 0
count, err = sa.getNewIssuancesByFQDNSet(sa.dbMap, []setHash{setHash{0xC0, 0xFF, 0xEE}, setHash{0x13, 0x37}}, earliest)
count, err = sa.getNewIssuancesByFQDNSet(sa.dbMap, []setHash{{0xC0, 0xFF, 0xEE}, {0x13, 0x37}}, earliest)
test.AssertNotError(t, err, "Error calling getNewIssuancesByFQDNSet for non-existent set hashes")
test.AssertEquals(t, count, 0)
@ -2019,7 +2019,7 @@ func TestCountPendingAuthorizations2(t *testing.T) {
func TestAuthzModelMapToPB(t *testing.T) {
baseExpires := time.Now()
input := map[string]authzModel{
"example.com": authzModel{
"example.com": {
ID: 123,
IdentifierType: 0,
IdentifierValue: "example.com",
@ -2028,7 +2028,7 @@ func TestAuthzModelMapToPB(t *testing.T) {
Expires: baseExpires,
Challenges: 4,
},
"www.example.com": authzModel{
"www.example.com": {
ID: 124,
IdentifierType: 0,
IdentifierValue: "www.example.com",
@ -2037,7 +2037,7 @@ func TestAuthzModelMapToPB(t *testing.T) {
Expires: baseExpires,
Challenges: 1,
},
"other.example.net": authzModel{
"other.example.net": {
ID: 125,
IdentifierType: 0,
IdentifierValue: "other.example.net",

View File

@ -76,7 +76,7 @@ func main() {
ID: core.NewToken(),
RegistrationID: 1,
Expires: &expires,
Combinations: [][]int{[]int{1, 2, 3}},
Combinations: [][]int{{1, 2, 3}},
Status: "pending",
Identifier: identifier.ACMEIdentifier{
Type: "dns",

View File

@ -742,7 +742,7 @@ func TestFetchHTTP(t *testing.T) {
"Fetching http://example.com/timeout: " +
"Timeout after connect (your server may be slow or overloaded)"),
ExpectedRecords: []core.ValidationRecord{
core.ValidationRecord{
{
Hostname: "example.com",
Port: strconv.Itoa(httpPort),
URL: "http://example.com/timeout",
@ -768,7 +768,7 @@ func TestFetchHTTP(t *testing.T) {
`redirect target. Only "http" and "https" protocol schemes ` +
`are supported, not "gopher"`),
ExpectedRecords: []core.ValidationRecord{
core.ValidationRecord{
{
Hostname: "example.com",
Port: strconv.Itoa(httpPort),
URL: "http://example.com/redir-bad-proto",
@ -785,7 +785,7 @@ func TestFetchHTTP(t *testing.T) {
"Fetching https://example.com:1987: Invalid port in redirect target. "+
"Only ports %d and 443 are supported, not 1987", httpPort),
ExpectedRecords: []core.ValidationRecord{
core.ValidationRecord{
{
Hostname: "example.com",
Port: strconv.Itoa(httpPort),
URL: "http://example.com/redir-bad-port",
@ -802,7 +802,7 @@ func TestFetchHTTP(t *testing.T) {
"Fetching https://127.0.0.1: Invalid host in redirect target " +
`"127.0.0.1". Only domain names are supported, not IP addresses`),
ExpectedRecords: []core.ValidationRecord{
core.ValidationRecord{
{
Hostname: "example.com",
Port: strconv.Itoa(httpPort),
URL: "http://example.com/redir-bad-host",
@ -819,7 +819,7 @@ func TestFetchHTTP(t *testing.T) {
"Invalid response from http://example.com/bad-status-code " +
"[127.0.0.1]: 410"),
ExpectedRecords: []core.ValidationRecord{
core.ValidationRecord{
{
Hostname: "example.com",
Port: strconv.Itoa(httpPort),
URL: "http://example.com/bad-status-code",
@ -837,7 +837,7 @@ func TestFetchHTTP(t *testing.T) {
"[127.0.0.1]: %q", expectedTruncatedResp.String(),
),
ExpectedRecords: []core.ValidationRecord{
core.ValidationRecord{
{
Hostname: "example.com",
Port: strconv.Itoa(httpPort),
URL: "http://example.com/resp-too-big",
@ -853,7 +853,7 @@ func TestFetchHTTP(t *testing.T) {
ExpectedProblem: probs.ConnectionFailure(
"Fetching http://ipv6.localhost/ok: Error getting validation data"),
ExpectedRecords: []core.ValidationRecord{
core.ValidationRecord{
{
Hostname: "ipv6.localhost",
Port: strconv.Itoa(httpPort),
URL: "http://ipv6.localhost/ok",
@ -868,7 +868,7 @@ func TestFetchHTTP(t *testing.T) {
Path: "/ok",
ExpectedBody: "ok",
ExpectedRecords: []core.ValidationRecord{
core.ValidationRecord{
{
Hostname: "ipv4.and.ipv6.localhost",
Port: strconv.Itoa(httpPort),
URL: "http://ipv4.and.ipv6.localhost/ok",
@ -876,7 +876,7 @@ func TestFetchHTTP(t *testing.T) {
// The first validation record should have used the IPv6 addr
AddressUsed: net.ParseIP("::1"),
},
core.ValidationRecord{
{
Hostname: "ipv4.and.ipv6.localhost",
Port: strconv.Itoa(httpPort),
URL: "http://ipv4.and.ipv6.localhost/ok",
@ -892,7 +892,7 @@ func TestFetchHTTP(t *testing.T) {
Path: "/ok",
ExpectedBody: "ok",
ExpectedRecords: []core.ValidationRecord{
core.ValidationRecord{
{
Hostname: "example.com",
Port: strconv.Itoa(httpPort),
URL: "http://example.com/ok",
@ -907,14 +907,14 @@ func TestFetchHTTP(t *testing.T) {
Path: "/redir-uppercase-publicsuffix",
ExpectedBody: "ok",
ExpectedRecords: []core.ValidationRecord{
core.ValidationRecord{
{
Hostname: "example.com",
Port: strconv.Itoa(httpPort),
URL: "http://example.com/redir-uppercase-publicsuffix",
AddressesResolved: []net.IP{net.ParseIP("127.0.0.1")},
AddressUsed: net.ParseIP("127.0.0.1"),
},
core.ValidationRecord{
{
Hostname: "example.com",
Port: strconv.Itoa(httpPort),
URL: "http://example.com/ok",

View File

@ -719,27 +719,27 @@ func TestLogRemoteValidationDifferentials(t *testing.T) {
name: "remote and primary results equal (all nil)",
primaryResult: nil,
remoteProbs: []*remoteValidationResult{
&remoteValidationResult{Problem: nil, VAHostname: "remoteA"},
&remoteValidationResult{Problem: nil, VAHostname: "remoteB"},
&remoteValidationResult{Problem: nil, VAHostname: "remoteC"},
{Problem: nil, VAHostname: "remoteA"},
{Problem: nil, VAHostname: "remoteB"},
{Problem: nil, VAHostname: "remoteC"},
},
},
{
name: "remote and primary results equal (not nil)",
primaryResult: egProbA,
remoteProbs: []*remoteValidationResult{
&remoteValidationResult{Problem: egProbA, VAHostname: "remoteA"},
&remoteValidationResult{Problem: egProbA, VAHostname: "remoteB"},
&remoteValidationResult{Problem: egProbA, VAHostname: "remoteC"},
{Problem: egProbA, VAHostname: "remoteA"},
{Problem: egProbA, VAHostname: "remoteB"},
{Problem: egProbA, VAHostname: "remoteC"},
},
},
{
name: "remote and primary differ (primary nil)",
primaryResult: nil,
remoteProbs: []*remoteValidationResult{
&remoteValidationResult{Problem: egProbA, VAHostname: "remoteA"},
&remoteValidationResult{Problem: nil, VAHostname: "remoteB"},
&remoteValidationResult{Problem: egProbB, VAHostname: "remoteC"},
{Problem: egProbA, VAHostname: "remoteA"},
{Problem: nil, VAHostname: "remoteB"},
{Problem: egProbB, VAHostname: "remoteC"},
},
expectedLog: `INFO: remoteVADifferentials JSON={"Domain":"example.com","AccountID":1999,"ChallengeType":"blorpus-01","PrimaryResult":null,"RemoteSuccesses":1,"RemoteFailures":[{"VAHostname":"remoteA","Problem":{"type":"dns","detail":"root DNS servers closed at 4:30pm","status":400}},{"VAHostname":"remoteC","Problem":{"type":"orderNotReady","detail":"please take a number","status":403}}]}`,
},
@ -747,9 +747,9 @@ func TestLogRemoteValidationDifferentials(t *testing.T) {
name: "remote and primary differ (primary not nil)",
primaryResult: egProbA,
remoteProbs: []*remoteValidationResult{
&remoteValidationResult{Problem: nil, VAHostname: "remoteA"},
&remoteValidationResult{Problem: egProbB, VAHostname: "remoteB"},
&remoteValidationResult{Problem: nil, VAHostname: "remoteC"},
{Problem: nil, VAHostname: "remoteA"},
{Problem: egProbB, VAHostname: "remoteB"},
{Problem: nil, VAHostname: "remoteC"},
},
expectedLog: `INFO: remoteVADifferentials JSON={"Domain":"example.com","AccountID":1999,"ChallengeType":"blorpus-01","PrimaryResult":{"type":"dns","detail":"root DNS servers closed at 4:30pm","status":400},"RemoteSuccesses":2,"RemoteFailures":[{"VAHostname":"remoteB","Problem":{"type":"orderNotReady","detail":"please take a number","status":403}}]}`,
},

View File

@ -18,14 +18,14 @@ func TestSendErrorSubProblemNamespace(t *testing.T) {
Detail: "bad",
}).WithSubErrors(
[]berrors.SubBoulderError{
berrors.SubBoulderError{
{
Identifier: identifier.DNSIdentifier("example.com"),
BoulderError: &berrors.BoulderError{
Type: berrors.Malformed,
Detail: "nop",
},
},
berrors.SubBoulderError{
{
Identifier: identifier.DNSIdentifier("what about example.com"),
BoulderError: &berrors.BoulderError{
Type: berrors.Malformed,
@ -72,14 +72,14 @@ func TestSendErrorSubProbLogging(t *testing.T) {
Detail: "bad",
}).WithSubErrors(
[]berrors.SubBoulderError{
berrors.SubBoulderError{
{
Identifier: identifier.DNSIdentifier("example.com"),
BoulderError: &berrors.BoulderError{
Type: berrors.Malformed,
Detail: "nop",
},
},
berrors.SubBoulderError{
{
Identifier: identifier.DNSIdentifier("what about example.com"),
BoulderError: &berrors.BoulderError{
Type: berrors.Malformed,

View File

@ -392,8 +392,8 @@ func TestValidPOSTRequest(t *testing.T) {
Name: "POST with a Replay-Nonce HTTP header",
Headers: map[string][]string{
"Content-Length": dummyContentLength,
"Replay-Nonce": []string{"ima-misplaced-nonce"},
"Content-Type": []string{expectedJWSContentType},
"Replay-Nonce": {"ima-misplaced-nonce"},
"Content-Type": {expectedJWSContentType},
},
HTTPStatus: http.StatusBadRequest,
ProblemDetail: "HTTP requests should NOT contain Replay-Nonce header. Use JWS nonce field",
@ -404,7 +404,7 @@ func TestValidPOSTRequest(t *testing.T) {
Name: "POST with an empty POST body",
Headers: map[string][]string{
"Content-Length": dummyContentLength,
"Content-Type": []string{expectedJWSContentType},
"Content-Type": {expectedJWSContentType},
},
HTTPStatus: http.StatusBadRequest,
ProblemDetail: "No body on POST",
@ -426,7 +426,7 @@ func TestValidPOSTRequest(t *testing.T) {
Name: "POST with an invalid Content-Type header",
Headers: map[string][]string{
"Content-Length": dummyContentLength,
"Content-Type": []string{"fresh.and.rare"},
"Content-Type": {"fresh.and.rare"},
},
HTTPStatus: http.StatusUnsupportedMediaType,
ProblemDetail: fmt.Sprintf(

View File

@ -369,7 +369,7 @@ func makePostRequestWithPath(path string, body string) *http.Request {
RemoteAddr: "1.1.1.1:7882",
Header: map[string][]string{
"Content-Length": {strconv.Itoa(len(body))},
"Content-Type": []string{expectedJWSContentType},
"Content-Type": {expectedJWSContentType},
},
Body: makeBody(body),
Host: "localhost",
@ -1403,7 +1403,7 @@ func TestNewAccount(t *testing.T) {
URL: mustParseURL(newAcctPath),
Header: map[string][]string{
"Content-Length": {"0"},
"Content-Type": []string{expectedJWSContentType},
"Content-Type": {expectedJWSContentType},
},
},
`{"type":"` + probs.V2ErrorNS + `malformed","detail":"No body on POST","status":400}`,
@ -2210,7 +2210,7 @@ func TestNewOrder(t *testing.T) {
Method: "POST",
Header: map[string][]string{
"Content-Length": {"0"},
"Content-Type": []string{expectedJWSContentType},
"Content-Type": {expectedJWSContentType},
},
},
ExpectedBody: `{"type":"` + probs.V2ErrorNS + `malformed","detail":"No body on POST","status":400}`,
@ -2314,7 +2314,7 @@ func TestFinalizeOrder(t *testing.T) {
Method: "POST",
Header: map[string][]string{
"Content-Length": {"0"},
"Content-Type": []string{expectedJWSContentType},
"Content-Type": {expectedJWSContentType},
},
},
ExpectedBody: `{"type":"` + probs.V2ErrorNS + `malformed","detail":"No body on POST","status":400}`,