Skip to content

Add field to NginxProxy to allow disabling HTTP2 #1925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Refactor test and fix docstring
  • Loading branch information
ciarams87 committed May 16, 2024
commit 1e021371fe145308958b1ab1282c53acb677a0c4
46 changes: 25 additions & 21 deletions internal/mode/static/nginx/config/base_http_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,43 @@ import (
)

func TestExecuteBaseHttp(t *testing.T) {
conf := dataplane.Configuration{
confOn := dataplane.Configuration{
BaseHTTPConfig: dataplane.BaseHTTPConfig{
HTTP2: true,
},
}

g := NewWithT(t)
expSubStrings := map[string]int{
"http2 on;": 1,
}

for expSubStr, expCount := range expSubStrings {
res := executeBaseHTTPConfig(conf)
g.Expect(res).To(HaveLen(1))
g.Expect(expCount).To(Equal(strings.Count(string(res[0].data), expSubStr)))
}
}

func TestExecuteBaseHttpEmpty(t *testing.T) {
conf := dataplane.Configuration{
confOff := dataplane.Configuration{
BaseHTTPConfig: dataplane.BaseHTTPConfig{
HTTP2: false,
},
}

g := NewWithT(t)
expSubStrings := map[string]int{
"http2 on;": 0,
expSubStr := "http2 on;"

tests := []struct {
name string
conf dataplane.Configuration
expCount int
}{
{
name: "http2 on",
conf: confOn,
expCount: 1,
},
{
name: "http2 off",
expCount: 0,
conf: confOff,
},
}

for expSubStr, expCount := range expSubStrings {
res := executeBaseHTTPConfig(conf)
for _, test := range tests {

g := NewWithT(t)

res := executeBaseHTTPConfig(test.conf)
g.Expect(res).To(HaveLen(1))
g.Expect(expCount).To(Equal(strings.Count(string(res[0].data), expSubStr)))
g.Expect(test.expCount).To(Equal(strings.Count(string(res[0].data), expSubStr)))
}
}
2 changes: 1 addition & 1 deletion internal/mode/static/state/dataplane/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,6 @@ type SpanAttribute struct {

// BaseHTTPConfig holds the configuration options at the http context.
type BaseHTTPConfig struct {
// HTTP2 specifies whether http2 should be enabled or disabled for all servers.
// HTTP2 specifies whether http2 should be enabled for all servers.
HTTP2 bool
}