aboutsummaryrefslogtreecommitdiff
path: root/test/podman_networking.bats
blob: b2196b4bc6462de5f1f7ab47cb9ad3838336d325 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bats

load helpers

function teardown() {
    cleanup_test
}

function setup() {
    copy_images
}

@test "test network connection with default bridge" {
    run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -dt ${ALPINE} wget www.yahoo.com
    echo "$output"
    [ "$status" -eq 0 ]
    run ${PODMAN_BINARY} ${PODMAN_OPTIONS} wait --latest
    echo "$output"
    [ "$status" -eq 0 ]
}

@test "test network connection with host" {
    run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -dt --network host ${ALPINE} wget www.yahoo.com
    echo "$output"
    [ "$status" -eq 0 ]
    run ${PODMAN_BINARY} ${PODMAN_OPTIONS} wait --latest
    echo "$output"
    [ "$status" -eq 0 ]
}

@test "expose port 222" {
    run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -dt --expose 222-223 ${ALPINE} /bin/sh
    echo "$output"
    [ "$status" -eq 0 ]
    run bash -c "iptables -t nat -L"
    echo "$output"
    [ "$status" -eq 0 ]
    run bash -c "iptables -t nat -L | grep 223"
    echo "$output"
    [ "$status" -eq 0 ]
}

@test "expose host port 80 to container port 8000" {
    run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -dt -p 80:8000 ${ALPINE} /bin/sh
    echo "$output"
    [ "$status" -eq 0 ]
    run bash -c "iptables -t nat -L | grep 8000"
    echo "$output"
    [ "$status" -eq 0 ]
}