MCPcopy Create free account
hub / github.com/supabase/auth / TestEncryptedStringPositive

Function TestEncryptedStringPositive

internal/crypto/crypto_test.go:80–104  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

78}
79
80func TestEncryptedStringPositive(t *testing.T) {
81 id := uuid.Must(uuid.NewV4()).String()
82
83 es, err := NewEncryptedString(id, []byte("data"), "key-id", "pwFoiPyybQMqNmYVN0gUnpbfpGQV2sDv9vp0ZAxi_Y4")
84 assert.NoError(t, err)
85
86 assert.Equal(t, es.KeyID, "key-id")
87 assert.Equal(t, es.Algorithm, "aes-gcm-hkdf")
88 assert.Len(t, es.Data, 20)
89 assert.Len(t, es.Nonce, 12)
90
91 dec := ParseEncryptedString(es.String())
92
93 assert.NotNil(t, dec)
94 assert.Equal(t, dec.Algorithm, "aes-gcm-hkdf")
95 assert.Len(t, dec.Data, 20)
96 assert.Len(t, dec.Nonce, 12)
97
98 decrypted, err := dec.Decrypt(id, map[string]string{
99 "key-id": "pwFoiPyybQMqNmYVN0gUnpbfpGQV2sDv9vp0ZAxi_Y4",
100 })
101
102 assert.NoError(t, err)
103 assert.Equal(t, []byte("data"), decrypted)
104}
105
106func TestParseEncryptedStringNegative(t *testing.T) {
107 negativeExamples := []string{

Callers

nothing calls this directly

Calls 5

StringMethod · 0.95
NewEncryptedStringFunction · 0.85
ParseEncryptedStringFunction · 0.85
EqualMethod · 0.80
DecryptMethod · 0.80

Tested by

no test coverage detected