Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test/system: Ensure that the user is part of a group with the same name, and the process started by 'podman exec' has all groups #1447

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
238 changes: 238 additions & 0 deletions test/system/206-user.bats
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ teardown() {
run --keep-empty-lines --separate-stderr "$TOOLBX" run cat /etc/group

assert_success
assert_line --regexp "^$USER:x:[[:digit:]]+:$USER$"
assert_line --regexp "^(sudo|wheel):x:[[:digit:]]+:$USER$"
assert [ ${#lines[@]} -gt 1 ]

Expand All @@ -447,6 +448,7 @@ teardown() {
run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro arch cat /etc/group

assert_success
assert_line --regexp "^$USER:x:[[:digit:]]+:$USER$"
assert_line --regexp "^wheel:x:[[:digit:]]+:$USER$"
assert [ ${#lines[@]} -gt 1 ]

Expand All @@ -460,6 +462,7 @@ teardown() {
run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro fedora --release 34 cat /etc/group

assert_success
assert_line --regexp "^$USER:x:[[:digit:]]+:$USER$"
assert_line --regexp "^wheel:x:[[:digit:]]+:$USER$"
assert [ ${#lines[@]} -gt 1 ]

Expand All @@ -473,6 +476,7 @@ teardown() {
run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro rhel --release 8.9 cat /etc/group

assert_success
assert_line --regexp "^$USER:x:[[:digit:]]+:$USER$"
assert_line --regexp "^wheel:x:[[:digit:]]+:$USER$"
assert [ ${#lines[@]} -gt 1 ]

Expand All @@ -486,6 +490,7 @@ teardown() {
run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro ubuntu --release 16.04 cat /etc/group

assert_success
assert_line --regexp "^$USER:x:[[:digit:]]+:$USER$"
assert_line --regexp "^sudo:x:[[:digit:]]+:$USER$"
assert [ ${#lines[@]} -gt 1 ]

Expand All @@ -499,6 +504,7 @@ teardown() {
run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro ubuntu --release 18.04 cat /etc/group

assert_success
assert_line --regexp "^$USER:x:[[:digit:]]+:$USER$"
assert_line --regexp "^sudo:x:[[:digit:]]+:$USER$"
assert [ ${#lines[@]} -gt 1 ]

Expand All @@ -512,9 +518,241 @@ teardown() {
run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro ubuntu --release 20.04 cat /etc/group

assert_success
assert_line --regexp "^$USER:x:[[:digit:]]+:$USER$"
assert_line --regexp "^sudo:x:[[:digit:]]+:$USER$"
assert [ ${#lines[@]} -gt 1 ]

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]
}

@test "user: id(1) for $USER inside the default container" {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests fail if I revert the crun fix. So, I suppose they serve their purpose.

create_default_container

run --keep-empty-lines --separate-stderr "$TOOLBX" run id

assert_success

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

local output_id="${lines[0]}"

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]

run --keep-empty-lines --separate-stderr "$TOOLBX" run id "$USER"

assert_success
assert_line --index 0 "$output_id"

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]
}

@test "user: id(1) for $USER inside Arch Linux" {
create_distro_container arch latest arch-toolbox-latest

run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro arch id

assert_success

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

local output_id="${lines[0]}"

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]

run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro arch id "$USER"

assert_success
assert_line --index 0 "$output_id"

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]
}

@test "user: id(1) for $USER inside Fedora 34" {
create_distro_container fedora 34 fedora-toolbox-34

run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro fedora --release 34 id

assert_success

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

local output_id="${lines[0]}"

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]

run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro fedora --release 34 id "$USER"

assert_success
assert_line --index 0 "$output_id"

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]
}

@test "user: id(1) for $USER inside RHEL 8.9" {
create_distro_container rhel 8.9 rhel-toolbox-8.9

run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro rhel --release 8.9 id

assert_success

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

local output_id="${lines[0]}"

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]

run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro rhel --release 8.9 id "$USER"

assert_success
assert_line --index 0 "$output_id"

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]
}

@test "user: id(1) for $USER inside Ubuntu 16.04" {
create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04

run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro ubuntu --release 16.04 id

assert_success

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

local output_id="${lines[0]}"

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]

run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro ubuntu --release 16.04 id "$USER"

assert_success
assert_line --index 0 "$output_id"

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]
}

@test "user: id(1) for $USER inside Ubuntu 18.04" {
create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04

run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro ubuntu --release 18.04 id

assert_success

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

local output_id="${lines[0]}"

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]

run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro ubuntu --release 18.04 id "$USER"

assert_success
assert_line --index 0 "$output_id"

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]
}

@test "user: id(1) for $USER inside Ubuntu 20.04" {
create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04

run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro ubuntu --release 20.04 id

assert_success

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

local output_id="${lines[0]}"

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]

run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro ubuntu --release 20.04 id "$USER"

assert_success
assert_line --index 0 "$output_id"

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]
}
Loading