8000 Update tests · nginx/kubernetes-ingress@17355aa · GitHub
[go: up one dir, main page]

Skip to content

Commit 17355aa

Browse files
committed
Update tests
1 parent 06ed050 commit 17355aa

File tree

3 files changed

+39
-26
lines changed

3 files changed

+39
-26
lines changed

internal/configs/version1/template_test.go

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -679,12 +679,14 @@ func TestExecuteTemplate_ForMainForNGINXWithHTTP2On(t *testing.T) {
679679
}
680680

681681
wantDirectives := []string{
682+
"listen 443 ssl default_server;",
683+
"listen [::]:443 ssl default_server;",
682684
"http2 on;",
683685
}
684686

685687
unwantDirectives := []string{
686-
"listen 443 ssl http2",
687-
"listen [::]:443 ssl http2",
688+
"listen 443 ssl default_server http2;",
689+
"listen [::]:443 ssl default_server http2;",
688690
}
689691

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

717719
wantDirectives := []string{
720+
"listen 443 ssl default_server;",
721+
"listen [::]:443 ssl default_server;",
718722
"http2 on;",
719723
}
720724

721725
unwantDirectives := []string{
722-
"listen 443 ssl http2",
723-
"listen [::]:443 ssl http2",
726+
"listen 443 ssl default_server http2;",
727+
"listen [::]:443 ssl default_server http2;",
724728
}
725729

726730
mainConf := buf.String()
@@ -751,8 +755,8 @@ func TestExecuteTemplate_ForMainForNGINXWithHTTP2Off(t *testing.T) {
751755
}
752756

753757
wantDirectives := []string{
754-
"listen 443 ssl",
755-
"listen [::]:443 ssl",
758+
"listen 443 ssl default_server;",
759+
"listen [::]:443 ssl default_server;",
756760
}
757761

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

789793
wantDirectives := []string{
790-
"listen 443 ssl",
791-
"listen [::]:443 ssl",
794+
"listen 443 ssl default_server;",
795+
"listen [::]:443 ssl default_server;",
792796
}
793797

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

825829
wantDirectives := []string{
830+
"listen 443 ssl;",
831+
"listen [::]:443 ssl;",
826832
"http2 on;",
827833
}
828834

829835
unwantDirectives := []string{
830-
"listen 443 ssl http2",
831-
"listen [::]:443 ssl http2",
836+
"listen 443 ssl http2;",
837+
"listen [::]:443 ssl http2;",
832838
}
833839

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

860866
wantDirectives := []string{
867+
"listen 443 ssl;",
868+
"listen [::]:443 ssl;",
861869
"http2 on;",
862870
}
863871

864872
unwantDirectives := []string{
865-
"listen 443 ssl http2",
866-
"listen [::]:443 ssl http2",
873+
"listen 443 ssl http2;",
874+
"listen [::]:443 ssl http2;",
867875
}
868876

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

895903
wantDirectives := []string{
896-
"listen 443 ssl",
897-
"listen [::]:443 ssl",
904+
"listen 443 ssl;",
905+
"listen [::]:443 ssl;",
898906
}
899907

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

930938
wantDirectives := []string{
931-
"listen 443 ssl",
932-
"listen [::]:443 ssl",
939+
"listen 443 ssl;",
940+
"listen [::]:443 ssl;",
933941
}
934942

935943
unwantDirectives := []string{

internal/configs/version2/templates_test.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ func TestExecuteVirtualServerTemplate_RendersPlusTemplateWithHTTP2On(t *testing.
174174
t.Error(err)
175175
}
176176
wantStrings := []string{
177+
"listen 443 ssl proxy_protocol;",
178+
"listen [::]:443 ssl proxy_protocol;",
177179
"http2 on;",
178180
}
179181
for _, want := range wantStrings {
@@ -183,8 +185,8 @@ func TestExecuteVirtualServerTemplate_RendersPlusTemplateWithHTTP2On(t *testing.
183185
}
184186

185187
unwantStrings := []string{
186-
"listen 443 ssl http2",
187-
"listen [::]:443 ssl http2",
188+
"listen 443 ssl http2 proxy_protocol;",
189+
"listen [::]:443 ssl http2 proxy_protocol;",
188190
}
189191

190192
for _, want := range unwantStrings {
@@ -204,8 +206,8 @@ func TestExecuteVirtualServerTemplate_RendersPlusTemplateWithHTTP2Off(t *testing
204206
t.Error(err)
205207
}
206208
wantStrings := []string{
207-
"listen 443 ssl",
208-
"listen [::]:443 ssl",
209+
"listen 443 ssl proxy_protocol;",
210+
"listen [::]:443 ssl proxy_protocol;",
209211
}
210212
for _, want := range wantStrings {
211213
if !bytes.Contains(got, []byte(want)) {
@@ -234,6 +236,8 @@ func TestExecuteVirtualServerTemplate_RendersOSSTemplateWithHTTP2On(t *testing.T
234236
t.Error(err)
235237
}
236238
wantStrings := []string{
239+
"listen 443 ssl proxy_protocol;",
240+
"listen [::]:443 ssl proxy_protocol;",
237241
"http2 on;",
238242
}
239243
for _, want := range wantStrings {
@@ -243,8 +247,8 @@ func TestExecuteVirtualServerTemplate_RendersOSSTemplateWithHTTP2On(t *testing.T
243247
}
244248

245249
unwantStrings := []string{
246-
"listen 443 ssl http2",
247-
"listen [::]:443 ssl http2",
250+
"listen 443 ssl http2 proxy_protocol;",
251+
"listen [::]:443 ssl http2 proxy_protocol;",
248252
}
249253

250254
for _, want := range unwantStrings {
@@ -264,8 +268,8 @@ func TestExecuteVirtualServerTemplate_RendersOSSTemplateWithHTTP2Off(t *testing.
264268
t.Error(err)
265269
}
266270
wantStrings := []string{
267-
"listen 443 ssl",
268-
"listen [::]:443 ssl",
271+
"listen 443 ssl proxy_protocol;",
272+
"listen [::]:443 ssl proxy_protocol;",
269273
}
270274
for _, want := range wantStrings {
271275
if !bytes.Contains(got, []byte(want)) {

tests/suite/test_virtual_server_configmap_keys.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,14 @@ def assert_defaults_of_keys_with_validation_in_main_config(config, unexpected_va
114114
def assert_ssl_keys(config):
115115
# based on f"{TEST_DATA}/virtual-server-configmap-keys/configmap-ssl-keys.yaml"
116116
assert "if ($schema = 'http') {" not in config
117-
assert "listen 443 ssl http2 proxy_protocol;" in config
117+
assert "listen 443 ssl proxy_protocol;" in config
118+
assert "http2 on;" in config
118119

119120

120121
def assert_defaults_of_ssl_keys(config):
121122
assert "if ($schema = 'http') {" not in config
122123
assert "listen 443 ssl;" in config
123-
assert "http2" not in config
124+
assert "http2 on;" not in config
124125

125126

126127
@pytest.fixture(scope="function")

0 commit comments

Comments
 (0)
0