Пример #1
0
func TestHttp_configsSettingAll(t *testing.T) {

	http := httpModForTests()
	config := new(config.Http)

	// Assign config vars
	config.Ports = []int{80, 8080}

	trueVar := true
	config.SendRequest = &trueVar
	config.SendResponse = &trueVar
	config.Hide_keywords = []string{"a", "b"}
	config.Redact_authorization = &trueVar
	config.Send_all_headers = &trueVar
	config.Split_cookie = &trueVar
	realIPHeader := "X-Forwarded-For"
	config.Real_ip_header = &realIPHeader

	// Set config
	http.setFromConfig(*config)

	// Check if http config is set correctly
	assert.Equal(t, config.Ports, http.Ports)
	assert.Equal(t, config.Ports, http.GetPorts())
	assert.Equal(t, *config.SendRequest, http.SendRequest)
	assert.Equal(t, *config.SendResponse, http.SendResponse)
	assert.Equal(t, config.Hide_keywords, http.HideKeywords)
	assert.Equal(t, *config.Redact_authorization, http.RedactAuthorization)
	assert.True(t, http.parserConfig.SendHeaders)
	assert.True(t, http.parserConfig.SendAllHeaders)
	assert.Equal(t, *config.Split_cookie, http.SplitCookie)
	assert.Equal(t, strings.ToLower(*config.Real_ip_header), http.parserConfig.RealIPHeader)
}
Пример #2
0
func TestHttp_configsSettingHeaders(t *testing.T) {

	http := httpModForTests()
	config := new(config.Http)

	// Assign config vars
	config.Send_headers = []string{"a", "b", "c"}

	// Set config
	http.setFromConfig(*config)

	// Check if http config is set correctly
	assert.True(t, http.parserConfig.SendHeaders)
	assert.Equal(t, len(config.Send_headers), len(http.parserConfig.HeadersWhitelist))

	for _, val := range http.parserConfig.HeadersWhitelist {
		assert.True(t, val)
	}
}