MCPcopy
hub / github.com/kubernetes/kops / Test_ProxyFunc

Function Test_ProxyFunc

pkg/model/bootstrapscript_test.go:39–73  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

37)
38
39func Test_ProxyFunc(t *testing.T) {
40 cluster := &kops.Cluster{}
41 cluster.Spec.Networking.EgressProxy = &kops.EgressProxySpec{
42 HTTPProxy: kops.HTTPProxy{
43 Host: "example.com",
44 Port: 80,
45 },
46 }
47
48 nodeupScript := &resources.NodeUpScript{}
49 nodeupScript.WithProxyEnv(cluster)
50
51 script, err := nodeupScript.ProxyEnv()
52 if err != nil {
53 t.Fatalf("ProxyEnv failed: %v", err)
54 }
55 if script == "" {
56 t.Fatalf("script cannot be empty")
57 }
58
59 if !strings.Contains(script, "echo \"http_proxy=http://example.com:80\"") {
60 t.Fatalf("script not setting http_proxy properly")
61 }
62
63 cluster.Spec.Networking.EgressProxy.ProxyExcludes = "www.google.com,www.kubernetes.io"
64
65 script, err = nodeupScript.ProxyEnv()
66 if err != nil {
67 t.Fatalf("ProxyEnv failed: %v", err)
68 }
69
70 if !strings.Contains(script, "no_proxy="+cluster.Spec.Networking.EgressProxy.ProxyExcludes) {
71 t.Fatalf("script not setting no_proxy properly")
72 }
73}
74
75type nodeupConfigBuilder struct {
76 cluster *kops.Cluster

Callers

nothing calls this directly

Calls 2

WithProxyEnvMethod · 0.95
ProxyEnvMethod · 0.80

Tested by

no test coverage detected