summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/e2e/network_create_test.go49
-rw-r--r--test/e2e/play_kube_test.go2
-rw-r--r--test/system/271-tcp-cors-server.bats44
3 files changed, 94 insertions, 1 deletions
diff --git a/test/e2e/network_create_test.go b/test/e2e/network_create_test.go
index 2bec88020..fb4a144fa 100644
--- a/test/e2e/network_create_test.go
+++ b/test/e2e/network_create_test.go
@@ -244,10 +244,59 @@ var _ = Describe("Podman network create", func() {
Expect(bridgePlugin.IPAM.Routes[0].Dest).To(Equal("::/0"))
Expect(bridgePlugin.IPAM.Routes[1].Dest).To(Equal("0.0.0.0/0"))
+ Expect(bridgePlugin.IPAM.Ranges).To(HaveLen(2))
+ Expect(bridgePlugin.IPAM.Ranges[0]).To(HaveLen(1))
+ Expect(bridgePlugin.IPAM.Ranges[0][0].Subnet).ToNot(BeEmpty())
+ Expect(bridgePlugin.IPAM.Ranges[1]).To(HaveLen(1))
+ Expect(bridgePlugin.IPAM.Ranges[1][0].Subnet).ToNot(BeEmpty())
+
+ _, subnet11, err := net.ParseCIDR(bridgePlugin.IPAM.Ranges[0][0].Subnet)
+ Expect(err).To(BeNil())
+ _, subnet12, err := net.ParseCIDR(bridgePlugin.IPAM.Ranges[1][0].Subnet)
+ Expect(err).To(BeNil())
+
// Once a container executes a new network, the nic will be created. We should clean those up
// best we can
defer removeNetworkDevice(bridgePlugin.BrName)
+ // create a second network to check the auto assigned ipv4 subnet does not overlap
+ // https://github.com/containers/podman/issues/11032
+ netName2 := "dual-" + stringid.GenerateNonCryptoID()
+ nc = podmanTest.Podman([]string{"network", "create", "--subnet", "fd00:6:3:2:1::/64", "--ipv6", netName2})
+ nc.WaitWithDefaultTimeout()
+ defer podmanTest.removeCNINetwork(netName2)
+ Expect(nc).Should(Exit(0))
+
+ // Inspect the network configuration
+ inspect = podmanTest.Podman([]string{"network", "inspect", netName2})
+ inspect.WaitWithDefaultTimeout()
+
+ // JSON the network configuration into something usable
+ err = json.Unmarshal([]byte(inspect.OutputToString()), &results)
+ Expect(err).To(BeNil())
+ result = results[0]
+ Expect(result["name"]).To(Equal(netName2))
+
+ // JSON the bridge info
+ bridgePlugin, err = genericPluginsToBridge(result["plugins"], "bridge")
+ Expect(err).To(BeNil())
+ Expect(bridgePlugin.IPAM.Routes[0].Dest).To(Equal("::/0"))
+ Expect(bridgePlugin.IPAM.Routes[1].Dest).To(Equal("0.0.0.0/0"))
+ Expect(bridgePlugin.IPAM.Ranges).To(HaveLen(2))
+ Expect(bridgePlugin.IPAM.Ranges[0]).To(HaveLen(1))
+ Expect(bridgePlugin.IPAM.Ranges[0][0].Subnet).ToNot(BeEmpty())
+ Expect(bridgePlugin.IPAM.Ranges[1]).To(HaveLen(1))
+ Expect(bridgePlugin.IPAM.Ranges[1][0].Subnet).ToNot(BeEmpty())
+
+ _, subnet21, err := net.ParseCIDR(bridgePlugin.IPAM.Ranges[0][0].Subnet)
+ Expect(err).To(BeNil())
+ _, subnet22, err := net.ParseCIDR(bridgePlugin.IPAM.Ranges[1][0].Subnet)
+ Expect(err).To(BeNil())
+
+ // check that the subnets do not overlap
+ Expect(subnet11.Contains(subnet21.IP)).To(BeFalse())
+ Expect(subnet12.Contains(subnet22.IP)).To(BeFalse())
+
try := podmanTest.Podman([]string{"run", "-it", "--rm", "--network", netName, ALPINE, "sh", "-c", "ip addr show eth0 | grep global | awk ' /inet6 / {print $2}'"})
try.WaitWithDefaultTimeout()
diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go
index 5e303bf2f..66bfdefe7 100644
--- a/test/e2e/play_kube_test.go
+++ b/test/e2e/play_kube_test.go
@@ -1729,7 +1729,7 @@ var _ = Describe("Podman play kube", func() {
})
It("podman play kube with pull policy of missing", func() {
- ctr := getCtr(withPullPolicy("missing"), withImage(BB))
+ ctr := getCtr(withPullPolicy("Missing"), withImage(BB))
err := generateKubeYaml("pod", getPod(withCtr(ctr)), kubeYaml)
Expect(err).To(BeNil())
diff --git a/test/system/271-tcp-cors-server.bats b/test/system/271-tcp-cors-server.bats
new file mode 100644
index 000000000..cdfa82e82
--- /dev/null
+++ b/test/system/271-tcp-cors-server.bats
@@ -0,0 +1,44 @@
+#!/usr/bin/env bats -*- bats -*-
+#
+# Tests podman system service CORS enabled
+#
+
+load helpers
+
+SERVICE_NAME="podman_test_$(random_string)"
+
+SERVICE_TCP_HOST="localhost"
+
+SERVICE_FILE="$UNIT_DIR/$SERVICE_NAME.service"
+SOCKET_FILE="$UNIT_DIR/$SERVICE_NAME.socket"
+
+@test "podman system service - tcp CORS" {
+ skip_if_remote "system service tests are meaningless over remote"
+ PORT=$(( ((RANDOM<<15)|RANDOM) % 63001 + 2000 ))
+ run_podman system service --cors="*" tcp:$SERVICE_TCP_HOST:$PORT -t 20 &
+ podman_pid="$!"
+ sleep 5s
+ run curl -s --max-time 10 -vvv $SERVICE_TCP_HOST:$PORT/_ping 2>&1
+ is "$output" ".*< Access-Control-Allow-Origin: \*.*" "access-control-allow-origin verifies CORS is set"
+ kill $podman_pid
+ wait $podman_pid || true
+}
+
+@test "podman system service - tcp without CORS" {
+ skip_if_remote "system service tests are meaningless over remote"
+ PORT=$(( ((RANDOM<<15)|RANDOM) % 63001 + 2000 ))
+ run_podman system service tcp:$SERVICE_TCP_HOST:$PORT -t 20 &
+ podman_pid="$!"
+ sleep 5s
+ (curl -s --max-time 10 -vvv $SERVICE_TCP_HOST:$PORT/_ping 2>&1 | grep -Eq "Access-Control-Allow-Origin:") && false || true
+ kill $podman_pid
+ wait $podman_pid || true
+}
+
+@test "podman system service - CORS enabled in logs" {
+ skip_if_remote "system service tests are meaningless over remote"
+ run_podman system service --log-level="debug" --cors="*" -t 1
+ is "$output" ".*CORS Headers were set to \*.*" "debug log confirms CORS headers set"
+}
+
+# vim: filetype=sh