Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shaun-nx committed Oct 17, 2023
1 parent 06ed050 commit 17355aa
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 26 deletions.
40 changes: 24 additions & 16 deletions internal/configs/version1/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,12 +679,14 @@ func TestExecuteTemplate_ForMainForNGINXWithHTTP2On(t *testing.T) {
}

wantDirectives := []string{
"listen 443 ssl default_server;",
"listen [::]:443 ssl default_server;",
"http2 on;",
}

unwantDirectives := []string{
"listen 443 ssl http2",
"listen [::]:443 ssl http2",
"listen 443 ssl default_server http2;",
"listen [::]:443 ssl default_server http2;",
}

mainConf := buf.String()
Expand Down Expand Up @@ -715,12 +717,14 @@ func TestExecuteTemplate_ForMainForNGINXPlusWithHTTP2On(t *testing.T) {
}

wantDirectives := []string{
"listen 443 ssl default_server;",
"listen [::]:443 ssl default_server;",
"http2 on;",
}

unwantDirectives := []string{
"listen 443 ssl http2",
"listen [::]:443 ssl http2",
"listen 443 ssl default_server http2;",
"listen [::]:443 ssl default_server http2;",
}

mainConf := buf.String()
Expand Down Expand Up @@ -751,8 +755,8 @@ func TestExecuteTemplate_ForMainForNGINXWithHTTP2Off(t *testing.T) {
}

wantDirectives := []string{
"listen 443 ssl",
"listen [::]:443 ssl",
"listen 443 ssl default_server;",
"listen [::]:443 ssl default_server;",
}

unwantDirectives := []string{
Expand Down Expand Up @@ -787,8 +791,8 @@ func TestExecuteTemplate_ForMainForNGINXPlusWithHTTP2Off(t *testing.T) {
}

wantDirectives := []string{
"listen 443 ssl",
"listen [::]:443 ssl",
"listen 443 ssl default_server;",
"listen [::]:443 ssl default_server;",
}

unwantDirectives := []string{
Expand Down Expand Up @@ -823,12 +827,14 @@ func TestExecuteTemplate_ForIngressForNGINXPlusWithHTTP2On(t *testing.T) {
ingConf := buf.String()

wantDirectives := []string{
"listen 443 ssl;",
"listen [::]:443 ssl;",
"http2 on;",
}

unwantDirectives := []string{
"listen 443 ssl http2",
"listen [::]:443 ssl http2",
"listen 443 ssl http2;",
"listen [::]:443 ssl http2;",
}

for _, want := range wantDirectives {
Expand Down Expand Up @@ -858,12 +864,14 @@ func TestExecuteTemplate_ForIngressForNGINXWithHTTP2On(t *testing.T) {
ingConf := buf.String()

wantDirectives := []string{
"listen 443 ssl;",
"listen [::]:443 ssl;",
"http2 on;",
}

unwantDirectives := []string{
"listen 443 ssl http2",
"listen [::]:443 ssl http2",
"listen 443 ssl http2;",
"listen [::]:443 ssl http2;",
}

for _, want := range wantDirectives {
Expand Down Expand Up @@ -893,8 +901,8 @@ func TestExecuteTemplate_ForIngressForNGINXPlusWithHTTP2Off(t *testing.T) {
ingConf := buf.String()

wantDirectives := []string{
"listen 443 ssl",
"listen [::]:443 ssl",
"listen 443 ssl;",
"listen [::]:443 ssl;",
}

unwantDirectives := []string{
Expand Down Expand Up @@ -928,8 +936,8 @@ func TestExecuteTemplate_ForIngressForNGINXWithHTTP2Off(t *testing.T) {
ingConf := buf.String()

wantDirectives := []string{
"listen 443 ssl",
"listen [::]:443 ssl",
"listen 443 ssl;",
"listen [::]:443 ssl;",
}

unwantDirectives := []string{
Expand Down
20 changes: 12 additions & 8 deletions internal/configs/version2/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ func TestExecuteVirtualServerTemplate_RendersPlusTemplateWithHTTP2On(t *testing.
t.Error(err)
}
wantStrings := []string{
"listen 443 ssl proxy_protocol;",
"listen [::]:443 ssl proxy_protocol;",
"http2 on;",
}
for _, want := range wantStrings {
Expand All @@ -183,8 +185,8 @@ func TestExecuteVirtualServerTemplate_RendersPlusTemplateWithHTTP2On(t *testing.
}

unwantStrings := []string{
"listen 443 ssl http2",
"listen [::]:443 ssl http2",
"listen 443 ssl http2 proxy_protocol;",
"listen [::]:443 ssl http2 proxy_protocol;",
}

for _, want := range unwantStrings {
Expand All @@ -204,8 +206,8 @@ func TestExecuteVirtualServerTemplate_RendersPlusTemplateWithHTTP2Off(t *testing
t.Error(err)
}
wantStrings := []string{
"listen 443 ssl",
"listen [::]:443 ssl",
"listen 443 ssl proxy_protocol;",
"listen [::]:443 ssl proxy_protocol;",
}
for _, want := range wantStrings {
if !bytes.Contains(got, []byte(want)) {
Expand Down Expand Up @@ -234,6 +236,8 @@ func TestExecuteVirtualServerTemplate_RendersOSSTemplateWithHTTP2On(t *testing.T
t.Error(err)
}
wantStrings := []string{
"listen 443 ssl proxy_protocol;",
"listen [::]:443 ssl proxy_protocol;",
"http2 on;",
}
for _, want := range wantStrings {
Expand All @@ -243,8 +247,8 @@ func TestExecuteVirtualServerTemplate_RendersOSSTemplateWithHTTP2On(t *testing.T
}

unwantStrings := []string{
"listen 443 ssl http2",
"listen [::]:443 ssl http2",
"listen 443 ssl http2 proxy_protocol;",
"listen [::]:443 ssl http2 proxy_protocol;",
}

for _, want := range unwantStrings {
Expand All @@ -264,8 +268,8 @@ func TestExecuteVirtualServerTemplate_RendersOSSTemplateWithHTTP2Off(t *testing.
t.Error(err)
}
wantStrings := []string{
"listen 443 ssl",
"listen [::]:443 ssl",
"listen 443 ssl proxy_protocol;",
"listen [::]:443 ssl proxy_protocol;",
}
for _, want := range wantStrings {
if !bytes.Contains(got, []byte(want)) {
Expand Down
5 changes: 3 additions & 2 deletions tests/suite/test_virtual_server_configmap_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,14 @@ def assert_defaults_of_keys_with_validation_in_main_config(config, unexpected_va
def assert_ssl_keys(config):
# based on f"{TEST_DATA}/virtual-server-configmap-keys/configmap-ssl-keys.yaml"
assert "if ($schema = 'http') {" not in config
assert "listen 443 ssl http2 proxy_protocol;" in config
assert "listen 443 ssl proxy_protocol;" in config
assert "http2 on;" in config


def assert_defaults_of_ssl_keys(config):
assert "if ($schema = 'http') {" not in config
assert "listen 443 ssl;" in config
assert "http2" not in config
assert "http2 on;" not in config


@pytest.fixture(scope="function")
Expand Down

0 comments on commit 17355aa

Please sign in to comment.