upda/util/encryption_test.go
Varakh 3532af74f2
All checks were successful
/ build (push) Successful in 3m37s
feat(actions): Add actions and secrets (with proper asynchronous enqueue and dequeue mechanism) (#22)
Reviewed-on: #22
Co-authored-by: Varakh <varakh@varakh.de>
Co-committed-by: Varakh <varakh@varakh.de>
2024-04-26 12:37:50 +00:00

37 lines
704 B
Go

package util
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestEncryptsAndDecrypts(t *testing.T) {
a := assert.New(t)
testSecret := "mysecretpassword"
testText := "the super secret text"
encrypted, err := EncryptAndEncode(testText, testSecret)
a.Nil(err)
a.NotEmpty(encrypted)
a.NotEqual(testText, encrypted)
decrypted, err := DecryptAndDecode(encrypted, testSecret)
a.Nil(err)
a.Equal(testText, decrypted)
}
func TestEncodeAndDecode(t *testing.T) {
a := assert.New(t)
s := "my to be encoded value"
encoded, err := ConvertToBase64([]byte(s))
a.Nil(err)
a.NotEmpty(encoded)
decoded, err := ConvertFromBase64(encoded)
a.Nil(err)
a.Equal(s, string(decoded))
}