Skip to content

Commit bdb93fc

Browse files
committed
Add back unit test
Signed-off-by: Jason Parraga <[email protected]>
1 parent 817854d commit bdb93fc

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

flyteadmin/auth/cookie_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,24 @@ func TestSecureCookieLifecycle(t *testing.T) {
7676
}
7777
}
7878

79+
func TestNewCsrfToken(t *testing.T) {
80+
// Generate many tokens and assert uniqueness and decodability
81+
const n = 1000
82+
seen := make(map[string]struct{}, n)
83+
84+
for i := 0; i < n; i++ {
85+
tok, err := NewCsrfToken()
86+
require.NoError(t, err)
87+
require.Len(t, tok, 44)
88+
89+
if _, ok := seen[tok]; ok {
90+
t.Fatalf("duplicate token generated at i=%d", i)
91+
}
92+
seen[tok] = struct{}{}
93+
}
94+
95+
}
96+
7997
func TestNewCsrfCookie(t *testing.T) {
8098
tests := []struct {
8199
name string

0 commit comments

Comments
 (0)