23 lines
509 B
Go
23 lines
509 B
Go
|
|
package shared
|
||
|
|
|
||
|
|
import (
|
||
|
|
"testing"
|
||
|
|
|
||
|
|
"github.com/stretchr/testify/assert"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestEncryptionClient(t *testing.T) {
|
||
|
|
|
||
|
|
client := encryptionClient{Secret: `abc&1*~#^2^#s0^=)^^7%b34`}
|
||
|
|
|
||
|
|
t.Run("encrypt/ decyrpt works", func(t *testing.T) {
|
||
|
|
text := "sample text to test encryption"
|
||
|
|
encodedText, err := client.Encrypt(text)
|
||
|
|
assert.NoError(t, err)
|
||
|
|
assert.NotEqual(t, text, encodedText)
|
||
|
|
decodedText, err := client.Decrypt(encodedText)
|
||
|
|
assert.NoError(t, err)
|
||
|
|
assert.Equal(t, text, decodedText)
|
||
|
|
})
|
||
|
|
}
|