Skip to content

Commit

Permalink
Merge pull request #79 from nginxinc/way-nlb-4175
Browse files Browse the repository at this point in the history
fix: add missing zone_sync_ssl_conf_command directive
  • Loading branch information
dylan-way authored Jan 11, 2024
2 parents fb99b89 + 0a13f34 commit 7dbe9ae
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 0 deletions.
3 changes: 3 additions & 0 deletions analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -2370,6 +2370,9 @@ var directives = map[string][]uint{
"zone_sync_ssl_ciphers": {
ngxStreamMainConf | ngxStreamSrvConf | ngxConfTake1,
},
"zone_sync_ssl_conf_command": {
ngxStreamMainConf | ngxStreamSrvConf | ngxConfTake2,
},
"zone_sync_ssl_crl": {
ngxStreamMainConf | ngxStreamSrvConf | ngxConfTake1,
},
Expand Down
134 changes: 134 additions & 0 deletions analyze_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,140 @@ func TestAnalyzeFlagArgs(t *testing.T) {
})
}

//nolint:funlen
func TestAnalyze_zone_sync(t *testing.T) {
t.Parallel()
testcases := map[string]struct {
stmt *Directive
ctx blockCtx
wantErr bool
}{
"zone_sync in stream server context ok": {
&Directive{
Directive: "zone_sync",
Args: []string{},
Line: 5,
},
blockCtx{"stream", "server"},
false,
},
"zone_sync invalid context": {
&Directive{
Directive: "zone_sync",
Args: []string{},
Line: 5,
},
blockCtx{"stream"},
true,
},
"zone_sync invalid args": {
&Directive{
Directive: "zone_sync",
Args: []string{"invalid"},
Line: 5,
},
blockCtx{"stream", "server"},
true,
},
"zone_sync_ssl in stream context ok": {
&Directive{
Directive: "zone_sync_ssl",
Args: []string{"off"},
Line: 5,
},
blockCtx{"stream"},
false,
},
"zone_sync_ssl in stream server context ok": {
&Directive{
Directive: "zone_sync_ssl",
Args: []string{"on"},
Line: 5,
},
blockCtx{"stream", "server"},
false,
},
"zone_sync_ssl invalid context": {
&Directive{
Directive: "zone_sync_ssl",
Args: []string{"off"},
Line: 5,
},
blockCtx{"http"},
true,
},
"zone_sync_ssl invalid args": {
&Directive{
Directive: "zone_sync_ssl",
Args: []string{"invalid"},
Line: 5,
},
blockCtx{"stream"},
true,
},
"zone_sync_ssl_conf_command in stream context ok": {
&Directive{
Directive: "zone_sync_ssl_conf_command",
Args: []string{"somename", "somevalue"},
Line: 5,
},
blockCtx{"stream"},
false,
},
"zone_sync_ssl_conf_command in stream server context ok": {
&Directive{
Directive: "zone_sync_ssl_conf_command",
Args: []string{"somename", "somevalue"},
Line: 5,
},
blockCtx{"stream", "server"},
false,
},
"zone_sync_ssl_conf_command invalid context": {
&Directive{
Directive: "zone_sync_ssl_conf_command",
Args: []string{"somename", "somevalue"},
Line: 5,
},
blockCtx{"http", "server"},
true,
},
"zone_sync_ssl_conf_command missing one arg": {
&Directive{
Directive: "zone_sync_ssl_conf_command",
Args: []string{"somename"},
Line: 5,
},
blockCtx{"stream", "server"},
true,
},
"zone_sync_ssl_conf_command missing both args": {
&Directive{
Directive: "zone_sync_ssl_conf_command",
Args: []string{},
Line: 5,
},
blockCtx{"stream", "server"},
true,
},
}

for name, tc := range testcases {
tc := tc
t.Run(name, func(t *testing.T) {
t.Parallel()
err := analyze("nginx.conf", tc.stmt, ";", tc.ctx, &ParseOptions{})
if !tc.wantErr && err != nil {
t.Fatal(err)
}

if tc.wantErr && err == nil {
t.Fatal("expected error, got nil")
}
})
}
}

func TestAnalyze_nap_app_protect_enable(t *testing.T) {
t.Parallel()
testcases := map[string]struct {
Expand Down

0 comments on commit 7dbe9ae

Please sign in to comment.