@@ -36,6 +36,8 @@ func TestEmitCWPStatus(t *testing.T) {
36
36
tests := []struct {
37
37
name string
38
38
proxyConfig * configv1.Proxy
39
+ infraConfig * configv1.Infrastructure
40
+ apiServerURL string
39
41
expectErr bool
40
42
expectedError string
41
43
setupMocks func (* mock_metrics.MockEmitter )
@@ -81,6 +83,65 @@ func TestEmitCWPStatus(t *testing.T) {
81
83
Times (1 )
82
84
},
83
85
},
86
+ {
87
+ name : "missing clusterDomain and .apps.clusterDomain in no_proxy" ,
88
+ proxyConfig : & configv1.Proxy {
89
+ ObjectMeta : metav1.ObjectMeta {Name : "cluster" },
90
+ Spec : configv1.ProxySpec {
91
+ NoProxy : "localhost,.svc,.cluster.local" ,
92
+ },
93
+ },
94
+ infraConfig : & configv1.Infrastructure {
95
+ ObjectMeta : metav1.ObjectMeta {Name : "cluster" },
96
+ Status : configv1.InfrastructureStatus {
97
+ APIServerInternalURL : "https://api-int.clusterDomain:6443" ,
98
+ },
99
+ },
100
+ apiServerURL : "https://api.clusterDomain:6443" ,
101
+ expectErr : false ,
102
+ expectedError : "" ,
103
+ setupMocks : func (m * mock_metrics.MockEmitter ) {
104
+ m .EXPECT ().
105
+ EmitGauge ("clusterWideProxy.status" , int64 (1 ), gomock .Any ()).
106
+ Times (1 )
107
+ },
108
+ },
109
+ {
110
+ name : "CWP enabled with complete no_proxy list" ,
111
+ proxyConfig : & configv1.Proxy {
112
+ ObjectMeta : metav1.ObjectMeta {Name : "cluster" },
113
+ Spec : configv1.ProxySpec {
114
+ NoProxy : "localhost,127.0.0.1,.svc,.cluster.local,169.254.169.254,168.63.129.16,.apps.clusterDomain,api.clusterDomain,api-int.clusterDomain" ,
115
+ },
116
+ },
117
+ infraConfig : & configv1.Infrastructure {
118
+ ObjectMeta : metav1.ObjectMeta {Name : "cluster" },
119
+ Status : configv1.InfrastructureStatus {
120
+ APIServerInternalURL : "https://api-int.clusterDomain:6443" ,
121
+ },
122
+ },
123
+ expectErr : false ,
124
+ setupMocks : func (m * mock_metrics.MockEmitter ) {
125
+ m .EXPECT ().
126
+ EmitGauge ("clusterWideProxy.status" , int64 (1 ), gomock .Any ()).
127
+ Times (1 )
128
+ },
129
+ },
130
+ {
131
+ name : "CWP enabled with complete with clusterDomain (not having api or api-int or .apps.clusterDomain)int no_proxy list" ,
132
+ proxyConfig : & configv1.Proxy {
133
+ ObjectMeta : metav1.ObjectMeta {Name : "cluster" },
134
+ Spec : configv1.ProxySpec {
135
+ NoProxy : "localhost,127.0.0.1,.svc,.cluster.local,169.254.169.254,168.63.129.16,clusterDomain" ,
136
+ },
137
+ },
138
+ expectErr : false ,
139
+ setupMocks : func (m * mock_metrics.MockEmitter ) {
140
+ m .EXPECT ().
141
+ EmitGauge ("clusterWideProxy.status" , int64 (1 ), gomock .Any ()).
142
+ Times (1 )
143
+ },
144
+ },
84
145
}
85
146
86
147
for _ , tt := range tests {
0 commit comments