From f6cdaa3d3d37ad4063ab25ea7476e3756270e3f5 Mon Sep 17 00:00:00 2001 From: Alexei Ledenev <alexei.led@gmail.com> Date: Wed, 18 May 2016 12:25:26 +0300 Subject: [PATCH] external test configuration can be specified in 0_config file; it's regular bash file (ignored by git), see '0_config.example' --- .gitignore | 1 + bats_tests/0_config.example | 4 ++++ bats_tests/1_host_configuration.bats | 4 ++-- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 bats_tests/0_config.example 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