MCPcopy
hub / github.com/smallstep/cli / TestTrimURL

Function TestTrimURL

command/certificate/remote_test.go:11–40  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestTrimURL(t *testing.T) {
12 type newTest struct {
13 input, host string
14 isURL bool
15 err error
16 }
17 tests := map[string]newTest{
18 "true-http": {"https://smallstep.com", "smallstep.com:443", true, nil},
19 "true-tcp": {"tcp://smallstep.com:8080", "smallstep.com:8080", true, nil},
20 "true-tls": {"tls://smallstep.com/onboarding", "smallstep.com:443", true, nil},
21 "false": {"./certs/root_ca.crt", "", false, nil},
22 "false-err": {"https://google.com hello", "", false, errors.New("error parsing URL 'https://google.com hello'")},
23 "true-http-case": {"hTtPs://sMaLlStEp.cOm", "sMaLlStEp.cOm:443", true, nil},
24 }
25
26 for name, tc := range tests {
27 t.Run(name, func(t *testing.T) {
28 host, isURL, err := trimURL(tc.input)
29 assert.Equals(t, tc.host, host)
30 assert.Equals(t, tc.isURL, isURL)
31 if err != nil {
32 if assert.NotNil(t, tc.err) {
33 assert.HasPrefix(t, err.Error(), tc.err.Error())
34 }
35 } else {
36 assert.Nil(t, tc.err)
37 }
38 })
39 }
40}
41
42func TestGetPeerCertificateServerName(t *testing.T) {
43 host := "smallstep.com"

Callers

nothing calls this directly

Calls 3

trimURLFunction · 0.85
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…