MCPcopy
hub / github.com/fabiolb/fabio / TestNewSource

Function TestNewSource

cert/source_test.go:73–166  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

71}
72
73func TestNewSource(t *testing.T) {
74 certsource := func(typ string) config.CertSource {
75 return config.CertSource{
76 Type: typ,
77 Name: "name",
78 CertPath: "cert",
79 KeyPath: "key",
80 ClientCAPath: "clientca",
81 CAUpgradeCN: "upgcn",
82 Refresh: 3 * time.Second,
83 Header: http.Header{"A": []string{"b"}},
84 }
85 }
86 tests := []struct {
87 desc string
88 cfg config.CertSource
89 src Source
90 err string
91 }{
92 {
93 desc: "invalid",
94 cfg: config.CertSource{
95 Type: "invalid",
96 },
97 src: nil,
98 err: `invalid certificate source "invalid"`,
99 },
100 {
101 desc: "file",
102 cfg: certsource("file"),
103 src: FileSource{
104 CertFile: "cert",
105 KeyFile: "key",
106 ClientAuthFile: "clientca",
107 CAUpgradeCN: "upgcn",
108 },
109 },
110 {
111 desc: "path",
112 cfg: certsource("path"),
113 src: PathSource{
114 CertPath: "cert",
115 ClientCAPath: "clientca",
116 CAUpgradeCN: "upgcn",
117 Refresh: 3 * time.Second,
118 },
119 },
120 {
121 desc: "http",
122 cfg: certsource("http"),
123 src: HTTPSource{
124 CertURL: "cert",
125 ClientCAURL: "clientca",
126 CAUpgradeCN: "upgcn",
127 Refresh: 3 * time.Second,
128 },
129 },
130 {

Callers

nothing calls this directly

Calls 2

NewSourceFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected