(t *testing.T)
| 37 | ) |
| 38 | |
| 39 | func 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 | |
| 75 | type nodeupConfigBuilder struct { |
| 76 | cluster *kops.Cluster |
nothing calls this directly
no test coverage detected