MCPcopy
hub / github.com/caddyserver/caddy / TestInlineCAPoolUnmarshalCaddyfile

Function TestInlineCAPoolUnmarshalCaddyfile

modules/caddytls/capools_test.go:21–104  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19)
20
21func TestInlineCAPoolUnmarshalCaddyfile(t *testing.T) {
22 type args struct {
23 d *caddyfile.Dispenser
24 }
25 tests := []struct {
26 name string
27 args args
28 expected InlineCAPool
29 wantErr bool
30 }{
31 {
32 name: "configuring no certificatest produces an error",
33 args: args{
34 d: caddyfile.NewTestDispenser(`
35 inline {
36 }
37 `),
38 },
39 wantErr: true,
40 },
41 {
42 name: "configuring certificates as arguments in-line produces an error",
43 args: args{
44 d: caddyfile.NewTestDispenser(fmt.Sprintf(`
45 inline %s
46 `, test_der_1)),
47 },
48 wantErr: true,
49 },
50 {
51 name: "single cert",
52 args: args{
53 d: caddyfile.NewTestDispenser(fmt.Sprintf(`
54 inline {
55 trust_der %s
56 }
57 `, test_der_1)),
58 },
59 expected: InlineCAPool{
60 TrustedCACerts: []string{test_der_1},
61 },
62 wantErr: false,
63 },
64 {
65 name: "multiple certs in one line",
66 args: args{
67 d: caddyfile.NewTestDispenser(fmt.Sprintf(`
68 inline {
69 trust_der %s %s
70 }
71 `, test_der_1, test_der_1),
72 ),
73 },
74 expected: InlineCAPool{
75 TrustedCACerts: []string{test_der_1, test_der_1},
76 },
77 },
78 {

Callers

nothing calls this directly

Calls 2

UnmarshalCaddyfileMethod · 0.95
NewTestDispenserFunction · 0.92

Tested by

no test coverage detected