Skip to content

Commit

Permalink
adding integration tests (#34)
Browse files Browse the repository at this point in the history
* adds tests
  
```
ok 1 test admin eicar Upload
ok 2 test admin clean upload
ok 3 test admin pup Upload
ok 4 test testuser eicar Upload
ok 5 test testuser clean Upload
ok 6 test testuser pup Upload
ok 7 test upload when vaas does not function
ok 8 test croned scan for admin files
ok 9 test croned scan for testuser files
```

tagging tests still missing but having an idea

* refactors the install script, so it does more stuff in parallel
* adds occ console command to make testing more reliable
* refactors APP_ID usage

---------

Co-authored-by: Simonis, Matthias <[email protected]>
  • Loading branch information
unglaublicherdude and Simonis, Matthias authored Jun 12, 2024
1 parent dd8182f commit 8965e55
Show file tree
Hide file tree
Showing 21 changed files with 1,800 additions and 178 deletions.
7 changes: 2 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "make build && composer install",
"features": {
"ghcr.io/devcontainers/features/node:1": {
"nodeGypDependencies": true,
"version": "lts",
"nvmVersion": "latest"
}
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/edouard-lopez/devcontainer-features/bats:0": {}
}
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
Expand Down
71 changes: 35 additions & 36 deletions .github/workflows/release-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,50 @@ on:
branches: ["main"]

jobs:
# test:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-node@v4
# name: setup node
# with:
# node-version: 20
# - name: Setup BATS
# uses: mig4/setup-bats@v1
# with:
# bats-version: 1.11.0
# - uses: docker-practice/actions-setup-docker@master
# - name: install nextcloud
# env:
# CLIENT_ID: ${{ secrets.VAAS_CLIENT_ID }}
# CLIENT_SECRET: ${{ secrets.VAAS_CLIENT_SECRET }}
# run: ./install.sh
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
name: setup node
with:
node-version: 20

- name: Setup BATS
uses: mig4/setup-bats@v1
with:
bats-version: 1.11.0

- uses: docker-practice/actions-setup-docker@master
- name: install nextcloud
env:
CLIENT_ID: ${{ secrets.VAAS_CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.VAAS_CLIENT_SECRET }}
run: ./install.sh

# - name: run tests
# env:
# CLIENT_ID: ${{ secrets.VAAS_CLIENT_ID }}
# CLIENT_SECRET: ${{ secrets.VAAS_CLIENT_SECRET }}
# run: bats --no-parallelize-across-files --jobs 3 ./tests
- name: run tests
env:
CLIENT_ID: ${{ secrets.VAAS_CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.VAAS_CLIENT_SECRET }}
run: bats --no-parallelize-across-files --jobs 2 ./tests

# - uses: actions/upload-artifact@master
# with:
# name: build-dir
# path: build/
- uses: actions/upload-artifact@master
with:
name: build-dir
path: build/

release:
# needs:
# - test
needs:
- test
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4

# - uses: actions/download-artifact@master
# with:
# name: build-dir
# path: build/

- name: Build for appstore
run: make appstore
- uses: actions/download-artifact@master
with:
name: build-dir
path: build/

- name: replace version
id: replace-version
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,5 @@ dev-environment*/
js/
*.cache
.uuid
eicar.com.txt
tmp/
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
"php-cs-fixer.executablePath": "/workspaces/nextcloud-gdata-antivirus/vendor/bin/php-cs-fixer",
"php-cs-fixer.onsave": true,
"php-cs-fixer.autoFixByBracket": true,
"php-cs-fixer.autoFixBySemicolon": true
"php-cs-fixer.autoFixBySemicolon": true,
"[php]": {
"editor.defaultFormatter": "junstyle.php-cs-fixer"
},
}
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,18 @@ endif
.PHONY: npm
npm:
ifeq (,$(wildcard $(CURDIR)/package.json))
npm install
ifeq (,$(wildcard $(CURDIR)/package-lock.json))
npm install --no-audit --progress=false
else
npm ci
endif
cd js && $(npm) run build
else
npm install
ifeq (,$(wildcard $(CURDIR)/package-lock.json))
npm install --no-audit --progress=false
else
npm ci
endif
npm run build
endif

Expand Down
4 changes: 4 additions & 0 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ If you have any questions about scanning, usage or similar, please feel free to
<admin-section>OCA\GDataVaas\Settings\VaasAdminSection</admin-section>
<admin>OCA\GDataVaas\Settings\VaasAdmin</admin>
</settings>
<commands>
<command>OCA\GDataVaas\Command\ScanCommand</command>
<command>OCA\GDataVaas\Command\TagUnscannedCommand</command>
</commands>
<dependencies>
<nextcloud min-version="27" max-version="28"/>
</dependencies>
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"require-dev": {
"nextcloud/ocp": "dev-stable28",
"psalm/phar": "^5.17.0",
"nextcloud/coding-standard": "^v1.1.1"
"nextcloud/coding-standard": "^v1.1.1",
"symfony/console": "^6.4"
},
"scripts": {
"lint": "find lib -name \\*.php -not -path './vendor/*' -print0 | xargs -0 -n1 php -l",
Expand Down
Loading

0 comments on commit 8965e55

Please sign in to comment.