Archived
initial
This commit is contained in:
59 files changed
+11046
No files matched your search
@@ -0,0 +1,25 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestTokenCipherRoundTripAndRandomNonce(t *testing.T) {
|
||||
cipher, err := NewTokenCipher(bytes.Repeat([]byte{7}, 32))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
one, err := cipher.Encrypt("access-token")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
two, _ := cipher.Encrypt("access-token")
|
||||
if bytes.Equal(one, two) {
|
||||
t.Fatal("ciphertext reused a nonce")
|
||||
}
|
||||
plain, err := cipher.Decrypt(one)
|
||||
if err != nil || plain != "access-token" {
|
||||
t.Fatalf("round trip = %q, %v", plain, err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user