-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bdfde15
commit b8f1d7e
Showing
3 changed files
with
34 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,3 +63,4 @@ js/ | |
*.cache | ||
.uuid | ||
eicar.com.txt | ||
tmp/ |
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 |
---|---|---|
@@ -1,51 +1,58 @@ | ||
#!/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 | ||
mkdir -p ./tmp/functionality-parallel/ | ||
echo 'nothingwronghere' > ./tmp/functionality-parallel//clean.txt | ||
echo 'X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*' > ./tmp/functionality-parallel/eicar.com.txt | ||
curl --output ./tmp/functionality-parallel/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" { | ||
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) | ||
RESULT=$(curl --silent -w "%{http_code}" -u admin:admin -T ./tmp/functionality-parallel/eicar.com.txt http://127.0.0.1/remote.php/dav/files/admin/functionality-parallel.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 | ||
curl --silent -q -u admin:admin -X DELETE http://127.0.0.1/remote.php/dav/files/admin/functionality-parallel.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) | ||
RESULT=$(curl -w "%{http_code}" -u admin:admin -T ./tmp/functionality-parallel/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/clean.txt | ||
curl --silent -q -u admin:admin -X DELETE http://127.0.0.1/remote.php/dav/files/admin/functionality-parallel.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) | ||
RESULT=$(curl --silent -w "%{http_code}" -u admin:admin -T ./tmp/functionality-parallel/pup.exe http://127.0.0.1/remote.php/dav/files/admin/functionality-parallel.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 | ||
curl --silent -q -u admin:admin -X DELETE http://127.0.0.1/remote.php/dav/files/admin/functionality-parallel.pup.exe | ||
[[ $RESULT -ge 200 && $RESULT -lt 300 ]] | ||
} | ||
|
||
@test "test testuser eicar Upload" { | ||
RESULT=$(curl --silent -w "%{http_code}" -u testuser:myfancysecurepassword234 -T /tmp/eicar.com.txt http://127.0.0.1/remote.php/dav/files/testuser/eicar.com.txt) | ||
RESULT=$(curl --silent -w "%{http_code}" -u testuser:myfancysecurepassword234 -T ./tmp/functionality-parallel/eicar.com.txt http://127.0.0.1/remote.php/dav/files/testuser/functionality-parallel.eicar.com.txt) | ||
echo "Actual: $RESULT" | ||
curl --silent -q -u testuser:myfancysecurepassword234 -X DELETE http://127.0.0.1/remote.php/dav/files/testuser/functionality-parallel.eicar.com.txt | ||
[[ "$RESULT" =~ "Virus EICAR-Test-File is detected in the file. Upload cannot be completed." ]] | ||
} | ||
|
||
@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) | ||
STATUS_CODE=$(curl --silent -w "%{http_code}" -w "%{http_code}" -u testuser:myfancysecurepassword234 -T ./tmp/functionality-parallel/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/clean.txt | ||
curl --silent -q -u testuser:myfancysecurepassword234 -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 /tmp/pup.exe http://127.0.0.1/remote.php/dav/files/testuser/pup.exe) | ||
RESULT=$(curl --silent -w "%{http_code}" -w "%{http_code}" -u testuser:myfancysecurepassword234 -T ./tmp/functionality-parallel/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/pup.exe | ||
curl --silent -q -u testuser:myfancysecurepassword234 -X DELETE http://127.0.0.1/remote.php/dav/files/testuser/functionality-parallel.pup.exe | ||
[[ $RESULT -ge 200 && $RESULT -lt 300 ]] || exit 1 | ||
} | ||
|
||
@tearddown_file() { | ||
rm -rf ./tmp/functionality-parallel/ | ||
} | ||
|
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 |
---|---|---|
@@ -1,23 +1,25 @@ | ||
#!/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 | ||
mkdir -p ./tmp/functionality-sequential/ | ||
echo 'nothingwronghere' > ./tmp/functionality-sequential/clean.txt | ||
echo 'X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*' > ./tmp/functionality-sequential//eicar.com.txt | ||
curl --output ./tmp/functionality-sequential/pup.exe http://amtso.eicar.org/PotentiallyUnwanted.exe | ||
BATS_NO_PARALLELIZE_WITHIN_FILE=true | ||
} | ||
|
||
setup() { | ||
docker exec --user www-data -i nextcloud-container php occ config:app:set gdatavaas clientSecret --value="WRONG_PASSWORD" | ||
} | ||
|
||
@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) | ||
docker exec --user www-data -i nextcloud-container php occ config:app:set gdatavaas clientSecret --value="WRONG_PASSWORD" | ||
RESULT=$(curl --silent -w "%{http_code}" -u admin:admin -T ./tmp/functionality-sequential/eicar.com.txt http://127.0.0.1/remote.php/dav/files/admin/functionality-sequential.eicar.com.txt) | ||
docker exec --user www-data -i nextcloud-container php occ config:app:set gdatavaas clientSecret --value="$CLIENT_SECRET" | ||
curl --silent -q -u admin:admin -X DELETE http://127.0.0.1/remote.php/dav/files/admin/functionality-sequential.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 -ge 200 && $RESULT -lt 300 ]] | ||
} | ||
|
||
tearddown() { | ||
docker exec --user www-data -i nextcloud-container php occ config:app:set gdatavaas clientSecret --value="$CLIENT_SECRET" | ||
tearddown_file() { | ||
sleep 2 | ||
rm -rf ./tmp/functionality-sequential/ | ||
} |