-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Add end to end tests with bats
- Loading branch information
1 parent
7b34f3b
commit 346e79a
Showing
13 changed files
with
120 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
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,5 @@ | ||
# SPDX-FileCopyrightText: AISEC Pentesting Team | ||
# | ||
# SPDX-License-Identifier: CC0-1.0 | ||
|
||
shell=bash |
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
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,10 @@ | ||
#!/usr/bin/env bats | ||
|
||
# SPDX-FileCopyrightText: AISEC Pentesting Team | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
@test "invoke gallia without parameters" { | ||
# Should fail and print help page. | ||
run -64 gallia | ||
} |
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,37 @@ | ||
#!/usr/bin/env bats | ||
|
||
# SPDX-FileCopyrightText: AISEC Pentesting Team | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
load helpers.sh | ||
|
||
run_vecu() { | ||
close_non_std_fds | ||
gallia script vecu "unix-lines:///tmp/vecu.sock" rng --seed 3 --mandatory_sessions "[1, 2, 3]" --mandatory_services "[DiagnosticSessionControl, EcuReset, ReadDataByIdentifier, WriteDataByIdentifier, RoutineControl, SecurityAccess, ReadMemoryByAddress, WriteMemoryByAddress, RequestDownload, RequestUpload, TesterPresent, ReadDTCInformation, ClearDiagnosticInformation, InputOutputControlByIdentifier]" | ||
} | ||
|
||
setup_file() { | ||
{ | ||
echo "[gallia]" | ||
echo "[gallia.scanner]" | ||
echo 'target = "unix-lines:///tmp/vecu.sock"' | ||
echo 'dumpcap = false' | ||
|
||
echo "[gallia.protocols.uds]" | ||
echo 'ecu_reset = 0x01' | ||
} > "$BATS_FILE_TMPDIR/gallia.toml" | ||
|
||
export GALLIA_CONFIG="$BATS_FILE_TMPDIR/gallia.toml" | ||
|
||
run_vecu & | ||
} | ||
|
||
teardown_file() { | ||
kill -9 "$(pgrep gallia)" | ||
rm -f /tmp/vecu.sock | ||
} | ||
|
||
@test "scan services" { | ||
gallia scan uds services --sessions 1 2 --check-session | ||
} |
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,11 @@ | ||
# SPDX-FileCopyrightText: AISEC Pentesting Team | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
close_non_std_fds() { | ||
for fd in $(ls /proc/$BASHPID/fd); do | ||
if [[ $fd -gt 2 ]]; then | ||
eval "exec $fd>&-" || true | ||
fi | ||
done | ||
} |
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,13 @@ | ||
# SPDX-FileCopyrightText: AISEC Pentesting Team | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
setup_suite() { | ||
bats_require_minimum_version 1.5.0 | ||
|
||
# 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" | ||
|
||
cd "$BATS_TEST_TMPDIR" || exit 1 | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.