MCPcopy Index your code
hub / github.com/coder/coder / requireEncryptedEquals

Function requireEncryptedEquals

enterprise/cli/server_dbcrypt_test.go:286–300  ·  view source on GitHub ↗
(t *testing.T, c dbcrypt.Cipher, expected, actual string)

Source from the content-addressed store, hash-verified

284}
285
286func requireEncryptedEquals(t *testing.T, c dbcrypt.Cipher, expected, actual string) {
287 t.Helper()
288 var decodedVal []byte
289 var err error
290 if _, ok := c.(*nullCipher); !ok {
291 decodedVal, err = base64.StdEncoding.DecodeString(actual)
292 require.NoError(t, err, "failed to decode base64 string")
293 } else {
294 // If a nullCipher is being used, we expect the value not to be encrypted.
295 decodedVal = []byte(actual)
296 }
297 val, err := c.Decrypt(decodedVal)
298 require.NoError(t, err, "failed to decrypt value")
299 require.Equal(t, expected, string(val))
300}
301
302func requireEncryptedWithCipher(ctx context.Context, t *testing.T, db database.Store, c dbcrypt.Cipher, userID uuid.UUID) {
303 t.Helper()

Callers 1

Calls 4

DecodeStringMethod · 0.80
HelperMethod · 0.65
DecryptMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected