]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/crypto/tls/handshake_server_test.go
[dev.boringcrypto] all: merge master (2f0da6d) into dev.boringcrypto
[gostls13.git] / src / crypto / tls / handshake_server_test.go
index 36d48bc942ca03f63281d3212b660ef4f1bf180b..050a321e7f3119ba5aa93b5552c624a38a1bfde0 100644 (file)
@@ -6,7 +6,6 @@ package tls
 
 import (
        "bytes"
-       "context"
        "crypto"
        "crypto/elliptic"
        "crypto/x509"
@@ -18,7 +17,6 @@ import (
        "os"
        "os/exec"
        "path/filepath"
-       "runtime"
        "strings"
        "testing"
        "time"
@@ -40,12 +38,10 @@ func testClientHelloFailure(t *testing.T, serverConfig *Config, m handshakeMessa
                cli.writeRecord(recordTypeHandshake, m.marshal())
                c.Close()
        }()
-       ctx := context.Background()
        conn := Server(s, serverConfig)
-       ch, err := conn.readClientHello(ctx)
+       ch, err := conn.readClientHello()
        hs := serverHandshakeState{
                c:           conn,
-               ctx:         ctx,
                clientHello: ch,
        }
        if err == nil {
@@ -1425,11 +1421,9 @@ func TestSNIGivenOnFailure(t *testing.T) {
                c.Close()
        }()
        conn := Server(s, serverConfig)
-       ctx := context.Background()
-       ch, err := conn.readClientHello(ctx)
+       ch, err := conn.readClientHello()
        hs := serverHandshakeState{
                c:           conn,
-               ctx:         ctx,
                clientHello: ch,
        }
        if err == nil {
@@ -1683,46 +1677,6 @@ func TestMultipleCertificates(t *testing.T) {
        }
 }
 
-func TestServerHandshakeContextCancellation(t *testing.T) {
-       c, s := localPipe(t)
-       clientConfig := testConfig.Clone()
-       clientErr := make(chan error, 1)
-       ctx, cancel := context.WithCancel(context.Background())
-       defer cancel()
-       go func() {
-               defer close(clientErr)
-               defer c.Close()
-               clientHello := &clientHelloMsg{
-                       vers:               VersionTLS10,
-                       random:             make([]byte, 32),
-                       cipherSuites:       []uint16{TLS_RSA_WITH_RC4_128_SHA},
-                       compressionMethods: []uint8{compressionNone},
-               }
-               cli := Client(c, clientConfig)
-               _, err := cli.writeRecord(recordTypeHandshake, clientHello.marshal())
-               cancel()
-               clientErr <- err
-       }()
-       conn := Server(s, testConfig)
-       err := conn.HandshakeContext(ctx)
-       if err == nil {
-               t.Fatal("Server handshake did not error when the context was canceled")
-       }
-       if err != context.Canceled {
-               t.Errorf("Unexpected server handshake error: %v", err)
-       }
-       if err := <-clientErr; err != nil {
-               t.Errorf("Unexpected client error: %v", err)
-       }
-       if runtime.GOARCH == "wasm" {
-               t.Skip("conn.Close does not error as expected when called multiple times on WASM")
-       }
-       err = conn.Close()
-       if err == nil {
-               t.Error("Server connection was not closed when the context was canceled")
-       }
-}
-
 func TestAESCipherReordering(t *testing.T) {
        currentAESSupport := hasAESGCMHardwareSupport
        defer func() { hasAESGCMHardwareSupport = currentAESSupport; initDefaultCipherSuites() }()