Skip to content

Commit

Permalink
make tests more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
unglaublicherdude committed Jun 11, 2024
1 parent 638143c commit bdfde15
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ endif
npm:
ifeq (,$(wildcard $(CURDIR)/package.json))
ifeq (,$(wildcard $(CURDIR)/package-lock.json))
npm install
npm install --no-audit --progress=false
else
npm ci
endif
cd js && $(npm) run build
else
ifeq (,$(wildcard $(CURDIR)/package-lock.json))
npm install
npm install --no-audit --progress=false
else
npm ci
endif
Expand Down
5 changes: 5 additions & 0 deletions tests/functionality-parallel.bats
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ setup_file() {
@test "test admin eicar Upload" {
RESULT=$(curl --silent -w "%{http_code}" -u admin:admin -T /tmp/eicar.com.txt http://127.0.0.1/remote.php/dav/files/admin/eicar.com.txt)
echo "Actual: $RESULT"
curl --silent -q -u admin:admin -X DELETE http://127.0.0.1/remote.php/dav/files/admin/eicar.com.txt
[[ "$RESULT" =~ "Virus EICAR-Test-File is detected in the file. Upload cannot be completed." ]]
}

@test "test admin clean Upload" {
RESULT=$(curl -w "%{http_code}" -u admin:admin -T /tmp/clean.txt http://127.0.0.1/remote.php/dav/files/admin/clean.txt)
echo "Actual: $RESULT"
curl --silent -q -u admin:admin -X DELETE http://127.0.0.1/remote.php/dav/files/admin/clean.txt
[[ $RESULT -ge 200 && $RESULT -lt 300 ]]
}

@test "test admin pup Upload" {
RESULT=$(curl --silent -w "%{http_code}" -u admin:admin -T /tmp/pup.exe http://127.0.0.1/remote.php/dav/files/admin/pup.exe)
echo "Actual: $RESULT"
curl --silent -q -u admin:admin -X DELETE http://127.0.0.1/remote.php/dav/files/admin/pup.exe
[[ $RESULT -ge 200 && $RESULT -lt 300 ]]
}

Expand All @@ -35,12 +38,14 @@ setup_file() {
@test "test testuser clean Upload" {
STATUS_CODE=$(curl --silent -w "%{http_code}" -w "%{http_code}" -u testuser:myfancysecurepassword234 -T /tmp/clean.txt http://127.0.0.1/remote.php/dav/files/testuser/clean.txt)
echo "Actual: $RESULT"
curl --silent -q -u testuser:myfancysecurepassword234 -X DELETE http://127.0.0.1/remote.php/dav/files/testuser/clean.txt
[[ $STATUS_CODE -ge 200 && $STATUS_CODE -lt 300 ]] || exit 1
}

@test "test testuser pup Upload" {
RESULT=$(curl --silent -w "%{http_code}" -w "%{http_code}" -u testuser:myfancysecurepassword234 -T /tmp/pup.exe http://127.0.0.1/remote.php/dav/files/testuser/pup.exe)
echo "Actual: $RESULT"
curl --silent -q -u testuser:myfancysecurepassword234 -X DELETE http://127.0.0.1/remote.php/dav/files/testuser/pup.exe
[[ $RESULT -ge 200 && $RESULT -lt 300 ]] || exit 1
}

6 changes: 5 additions & 1 deletion tests/functionality-sequential.bats
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env bats

setup_file() {
echo 'nothingwronghere' > /tmp/clean.txt
echo 'X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*' > /tmp/eicar.com.txt
curl --output /tmp/pup.exe http://amtso.eicar.org/PotentiallyUnwanted.exe
BATS_NO_PARALLELIZE_WITHIN_FILE=true
}

Expand All @@ -11,7 +14,8 @@ setup() {
@test "test upload when vaas does not function" {
RESULT=$(curl --silent -w "%{http_code}" -u admin:admin -T /tmp/eicar.com.txt http://127.0.0.1/remote.php/dav/files/admin/eicar.com.txt)
echo "Actual: $RESULT"
[[ $RESULT -ge 200 && $RESULT -lt 300 ]] || exit 1
curl --silent -q -u admin:admin -X DELETE http://127.0.0.1/remote.php/dav/files/admin/eicar.com.txt
[[ $RESULT -ge 200 && $RESULT -lt 300 ]]
}

tearddown() {
Expand Down

0 comments on commit bdfde15

Please sign in to comment.