mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2026-10-22 04:32:02 +02:00
Improvements to Session State code (#536)
* Drop SessionStateJSON wrapper * Use EncrpytInto/DecryptInto to reduce sessionstate Co-authored-by: Henry Jenkins <henry@henryjenkins.name>
This commit is contained in:
co-authored by
Henry Jenkins
parent
6a88da7f7a
commit
f7b28cb1d3
@@ -133,3 +133,25 @@ func TestEncodeAndDecodeAccessTokenB64(t *testing.T) {
|
||||
assert.NotEqual(t, token, encoded)
|
||||
assert.Equal(t, token, decoded)
|
||||
}
|
||||
|
||||
func TestEncodeIntoAndDecodeIntoAccessToken(t *testing.T) {
|
||||
const secret = "0123456789abcdefghijklmnopqrstuv"
|
||||
c, err := NewCipher([]byte(secret))
|
||||
assert.Equal(t, nil, err)
|
||||
|
||||
token := "my access token"
|
||||
originalToken := token
|
||||
|
||||
assert.Equal(t, nil, c.EncryptInto(&token))
|
||||
assert.NotEqual(t, originalToken, token)
|
||||
|
||||
assert.Equal(t, nil, c.DecryptInto(&token))
|
||||
assert.Equal(t, originalToken, token)
|
||||
|
||||
// Check no errors with empty or nil strings
|
||||
empty := ""
|
||||
assert.Equal(t, nil, c.EncryptInto(&empty))
|
||||
assert.Equal(t, nil, c.DecryptInto(&empty))
|
||||
assert.Equal(t, nil, c.EncryptInto(nil))
|
||||
assert.Equal(t, nil, c.DecryptInto(nil))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user