~ubuntu-branches/ubuntu/utopic/hockeypuck/utopic-proposed

« back to all changes in this revision

Viewing changes to build/src/code.google.com/p/go.crypto/ssh/test/tcpip_test.go

  • Committer: Package Import Robot
  • Author(s): Casey Marshall
  • Date: 2014-04-13 20:06:01 UTC
  • Revision ID: package-import@ubuntu.com-20140413200601-oxdlqn1gy0x8m55u
Tags: 1.0~rel20140413+7a1892a~trusty
Hockeypuck 1.0 release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2012 The Go Authors. All rights reserved.
 
2
// Use of this source code is governed by a BSD-style
 
3
// license that can be found in the LICENSE file.
 
4
 
 
5
// +build !windows
 
6
 
 
7
package test
 
8
 
 
9
// direct-tcpip functional tests
 
10
 
 
11
import (
 
12
        "net"
 
13
        "net/http"
 
14
        "testing"
 
15
)
 
16
 
 
17
func TestTCPIPHTTP(t *testing.T) {
 
18
        // google.com will generate at least one redirect, possibly three
 
19
        // depending on your location.
 
20
        doTest(t, "http://google.com")
 
21
}
 
22
 
 
23
func TestTCPIPHTTPS(t *testing.T) {
 
24
        doTest(t, "https://encrypted.google.com/")
 
25
}
 
26
 
 
27
func doTest(t *testing.T, url string) {
 
28
        server := newServer(t)
 
29
        defer server.Shutdown()
 
30
        conn := server.Dial(clientConfig())
 
31
        defer conn.Close()
 
32
 
 
33
        tr := &http.Transport{
 
34
                Dial: func(n, addr string) (net.Conn, error) {
 
35
                        return conn.Dial(n, addr)
 
36
                },
 
37
        }
 
38
        client := &http.Client{
 
39
                Transport: tr,
 
40
        }
 
41
        resp, err := client.Get(url)
 
42
        if err != nil {
 
43
                t.Fatalf("unable to proxy: %s", err)
 
44
        }
 
45
        // got a body without error
 
46
        t.Log(resp)
 
47
}