(t *testing.T)
| 22 | ) |
| 23 | |
| 24 | func TestMergeProxyConfigs(t *testing.T) { |
| 25 | tests := []struct { |
| 26 | name string |
| 27 | operatorConfig *controller.Proxy |
| 28 | clusterConfig *controller.Proxy |
| 29 | expectedConfig *controller.Proxy |
| 30 | }{ |
| 31 | { |
| 32 | name: "Uses operatorConfig as base when configured", |
| 33 | operatorConfig: &controller.Proxy{ |
| 34 | HttpProxy: pointer.String("test-operator-http"), |
| 35 | HttpsProxy: pointer.String("test-operator-https"), |
| 36 | NoProxy: pointer.String("test-operator-noproxy"), |
| 37 | }, |
| 38 | clusterConfig: &controller.Proxy{ |
| 39 | HttpProxy: pointer.String("test-cluster-http"), |
| 40 | HttpsProxy: pointer.String("test-cluster-https"), |
| 41 | NoProxy: pointer.String("test-cluster-noproxy"), |
| 42 | }, |
| 43 | expectedConfig: &controller.Proxy{ |
| 44 | HttpProxy: pointer.String("test-operator-http"), |
| 45 | HttpsProxy: pointer.String("test-operator-https"), |
| 46 | NoProxy: pointer.String("test-cluster-noproxy,test-operator-noproxy"), |
| 47 | }, |
| 48 | }, |
| 49 | { |
| 50 | name: "Uses clusterConfig when operator not configured", |
| 51 | operatorConfig: &controller.Proxy{ |
| 52 | HttpProxy: nil, |
| 53 | HttpsProxy: nil, |
| 54 | NoProxy: nil, |
| 55 | }, |
| 56 | clusterConfig: &controller.Proxy{ |
| 57 | HttpProxy: pointer.String("test-cluster-http"), |
| 58 | HttpsProxy: pointer.String("test-cluster-https"), |
| 59 | NoProxy: pointer.String("test-cluster-noproxy"), |
| 60 | }, |
| 61 | expectedConfig: &controller.Proxy{ |
| 62 | HttpProxy: pointer.String("test-cluster-http"), |
| 63 | HttpsProxy: pointer.String("test-cluster-https"), |
| 64 | NoProxy: pointer.String("test-cluster-noproxy"), |
| 65 | }, |
| 66 | }, |
| 67 | { |
| 68 | name: "Can set empty strings to unset autodetected fields", |
| 69 | operatorConfig: &controller.Proxy{ |
| 70 | HttpProxy: pointer.String(""), |
| 71 | HttpsProxy: pointer.String(""), |
| 72 | NoProxy: pointer.String(""), |
| 73 | }, |
| 74 | clusterConfig: &controller.Proxy{ |
| 75 | HttpProxy: pointer.String("test-cluster-http"), |
| 76 | HttpsProxy: pointer.String("test-cluster-https"), |
| 77 | NoProxy: pointer.String("test-cluster-noproxy"), |
| 78 | }, |
| 79 | expectedConfig: &controller.Proxy{}, |
| 80 | }, |
| 81 | { |
nothing calls this directly
no test coverage detected