Skip to content

Commit

Permalink
Add tests for loading TLS and mTLS TCP connections
Browse files Browse the repository at this point in the history
  • Loading branch information
meln5674 committed Dec 28, 2024
1 parent fe1108b commit 67a1b07
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion pkg/config/connections_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ var _ = Describe("Connections conf", func() {
})

Context("GetConnection/Farm", func() {
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"]}}}`
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"]}}}`
const defContainersConf = `
[engine]
active_service = "containers"
Expand Down Expand Up @@ -166,6 +166,24 @@ var _ = Describe("Connections conf", func() {
Destination: Destination{URI: "ssh://test", Identity: ".ssh/id", IsMachine: true},
}))

con, err = conf.GetConnection("TLS", false)
gomega.Expect(err).ToNot(gomega.HaveOccurred())
gomega.Expect(con).To(gomega.Equal(&Connection{
Name: "TLS",
Default: false,
ReadWrite: true,
Destination: Destination{URI: "tcp://podman.io:443", TLSCAFile: "/path/to/ca.pem"},
}))

con, err = conf.GetConnection("mTLS", false)
gomega.Expect(err).ToNot(gomega.HaveOccurred())
gomega.Expect(con).To(gomega.Equal(&Connection{
Name: "mTLS",
Default: false,
ReadWrite: true,
Destination: Destination{URI: "tcp://podman.io:443/subpath", TLSCAFile: "/path/to/ca.pem", TLSCertFile: "/path/to/tls.crt", TLSKeyFile: "/path/to/tls.key"},
}))

con, err = conf.GetConnection("containers", false)
gomega.Expect(err).ToNot(gomega.HaveOccurred())
gomega.Expect(con).To(gomega.Equal(&Connection{
Expand Down

0 comments on commit 67a1b07

Please sign in to comment.