-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f87531
commit b6a7833
Showing
3 changed files
with
62 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# SPDX-FileCopyrightText: Stefan Tatschner | ||
# | ||
# SPDX-License-Identifier: CC0-1.0 | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
bats: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: install bats | ||
uses: brokenpip3/[email protected] | ||
- name: run bats | ||
run: | | ||
bats -x -r tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env bats | ||
|
||
# SPDX-FileCopyrightText: AISEC Pentesting Team | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
setup() { | ||
# https://bats-core.readthedocs.io/en/stable/tutorial.html#let-s-do-some-setup | ||
DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )" | ||
PATH="$DIR/..:$PATH" | ||
} | ||
|
||
@test "invoke penrun without parameters" { | ||
local tmpdir | ||
tmpdir="$(mktemp -d)" | ||
( | ||
cd "$tmpdir" | ||
penrun -c /dev/null ls -lah | ||
if [[ ! -d "ls" ]]; then | ||
echo "output directory is missing" | ||
return 1 | ||
fi | ||
|
||
mapfile -t meta < "ls/LATEST/META.json" | ||
for line in "${meta[@]}"; do | ||
local cmd | ||
local exit_code | ||
if [[ "$line" =~ EXIT:(.+) ]]; then | ||
exit_code="${BASH_REMATCH[1]}" | ||
if ((exit_code != 0)); then | ||
return 1 | ||
fi | ||
fi | ||
if [[ "$line" =~ COMMAND:(.+)\s$ ]]; then | ||
cmd="${BASH_REMATCH[1]}" | ||
if [[ "$cmd" != "ls -lah" ]]; then | ||
echo "$cmd" | ||
return 1 | ||
fi | ||
fi | ||
done | ||
|
||
rm -rf "$tmpdir" | ||
) | ||
} |