Commit 186d3e30 authored by Tamir Duberstein's avatar Tamir Duberstein Committed by Brad Fitzpatrick

crypto/tls: tests prefer constants to opaque literals

This is minor cleanup that makes the tests more readable.

Change-Id: I9f1f98f0f035096c284bdf3501e7520517a3e4d9
Reviewed-on: https://go-review.googlesource.com/19993Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 92408107
...@@ -105,16 +105,16 @@ func TestRejectBadProtocolVersion(t *testing.T) { ...@@ -105,16 +105,16 @@ func TestRejectBadProtocolVersion(t *testing.T) {
func TestNoSuiteOverlap(t *testing.T) { func TestNoSuiteOverlap(t *testing.T) {
clientHello := &clientHelloMsg{ clientHello := &clientHelloMsg{
vers: 0x0301, vers: VersionTLS10,
cipherSuites: []uint16{0xff00}, cipherSuites: []uint16{0xff00},
compressionMethods: []uint8{0}, compressionMethods: []uint8{compressionNone},
} }
testClientHelloFailure(t, testConfig, clientHello, "no cipher suite supported by both client and server") testClientHelloFailure(t, testConfig, clientHello, "no cipher suite supported by both client and server")
} }
func TestNoCompressionOverlap(t *testing.T) { func TestNoCompressionOverlap(t *testing.T) {
clientHello := &clientHelloMsg{ clientHello := &clientHelloMsg{
vers: 0x0301, vers: VersionTLS10,
cipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA}, cipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA},
compressionMethods: []uint8{0xff}, compressionMethods: []uint8{0xff},
} }
...@@ -123,9 +123,9 @@ func TestNoCompressionOverlap(t *testing.T) { ...@@ -123,9 +123,9 @@ func TestNoCompressionOverlap(t *testing.T) {
func TestNoRC4ByDefault(t *testing.T) { func TestNoRC4ByDefault(t *testing.T) {
clientHello := &clientHelloMsg{ clientHello := &clientHelloMsg{
vers: 0x0301, vers: VersionTLS10,
cipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA}, cipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA},
compressionMethods: []uint8{0}, compressionMethods: []uint8{compressionNone},
} }
serverConfig := *testConfig serverConfig := *testConfig
// Reset the enabled cipher suites to nil in order to test the // Reset the enabled cipher suites to nil in order to test the
...@@ -138,9 +138,9 @@ func TestDontSelectECDSAWithRSAKey(t *testing.T) { ...@@ -138,9 +138,9 @@ func TestDontSelectECDSAWithRSAKey(t *testing.T) {
// Test that, even when both sides support an ECDSA cipher suite, it // Test that, even when both sides support an ECDSA cipher suite, it
// won't be selected if the server's private key doesn't support it. // won't be selected if the server's private key doesn't support it.
clientHello := &clientHelloMsg{ clientHello := &clientHelloMsg{
vers: 0x0301, vers: VersionTLS10,
cipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA}, cipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA},
compressionMethods: []uint8{0}, compressionMethods: []uint8{compressionNone},
supportedCurves: []CurveID{CurveP256}, supportedCurves: []CurveID{CurveP256},
supportedPoints: []uint8{pointFormatUncompressed}, supportedPoints: []uint8{pointFormatUncompressed},
} }
...@@ -163,9 +163,9 @@ func TestDontSelectRSAWithECDSAKey(t *testing.T) { ...@@ -163,9 +163,9 @@ func TestDontSelectRSAWithECDSAKey(t *testing.T) {
// Test that, even when both sides support an RSA cipher suite, it // Test that, even when both sides support an RSA cipher suite, it
// won't be selected if the server's private key doesn't support it. // won't be selected if the server's private key doesn't support it.
clientHello := &clientHelloMsg{ clientHello := &clientHelloMsg{
vers: 0x0301, vers: VersionTLS10,
cipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, cipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA},
compressionMethods: []uint8{0}, compressionMethods: []uint8{compressionNone},
supportedCurves: []CurveID{CurveP256}, supportedCurves: []CurveID{CurveP256},
supportedPoints: []uint8{pointFormatUncompressed}, supportedPoints: []uint8{pointFormatUncompressed},
} }
...@@ -788,9 +788,9 @@ func TestHandshakeServerSNIGetCertificateError(t *testing.T) { ...@@ -788,9 +788,9 @@ func TestHandshakeServerSNIGetCertificateError(t *testing.T) {
} }
clientHello := &clientHelloMsg{ clientHello := &clientHelloMsg{
vers: 0x0301, vers: VersionTLS10,
cipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA}, cipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA},
compressionMethods: []uint8{0}, compressionMethods: []uint8{compressionNone},
serverName: "test", serverName: "test",
} }
testClientHelloFailure(t, &serverConfig, clientHello, errMsg) testClientHelloFailure(t, &serverConfig, clientHello, errMsg)
...@@ -808,9 +808,9 @@ func TestHandshakeServerEmptyCertificates(t *testing.T) { ...@@ -808,9 +808,9 @@ func TestHandshakeServerEmptyCertificates(t *testing.T) {
serverConfig.Certificates = nil serverConfig.Certificates = nil
clientHello := &clientHelloMsg{ clientHello := &clientHelloMsg{
vers: 0x0301, vers: VersionTLS10,
cipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA}, cipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA},
compressionMethods: []uint8{0}, compressionMethods: []uint8{compressionNone},
} }
testClientHelloFailure(t, &serverConfig, clientHello, errMsg) testClientHelloFailure(t, &serverConfig, clientHello, errMsg)
...@@ -819,9 +819,9 @@ func TestHandshakeServerEmptyCertificates(t *testing.T) { ...@@ -819,9 +819,9 @@ func TestHandshakeServerEmptyCertificates(t *testing.T) {
serverConfig.GetCertificate = nil serverConfig.GetCertificate = nil
clientHello = &clientHelloMsg{ clientHello = &clientHelloMsg{
vers: 0x0301, vers: VersionTLS10,
cipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA}, cipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA},
compressionMethods: []uint8{0}, compressionMethods: []uint8{compressionNone},
} }
testClientHelloFailure(t, &serverConfig, clientHello, "no certificates") testClientHelloFailure(t, &serverConfig, clientHello, "no certificates")
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment