github.com/cozy/cozy-stack@v0.0.0-20240603063001-31110fa4cae1/pkg/crypto/utils_test.go (about)

     1  package crypto
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  	"github.com/stretchr/testify/require"
     8  )
     9  
    10  func TestGenerateRandomBytes(t *testing.T) {
    11  	val := GenerateRandomBytes(16)
    12  	assert.Len(t, val, 16)
    13  	assert.NotEmpty(t, string(val))
    14  }
    15  
    16  func TestEncoding(t *testing.T) {
    17  	for _, value := range testStrings {
    18  		encoded := Base64Encode([]byte(value))
    19  		decoded, err := Base64Decode(encoded)
    20  		require.NoError(t, err)
    21  
    22  		if !assert.Equal(t, value, string(decoded)) {
    23  			return
    24  		}
    25  	}
    26  }