Skip to content

Commit 7dbe9ae

Browse files
authored
Merge pull request #79 from nginxinc/way-nlb-4175
fix: add missing zone_sync_ssl_conf_command directive
2 parents fb99b89 + 0a13f34 commit 7dbe9ae

File tree

2 files changed

+137
-0
lines changed

2 files changed

+137
-0
lines changed

analyze.go

+3
Original file line numberDiff line numberDiff line change
@@ -2370,6 +2370,9 @@ var directives = map[string][]uint{
23702370
"zone_sync_ssl_ciphers": {
23712371
ngxStreamMainConf | ngxStreamSrvConf | ngxConfTake1,
23722372
},
2373+
"zone_sync_ssl_conf_command": {
2374+
ngxStreamMainConf | ngxStreamSrvConf | ngxConfTake2,
2375+
},
23732376
"zone_sync_ssl_crl": {
23742377
ngxStreamMainConf | ngxStreamSrvConf | ngxConfTake1,
23752378
},

analyze_test.go

+134
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,140 @@ func TestAnalyzeFlagArgs(t *testing.T) {
377377
})
378378
}
379379

380+
//nolint:funlen
381+
func TestAnalyze_zone_sync(t *testing.T) {
382+
t.Parallel()
383+
testcases := map[string]struct {
384+
stmt *Directive
385+
ctx blockCtx
386+
wantErr bool
387+
}{
388+
"zone_sync in stream server context ok": {
389+
&Directive{
390+
Directive: "zone_sync",
391+
Args: []string{},
392+
Line: 5,
393+
},
394+
blockCtx{"stream", "server"},
395+
false,
396+
},
397+
"zone_sync invalid context": {
398+
&Directive{
399+
Directive: "zone_sync",
400+
Args: []string{},
401+
Line: 5,
402+
},
403+
blockCtx{"stream"},
404+
true,
405+
},
406+
"zone_sync invalid args": {
407+
&Directive{
408+
Directive: "zone_sync",
409+
Args: []string{"invalid"},
410+
Line: 5,
411+
},
412+
blockCtx{"stream", "server"},
413+
true,
414+
},
415+
"zone_sync_ssl in stream context ok": {
416+
&Directive{
417+
Directive: "zone_sync_ssl",
418+
Args: []string{"off"},
419+
Line: 5,
420+
},
421+
blockCtx{"stream"},
422+
false,
423+
},
424+
"zone_sync_ssl in stream server context ok": {
425+
&Directive{
426+
Directive: "zone_sync_ssl",
427+
Args: []string{"on"},
428+
Line: 5,
429+
},
430+
blockCtx{"stream", "server"},
431+
false,
432+
},
433+
"zone_sync_ssl invalid context": {
434+
&Directive{
435+
Directive: "zone_sync_ssl",
436+
Args: []string{"off"},
437+
Line: 5,
438+
},
439+
blockCtx{"http"},
440+
true,
441+
},
442+
"zone_sync_ssl invalid args": {
443+
&Directive{
444+
Directive: "zone_sync_ssl",
445+
Args: []string{"invalid"},
446+
Line: 5,
447+
},
448+
blockCtx{"stream"},
449+
true,
450+
},
451+
"zone_sync_ssl_conf_command in stream context ok": {
452+
&Directive{
453+
Directive: "zone_sync_ssl_conf_command",
454+
Args: []string{"somename", "somevalue"},
455+
Line: 5,
456+
},
457+
blockCtx{"stream"},
458+
false,
459+
},
460+
"zone_sync_ssl_conf_command in stream server context ok": {
461+
&Directive{
462+
Directive: "zone_sync_ssl_conf_command",
463+
Args: []string{"somename", "somevalue"},
464+
Line: 5,
465+
},
466+
blockCtx{"stream", "server"},
467+
false,
468+
},
469+
"zone_sync_ssl_conf_command invalid context": {
470+
&Directive{
471+
Directive: "zone_sync_ssl_conf_command",
472+
Args: []string{"somename", "somevalue"},
473+
Line: 5,
474+
},
475+
blockCtx{"http", "server"},
476+
true,
477+
},
478+
"zone_sync_ssl_conf_command missing one arg": {
479+
&Directive{
480+
Directive: "zone_sync_ssl_conf_command",
481+
Args: []string{"somename"},
482+
Line: 5,
483+
},
484+
blockCtx{"stream", "server"},
485+
true,
486+
},
487+
"zone_sync_ssl_conf_command missing both args": {
488+
&Directive{
489+
Directive: "zone_sync_ssl_conf_command",
490+
Args: []string{},
491+
Line: 5,
492+
},
493+
blockCtx{"stream", "server"},
494+
true,
495+
},
496+
}
497+
498+
for name, tc := range testcases {
499+
tc := tc
500+
t.Run(name, func(t *testing.T) {
501+
t.Parallel()
502+
err := analyze("nginx.conf", tc.stmt, ";", tc.ctx, &ParseOptions{})
503+
if !tc.wantErr && err != nil {
504+
t.Fatal(err)
505+
}
506+
507+
if tc.wantErr && err == nil {
508+
t.Fatal("expected error, got nil")
509+
}
510+
})
511+
}
512+
}
513+
380514
func TestAnalyze_nap_app_protect_enable(t *testing.T) {
381515
t.Parallel()
382516
testcases := map[string]struct {

0 commit comments

Comments
 (0)