From 91b75d90c7016d935a81cd6280567a7121b68f4f Mon Sep 17 00:00:00 2001 From: vaas-bot <108060048+ata-no-one@users.noreply.github.com> Date: Fri, 6 Sep 2024 12:23:41 +0200 Subject: [PATCH] chore(deps): update dependency gdata/vaas to v9 (#98) * chore(deps): update dependency gdata/vaas to v9 * async upload --------- Co-authored-by: Renovate Bot Co-authored-by: Kevin Heise Co-authored-by: Lennart Dohmann Co-authored-by: Lennart Dohmann Co-authored-by: unglaublicherdude --- .devcontainer/postCreateCommands.sh | 4 +++ .github/workflows/release-app.yml | 20 +++++++++--- .gitignore | 8 +++-- .vscode/launch.json | 2 +- Dockerfile.Nextcloud | 36 +++++++++++++++++++--- Makefile | 10 ++++++ README.md | 2 +- compose-install.yaml | 15 ++++----- composer.json | 6 ++-- composer.local.vaas.json | 14 +++++++++ install.sh | 18 +++++++++-- lib/AvirWrapper.php | 42 +++++++++++++------------- lib/CacheEntryListener.php | 2 ++ lib/Service/VerdictService.php | 25 ++++++++++----- package.json | 5 +-- tests/bats/functionality-parallel.bats | 41 +++++++++++++++++++++++-- tests/unittests/VerdictServiceTest.php | 13 ++++++++ use-local-vaas.sh | 26 ++++++++++++++++ use-packagist-vaas.sh | 8 +++++ xdebug.ini | 3 +- xdebug.local.ini | 7 +++++ 21 files changed, 248 insertions(+), 59 deletions(-) create mode 100644 composer.local.vaas.json create mode 100755 use-local-vaas.sh create mode 100755 use-packagist-vaas.sh create mode 100644 xdebug.local.ini diff --git a/.devcontainer/postCreateCommands.sh b/.devcontainer/postCreateCommands.sh index 88e870c5..b7f0536c 100755 --- a/.devcontainer/postCreateCommands.sh +++ b/.devcontainer/postCreateCommands.sh @@ -5,10 +5,14 @@ sudo apt-get install -y bash-completion vim iputils-ping telnet sudo bash -c "docker completion bash > /usr/share/bash-completion/completions/docker" sudo bash -c "composer completion bash > /usr/share/bash-completion/completions/composer" sudo bash -c "npm completion > /usr/share/bash-completion/completions/npm" +sudo cp xdebug.local.ini /usr/local/etc/php/conf.d/xdebug.ini +sudo curl -sS https://webi.sh/gh | sh echo ". /usr/share/bash-completion/bash_completion" >> /home/vscode/.bashrc NEXTCLOUD_VERSION=$(grep -oP "[0-9]+\.[0-9]+\.[0-9]+" install.sh) +mkdir -p ~/.ssh/ +ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts git clone --depth 1 --recurse-submodules --single-branch --branch v$NEXTCLOUD_VERSION git@github.com:nextcloud/server.git ./nextcloud-server cd nextcloud-server git submodule update --init diff --git a/.github/workflows/release-app.yml b/.github/workflows/release-app.yml index 1642f62f..b9d7655f 100644 --- a/.github/workflows/release-app.yml +++ b/.github/workflows/release-app.yml @@ -52,26 +52,36 @@ jobs: CLIENT_ID: ${{ secrets.VAAS_CLIENT_ID }} CLIENT_SECRET: ${{ secrets.VAAS_CLIENT_SECRET }} run: | - composer install --quiet + composer install ./vendor/bin/phpunit --bootstrap tests/unittests/bootstrap.php tests/unittests/ --testdox - name: install nextcloud env: CLIENT_ID: ${{ secrets.VAAS_CLIENT_ID }} CLIENT_SECRET: ${{ secrets.VAAS_CLIENT_SECRET }} - run: ./install.sh ${{ matrix.nextcloud_version }} + run: ./install.sh ${{ matrix.nextcloud_version }} 1 - name: run tests + id: bats-tests env: CLIENT_ID: ${{ secrets.VAAS_CLIENT_ID }} CLIENT_SECRET: ${{ secrets.VAAS_CLIENT_SECRET }} - run: bats --no-parallelize-across-files --jobs 2 ./tests/bats + run: | + if bats --verbose-run --timing --trace --no-parallelize-across-files --jobs 2 ./tests/bats; then + echo "bats_run=success" | tee -a "$GITHUB_OUTPUT"; + else + echo "bats_run=fail" | tee -a "$GITHUB_OUTPUT"; + fi - uses: actions/upload-artifact@master with: overwrite: true - name: build-dir - path: build/ + name: core-dump + path: coredumps/* + + - name: fail if bats tests did fail + if: steps.bats-tests.outputs.bats_run == 'fail' + run: exit 1 release: needs: diff --git a/.gitignore b/.gitignore index 2067da1c..3d05ad75 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ .idea *.local *.iml +*.local.php /build/ node_modules/ /.php_cs.cache @@ -64,5 +65,8 @@ js/ .uuid eicar.com.txt tmp/ - -nextcloud-server/ \ No newline at end of file +core.1 +nextcloud-server/ +core-dump.zip +apache/ +**/vendor/* \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 79e7748b..b78774f5 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -26,7 +26,7 @@ "name": "Listen for Xdebug", "type": "php", "request": "launch", - "port": 9000 + "port": 9003 }, { "name": "Launch currently open script", diff --git a/Dockerfile.Nextcloud b/Dockerfile.Nextcloud index 2f7c9b52..0c4fe7ea 100644 --- a/Dockerfile.Nextcloud +++ b/Dockerfile.Nextcloud @@ -1,8 +1,36 @@ -ARG NEXTCLOUD_VERSION=29.0.4 +ARG NEXTCLOUD_VERSION=29.0.6 +ARG INSTALL_XDEBUG=1 FROM nextcloud:${NEXTCLOUD_VERSION} -RUN apt update && apt install -y less vim telnet iputils-ping +RUN apt update && apt install -y \ + less vim telnet iputils-ping gdb libexpat1-dev libapr1-dev libaprutil1-dev devscripts debmake \ + bison jdupes libbrotli-dev liblua5.4-dev libnghttp2-dev libssl-dev libxml2-dev libcurl4-openssl-dev libjansson-dev +# RUN curl -L -o /tmp/apache2_2.4.61.orig.tar.gz https://launchpad.net/debian/+archive/primary/+sourcefiles/apache2/2.4.61-1/apache2_2.4.61.orig.tar.gz \ +# && tar -xzf /tmp/apache2_2.4.61.orig.tar.gz -C /tmp \ +# && mv /tmp/httpd-2.4.61 /tmp/apache2-2.4.61 \ +# && curl -L -o /tmp/apache2_2.4.61-1.debian.tar.xz https://launchpad.net/debian/+archive/primary/+sourcefiles/apache2/2.4.61-1/apache2_2.4.61-1.debian.tar.xz \ +# && tar -xf /tmp/apache2_2.4.61-1.debian.tar.xz -C /tmp \ +# && mv /tmp/debian /tmp/apache2-2.4.61/debian \ +# && cd /tmp/apache2-2.4.61 \ +# && debuild || echo "no signature" +RUN curl -o /root/.gdbinit https://raw.githubusercontent.com/php/php-src/master/.gdbinit +RUN ulimit -c unlimited +RUN mkdir -p /tmp/apache2-coredump \ + && chown -R www-data:www-data /tmp/apache2-coredump \ + && chmod 777 /tmp/apache2-coredump \ + && echo "CoreDumpDirectory /tmp/apache2-coredump" >> /etc/apache2/apache2.conf ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ -RUN install-php-extensions gd xdebug -COPY xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" +RUN sed -i 's/max_execution_time = 30/max_execution_time = -1/g' "$PHP_INI_DIR/php.ini" +RUN sed -i 's/max_input_time = 60/max_input_time = -1/g' "$PHP_INI_DIR/php.ini" +RUN sed -i 's/memory_limit = 128M/memory_limit = -1/g' "$PHP_INI_DIR/php.ini" +RUN echo "error_log = /var/www/html/data/php.log" >> "$PHP_INI_DIR/php.ini" +RUN sed -i 's/#LogLevel info ssl:warn/LogLevel debug/g' /etc/apache2/sites-available/000-default.conf + +COPY xdebug.ini /tmp/xdebug.ini +RUN if [[ "$INSTALL_XDEBUG" == "1" ]]; then \ + install-php-extensions gd xdebug; \ + mv /tmp/xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \ + fi + diff --git a/Makefile b/Makefile index 2f5293d5..222cb8a7 100644 --- a/Makefile +++ b/Makefile @@ -121,6 +121,16 @@ appstore: build tar czf $(appstore_package_name).tar.gz \ --transform s/$(app_directory_name)/$(app_real_name)/ \ --exclude-vcs \ + --exclude="../$(app_directory_name)/opcache-disabled.ini" \ + --exclude="../$(app_directory_name)/opcache-blacklist.txt" \ + --exclude="../$(app_directory_name)/artifacts" \ + --exclude="../$(app_directory_name)/tmp*" \ + --exclude="../$(app_directory_name)/Dockerfile*" \ + --exclude="../$(app_directory_name)/nextcloud-server*" \ + --exclude="../$(app_directory_name)/compose-install.yaml" \ + --exclude="../$(app_directory_name)/empty-skeleton.config.php" \ + --exclude="../$(app_directory_name)/get-matrix.sh" \ + --exclude="../$(app_directory_name)/xdebug.*" \ --exclude="../$(app_directory_name)/build" \ --exclude="../$(app_directory_name)/tests" \ --exclude="../$(app_directory_name)/Makefile" \ diff --git a/README.md b/README.md index cb3e1a84..2ec8ea12 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ The `install.sh` script is used to set up and configure a Nextcloud instance wit If you want to use the ResourceOwnerPasswordFlow you have to set these settings manually in the Nextcloud settings after the installation. 2. **Specify the Nextcloud server version**: - - The Nextcloud version defaults to 29.0.4 + - The Nextcloud version defaults to 29.0.6 - You can start the `install.sh` script with the desired Nextcloud version as an argument, e.g. `./install.sh 29` 3. **Smtp4Dev**: diff --git a/compose-install.yaml b/compose-install.yaml index 586d9620..4e8d352e 100644 --- a/compose-install.yaml +++ b/compose-install.yaml @@ -5,10 +5,16 @@ services: dockerfile: Dockerfile.Nextcloud args: - NEXTCLOUD_VERSION=${NEXTCLOUD_VERSION:-29.0.3} + - INSTALL_XDEBUG=${INSTALL_XDEBUG:-1} environment: - - XDEBUG_MODE=${XDEBUG_MODE:-develop} + XDEBUG_MODE: ${XDEBUG_MODE:-develop} ports: - "80:80" + privileged: true + # cap_add: + # - SYS_PTRACE + # - SYS_ADMIN + # - NET_ADMIN container_name: nextcloud-container hostname: nextcloud-container depends_on: @@ -16,11 +22,6 @@ services: restart: unless-stopped networks: - nextcloud-network - healthcheck: - test: 'php occ status | grep "installed: false"' - interval: 5s - timeout: 2s - retries: 10 smtp: image: rnwood/smtp4dev:v3 container_name: smtp @@ -34,4 +35,4 @@ services: - nextcloud-network networks: - nextcloud-network: \ No newline at end of file + nextcloud-network: diff --git a/composer.json b/composer.json index a4fd472e..a5bd3850 100644 --- a/composer.json +++ b/composer.json @@ -9,13 +9,13 @@ } ], "require": { - "gdata/vaas": "8.0.2", + "gdata/vaas": "v9.0.4", "coduo/php-humanizer": "^5.0" }, "require-dev": { - "nextcloud/ocp": "v29.0.4", + "nextcloud/ocp": "v29.0.6", "psalm/phar": "5.25.0", - "nextcloud/coding-standard": "v1.2.1", + "nextcloud/coding-standard": "v1.2.3", "phpunit/phpunit": "10.5.30", "symfony/console": "6.4.10" }, diff --git a/composer.local.vaas.json b/composer.local.vaas.json new file mode 100644 index 00000000..d403e82d --- /dev/null +++ b/composer.local.vaas.json @@ -0,0 +1,14 @@ +{ + "repositories": [ + { + "type": "path", + "url": "./gdata/php/src/vaas", + "options": { + "symlink": false + } + } + ], + "require": { + "gdata/vaas": "@dev" + } +} \ No newline at end of file diff --git a/install.sh b/install.sh index 37a4930b..86115ac6 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,7 @@ #!/bin/bash -export NEXTCLOUD_VERSION=${1:-29.0.4} +export NEXTCLOUD_VERSION=${1:-29.0.6} +export INSTALL_XDEBUG=${2:-1} export XDEBUG_MODE=${XDEBUG_MODE:-develop} source .env-local || echo "No .env-local file found." @@ -11,6 +12,15 @@ setup_nextcloud () { docker compose -f compose-install.yaml rm --force --stop --volumes docker compose -f compose-install.yaml up --build --quiet-pull --wait -d --force-recreate --renew-anon-volumes --remove-orphans + docker exec -i nextcloud-container ulimit -c unlimited + docker exec -i nextcloud-container bash -c 'echo "/tmp/apache2-coredump/core-%e-%s-%u-%g-%p-%t" > /proc/sys/kernel/core_pattern' + + until docker exec --user www-data -i nextcloud-container php occ status | grep "installed: false" + do + echo "waiting for nextcloud to be initialized" + sleep 2 + done + echo "copy config for empty skeleton" docker cp ./empty-skeleton.config.php nextcloud-container:/var/www/html/config/config.php docker exec -i nextcloud-container chown www-data:www-data /var/www/html/config/config.php @@ -23,6 +33,8 @@ setup_nextcloud () { docker exec --user www-data -i nextcloud-container php occ log:manage --level DEBUG docker exec --user www-data -i nextcloud-container php occ app:disable firstrunwizard + docker exec --user www-data -i nextcloud-container php occ app:disable weather_status + docker exec --user www-data -i nextcloud-container php occ config:system:set trusted_domains 2 --value=192.168.5.80 echo "setup nextcloud finished" } @@ -71,4 +83,6 @@ docker exec --user www-data -i nextcloud-container php occ user:setting admin se source install.local || echo "No additional install script found." # Has to be done, to get the dev-requirements installed again -composer install +composer install --quiet & + +composer info \ No newline at end of file diff --git a/lib/AvirWrapper.php b/lib/AvirWrapper.php index d6ae2ba6..7dc3e4d7 100644 --- a/lib/AvirWrapper.php +++ b/lib/AvirWrapper.php @@ -145,27 +145,27 @@ function () use ($path, $logger) { return; } - try { - $verdict = $this->verdictService->scan($localPath); - } catch (EntityTooLargeException) { - $this->logger->error("File $localPath is larger than " . NumberHumanizer::binarySuffix(VerdictService::MAX_FILE_SIZE, 'de')); - } catch (FileDoesNotExistException) { - $this->logger->error("File $localPath does not exist on upload"); - } catch (InvalidSha256Exception) { - $this->logger->error("Invalid SHA256 for file $localPath on upload"); - } catch (NotFoundException) { - $this->logger->error("File $localPath not found on upload"); - } catch (NotPermittedException) { - $this->logger->error("Current settings do not permit scanning file $localPath on upload"); - } catch (TimeoutException) { - $this->logger->error("Scanning timed out for file $localPath on upload"); - } catch (UploadFailedException|ServerException) { - $this->logger->error("File $localPath could not be scanned on upload with GData VaaS because there was a temporary upstream server error"); - } catch (VaasAuthenticationException) { - $this->logger->error("Authentication for VaaS scan failed. Please check your credentials."); - } catch (\Exception $e) { - $this->logger->error("Unexpected error while scanning file " . $localPath . " on upload: " . $e->getMessage()); - } + try { + $verdict = $this->verdictService->scan($localPath); + } catch (EntityTooLargeException) { + $this->logger->error("File $localPath is larger than " . NumberHumanizer::binarySuffix(VerdictService::MAX_FILE_SIZE, 'de')); + } catch (FileDoesNotExistException) { + $this->logger->error("File $localPath does not exist on upload"); + } catch (InvalidSha256Exception) { + $this->logger->error("Invalid SHA256 for file $localPath on upload"); + } catch (NotFoundException) { + $this->logger->error("File $localPath not found on upload"); + } catch (NotPermittedException) { + $this->logger->error("Current settings do not permit scanning file $localPath on upload"); + } catch (TimeoutException) { + $this->logger->error("Scanning timed out for file $localPath on upload"); + } catch (UploadFailedException|ServerException) { + $this->logger->error("File $localPath could not be scanned on upload with GData VaaS because there was a temporary upstream server error"); + } catch (VaasAuthenticationException) { + $this->logger->error("Authentication for VaaS scan failed. Please check your credentials."); + } catch (\Exception $e) { + $this->logger->error("Unexpected error while scanning file " . $localPath . " on upload: " . $e->getMessage()); + } $logger->debug("Verdict for " . $localPath . " is " . $verdict->Verdict->value); if ($verdict->Verdict == Verdict::MALICIOUS) { diff --git a/lib/CacheEntryListener.php b/lib/CacheEntryListener.php index 76705201..5130e737 100644 --- a/lib/CacheEntryListener.php +++ b/lib/CacheEntryListener.php @@ -31,6 +31,7 @@ public static function register(IRegistrationContext $context): void { } public function handle(Event $event): void { + $this->logger->debug("CacheEntryListener"); if (!$event instanceof AbstractCacheEvent) { return; } @@ -39,6 +40,7 @@ public function handle(Event $event): void { $path = $event->getPath(); $fileId = $event->getFileId(); + $this->logger->debug("GotFields"); if (self::shouldTag($path) && !$this->tagService->hasAnyVaasTag($fileId)) { $this->logger->debug("Handling " . get_class($event) . " for " . $path); diff --git a/lib/Service/VerdictService.php b/lib/Service/VerdictService.php index add4e8ba..d9e9fbaa 100644 --- a/lib/Service/VerdictService.php +++ b/lib/Service/VerdictService.php @@ -9,14 +9,14 @@ use OCP\Files\NotPermittedException; use OCP\IAppConfig; use Psr\Log\LoggerInterface; -use VaasSdk\ClientCredentialsGrantAuthenticator; +use VaasSdk\Authentication\ClientCredentialsGrantAuthenticator; +use VaasSdk\Authentication\ResourceOwnerPasswordGrantAuthenticator; use VaasSdk\Exceptions\FileDoesNotExistException; use VaasSdk\Exceptions\InvalidSha256Exception; use VaasSdk\Exceptions\TimeoutException; use VaasSdk\Exceptions\UploadFailedException; use VaasSdk\Exceptions\VaasAuthenticationException; use VaasSdk\Message\VaasVerdict; -use VaasSdk\ResourceOwnerPasswordGrantAuthenticator; use VaasSdk\Vaas; use VaasSdk\VaasOptions; @@ -128,7 +128,6 @@ public static function isFileTooLargeToScan(string $path): bool { return ($size === false) || $size > self::MAX_FILE_SIZE; } - /** * Scans a file for malicious content with G DATA Verdict-as-a-Service and returns the verdict. * @param string $filePath The local path to the file to scan. @@ -232,24 +231,34 @@ public function removeWhitespacesAroundComma(string $s): string { } /** + * @param string $authMethod + * @return ClientCredentialsGrantAuthenticator|ResourceOwnerPasswordGrantAuthenticator * @throws VaasAuthenticationException */ - private function createAndConnectVaas(): Vaas { - if ($this->authMethod === 'ResourceOwnerPassword') { - $this->authenticator = new ResourceOwnerPasswordGrantAuthenticator( + public function getAuthenticator(string $authMethod): ClientCredentialsGrantAuthenticator|ResourceOwnerPasswordGrantAuthenticator { + if ($authMethod === 'ResourceOwnerPassword') { + return new ResourceOwnerPasswordGrantAuthenticator( "nextcloud-customer", $this->username, $this->password, $this->tokenEndpoint ); - } elseif ($this->authMethod === 'ClientCredentials') { - $this->authenticator = new ClientCredentialsGrantAuthenticator( + } elseif ($authMethod === 'ClientCredentials') { + return new ClientCredentialsGrantAuthenticator( $this->clientId, $this->clientSecret, $this->tokenEndpoint ); + } else { + throw new VaasAuthenticationException("Invalid auth method: " . $authMethod); } + } + /** + * @throws VaasAuthenticationException + */ + public function createAndConnectVaas(): Vaas { + $this->authenticator = $this->getAuthenticator($this->authMethod); $options = new VaasOptions(false, false); $vaas = new Vaas($this->vaasUrl, $this->logger, $options); $vaas->Connect($this->authenticator->getToken()); diff --git a/package.json b/package.json index 8174aa82..86f556fc 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "license": "AGPL-3.0-or-later", "private": true, "scripts": { - "build": "webpack --node-env production --progress", + "build": "webpack --node-env production", "dev": "webpack --node-env development --progress", "watch": "webpack --node-env development --progress --watch", "serve": "webpack --node-env development serve --progress", @@ -40,7 +40,8 @@ }, "overrides": { "@nextcloud/webpack-vue-config": { - "webpack-dev-server": "5.0.4" + "webpack-dev-server": "5.0.4", + "vue-loader": "^17" } } } \ No newline at end of file diff --git a/tests/bats/functionality-parallel.bats b/tests/bats/functionality-parallel.bats index e81f1ac4..48a9f6d7 100755 --- a/tests/bats/functionality-parallel.bats +++ b/tests/bats/functionality-parallel.bats @@ -15,14 +15,51 @@ setup_file() { } @test "test admin eicar Upload" { - RESULT=$(echo $EICAR_STRING | curl --silent -w "%{http_code}" -u admin:admin -T - http://127.0.0.1/remote.php/dav/files/admin/functionality-parallel.eicar.com.txt) + EICAR_LENGTH=$(echo $EICAR_STRING | wc -c) + RESULT=$(echo $EICAR_STRING | curl -v -X PUT -d"$EICAR_STRING" -w "%{http_code}" -u admin:admin -T - http://127.0.0.1/remote.php/dav/files/admin/functionality-parallel.eicar.com.txt || echo "curl failed") + + if [[ "$RESULT" =~ "curl failed" ]]; then + echo "debugging stuff" + docker exec -i nextcloud-container ls -lha /tmp/apache2-coredump + mkdir -p ./coredumps + docker container cp nextcloud-container:/tmp/apache2-coredump/* ./coredumps + ls -lha ./coredumps + $DOCKER_EXEC_WITH_USER -i nextcloud-container ls -lha data + $DOCKER_EXEC_WITH_USER -i nextcloud-container ls -lha data/admin + $DOCKER_EXEC_WITH_USER -i nextcloud-container ls -lha data/admin/files + $DOCKER_EXEC_WITH_USER -i nextcloud-container cat .htaccess + df -h + free + mpstat + docker stats --no-stream --no-trunc + $DOCKER_EXEC_WITH_USER -i nextcloud-container cat data/nextcloud.log + $DOCKER_EXEC_WITH_USER -i nextcloud-container cat /var/www/html/data/php.log + docker logs nextcloud-container + fi + echo "Actual: $RESULT" curl --silent -q -u admin:admin -X DELETE http://127.0.0.1/remote.php/dav/files/admin/functionality-parallel.eicar.com.txt || echo "file not found" [[ "$RESULT" =~ "Upload cannot be completed." ]] } @test "test admin clean upload" { - RESULT=$(echo $CLEAN_STRING | curl -w "%{http_code}" -u admin:admin -T - http://127.0.0.1/remote.php/dav/files/admin/functionality-parallel.clean.txt) + RESULT=$(echo $CLEAN_STRING | curl -w "%{http_code}" -u admin:admin -T - http://127.0.0.1/remote.php/dav/files/admin/functionality-parallel.clean.txt || echo "curl failed") + + if [[ "$RESULT" =~ "curl failed" ]]; then + echo "debugging stuff" + $DOCKER_EXEC_WITH_USER -i nextcloud-container ls -lha data + $DOCKER_EXEC_WITH_USER -i nextcloud-container ls -lha data/admin + $DOCKER_EXEC_WITH_USER -i nextcloud-container ls -lha data/admin/files + $DOCKER_EXEC_WITH_USER -i nextcloud-container cat .htaccess + df -h + free + mpstat + docker stats --no-stream --no-trunc + $DOCKER_EXEC_WITH_USER -i nextcloud-container cat data/nextcloud.log + $DOCKER_EXEC_WITH_USER -i nextcloud-container cat /var/www/html/data/php.log + docker logs nextcloud-container + fi + 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 || echo "file not found" [[ $RESULT -ge 200 && $RESULT -lt 300 ]] diff --git a/tests/unittests/VerdictServiceTest.php b/tests/unittests/VerdictServiceTest.php index 928ea080..8b97059f 100644 --- a/tests/unittests/VerdictServiceTest.php +++ b/tests/unittests/VerdictServiceTest.php @@ -2,6 +2,7 @@ namespace unittests; +use League\OAuth2\Client\Token\ResourceOwnerAccessTokenInterface; use OCA\GDataVaas\AppInfo\Application; use OCA\GDataVaas\Service\FileService; use OCA\GDataVaas\Service\TagService; @@ -10,6 +11,7 @@ use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; use Psr\Log\Test\TestLogger; +use VaasSdk\Authentication\ResourceOwnerPasswordGrantAuthenticator; class VerdictServiceTest extends TestCase { private LoggerInterface $logger; @@ -170,6 +172,17 @@ public function testRemoveWhitespacesAroundComma_ShouldRemoveWhitespaces(): void $this->assertEquals('a,b,c,d', $result3); } + public function testAuthenticator(): void { + $verdictService = new VerdictService( + $this->logger, + $this->createMock(IAppConfig::class), + $this->createMock(FileService::class), + $this->createMock(TagService::class)); + + $authenticator = $verdictService->getAuthenticator("ResourceOwnerPassword"); + $this->assertInstanceOf(ResourceOwnerPasswordGrantAuthenticator::class, $authenticator); + } + private function getAppConfigMock(array $scanOnlyThis, array $doNotScanThis): IAppConfig { $appConfig = $this->createMock(IAppConfig::class); $appConfig diff --git a/use-local-vaas.sh b/use-local-vaas.sh new file mode 100755 index 00000000..2f0c2769 --- /dev/null +++ b/use-local-vaas.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +BRANCH_NAME=${1:-php-connection-gets-lost-when-idle-after-connectasdfs} +GIT_REPO=${2:-git@github.com:GDATASoftwareAG/vaas.git} + +if git ls-remote --heads $GIT_REPO refs/heads/$BRANCH_NAME; then + echo "Branch $BRANCH_NAME exists in $GIT_REPO" +else + echo "Branch $BRANCH_NAME does not exist in $GIT_REPO" + exit 1 +fi + +git clone --no-checkout --depth 1 --recurse-submodules --single-branch --branch $BRANCH_NAME $GIT_REPO ./gdata +cd ./gdata +git sparse-checkout init +git sparse-checkout set ./php +git checkout +cd - + +rm -rf composer.lock +rm -rf vendor/ + +mv composer.json composer.packagist.vaas.json +if [ -f composer.local.vaas.json ]; then + jq -s '.[0] * .[1]' composer.packagist.vaas.json composer.local.vaas.json > composer.json +fi diff --git a/use-packagist-vaas.sh b/use-packagist-vaas.sh new file mode 100755 index 00000000..27c3da95 --- /dev/null +++ b/use-packagist-vaas.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +rm -rf composer.lock +rm -rf vendor/ + +if [ -f composer.packagist.vaas.json ]; then + mv composer.packagist.vaas.json composer.json +fi \ No newline at end of file diff --git a/xdebug.ini b/xdebug.ini index a99c6eea..d9e62b86 100644 --- a/xdebug.ini +++ b/xdebug.ini @@ -6,4 +6,5 @@ xdebug.log=/tmp/xdebug.log xdebug.mode=debug xdebug.discover_client_host=1 xdebug.idekey=PHPSTORM -xdebug.remote_handler=dbgp \ No newline at end of file +xdebug.remote_handler=dbgp +xdebug.log_level=0 \ No newline at end of file diff --git a/xdebug.local.ini b/xdebug.local.ini new file mode 100644 index 00000000..e3af4479 --- /dev/null +++ b/xdebug.local.ini @@ -0,0 +1,7 @@ +zend_extension=xdebug.so +xdebug.start_with_request=yes +xdebug.mode=debug +xdebug.discover_client_host=1 +xdebug.idekey=PHPSTORM +xdebug.remote_handler=dbgp +xdebug.log_level=0 \ No newline at end of file