sigs.k8s.io/seccomp-operator@v0.1.0/test/tc_run_pod_test.go (about)

     1  // +build e2e
     2  
     3  /*
     4  Copyright 2020 The Kubernetes Authors.
     5  
     6  Licensed under the Apache License, Version 2.0 (the "License");
     7  you may not use this file except in compliance with the License.
     8  You may obtain a copy of the License at
     9  
    10      http://www.apache.org/licenses/LICENSE-2.0
    11  
    12  Unless required by applicable law or agreed to in writing, software
    13  distributed under the License is distributed on an "AS IS" BASIS,
    14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    15  See the License for the specific language governing permissions and
    16  limitations under the License.
    17  */
    18  
    19  package e2e_test
    20  
    21  func (e *e2e) testCaseRunPod([]string) {
    22  	const (
    23  		examplePodPath = "examples/pod.yaml"
    24  		examplePodName = "test-pod"
    25  	)
    26  
    27  	e.logf("Creating the test pod: %s", examplePodPath)
    28  	e.kubectl("create", "-f", examplePodPath)
    29  	defer e.kubectl("delete", "-f", examplePodPath)
    30  
    31  	e.logf("Waiting for test pod to be ready")
    32  	e.kubectl("wait", "--for", "condition=ready", "pod", "--all")
    33  
    34  	e.logf("Testing that `rmdir` is not possible inside the pod")
    35  	failureOutput := e.kubectlFailure(
    36  		"exec", examplePodName, "--", "rmdir", "/home",
    37  	)
    38  	e.Contains(failureOutput,
    39  		"rmdir: failed to remove '/home': Operation not permitted",
    40  	)
    41  }