1
0
Fork 0
forked from forgejo/forgejo

Revert "[GITEA] rework long-term authentication"

This reverts commit 8d2dab94a6.
This commit is contained in:
Earl Warren 2024-01-16 14:11:28 +00:00
parent fd098cf75b
commit d694579bdf
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
17 changed files with 156 additions and 367 deletions

View file

@ -4,6 +4,8 @@
package util
import (
"crypto/aes"
"crypto/rand"
"fmt"
"os"
"testing"
@ -35,3 +37,21 @@ func TestCopyFile(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, testContent, dstContent)
}
func TestAESGCM(t *testing.T) {
t.Parallel()
key := make([]byte, aes.BlockSize)
_, err := rand.Read(key)
assert.NoError(t, err)
plaintext := []byte("this will be encrypted")
ciphertext, err := AESGCMEncrypt(key, plaintext)
assert.NoError(t, err)
decrypted, err := AESGCMDecrypt(key, ciphertext)
assert.NoError(t, err)
assert.Equal(t, plaintext, decrypted)
}