|
778 | 778 | assert "$output" =~ "$mac2" "mac address from cli is set on custom interface"
|
779 | 779 | }
|
780 | 780 |
|
781 |
| -### Rootless unshare testins |
| 781 | +### Rootless unshare testing |
782 | 782 |
|
783 | 783 | @test "Podman unshare --rootless-netns with Pasta" {
|
784 | 784 | skip_if_remote "unshare is local-only"
|
|
794 | 794 | run_podman unshare --rootless-netns ip addr
|
795 | 795 | is "$output" ".*${pasta_iface}.*"
|
796 | 796 | }
|
| 797 | + |
| 798 | +# https://github.com/containers/podman/issues/22653 |
| 799 | +@test "pasta/bridge and host.containers.internal" { |
| 800 | + skip_if_no_ipv4 "IPv4 not routable on the host" |
| 801 | + pasta_ip="$(default_addr 4)" |
| 802 | + |
| 803 | + for network in "pasta" "bridge"; do |
| 804 | + # special exit code logic needed here, it is possible that there is no host.containers.internal |
| 805 | + # when there is only one ip one the host and that one is used by pasta. |
| 806 | + # As such we have to deal with both cases. |
| 807 | + run_podman '?' run --rm --network=$network $IMAGE grep host.containers.internal /etc/hosts |
| 808 | + if [ "$status" -eq 0 ]; then |
| 809 | + assert "$output" !~ "$pasta_ip" "pasta host ip must not be assigned ($network)" |
| 810 | + assert "$(hostname -I)" =~ "$(cut -f1 <<<$output)" "ip is one of the host ips ($network)" |
| 811 | + elif [ "$status" -eq 1 ]; then |
| 812 | + # if only pasta ip then we cannot have a host.containers.internal entry |
| 813 | + # make sure this fact is actually the case |
| 814 | + assert "$pasta_ip" == "$(hostname -I | tr -d '[:space:]')" "pasta ip must the only one one the host ($network)" |
| 815 | + else |
| 816 | + die "unexpected exit code '$status' from grep or podman ($network)" |
| 817 | + fi |
| 818 | + done |
| 819 | + |
| 820 | + host_ip=$(hostname -I | cut -f 1 -d " ") |
| 821 | + run_podman run --rm --network=pasta:-a,169.254.0.2,-g,169.254.0.1,-n,24 $IMAGE grep host.containers.internal /etc/hosts |
| 822 | + assert "$output" =~ "^$host_ip" "uses host first ip" |
| 823 | +} |
0 commit comments