Skip to content

Commit

Permalink
test that headers are present after opening krypto challenge
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Pickett committed Sep 23, 2024
1 parent 888643f commit ddc3ada
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ee/localserver/krypto-ec-middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ func TestKryptoEcMiddleware(t *testing.T) {
challengeData := []byte(ulid.New())

koldieSessionId := ulid.New()
cmdRequestHeaders := map[string][]string{
"some_key": {ulid.New()},
"other_key": {ulid.New()},
}

cmdReqCallBackHeaders := map[string][]string{
kolideSessionIdHeaderKey: {koldieSessionId},
}
Expand All @@ -44,6 +49,7 @@ func TestKryptoEcMiddleware(t *testing.T) {
cmdReq := mustMarshal(t, v2CmdRequestType{
Path: "whatevs",
Body: cmdReqBody,
Headers: cmdRequestHeaders,
CallbackHeaders: cmdReqCallBackHeaders,
})

Expand Down Expand Up @@ -143,6 +149,12 @@ func TestKryptoEcMiddleware(t *testing.T) {
// this should match the responseData in the opened response
if testHandler == nil {
testHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

// make sure all the request headers are present
for k, v := range cmdRequestHeaders {
require.Equal(t, v[0], r.Header.Get(k))
}

reqBodyRaw, err := io.ReadAll(r.Body)
require.NoError(t, err)
defer r.Body.Close()
Expand Down

0 comments on commit ddc3ada

Please sign in to comment.