-
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
f6e8caf
commit 2e4c6a8
Showing
14 changed files
with
221 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,54 @@ | ||
#!/usr/bin/env bats | ||
|
||
# SPDX-FileCopyrightText: AISEC Pentesting Team | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
load helpers.sh | ||
|
||
setup_file() { | ||
setup_gallia_toml | ||
run_vecu & | ||
} | ||
|
||
teardown_file() { | ||
kill_vecu | ||
} | ||
|
||
@test "scan services" { | ||
gallia scan uds services --sessions 1 2 --check-session | ||
} | ||
|
||
@test "scan sessions" { | ||
gallia scan uds sessions --depth 2 | ||
} | ||
|
||
@test "scan fast" { | ||
gallia scan uds sessions --fast | ||
} | ||
|
||
@test "scan identifiers sid 0x22" { | ||
gallia scan uds identifiers --start 0 --end 100 --sid 0x22 | ||
} | ||
|
||
@test "scan identifiers sid 0x2e" { | ||
gallia scan uds identifiers --start 0 --end 100 --sid 0x2e | ||
} | ||
|
||
@test "scan identifiers sid 0x31" { | ||
gallia scan uds identifiers --start 0 --end 100 --sid 0x31 | ||
} | ||
|
||
@test "scan reset" { | ||
gallia scan uds reset | ||
} | ||
|
||
@test "scan dump-seeds" { | ||
gallia scan uds dump-seeds --duration 0.01 --level 0x2f | ||
} | ||
|
||
@test "scan memory" { | ||
for sid in 0x23 0x34 0x35 0x3d; do | ||
poetry run gallia scan uds memory --sid "$sid" | ||
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,60 @@ | ||
#!/usr/bin/env bats | ||
|
||
# SPDX-FileCopyrightText: AISEC Pentesting Team | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
load helpers.sh | ||
|
||
setup_file() { | ||
setup_gallia_toml | ||
run_vecu & | ||
} | ||
|
||
teardown_file() { | ||
kill_vecu | ||
} | ||
|
||
@test "primitive ecu-reset" { | ||
gallia primitive uds ecu-reset | ||
} | ||
|
||
@test "primitive vin" { | ||
gallia primitive uds vin | ||
} | ||
|
||
@test "primitive ping" { | ||
gallia primitive uds ping --count 2 | ||
} | ||
|
||
@test "primitive rdbi" { | ||
gallia primitive uds rdbi 0x108d | ||
} | ||
|
||
@test "primitive pdu" { | ||
gallia primitive uds pdu 1001 | ||
} | ||
|
||
@test "primitive wdbi" { | ||
gallia primitive uds wdbi 0x2266 --data 00 | ||
} | ||
|
||
@test "primitive dtc read" { | ||
gallia primitive uds dtc read | ||
} | ||
|
||
@test "primitive dtc clear" { | ||
gallia primitive uds dtc clear | ||
} | ||
|
||
@test "primitive dtc control stop" { | ||
gallia primitive uds dtc control --stop | ||
} | ||
|
||
@test "primitive dtc control resume" { | ||
gallia primitive uds dtc control --resume | ||
} | ||
|
||
@test "primitive iocbi reset-to-default" { | ||
gallia primitive uds iocbi 0x1000 reset-to-default | ||
} |
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,36 @@ | ||
# 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 | ||
} | ||
|
||
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]" | ||
} | ||
|
||
kill_vecu() { | ||
kill -9 "$(pgrep gallia)" | ||
rm -f /tmp/vecu.sock | ||
} | ||
|
||
setup_gallia_toml() { | ||
{ | ||
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" | ||
} | ||
|
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.