github.com/kata-containers/tests@v0.0.0-20240307153542-772105b56064/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  	get_pod_config_dir
    13  }
    14  
    15  @test "Security context" {
    16  	pod_name="security-context-test"
    17  
    18  	# Create pod
    19  	kubectl create -f "${pod_config_dir}/pod-security-context.yaml"
    20  
    21  	# Check pod creation
    22  	kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name"
    23  
    24  	# Check user
    25  	cmd="ps --user 1000 -f"
    26  	process="tail -f /dev/null"
    27  	kubectl exec $pod_name -- sh -c $cmd | grep "$process"
    28  }
    29  
    30  teardown() {
    31  	# Debugging information
    32  	kubectl describe "pod/$pod_name"
    33  
    34  	kubectl delete pod "$pod_name"
    35  }