MCPcopy Index your code
hub / github.com/getsops/sops / Test_encryptedKeyFromSecret

Function Test_encryptedKeyFromSecret

hcvault/keysource_test.go:328–353  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

326}
327
328func Test_encryptedKeyFromSecret(t *testing.T) {
329 tests := []struct {
330 name string
331 secret *api.Secret
332 want string
333 wantErr bool
334 }{
335 {name: "nil secret", secret: nil, wantErr: true},
336 {name: "secret with nil data", secret: &api.Secret{Data: nil}, wantErr: true},
337 {name: "secret without ciphertext data", secret: &api.Secret{Data: map[string]interface{}{"other": true}}, wantErr: true},
338 {name: "ciphertext non string", secret: &api.Secret{Data: map[string]interface{}{"ciphertext": 123}}, wantErr: true},
339 {name: "ciphertext data", secret: &api.Secret{Data: map[string]interface{}{"ciphertext": "secret string"}}, want: "secret string"},
340 }
341 for _, tt := range tests {
342 t.Run(tt.name, func(t *testing.T) {
343 got, err := encryptedKeyFromSecret(tt.secret)
344 if tt.wantErr {
345 assert.Error(t, err)
346 assert.Empty(t, got)
347 return
348 }
349 assert.NoError(t, err)
350 assert.Equal(t, tt.want, got)
351 })
352 }
353}
354
355func Test_dataKeyFromSecret(t *testing.T) {
356 tests := []struct {

Callers

nothing calls this directly

Calls 2

encryptedKeyFromSecretFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected