OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [net/] [http/] [proxy_test.go] - Blame information for rev 747

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2009 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
package http
6
 
7
import (
8
        "os"
9
        "testing"
10
)
11
 
12
// TODO(mattn):
13
//      test ProxyAuth
14
 
15
var UseProxyTests = []struct {
16
        host  string
17
        match bool
18
}{
19
        // Never proxy localhost:
20
        {"localhost:80", false},
21
        {"127.0.0.1", false},
22
        {"127.0.0.2", false},
23
        {"[::1]", false},
24
        {"[::2]", true}, // not a loopback address
25
 
26
        {"barbaz.net", false},     // match as .barbaz.net
27
        {"foobar.com", false},     // have a port but match
28
        {"foofoobar.com", true},   // not match as a part of foobar.com
29
        {"baz.com", true},         // not match as a part of barbaz.com
30
        {"localhost.net", true},   // not match as suffix of address
31
        {"local.localhost", true}, // not match as prefix as address
32
        {"barbarbaz.net", true},   // not match because NO_PROXY have a '.'
33
        {"www.foobar.com", true},  // not match because NO_PROXY is not .foobar.com
34
}
35
 
36
func TestUseProxy(t *testing.T) {
37
        oldenv := os.Getenv("NO_PROXY")
38
        defer os.Setenv("NO_PROXY", oldenv)
39
 
40
        no_proxy := "foobar.com, .barbaz.net"
41
        os.Setenv("NO_PROXY", no_proxy)
42
 
43
        for _, test := range UseProxyTests {
44
                if useProxy(test.host+":80") != test.match {
45
                        t.Errorf("useProxy(%v) = %v, want %v", test.host, !test.match, test.match)
46
                }
47
        }
48
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.