Skip to content

Commit

Permalink
Test GetTLSConnectionState
Browse files Browse the repository at this point in the history
Run GetTLSConnectionState on a non-tls connection (in a dedicated test)
and a tls connection.
Because initializing the TLS connection in the tests is non-trivial,

I hijacked the TestTLSCloseClientConnection test.
  • Loading branch information
cdevienne committed Dec 21, 2016
1 parent f94983a commit 872c9e0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions server/client_test.go
Expand Up @@ -107,6 +107,14 @@ func TestClientCreateAndInfo(t *testing.T) {
}
}

func TestNonTLSConnectionState(t *testing.T) {
_, c, _ := setupClient()
state := c.GetTLSConnectionState()
if state != nil {
t.Error("GetTLSConnectionState() returned non-nil")
}
}

func TestClientConnect(t *testing.T) {
_, c, _ := setupClient()

Expand Down Expand Up @@ -713,6 +721,11 @@ func TestTLSCloseClientConnection(t *testing.T) {
if cli == nil {
t.Fatal("Did not register client on time")
}
// Test GetTLSConnectionState
state := cli.GetTLSConnectionState()
if state == nil {
t.Error("GetTLSConnectionState() returned nil")
}
// Fill the buffer. Need to send 1 byte at a time so that we timeout here
// the nc.Close() would block due to a write that can not complete.
done := false
Expand Down

0 comments on commit 872c9e0

Please sign in to comment.