Merge pull request #6508 from owncloud/backport/tests-related-to-antivirus-service
[tests-only][full-ci]Backport/tests related to antivirus service
This commit is contained in:
8 files changed
+288
-19
No files matched your search
@@ -74,7 +74,21 @@ To run the tests that require an email server (tests tagged with `@email`), you
|
||||
|
||||
```bash
|
||||
START_EMAIL=true \
|
||||
BEHAT_FEATURE='tests/acceptance/features/apiEmailNotification/emailNotification.feature' \
|
||||
BEHAT_FEATURE='tests/acceptance/features/apiNotification/emailNotification.feature' \
|
||||
make -C tests/acceptance/docker test-ocis-feature-ocis-storage
|
||||
```
|
||||
|
||||
{{< /hint >}}
|
||||
|
||||
{{< hint info >}}
|
||||
To run the tests that require an antivirus service (tests tagged with `@antivirus`), you need to provide the following environment variables while running the tests.
|
||||
|
||||
```bash
|
||||
START_ANTIVIRUS=true \
|
||||
OCIS_ASYNC_UPLOADS=true \
|
||||
OCIS_ADD_RUN_SERVICES=antivirus \
|
||||
POSTPROCESSING_STEPS=virusscan \
|
||||
BEHAT_FEATURE='tests/acceptance/features/apiAntivirus/antivirus.feature' \
|
||||
make -C tests/acceptance/docker test-ocis-feature-ocis-storage
|
||||
```
|
||||
|
||||
@@ -428,7 +442,7 @@ The commands are ubuntu specific and may differ according to your system. You ca
|
||||
|
||||
#### 2. Setup clamAV With Docker
|
||||
##### a. Create a Volume
|
||||
For `clamAV` only local sockets can currently be configured we need to create a volume in order to share the socket with `oCIS server`. Run the following command to do so:
|
||||
For `clamAV` only local sockets can currently be configured, we need to create a volume in order to share the socket with `oCIS server`. Run the following command to do so:
|
||||
```bash
|
||||
docker volume create -d local -o device=/your/local/filesystem/path/ -o o=bind -o type=none clamav_vol
|
||||
```
|
||||
@@ -442,7 +456,7 @@ The path to the socket i.e. `/var/run/clamav/` may differ as per the image you a
|
||||
{{< /hint>}}
|
||||
|
||||
##### b. Change Ownership
|
||||
Change the ownership of the path of your local filesystem that the volume `clamav_vol` is mounted on. After running `clamav` through docker the ownership of the bound path gets changed. As we need to provide this path to ocis server the ownership should be changed back to $USER or whatever ownership that your server requires.
|
||||
Change the ownership of the path of your local filesystem that the volume `clamav_vol` is mounted on. After running `clamav` through docker the ownership of the bound path gets changed. As we need to provide this path to ocis server, the ownership should be changed back to $USER or whatever ownership that your server requires.
|
||||
```bash
|
||||
sudo chown -R $USER:$USER /your/local/filesystem/path/
|
||||
```
|
||||
@@ -451,7 +465,7 @@ Make sure that `clamAV` is fully up before running this command. The command is
|
||||
{{< /hint>}}
|
||||
|
||||
{{< hint info >}}
|
||||
If you want to use the same volume after the container is down. Before running the container once again you need to either remove all the data inside `/your/local/filesystem/path/` or give the ownership back. For instance, it ubuntu it might be `sudo chown -R systemd-network:systemd-journal /your/local/filesystem/path/` and repeat step 2 and 3`
|
||||
If you want to use the same volume after the container is down then before running the container once again, you either need to remove all the data inside `/your/local/filesystem/path/` or give the ownership back. For instance, on Ubuntu it might be `sudo chown -R systemd-network:systemd-journal /your/local/filesystem/path/` and repeat `step 2 and 3`
|
||||
{{< /hint>}}
|
||||
|
||||
### Run oCIS
|
||||
|
||||
@@ -205,6 +205,7 @@ default:
|
||||
- FilesVersionsContext:
|
||||
- SettingsContext:
|
||||
- OcisConfigContext:
|
||||
- PublicWebDavContext:
|
||||
|
||||
extensions:
|
||||
rdx\behatvars\BehatVariablesExtension: ~
|
||||
|
||||
@@ -186,11 +186,19 @@ testSuite: $(OCIS_WRAPPER) build-dev-image clean-docker-container
|
||||
COMPOSE_FILE=src/email.yml \
|
||||
docker-compose run start_email; \
|
||||
fi; \
|
||||
if [ "${START_ANTIVIRUS}" == "true" ]; then \
|
||||
COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME) \
|
||||
COMPOSE_FILE=src/antivirus.yml \
|
||||
docker-compose run start_antivirus; \
|
||||
fi; \
|
||||
COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME) \
|
||||
COMPOSE_FILE=$(COMPOSE_FILE) \
|
||||
STORAGE_DRIVER=$(STORAGE_DRIVER) \
|
||||
TEST_SOURCE=$(TEST_SOURCE) \
|
||||
WITH_WRAPPER=$(WITH_WRAPPER) \
|
||||
OCIS_ASYNC_UPLOADS=$(OCIS_ASYNC_UPLOADS) \
|
||||
OCIS_ADD_RUN_SERVICES=$(OCIS_ADD_RUN_SERVICES) \
|
||||
POSTPROCESSING_STEPS=$(POSTPROCESSING_STEPS) \
|
||||
OCIS_IMAGE_TAG=$(OCIS_IMAGE_TAG) \
|
||||
BEHAT_SUITE=$(BEHAT_SUITE) \
|
||||
BEHAT_FEATURE=$(BEHAT_FEATURE) \
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
services:
|
||||
start_antivirus:
|
||||
image: dadarek/wait-for-dependencies
|
||||
depends_on:
|
||||
- clamav
|
||||
command: clamav:3310
|
||||
clamav:
|
||||
image: owncloudci/clamavd
|
||||
volumes:
|
||||
- clamavSocket:/var/run/clamav/
|
||||
|
||||
volumes:
|
||||
clamavSocket:
|
||||
|
||||
@@ -22,6 +22,9 @@ services:
|
||||
IDM_CREATE_DEMO_USERS: "true"
|
||||
IDM_ADMIN_PASSWORD: "admin"
|
||||
FRONTEND_SEARCH_MIN_LENGTH: "2"
|
||||
OCIS_ASYNC_UPLOADS: $OCIS_ASYNC_UPLOADS
|
||||
OCIS_ADD_RUN_SERVICES: $OCIS_ADD_RUN_SERVICES
|
||||
|
||||
# s3ng specific settings
|
||||
STORAGE_USERS_S3NG_ENDPOINT: http://ceph:8080
|
||||
STORAGE_USERS_S3NG_REGION: default
|
||||
@@ -32,6 +35,19 @@ services:
|
||||
NOTIFICATIONS_SMTP_HOST: email
|
||||
NOTIFICATIONS_SMTP_PORT: 2500
|
||||
NOTIFICATIONS_SMTP_INSECURE: "true"
|
||||
|
||||
# antivirus
|
||||
ANTIVIRUS_SCANNER_TYPE: "clamav"
|
||||
ANTIVIRUS_CLAMAV_SOCKET: "/var/run/clamav/clamd.sock"
|
||||
|
||||
# postprocessing step
|
||||
POSTPROCESSING_STEPS: $POSTPROCESSING_STEPS
|
||||
volumes:
|
||||
- ../../../config:/drone/src/tests/config
|
||||
- ../../../ociswrapper/bin/ociswrapper:/usr/bin/ociswrapper
|
||||
- clamavSocket:/var/run/clamav/
|
||||
|
||||
volumes:
|
||||
clamavSocket:
|
||||
external:
|
||||
name: ocis-acceptance-tests_clamavSocket
|
||||
@@ -1,10 +1,9 @@
|
||||
@api @antivirus
|
||||
@api @antivirus @skipOnReva
|
||||
Feature: antivirus
|
||||
As a system administrator and user
|
||||
I want to protect myself and others from known viruses
|
||||
So that I can prevent files with viruses from being uploaded
|
||||
|
||||
|
||||
Background:
|
||||
Given user "Alice" has been created with default attributes and without skeleton files
|
||||
|
||||
@@ -24,12 +23,9 @@ Feature: antivirus
|
||||
| dav-path-version |
|
||||
| old |
|
||||
| new |
|
||||
|
||||
@skipOnRevaMaster
|
||||
Examples:
|
||||
| dav-path-version |
|
||||
| spaces |
|
||||
|
||||
|
||||
Scenario Outline: upload a file with virus
|
||||
Given using <dav-path-version> DAV path
|
||||
When user "Alice" uploads file "filesForUpload/filesWithVirus/eicar.com" to "/aFileWithVirus.txt" using the WebDAV API
|
||||
@@ -43,10 +39,6 @@ Feature: antivirus
|
||||
| dav-path-version |
|
||||
| old |
|
||||
| new |
|
||||
|
||||
@skipOnRevaMaster
|
||||
Examples:
|
||||
| dav-path-version |
|
||||
| spaces |
|
||||
|
||||
|
||||
@@ -72,10 +64,6 @@ Feature: antivirus
|
||||
| dav-path-version |
|
||||
| old |
|
||||
| new |
|
||||
|
||||
@skipOnRevaMaster
|
||||
Examples:
|
||||
| dav-path-version |
|
||||
| spaces |
|
||||
|
||||
|
||||
@@ -95,8 +83,214 @@ Feature: antivirus
|
||||
Examples:
|
||||
| dav-path-version |
|
||||
| old |
|
||||
| spaces |
|
||||
|
||||
@skipOnRevaMaster
|
||||
|
||||
Scenario Outline: upload a file with the virus to a public share
|
||||
Given using <dav-path-version> DAV path
|
||||
And user "Alice" has created folder "/uploadFolder"
|
||||
And user "Alice" has created a public link share with settings
|
||||
| path | /uploadFolder |
|
||||
| name | sharedlink |
|
||||
| permissions | change |
|
||||
| expireDate | 2040-01-01T23:59:59+0100 |
|
||||
When user "Alice" uploads file "filesForUpload/filesWithVirus/<filename>" to "/<newfilename>" using the WebDAV API
|
||||
Then the HTTP status code should be "201"
|
||||
And user "Alice" should get a notification with subject "Virus found" and message:
|
||||
| message |
|
||||
| Virus found in <newfilename>. Upload not possible. Virus: Win.Test.EICAR_HDB-1 |
|
||||
And as "Alice" file "/uploadFolder/<newfilename>" should not exist
|
||||
Examples:
|
||||
| dav-path-version | filename | newfilename |
|
||||
| old | eicar.com | virusFile1.txt |
|
||||
| old | eicar_com.zip | virusFile2.zip |
|
||||
| new | eicar.com | virusFile1.txt |
|
||||
| new | eicar_com.zip | virusFile2.zip |
|
||||
| spaces | eicar.com | virusFile1.txt |
|
||||
| spaces | eicar_com.zip | virusFile2.zip |
|
||||
|
||||
|
||||
Scenario Outline: upload a file with the virus to a password-protected public share
|
||||
Given using <dav-path-version> DAV path
|
||||
And user "Alice" has created folder "/uploadFolder"
|
||||
And user "Alice" has created a public link share with settings
|
||||
| path | /uploadFolder |
|
||||
| name | sharedlink |
|
||||
| permissions | change |
|
||||
| password | newpasswd |
|
||||
| expireDate | 2040-01-01T23:59:59+0100 |
|
||||
When user "Alice" uploads file "filesForUpload/filesWithVirus/<filename>" to "/<newfilename>" using the WebDAV API
|
||||
Then the HTTP status code should be "201"
|
||||
And user "Alice" should get a notification with subject "Virus found" and message:
|
||||
| message |
|
||||
| Virus found in <newfilename>. Upload not possible. Virus: Win.Test.EICAR_HDB-1 |
|
||||
And as "Alice" file "/uploadFolder/<newfilename>" should not exist
|
||||
Examples:
|
||||
| dav-path-version | filename | newfilename |
|
||||
| old | eicar.com | virusFile1.txt |
|
||||
| old | eicar_com.zip | virusFile2.zip |
|
||||
| new | eicar.com | virusFile1.txt |
|
||||
| new | eicar_com.zip | virusFile2.zip |
|
||||
| spaces | eicar.com | virusFile1.txt |
|
||||
| spaces | eicar_com.zip | virusFile2.zip |
|
||||
|
||||
|
||||
Scenario Outline: upload a file with virus to a user share
|
||||
Given using <dav-path-version> DAV path
|
||||
And user "Brian" has been created with default attributes and without skeleton files
|
||||
And user "Alice" has created folder "uploadFolder"
|
||||
And user "Alice" has shared folder "uploadFolder" with user "Brian" with permissions "all"
|
||||
And user "Brian" has accepted share "/uploadFolder" offered by user "Alice"
|
||||
When user "Brian" uploads file "filesForUpload/filesWithVirus/<filename>" to "/Shares/uploadFolder/<newfilename>" using the WebDAV API
|
||||
Then the HTTP status code should be "201"
|
||||
And user "Brian" should get a notification with subject "Virus found" and message:
|
||||
| message |
|
||||
| Virus found in <newfilename>. Upload not possible. Virus: Win.Test.EICAR_HDB-1 |
|
||||
And as "Brian" file "/Shares/uploadFolder/<newfilename>" should not exist
|
||||
And as "Alice" file "/uploadFolder/<newfilename>" should not exist
|
||||
Examples:
|
||||
| dav-path-version | filename | newfilename |
|
||||
| old | eicar.com | virusFile1.txt |
|
||||
| old | eicar_com.zip | virusFile2.zip |
|
||||
| new | eicar.com | virusFile1.txt |
|
||||
| new | eicar_com.zip | virusFile2.zip |
|
||||
|
||||
|
||||
Scenario Outline: upload a file with virus to a user share using spaces dav endpoint
|
||||
Given using spaces DAV path
|
||||
And user "Brian" has been created with default attributes and without skeleton files
|
||||
And user "Alice" has created folder "uploadFolder"
|
||||
And user "Alice" has shared folder "uploadFolder" with user "Brian" with permissions "all"
|
||||
And user "Brian" has accepted share "/uploadFolder" offered by user "Alice"
|
||||
When user "Brian" uploads a file "filesForUpload/filesWithVirus/<filename>" to "/uploadFolder/<newfilename>" in space "Shares" using the WebDAV API
|
||||
Then the HTTP status code should be "201"
|
||||
And user "Brian" should get a notification with subject "Virus found" and message:
|
||||
| message |
|
||||
| Virus found in <newfilename>. Upload not possible. Virus: Win.Test.EICAR_HDB-1 |
|
||||
And as "Brian" file "/Shares/uploadFolder/<newfilename>" should not exist
|
||||
And as "Alice" file "/uploadFolder/<newfilename>" should not exist
|
||||
Examples:
|
||||
| filename | newfilename |
|
||||
| eicar.com | virusFile1.txt |
|
||||
| eicar_com.zip | virusFile2.zip |
|
||||
|
||||
|
||||
Scenario Outline: upload a file with virus to a group share
|
||||
Given using <dav-path-version> DAV path
|
||||
And user "Brian" has been created with default attributes and without skeleton files
|
||||
And group "group1" has been created
|
||||
And user "Brian" has been added to group "group1"
|
||||
And user "Alice" has created folder "uploadFolder"
|
||||
And user "Alice" has shared folder "uploadFolder" with group "group1"
|
||||
And user "Brian" has accepted share "/uploadFolder" offered by user "Alice"
|
||||
When user "Brian" uploads file "filesForUpload/filesWithVirus/<filename>" to "/Shares/uploadFolder/<newfilename>" using the WebDAV API
|
||||
Then the HTTP status code should be "201"
|
||||
And user "Brian" should get a notification with subject "Virus found" and message:
|
||||
| message |
|
||||
| Virus found in <newfilename>. Upload not possible. Virus: Win.Test.EICAR_HDB-1 |
|
||||
And as "Brian" file "/Shares/uploadFolder/<newfilename>" should not exist
|
||||
And as "Alice" file "/uploadFolder/<newfilename>" should not exist
|
||||
Examples:
|
||||
| dav-path-version | filename | newfilename |
|
||||
| old | eicar.com | virusFile1.txt |
|
||||
| old | eicar_com.zip | virusFile2.zip |
|
||||
| new | eicar.com | virusFile1.txt |
|
||||
| new | eicar_com.zip | virusFile2.zip |
|
||||
|
||||
|
||||
Scenario Outline: upload a file with virus to a group share using spaces dav endpoint
|
||||
Given using spaces DAV path
|
||||
And user "Brian" has been created with default attributes and without skeleton files
|
||||
And group "group1" has been created
|
||||
And user "Brian" has been added to group "group1"
|
||||
And user "Alice" has created folder "uploadFolder"
|
||||
And user "Alice" has shared folder "uploadFolder" with group "group1"
|
||||
And user "Brian" has accepted share "/uploadFolder" offered by user "Alice"
|
||||
When user "Brian" uploads a file "filesForUpload/filesWithVirus/<filename>" to "/uploadFolder/<newfilename>" in space "Shares" using the WebDAV API
|
||||
Then the HTTP status code should be "201"
|
||||
And user "Brian" should get a notification with subject "Virus found" and message:
|
||||
| message |
|
||||
| Virus found in <newfilename>. Upload not possible. Virus: Win.Test.EICAR_HDB-1 |
|
||||
And as "Brian" file "/Shares/uploadFolder/<newfilename>" should not exist
|
||||
And as "Alice" file "/uploadFolder/<newfilename>" should not exist
|
||||
Examples:
|
||||
| filename | newfilename |
|
||||
| eicar.com | virusFile1.txt |
|
||||
| eicar_com.zip | virusFile2.zip |
|
||||
|
||||
|
||||
Scenario Outline: upload a file with virus to a project space
|
||||
Given using spaces DAV path
|
||||
And the administrator has given "Alice" the role "Space Admin" using the settings api
|
||||
And user "Alice" has created a space "new-space" with the default quota using the GraphApi
|
||||
And user "Alice" has created a folder "uploadFolder" in space "new-space"
|
||||
When user "Alice" uploads a file "filesForUpload/filesWithVirus/<filename>" to "/uploadFolder/<newfilename>" in space "new-space" using the WebDAV API
|
||||
Then the HTTP status code should be "201"
|
||||
And user "Alice" should get a notification with subject "Virus found" and message:
|
||||
| message |
|
||||
| Virus found in <newfilename>. Upload not possible. Virus: Win.Test.EICAR_HDB-1 |
|
||||
And for user "Alice" the space "new-space" should not contain these entries:
|
||||
| /uploadFolder/<newfilename> |
|
||||
When user "Alice" uploads a file "filesForUpload/filesWithVirus/<filename>" to "/<newfilename>" in space "new-space" using the WebDAV API
|
||||
Then the HTTP status code should be "201"
|
||||
And user "Alice" should get a notification with subject "Virus found" and message:
|
||||
| message |
|
||||
| Virus found in <newfilename>. Upload not possible. Virus: Win.Test.EICAR_HDB-1 |
|
||||
And for user "Alice" the space "new-space" should not contain these entries:
|
||||
| /<newfilename> |
|
||||
Examples:
|
||||
| filename | newfilename |
|
||||
| eicar.com | virusFile1.txt |
|
||||
| eicar_com.zip | virusFile2.zip |
|
||||
|
||||
|
||||
Scenario Outline: upload a file with virus to a shared project space
|
||||
Given using spaces DAV path
|
||||
And user "Brian" has been created with default attributes and without skeleton files
|
||||
And the administrator has given "Alice" the role "Space Admin" using the settings api
|
||||
And user "Alice" has created a space "new-space" with the default quota using the GraphApi
|
||||
And user "Alice" has shared a space "new-space" with settings:
|
||||
| shareWith | Brian |
|
||||
| role | editor |
|
||||
When user "Brian" uploads a file "/filesForUpload/filesWithVirus/<filename>" to "/<newfilename>" in space "new-space" using the WebDAV API
|
||||
Then the HTTP status code should be "201"
|
||||
And user "Brian" should get a notification with subject "Virus found" and message:
|
||||
| message |
|
||||
| Virus found in <newfilename>. Upload not possible. Virus: Win.Test.EICAR_HDB-1 |
|
||||
And for user "Brian" the space "new-space" should not contain these entries:
|
||||
| /<newfilename> |
|
||||
And for user "Alice" the space "new-space" should not contain these entries:
|
||||
| /<newfilename> |
|
||||
Examples:
|
||||
| filename | newfilename |
|
||||
| eicar.com | virusFile1.txt |
|
||||
| eicar_com.zip | virusFile2.zip |
|
||||
|
||||
@env-config
|
||||
Scenario Outline: upload a file with virus smaller than the upload threshold
|
||||
Given the config "ANTIVIRUS_MAX_SCAN_SIZE" has been set to "100"
|
||||
And using <dav-path-version> DAV path
|
||||
When user "Alice" uploads file "filesForUpload/filesWithVirus/eicar.com" to "/aFileWithVirus.txt" using the WebDAV API
|
||||
Then the HTTP status code should be "201"
|
||||
And user "Alice" should get a notification with subject "Virus found" and message:
|
||||
| message |
|
||||
| Virus found in aFileWithVirus.txt. Upload not possible. Virus: Win.Test.EICAR_HDB-1 |
|
||||
And as "Alice" file "/aFileWithVirus.txt" should not exist
|
||||
Examples:
|
||||
| dav-path-version |
|
||||
| old |
|
||||
| new |
|
||||
| spaces |
|
||||
|
||||
@env-config
|
||||
Scenario Outline: upload a file with virus larger than the upload threshold
|
||||
Given the config "ANTIVIRUS_MAX_SCAN_SIZE" has been set to "100"
|
||||
And using <dav-path-version> DAV path
|
||||
When user "Alice" uploads file "filesForUpload/filesWithVirus/eicar_com.zip" to "/aFileWithVirus.txt" using the WebDAV API
|
||||
Then the HTTP status code should be "201"
|
||||
And as "Alice" file "/aFileWithVirus.txt" should exist
|
||||
Examples:
|
||||
| dav-path-version |
|
||||
| old |
|
||||
| new |
|
||||
| spaces |
|
||||
@@ -1228,6 +1228,28 @@ class SpacesContext implements Context {
|
||||
$this->featureContext->uploadFileWithContent($user, $content, $destination);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^user "([^"]*)" uploads a file "([^"]*)" to "([^"]*)" in space "([^"]*)" using the WebDAV API$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
* @param string $spaceName
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theUserUploadsALocalFileToSpace(
|
||||
string $user,
|
||||
string $source,
|
||||
string $destination,
|
||||
string $spaceName
|
||||
): void {
|
||||
$this->setSpaceIDByName($user, $spaceName);
|
||||
$this->featureContext->userUploadsAFileTo($user, $source, $destination);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^user "([^"]*)" uploads a file inside space "([^"]*)" owned by the user "([^"]*)" with content "([^"]*)" to "([^"]*)" using the WebDAV API$/
|
||||
*
|
||||
|
||||
Binary file not shown.
Reference in new issue
Block a user