Skip to content

Commit

Permalink
test: add job rejection test case
Browse files Browse the repository at this point in the history
Signed-off-by: Hector Fernandez <[email protected]>
  • Loading branch information
hectorj2f committed Dec 27, 2022
1 parent 3f9ef92 commit e37beb4
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/e2e_test_cluster_image_policy_with_tsa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,33 @@ fi
kubectl delete -n ${NS} job demo
echo '::endgroup::'

# Publish the second test image
echo '::group:: publish test image demoimage'
pushd $(mktemp -d)
go mod init example.com/demo
cat <<EOF > main.go
package main
import "fmt"
func main() {
fmt.Println("hello world 2 TIMESTAMP")
}
EOF
sed -i'' -e "s@TIMESTAMP@${TIMESTAMP}@g" main.go
cat main.go
export demoimage2=`ko publish -B example.com/demo`
popd
echo '::endgroup::'

# We did not sign this, should fail due to TSA verification
echo '::group:: test job rejection'
if kubectl create -n ${NS} job demo2 --image=${demoimage2} ; then
echo Failed to block unsigned Job creation!
exit 1
else
echo Successfully blocked Job creation with unsigned image due to TSA verification
fi
echo '::endgroup::'

echo '::group::' Cleanup
kubectl delete cip --all
kubectl delete trustroot --all
Expand Down

0 comments on commit e37beb4

Please sign in to comment.