diff --git a/.gitignore b/.gitignore index 397b4a7..cfd3b2d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.log +bats_tests/0_config diff --git a/bats_tests/0_config.example b/bats_tests/0_config.example new file mode 100644 index 0000000..d95a242 --- /dev/null +++ b/bats_tests/0_config.example @@ -0,0 +1,4 @@ +#!/bin/bash + +# trusted users that can control Docker daemon +config_trusted_users=(vagrant docker ubuntu) diff --git a/bats_tests/1_host_configuration.bats b/bats_tests/1_host_configuration.bats index 6ed2e6e..034c9ef 100644 --- a/bats_tests/1_host_configuration.bats +++ b/bats_tests/1_host_configuration.bats @@ -1,5 +1,6 @@ #!/usr/bin/env bats +load "0_config" load "test_helper/bats-support/load" load "test_helper/bats-assert/load" load "$BATS_TEST_DIRNAME/../helper_lib.sh" @@ -45,12 +46,11 @@ load "$BATS_TEST_DIRNAME/../helper_lib.sh" # 1.6 @test "1.6 - Only allow trusted users to control Docker daemon" { - declare -a trusted_users=("vagrant" "docker" "ubuntu") users_string=$(awk -F':' '/^docker/{print $4}' /etc/group) docker_users=(${users_string//,/ }) for u in "${docker_users[@]}"; do local found=1 - for tu in "${trusted_users[@]}"; do + for tu in "${config_trusted_users[@]}"; do if [ "$u" = "$tu" ]; then found=0 fi