(t *testing.T)
| 353 | } |
| 354 | |
| 355 | func Test_dataKeyFromSecret(t *testing.T) { |
| 356 | tests := []struct { |
| 357 | name string |
| 358 | secret *api.Secret |
| 359 | want []byte |
| 360 | wantErr bool |
| 361 | }{ |
| 362 | {name: "nil secret", secret: nil, wantErr: true}, |
| 363 | {name: "secret with nil data", secret: &api.Secret{Data: nil}, wantErr: true}, |
| 364 | {name: "secret without plaintext data", secret: &api.Secret{Data: map[string]interface{}{"other": true}}, wantErr: true}, |
| 365 | {name: "plaintext non string", secret: &api.Secret{Data: map[string]interface{}{"plaintext": 123}}, wantErr: true}, |
| 366 | {name: "plaintext non base64", secret: &api.Secret{Data: map[string]interface{}{"plaintext": "notbase64"}}, wantErr: true}, |
| 367 | {name: "plaintext base64 data", secret: &api.Secret{Data: map[string]interface{}{"plaintext": "Zm9v"}}, want: []byte("foo")}, |
| 368 | } |
| 369 | for _, tt := range tests { |
| 370 | t.Run(tt.name, func(t *testing.T) { |
| 371 | got, err := dataKeyFromSecret(tt.secret) |
| 372 | if tt.wantErr { |
| 373 | assert.Error(t, err) |
| 374 | assert.Empty(t, got) |
| 375 | return |
| 376 | } |
| 377 | assert.NoError(t, err) |
| 378 | assert.Equal(t, tt.want, got) |
| 379 | }) |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | func Test_vaultClient(t *testing.T) { |
| 384 | t.Run("client", func(t *testing.T) { |
nothing calls this directly
no test coverage detected