github.com/dmaizel/tests@v0.0.0-20210728163746-cae6a2d9cee8/integration/kubernetes/k8s-security-context.bats (about) 1 #!/usr/bin/env bats 2 # 3 # Copyright (c) 2018 Intel Corporation 4 # 5 # SPDX-License-Identifier: Apache-2.0 6 # 7 8 load "${BATS_TEST_DIRNAME}/../../.ci/lib.sh" 9 load "${BATS_TEST_DIRNAME}/tests_common.sh" 10 11 setup() { 12 export KUBECONFIG="${KUBECONFIG:-$HOME/.kube/config}" 13 get_pod_config_dir 14 } 15 16 @test "Security context" { 17 pod_name="security-context-test" 18 19 # Create pod 20 kubectl create -f "${pod_config_dir}/pod-security-context.yaml" 21 22 # Check pod creation 23 kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name" 24 25 # Check user 26 cmd="ps --user 1000 -f" 27 process="tail -f /dev/null" 28 kubectl exec $pod_name -- sh -c $cmd | grep "$process" 29 } 30 31 teardown() { 32 # Debugging information 33 kubectl describe "pod/$pod_name" 34 35 kubectl delete pod "$pod_name" 36 }