Files
coder/coderd/httpapi/cookie_test.go
Steven Masley 9b5ee8f267 feat: Implement (but not enforce) CSRF for FE requests (#3786)
Future work is to enforce CSRF

Co-authored-by: Presley Pizzo <presley@coder.com>
2022-09-13 15:26:46 -04:00

36 lines
670 B
Go

package httpapi_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/coder/coder/coderd/httpapi"
)
func TestStripCoderCookies(t *testing.T) {
t.Parallel()
for _, tc := range []struct {
Input string
Output string
}{{
"testing=hello; wow=test",
"testing=hello; wow=test",
}, {
"coder_session_token=moo; wow=test",
"wow=test",
}, {
"another_token=wow; coder_session_token=ok",
"another_token=wow",
}, {
"coder_session_token=ok; oauth_state=wow; oauth_redirect=/",
"",
}} {
tc := tc
t.Run(tc.Input, func(t *testing.T) {
t.Parallel()
require.Equal(t, tc.Output, httpapi.StripCoderCookies(tc.Input))
})
}
}