upda/util/encryption_test.go
Varakh 66800d26df 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-28 22:27:34 +02: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))
}