Skip to content

Commit

Permalink
add some more variables
Browse files Browse the repository at this point in the history
  • Loading branch information
unglaublicherdude committed Jun 11, 2024
1 parent 445d4f2 commit 1f63ce5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
25 changes: 15 additions & 10 deletions tests/functionality-parallel.bats
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
#!/usr/bin/env bats

FOLDER_PREFIX=./tmp/functionality-parallel/
TESTUSER=testuser
TESTUSER_PASSWORD=myfancysecurepassword234

setup_file() {
mkdir -p $FOLDER_PREFIX
docker exec --env OC_PASS=$TESTUSER_PASSWORD --user www-data nextcloud-container php occ user:add $TESTUSER --password-from-env || echo "already exists"
docker exec --user www-data -i nextcloud-container php occ config:app:set gdatavaas clientSecret --value="$CLIENT_SECRET"
sleep 2
}

setup() {
echo 'nothingwronghere' > $FOLDER_PREFIX/clean.txt
echo 'X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*' > $FOLDER_PREFIX/eicar.com.txt
curl --output $FOLDER_PREFIX/pup.exe http://amtso.eicar.org/PotentiallyUnwanted.exe
docker exec --env OC_PASS=myfancysecurepassword234 --user www-data nextcloud-container php occ user:add testuser --password-from-env || echo "already exists"
docker exec --user www-data -i nextcloud-container php occ config:app:set gdatavaas clientSecret --value="$CLIENT_SECRET"
sleep 2
}

@test "test admin eicar Upload" {
Expand All @@ -19,7 +24,7 @@ setup_file() {
[[ "$RESULT" =~ "Upload cannot be completed." ]]
}

@test "test admin clean Upload" {
@test "test admin clean upload" {
RESULT=$(curl -w "%{http_code}" -u admin:admin -T $FOLDER_PREFIX/clean.txt http://127.0.0.1/remote.php/dav/files/admin/functionality-parallel.clean.txt)
echo "Actual: $RESULT"
curl --silent -q -u admin:admin -X DELETE http://127.0.0.1/remote.php/dav/files/admin/functionality-parallel.clean.txt
Expand All @@ -34,24 +39,24 @@ setup_file() {
}

@test "test testuser eicar Upload" {
RESULT=$(curl --silent -w "%{http_code}" -u testuser:myfancysecurepassword234 -T ./tmp/functionality-sequential//eicar.com.txt http://127.0.0.1/remote.php/dav/files/testuser/functionality-parallel.eicar.com.txt)
RESULT=$(curl --silent -w "%{http_code}" -u $TESTUSER:$TESTUSER_PASSWORD -T ./tmp/functionality-sequential//eicar.com.txt http://127.0.0.1/remote.php/dav/files/$TESTUSER/functionality-parallel.eicar.com.txt)
echo "Actual: $RESULT"
docker exec --user www-data -i nextcloud-container php occ config:app:get gdatavaas clientSecret
curl --silent -q -u testuser:myfancysecurepassword234 -X DELETE http://127.0.0.1/remote.php/dav/files/testuser/functionality-parallel.eicar.com.txt
curl --silent -q -u $TESTUSER:$TESTUSER_PASSWORD -X DELETE http://127.0.0.1/remote.php/dav/files/$TESTUSER/functionality-parallel.eicar.com.txt
[[ "$RESULT" =~ "Upload cannot be completed." ]]
}

@test "test testuser clean Upload" {
STATUS_CODE=$(curl --silent -w "%{http_code}" -w "%{http_code}" -u testuser:myfancysecurepassword234 -T $FOLDER_PREFIX/clean.txt http://127.0.0.1/remote.php/dav/files/testuser/functionality-parallel.clean.txt)
STATUS_CODE=$(curl --silent -w "%{http_code}" -w "%{http_code}" -u $TESTUSER:$TESTUSER_PASSWORD -T $FOLDER_PREFIX/clean.txt http://127.0.0.1/remote.php/dav/files/$TESTUSER/functionality-parallel.clean.txt)
echo "Actual: $RESULT"
curl --silent -q -u testuser:myfancysecurepassword234 -X DELETE http://127.0.0.1/remote.php/dav/files/testuser/functionality-parallel.clean.txt
curl --silent -q -u $TESTUSER:$TESTUSER_PASSWORD -X DELETE http://127.0.0.1/remote.php/dav/files/$TESTUSER/functionality-parallel.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 $FOLDER_PREFIX/pup.exe http://127.0.0.1/remote.php/dav/files/testuser/functionality-parallel.pup.exe)
RESULT=$(curl --silent -w "%{http_code}" -w "%{http_code}" -u $TESTUSER:$TESTUSER_PASSWORD -T $FOLDER_PREFIX/pup.exe http://127.0.0.1/remote.php/dav/files/$TESTUSER/functionality-parallel.pup.exe)
echo "Actual: $RESULT"
curl --silent -q -u testuser:myfancysecurepassword234 -X DELETE http://127.0.0.1/remote.php/dav/files/testuser/functionality-parallel.pup.exe
curl --silent -q -u $TESTUSER:$TESTUSER_PASSWORD -X DELETE http://127.0.0.1/remote.php/dav/files/$TESTUSER/functionality-parallel.pup.exe
[[ $RESULT -ge 200 && $RESULT -lt 300 ]] || exit 1
}

Expand Down
10 changes: 6 additions & 4 deletions tests/functionality-sequential.bats
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env bats

FOLDER_PREFIX=./tmp/functionality-sequential/
TESTUSER=testuser
TESTUSER_PASSWORD=myfancysecurepassword234

setup_file() {
mkdir -p $FOLDER_PREFIX/
Expand Down Expand Up @@ -38,16 +40,16 @@ setup_file() {

@test "test croned scan for testuser files" {
docker exec --user www-data -i nextcloud-container php occ config:app:set gdatavaas clientSecret --value="WRONG_PASSWORD"
curl --silent -w "%{http_code}" -u testuser:myfancysecurepassword234 -T $FOLDER_PREFIX/eicar.com.txt http://127.0.0.1/remote.php/dav/files/testuser/testuser.functionality-sequential.eicar.com.txt
curl --silent -w "%{http_code}" -u $TESTUSER:$TESTUSER_PASSWORD -T $FOLDER_PREFIX/eicar.com.txt http://127.0.0.1/remote.php/dav/files/$TESTUSER/$TESTUSER.functionality-sequential.eicar.com.txt
docker exec --user www-data -i nextcloud-container php occ config:app:set gdatavaas clientSecret --value="$CLIENT_SECRET"
docker exec --user www-data -i nextcloud-container php ./cron.php # tag unscanned
docker exec --user www-data -i nextcloud-container php ./cron.php # actual scan

LOGS=$(docker exec --user www-data -i nextcloud-container cat data/nextcloud.log | egrep "testuser.functionality-sequential.eicar.com.txt")
LOGS=$(docker exec --user www-data -i nextcloud-container cat data/nextcloud.log | egrep "$TESTUSER.functionality-sequential.eicar.com.txt")

curl --silent -q -u testuser:myfancysecurepassword234 -X DELETE http://127.0.0.1/remote.php/dav/files/testuser/testuser.functionality-sequential.eicar.com.txt
curl --silent -q -u $TESTUSER:$TESTUSER_PASSWORD -X DELETE http://127.0.0.1/remote.php/dav/files/$TESTUSER/$TESTUSER.functionality-sequential.eicar.com.txt

[[ $LOGS =~ ^.*testuser.functionality-sequential.eicar.com.txt.*Verdict:.*Malicious ]]
[[ $LOGS =~ ^.*$TESTUSER.functionality-sequential.eicar.com.txt.*Verdict:.*Malicious ]]
}

tearddown_file() {
Expand Down

0 comments on commit 1f63ce5

Please sign in to comment.