Skip to content

Commit b19d5aa

Browse files
committed
Add unit tests
1 parent 61b4e30 commit b19d5aa

File tree

9 files changed

+162
-652
lines changed

9 files changed

+162
-652
lines changed

.github/check_spdx.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# SPDX-License-Identifier: GPL-2.0-only
4+
# This file is part of Scapy RPC
5+
# See https://scapy.net/ for more information
6+
7+
# Check that all Scapy RPC files have a SPDX
8+
9+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
10+
ROOT_DIR=$SCRIPT_DIR/..
11+
12+
# http://mywiki.wooledge.org/BashFAQ/024
13+
# This documents an absolutely WTF behavior of bash.
14+
set +m
15+
shopt -s lastpipe
16+
17+
function check_path() {
18+
cd $ROOT_DIR
19+
RCODE=0
20+
for ext in "${@:2}"; do
21+
find $1 -name "*.$ext" | while read f; do
22+
if [[ "$f" == *"/ply/"* ]]; then
23+
# Skip PLY
24+
continue
25+
fi
26+
if [[ -z $(grep "SPDX" $f) ]]; then
27+
echo "$f"
28+
RCODE=1
29+
fi
30+
done
31+
done
32+
return $RCODE
33+
}
34+
35+
check_path midl-to-scapy py || exit $?
36+
check_path scapy-rpc py || exit $?

.github/workflows/unittests.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Scapy RPC unit tests
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
# The branches below must be a subset of the branches above
8+
branches: [master]
9+
10+
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/control-the-concurrency-of-workflows-and-jobs
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: ${{ !contains(github.ref, 'master')}}
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
health:
20+
name: Code health check
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout Scapy-rpc
24+
uses: actions/checkout@v4
25+
- name: Setup Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: "3.13"
29+
- name: Check black compliance
30+
uses: psf/black@stable
31+
with:
32+
src: "./scapy-rpc"
33+
use_pyproject: true
34+
- name: Run twine check
35+
run: tox -e twine
36+
spdx:
37+
name: Check SPDX identifiers
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Checkout Scapy
41+
uses: actions/checkout@v4
42+
- name: Launch script
43+
run: bash .github/check_spdx.sh

midl-to-scapy/idl/idl_scraper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"extras": [
4343
# Protocols not listed in the "list"
4444
"ms-oxcrpc",
45-
]
45+
],
4646
},
4747
{
4848
"name": "SharePoint Protocols",

scapy-rpc/msrpcs/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
# This file is part of Scapy RPC
3+
# See https://scapy.net/ for more information
4+
15
"""
26
Scapy RPC definitions
37
"""
@@ -11,7 +15,7 @@
1115

1216
def scapy_ext(plg):
1317
plg.config("Scapy RPC", __version__)
14-
for lay in pathlib.Path(__file__).parent.glob('*.py'):
18+
for lay in pathlib.Path(__file__).parent.glob("*.py"):
1519
if lay.name == "__init__.py":
1620
continue
1721
plg.register(

scapy-rpc/msrpcs/ms_adts_Claims.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)