Skip to content

Commit cc079d8

Browse files
committed
Add tests for loading TLS and mTLS TCP connections
Signed-off-by: Andrew Melnick <[email protected]>
1 parent afc0b54 commit cc079d8

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

pkg/config/connections_test.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ var _ = Describe("Connections conf", func() {
105105
})
106106

107107
Context("GetConnection/Farm", func() {
108-
const defConnectionsConf = `{"Connection":{"Default":"test","Connections":{"test":{"URI":"ssh://podman.io"},"QA":{"URI":"ssh://test","Identity":".ssh/id","IsMachine":true}}},"farm":{"Default":"farm1","List":{"farm1":["test"]}}}`
108+
const defConnectionsConf = `{"Connection":{"Default":"test","Connections":{"test":{"URI":"ssh://podman.io"},"QA":{"URI":"ssh://test","Identity":".ssh/id","IsMachine":true},"TLS": {"URI": "tcp://podman.io:443", "TLSCAFile":"/path/to/ca.pem"},"mTLS":{"URI": "tcp://podman.io:443/subpath", "TLSCAFile": "/path/to/ca.pem", "TLSCertFile": "/path/to/tls.crt", "TLSKeyFile": "/path/to/tls.key"}}},"farm":{"Default":"farm1","List":{"farm1":["test"]}}}`
109109
const defContainersConf = `
110110
[engine]
111111
active_service = "containers"
@@ -158,6 +158,24 @@ var _ = Describe("Connections conf", func() {
158158
Destination: Destination{URI: "ssh://test", Identity: ".ssh/id", IsMachine: true},
159159
}))
160160

161+
con, err = conf.GetConnection("TLS", false)
162+
gomega.Expect(err).ToNot(gomega.HaveOccurred())
163+
gomega.Expect(con).To(gomega.Equal(&Connection{
164+
Name: "TLS",
165+
Default: false,
166+
ReadWrite: true,
167+
Destination: Destination{URI: "tcp://podman.io:443", TLSCAFile: "/path/to/ca.pem"},
168+
}))
169+
170+
con, err = conf.GetConnection("mTLS", false)
171+
gomega.Expect(err).ToNot(gomega.HaveOccurred())
172+
gomega.Expect(con).To(gomega.Equal(&Connection{
173+
Name: "mTLS",
174+
Default: false,
175+
ReadWrite: true,
176+
Destination: Destination{URI: "tcp://podman.io:443/subpath", TLSCAFile: "/path/to/ca.pem", TLSCertFile: "/path/to/tls.crt", TLSKeyFile: "/path/to/tls.key"},
177+
}))
178+
161179
con, err = conf.GetConnection("containers", false)
162180
gomega.Expect(err).ToNot(gomega.HaveOccurred())
163181
gomega.Expect(con).To(gomega.Equal(&Connection{

0 commit comments

Comments
 (0)