MCPcopy
hub / github.com/oauth2-proxy/oauth2-proxy / TestEncodeAndDecodeAccessToken

Function TestEncodeAndDecodeAccessToken

pkg/encryption/cipher_test.go:13–28  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestEncodeAndDecodeAccessToken(t *testing.T) {
14 const secret = "0123456789abcdefghijklmnopqrstuv"
15 const token = "my access token"
16 cfb, err := NewCFBCipher([]byte(secret))
17 assert.NoError(t, err)
18 c := NewBase64Cipher(cfb)
19
20 encoded, err := c.Encrypt([]byte(token))
21 assert.Equal(t, nil, err)
22
23 decoded, err := c.Decrypt(encoded)
24 assert.Equal(t, nil, err)
25
26 assert.NotEqual(t, []byte(token), encoded)
27 assert.Equal(t, []byte(token), decoded)
28}
29
30func TestEncodeAndDecodeAccessTokenB64(t *testing.T) {
31 const secretBase64 = "A3Xbr6fu6Al0HkgrP1ztjb-mYiwmxgNPP-XbNsz1WBk="

Callers

nothing calls this directly

Calls 4

NewCFBCipherFunction · 0.85
NewBase64CipherFunction · 0.85
EncryptMethod · 0.65
DecryptMethod · 0.65

Tested by

no test coverage detected