@@ -132,6 +132,7 @@ func TestGenerate(t *testing.T) {
132
132
graph .PlusReportClientSSLCertificate : []byte ("cert" ),
133
133
graph .PlusReportClientSSLKey : []byte ("key" ),
134
134
},
135
+ NginxPlus : dataplane.NginxPlus {AllowedAddresses : []string {"127.0.0.3" , "25.0.0.3" }},
135
136
}
136
137
g := NewWithT (t )
137
138
@@ -144,7 +145,7 @@ func TestGenerate(t *testing.T) {
144
145
145
146
files := generator .Generate (conf )
146
147
147
- g .Expect (files ).To (HaveLen (17 ))
148
+ g .Expect (files ).To (HaveLen (18 ))
148
149
arrange := func (i , j int ) bool {
149
150
return files [i ].Path < files [j ].Path
150
151
}
@@ -155,6 +156,7 @@ func TestGenerate(t *testing.T) {
155
156
/etc/nginx/conf.d/config-version.conf
156
157
/etc/nginx/conf.d/http.conf
157
158
/etc/nginx/conf.d/matches.json
159
+ /etc/nginx/conf.d/plus-api.conf
158
160
/etc/nginx/includes/http_snippet1.conf
159
161
/etc/nginx/includes/http_snippet2.conf
160
162
/etc/nginx/includes/main_snippet1.conf
@@ -196,65 +198,76 @@ func TestGenerate(t *testing.T) {
196
198
g .Expect (httpCfg ).To (ContainSubstring ("include /etc/nginx/includes/http_snippet2.conf;" ))
197
199
198
200
g .Expect (files [2 ].Path ).To (Equal ("/etc/nginx/conf.d/matches.json" ))
199
-
200
201
g .Expect (files [2 ].Type ).To (Equal (file .TypeRegular ))
201
202
expString := "{}"
202
203
g .Expect (string (files [2 ].Content )).To (Equal (expString ))
203
204
205
+ g .Expect (files [3 ].Path ).To (Equal ("/etc/nginx/conf.d/plus-api.conf" ))
206
+ g .Expect (files [3 ].Type ).To (Equal (file .TypeRegular ))
207
+ httpCfg = string (files [3 ].Content )
208
+ g .Expect (httpCfg ).To (ContainSubstring ("listen unix:/var/run/nginx/nginx-plus-api.sock;" ))
209
+ g .Expect (httpCfg ).To (ContainSubstring ("access_log off;" ))
210
+ g .Expect (httpCfg ).To (ContainSubstring ("listen 8765;" ))
211
+ g .Expect (httpCfg ).To (ContainSubstring ("root /usr/share/nginx/html;" ))
212
+ g .Expect (httpCfg ).To (ContainSubstring ("allow 127.0.0.3;" ))
213
+ g .Expect (httpCfg ).To (ContainSubstring ("allow 25.0.0.3;" ))
214
+ g .Expect (httpCfg ).To (ContainSubstring ("deny all;" ))
215
+ g .Expect (httpCfg ).To (ContainSubstring ("location = /dashboard.html {}" ))
216
+
204
217
// snippet include files
205
218
// content is not checked in this test.
206
- g .Expect (files [3 ].Path ).To (Equal ("/etc/nginx/includes/http_snippet1.conf" ))
207
- g .Expect (files [4 ].Path ).To (Equal ("/etc/nginx/includes/http_snippet2.conf" ))
208
- g .Expect (files [5 ].Path ).To (Equal ("/etc/nginx/includes/main_snippet1.conf" ))
209
- g .Expect (files [6 ].Path ).To (Equal ("/etc/nginx/includes/main_snippet2.conf" ))
219
+ g .Expect (files [4 ].Path ).To (Equal ("/etc/nginx/includes/http_snippet1.conf" ))
220
+ g .Expect (files [5 ].Path ).To (Equal ("/etc/nginx/includes/http_snippet2.conf" ))
221
+ g .Expect (files [6 ].Path ).To (Equal ("/etc/nginx/includes/main_snippet1.conf" ))
222
+ g .Expect (files [7 ].Path ).To (Equal ("/etc/nginx/includes/main_snippet2.conf" ))
210
223
211
- g .Expect (files [7 ].Path ).To (Equal ("/etc/nginx/main-includes/deployment_ctx.json" ))
212
- deploymentCtx := string (files [7 ].Content )
224
+ g .Expect (files [8 ].Path ).To (Equal ("/etc/nginx/main-includes/deployment_ctx.json" ))
225
+ deploymentCtx := string (files [8 ].Content )
213
226
g .Expect (deploymentCtx ).To (ContainSubstring ("\" integration\" :\" ngf\" " ))
214
227
g .Expect (deploymentCtx ).To (ContainSubstring ("\" cluster_id\" :\" test-uid\" " ))
215
228
g .Expect (deploymentCtx ).To (ContainSubstring ("\" installation_id\" :\" test-uid-replicaSet\" " ))
216
229
g .Expect (deploymentCtx ).To (ContainSubstring ("\" cluster_node_count\" :1" ))
217
230
218
- g .Expect (files [8 ].Path ).To (Equal ("/etc/nginx/main-includes/main.conf" ))
219
- mainConfStr := string (files [8 ].Content )
231
+ g .Expect (files [9 ].Path ).To (Equal ("/etc/nginx/main-includes/main.conf" ))
232
+ mainConfStr := string (files [9 ].Content )
220
233
g .Expect (mainConfStr ).To (ContainSubstring ("load_module modules/ngx_otel_module.so;" ))
221
234
g .Expect (mainConfStr ).To (ContainSubstring ("include /etc/nginx/includes/main_snippet1.conf;" ))
222
235
g .Expect (mainConfStr ).To (ContainSubstring ("include /etc/nginx/includes/main_snippet2.conf;" ))
223
236
224
- g .Expect (files [9 ].Path ).To (Equal ("/etc/nginx/main-includes/mgmt.conf" ))
225
- mgmtConf := string (files [9 ].Content )
237
+ g .Expect (files [10 ].Path ).To (Equal ("/etc/nginx/main-includes/mgmt.conf" ))
238
+ mgmtConf := string (files [10 ].Content )
226
239
g .Expect (mgmtConf ).To (ContainSubstring ("usage_report endpoint=test-endpoint" ))
227
240
g .Expect (mgmtConf ).To (ContainSubstring ("license_token /etc/nginx/secrets/license.jwt" ))
228
241
g .Expect (mgmtConf ).To (ContainSubstring ("deployment_context /etc/nginx/main-includes/deployment_ctx.json" ))
229
242
g .Expect (mgmtConf ).To (ContainSubstring ("ssl_trusted_certificate /etc/nginx/secrets/mgmt-ca.crt" ))
230
243
g .Expect (mgmtConf ).To (ContainSubstring ("ssl_certificate /etc/nginx/secrets/mgmt-tls.crt" ))
231
244
g .Expect (mgmtConf ).To (ContainSubstring ("ssl_certificate_key /etc/nginx/secrets/mgmt-tls.key" ))
232
245
233
- g .Expect (files [10 ].Path ).To (Equal ("/etc/nginx/secrets/license.jwt" ))
234
- g .Expect (string (files [10 ].Content )).To (Equal ("license" ))
246
+ g .Expect (files [11 ].Path ).To (Equal ("/etc/nginx/secrets/license.jwt" ))
247
+ g .Expect (string (files [11 ].Content )).To (Equal ("license" ))
235
248
236
- g .Expect (files [11 ].Path ).To (Equal ("/etc/nginx/secrets/mgmt-ca.crt" ))
237
- g .Expect (string (files [11 ].Content )).To (Equal ("ca" ))
249
+ g .Expect (files [12 ].Path ).To (Equal ("/etc/nginx/secrets/mgmt-ca.crt" ))
250
+ g .Expect (string (files [12 ].Content )).To (Equal ("ca" ))
238
251
239
- g .Expect (files [12 ].Path ).To (Equal ("/etc/nginx/secrets/mgmt-tls.crt" ))
240
- g .Expect (string (files [12 ].Content )).To (Equal ("cert" ))
252
+ g .Expect (files [13 ].Path ).To (Equal ("/etc/nginx/secrets/mgmt-tls.crt" ))
253
+ g .Expect (string (files [13 ].Content )).To (Equal ("cert" ))
241
254
242
- g .Expect (files [13 ].Path ).To (Equal ("/etc/nginx/secrets/mgmt-tls.key" ))
243
- g .Expect (string (files [13 ].Content )).To (Equal ("key" ))
255
+ g .Expect (files [14 ].Path ).To (Equal ("/etc/nginx/secrets/mgmt-tls.key" ))
256
+ g .Expect (string (files [14 ].Content )).To (Equal ("key" ))
244
257
245
- g .Expect (files [14 ].Path ).To (Equal ("/etc/nginx/secrets/test-certbundle.crt" ))
246
- certBundle := string (files [14 ].Content )
258
+ g .Expect (files [15 ].Path ).To (Equal ("/etc/nginx/secrets/test-certbundle.crt" ))
259
+ certBundle := string (files [15 ].Content )
247
260
g .Expect (certBundle ).To (Equal ("test-cert" ))
248
261
249
- g .Expect (files [15 ]).To (Equal (file.File {
262
+ g .Expect (files [16 ]).To (Equal (file.File {
250
263
Type : file .TypeSecret ,
251
264
Path : "/etc/nginx/secrets/test-keypair.pem" ,
252
265
Content : []byte ("test-cert\n test-key" ),
253
266
}))
254
267
255
- g .Expect (files [16 ].Path ).To (Equal ("/etc/nginx/stream-conf.d/stream.conf" ))
256
- g .Expect (files [16 ].Type ).To (Equal (file .TypeRegular ))
257
- streamCfg := string (files [16 ].Content )
268
+ g .Expect (files [17 ].Path ).To (Equal ("/etc/nginx/stream-conf.d/stream.conf" ))
269
+ g .Expect (files [17 ].Type ).To (Equal (file .TypeRegular ))
270
+ streamCfg := string (files [17 ].Content )
258
271
g .Expect (streamCfg ).To (ContainSubstring ("listen unix:/var/run/nginx/app.example.com-443.sock" ))
259
272
g .Expect (streamCfg ).To (ContainSubstring ("listen 443" ))
260
273
g .Expect (streamCfg ).To (ContainSubstring ("app.example.com unix:/var/run/nginx/app.example.com-443.sock" ))
0 commit comments