Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Haytham Abuelfutuh <[email protected]>
  • Loading branch information
EngHabu committed Feb 27, 2021
1 parent 503f889 commit 954416e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/auth/cookie_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func NewCookieManager(ctx context.Context, hashKeyEncoded, blockKeyEncoded strin
if err != nil {
return CookieManager{}, errors.Wrapf(ErrB64Decoding, err, "Error decoding hash key bytes")
}

blockKey, err := base64.RawStdEncoding.DecodeString(blockKeyEncoded)
if err != nil {
return CookieManager{}, errors.Wrapf(ErrB64Decoding, err, "Error decoding block key bytes")
Expand Down
11 changes: 9 additions & 2 deletions pkg/auth/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,19 @@ func TestGetHTTPRequestCookieToMetadataHandler(t *testing.T) {
assert.NoError(t, err)
mockAuthCtx := mocks.AuthenticationContext{}
mockAuthCtx.On("CookieManager").Return(&cookieManager)
mockAuthCtx.OnOptions().Return(config.OAuthOptions{})
handler := GetHTTPRequestCookieToMetadataHandler(&mockAuthCtx)
req, err := http.NewRequest("GET", "/api/v1/projects", nil)
assert.NoError(t, err)
jwtCookie, err := NewSecureCookie(accessTokenCookieName, "a.b.c", cookieManager.hashKey, cookieManager.blockKey)

accessTokenCookie, err := NewSecureCookie(accessTokenCookieName, "a.b.c", cookieManager.hashKey, cookieManager.blockKey)
assert.NoError(t, err)
req.AddCookie(&accessTokenCookie)

idCookie, err := NewSecureCookie(idTokenCookieName, "a.b.c", cookieManager.hashKey, cookieManager.blockKey)
assert.NoError(t, err)
req.AddCookie(&jwtCookie)
req.AddCookie(&idCookie)

assert.Equal(t, "Bearer a.b.c", handler(ctx, req)["authorization"][0])
}

Expand Down

0 comments on commit 954416e

Please sign in to comment.