MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / TestValidateAPICreds

Function TestValidateAPICreds

pkg/credentials/credentials_test.go:25–49  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23)
24
25func 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
51func TestValidateOCIKeyPair(t *testing.T) {
52 assert := assert.New(t)

Callers

nothing calls this directly

Calls 3

ErrorMethod · 0.65
RunMethod · 0.45
ValidateMethod · 0.45

Tested by

no test coverage detected