Add tests for tags with custom values (#11686)

* Add tests for tags with custom values

* Fix typo in comments
This commit is contained in:
Erlison Santos 2024-07-26 20:08:22 -03:00 committed by Ricardo Katz
parent c8328ff133
commit 69a3a4d6d2

View file

@ -63,14 +63,61 @@ func TestCrossplaneTemplate(t *testing.T) {
require.NoError(t, err)
require.NoError(t, mimeFile.Close())
t.Run("it should be able to marshall and unmarshall the current configuration", func(t *testing.T) {
tplConfig := &config.TemplateConfig{
Cfg: config.NewDefault(),
}
tpl := crossplane.NewTemplate()
t.Run("it should be able to marshall and unmarshall the default configuration", func(t *testing.T) {
tplConfig.Cfg.DefaultSSLCertificate = defaultCertificate
tplConfig.Cfg.EnableBrotli = true
tplConfig.Cfg.HideHeaders = []string{"x-fake-header", "x-another-fake-header"}
tpl := crossplane.NewTemplate()
tpl.SetMimeFile(mimeFile.Name())
content, err := tpl.Write(tplConfig)
require.NoError(t, err)
tmpFile, err := os.CreateTemp("", "")
require.NoError(t, err)
_, err = tmpFile.Write(content)
require.NoError(t, err)
require.NoError(t, tmpFile.Close())
_, err = ngx_crossplane.Parse(tmpFile.Name(), &options)
require.NoError(t, err)
})
t.Run("it should be able to marshall and unmarshall the specified configuration", func(t *testing.T) {
tplConfig.Cfg.DefaultSSLCertificate = defaultCertificate
tplConfig.Cfg.UseProxyProtocol = true
tplConfig.Cfg.GRPCBufferSizeKb = 10 // default 0
tplConfig.Cfg.HTTP2MaxHeaderSize = "10" // default ""
tplConfig.Cfg.HTTP2MaxFieldSize = "10" // default ""
tplConfig.Cfg.HTTP2MaxRequests = 1 // default 0
tplConfig.Cfg.UseGzip = true // default false
tplConfig.Cfg.GzipDisable = "enable"
tplConfig.Cfg.ShowServerTokens = true // default false
tplConfig.Cfg.DisableAccessLog = false // TODO: test true
tplConfig.Cfg.DisableHTTPAccessLog = false
tplConfig.Cfg.EnableSyslog = true
tplConfig.Cfg.SyslogHost = "localhost"
// Example: openssl rand 80 | openssl enc -A -base64
tplConfig.Cfg.SSLSessionTicketKey = "lOj3+7Xe21K9GapKqqPIw/gCQm5S4C2lK8pVne6drEik0QqOQHAw1AaPSMdbAvXx2zZKKPCEG98+g3hzftmrfnePSIvokIIE+hHto3Kj1HQ="
tplConfig.Cfg.CustomHTTPErrors = []int{1024, 2048}
tplConfig.Cfg.AllowBackendServerHeader = true // default false
tplConfig.Cfg.BlockCIDRs = []string{"192.168.0.0/24", " 200.200.0.0/16 "} // default 0
tplConfig.Cfg.BlockUserAgents = []string{"someuseragent", " another/user-agent "} // default 0
tpl = crossplane.NewTemplate()
tpl.SetMimeFile(mimeFile.Name())
content, err := tpl.Write(tplConfig)
require.NoError(t, err)