-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
feat(lambda-promtail): Add possibility to set additional HTTP headers for promtail-client requests #11883
base: main
Are you sure you want to change the base?
feat(lambda-promtail): Add possibility to set additional HTTP headers for promtail-client requests #11883
Changes from all commits
8b1b53c
afef85c
f76a3fd
41c2897
082b8e9
fb6525f
250ad12
1e73dd9
8d90c10
6a8a19d
db32352
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,3 +64,33 @@ func TestLambdaPromtail_TestDropLabels(t *testing.T) { | |
require.NotContains(t, modifiedLabels, model.LabelName("A1")) | ||
require.Contains(t, modifiedLabels, model.LabelName("B2")) | ||
} | ||
|
||
func TestLambdaPromtail_ExtraHeadersValid(t *testing.T) { | ||
extraHeaders, err := parseExtraHeaders("X-Custom-Header,This!sATota\\yCu$t0mHe4der,My-Server_WantsThis,What_ever could go here?,Expected4Entry,yLKc+QSB5VF/Gp3VPN7oOxa98yxWMxeHOAo+CW6trow=") | ||
require.Nil(t, err) | ||
require.Len(t, extraHeaders, 3) | ||
require.Equal(t, extraHeaders["X-Custom-Header"], "This!sATota\\yCu$t0mHe4der") | ||
require.Equal(t, extraHeaders["My-Server_WantsThis"], "What_ever could go here?") | ||
require.Equal(t, extraHeaders["Expected4Entry"], "yLKc+QSB5VF/Gp3VPN7oOxa98yxWMxeHOAo+CW6trow=") | ||
} | ||
|
||
func TestLambdaPromtail_ExtraHeadersInvalidHeaderKey(t *testing.T) { | ||
extraHeaders, err := parseExtraHeaders("Th.s_Shou|d-Fa!l,a") | ||
require.Nil(t, extraHeaders) | ||
require.ErrorContains(t, err, "HTTP header key is invalid:") | ||
extraHeaders, err = parseExtraHeaders("Also Not Valid ,b") | ||
require.Nil(t, extraHeaders) | ||
require.ErrorContains(t, err, "HTTP header key is invalid:") | ||
} | ||
|
||
func TestLambdaPromtail_ExtraHeadersMissingValue(t *testing.T) { | ||
extraHeaders, err := parseExtraHeaders("A,a,B,b,C,c,D") | ||
require.Nil(t, extraHeaders) | ||
require.Errorf(t, err, invalidExtraHeadersError) | ||
} | ||
|
||
func TestLambdaPromtail_TestParseHeadersNoneProvided(t *testing.T) { | ||
extraLabels, err := parseExtraHeaders("") | ||
require.Len(t, extraLabels, 0) | ||
require.Nil(t, err) | ||
} | ||
Comment on lines
+68
to
+96
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lets simplify a bit and make this a table driven test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not really sure how a table driven test simplifies my test, but I am also not too experience with this kind of testing. Maybe you could give me a hint and what you had in mind here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rather than declaring 4 new tests, one for each of these success or failure scenarios, we would have one test with an array of input/expected output, see here https://go.dev/wiki/TableDrivenTests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @trc-ikeskin either the name here or on line 89 of the tests needs to change, I think
invalidExtraHeadersError
is enough