@@ -10,6 +10,7 @@ import (
10
10
gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
11
11
12
12
ngfAPIv1alpha1 "github.com/nginx/nginx-gateway-fabric/v2/apis/v1alpha1"
13
+ "github.com/nginx/nginx-gateway-fabric/v2/internal/framework/helpers"
13
14
"github.com/nginx/nginx-gateway-fabric/v2/tests/framework"
14
15
)
15
16
@@ -129,6 +130,66 @@ func TestClientSettingsPoliciesTargetRefGroup(t *testing.T) {
129
130
}
130
131
}
131
132
133
+ func TestClientSettingsPoliciesKeepAliveTimeout (t * testing.T ) {
134
+ t .Parallel ()
135
+ g := NewWithT (t )
136
+ k8sClient , err := getKubernetesClient (t )
137
+ g .Expect (err ).ToNot (HaveOccurred ())
138
+ tests := []struct {
139
+ policySpec ngfAPIv1alpha1.ClientSettingsPolicySpec
140
+ name string
141
+ wantErrors []string
142
+ }{
143
+ {
144
+ name : "Validate KeepAliveTimeout is not set" ,
145
+ policySpec : ngfAPIv1alpha1.ClientSettingsPolicySpec {
146
+ TargetRef : gatewayv1alpha2.LocalPolicyTargetReference {
147
+ Kind : gatewayKind ,
148
+ Group : gatewayGroup ,
149
+ },
150
+ KeepAlive : nil ,
151
+ },
152
+ },
153
+ {
154
+ name : "Validate KeepAlive is set" ,
155
+ policySpec : ngfAPIv1alpha1.ClientSettingsPolicySpec {
156
+ TargetRef : gatewayv1alpha2.LocalPolicyTargetReference {
157
+ Kind : gatewayKind ,
158
+ Group : gatewayGroup ,
159
+ },
160
+ KeepAlive : & ngfAPIv1alpha1.ClientKeepAlive {
161
+ Timeout : & ngfAPIv1alpha1.ClientKeepAliveTimeout {
162
+ Server : helpers.GetPointer [ngfAPIv1alpha1.Duration ]("5s" ),
163
+ Header : helpers.GetPointer [ngfAPIv1alpha1.Duration ]("2s" ),
164
+ },
165
+ },
166
+ },
167
+ },
168
+ {
169
+ name : "Validate Header cannot be set without Server" ,
170
+ wantErrors : []string {expectedHeaderWithoutServerError },
171
+ policySpec : ngfAPIv1alpha1.ClientSettingsPolicySpec {
172
+ TargetRef : gatewayv1alpha2.LocalPolicyTargetReference {
173
+ Kind : gatewayKind ,
174
+ Group : gatewayGroup ,
175
+ },
176
+ KeepAlive : & ngfAPIv1alpha1.ClientKeepAlive {
177
+ Timeout : & ngfAPIv1alpha1.ClientKeepAliveTimeout {
178
+ Header : helpers.GetPointer [ngfAPIv1alpha1.Duration ]("2s" ),
179
+ },
180
+ },
181
+ },
182
+ },
183
+ }
184
+
185
+ for _ , tt := range tests {
186
+ t .Run (tt .name , func (t * testing.T ) {
187
+ t .Parallel ()
188
+ validateClientSettingsPolicy (t , tt , g , k8sClient )
189
+ })
190
+ }
191
+ }
192
+
132
193
func validateClientSettingsPolicy (t * testing.T , tt struct {
133
194
policySpec ngfAPIv1alpha1.ClientSettingsPolicySpec
134
195
name string
0 commit comments