| 23 | ) |
| 24 | |
| 25 | func TestValidateAPICreds(t *testing.T) { |
| 26 | assert := assert.New(t) |
| 27 | |
| 28 | testCases := []struct { |
| 29 | name string |
| 30 | input *credentials.APICreds |
| 31 | wantError bool |
| 32 | }{ |
| 33 | {"empty secret", &credentials.APICreds{}, true}, |
| 34 | {"missing host", &credentials.APICreds{Host: "", Key: "p"}, true}, |
| 35 | {"missing key", &credentials.APICreds{Host: "host", Key: ""}, true}, |
| 36 | {"valid creds", &credentials.APICreds{Host: "h", Key: "p"}, false}, |
| 37 | } |
| 38 | |
| 39 | for _, tc := range testCases { |
| 40 | t.Run(tc.name, func(t *testing.T) { |
| 41 | err := tc.input.Validate() |
| 42 | if tc.wantError { |
| 43 | assert.Error(err) |
| 44 | } else { |
| 45 | assert.NoError(err) |
| 46 | } |
| 47 | }) |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | func TestValidateOCIKeyPair(t *testing.T) { |
| 52 | assert := assert.New(t) |