Skip to content

Commit

Permalink
try one more time with a local gdata/vaas
Browse files Browse the repository at this point in the history
  • Loading branch information
ata-no-one committed Aug 16, 2024
1 parent 9952bfa commit ffe60e9
Show file tree
Hide file tree
Showing 46 changed files with 3,552 additions and 39 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/release-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,26 @@ 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 }} 0

- 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/bats
run: bats --verbose-run --timing --trace --no-parallelize-across-files --jobs 2 ./tests/bats || echo "failed"

- uses: actions/upload-artifact@master
with:
overwrite: true
name: build-dir
path: build/
name: core-dump
path: coredumps/*

release:
needs:
Expand Down
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,8 @@ js/
.uuid
eicar.com.txt
tmp/

nextcloud-server/
core.1
nextcloud-server/
core-dump.zip
apache/
**/vendor/*
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9000
"port": 9003
},
{
"name": "Launch currently open script",
Expand Down
34 changes: 28 additions & 6 deletions Dockerfile.Nextcloud
Original file line number Diff line number Diff line change
@@ -1,16 +1,38 @@
ARG NEXTCLOUD_VERSION=29.0.4
ARG INSTALL_XDEBUG=1

FROM nextcloud:${NEXTCLOUD_VERSION}
FROM nextcloud:29.0.4

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
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 opcache-disabled.ini /usr/local/etc/php/conf.d/opcache-recommended.ini
#COPY opcache-blacklist.txt /usr/local/etc/php/conf.d/opcache-blacklist.txt
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

COPY opcache-disabled.ini /usr/local/etc/php/conf.d/opcache-recommended.ini
COPY opcache-blacklist.txt /usr/local/etc/php/conf.d/opcache-blacklist.txt
COPY xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
6 changes: 6 additions & 0 deletions compose-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
ports:
- "80:80"
privileged: true
# cap_add:
# - SYS_PTRACE
# - SYS_ADMIN
# - NET_ADMIN
container_name: nextcloud-container
hostname: nextcloud-container
depends_on:
Expand Down
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
}
],
"require": {
"gdata/vaas": "9.0.3",
"coduo/php-humanizer": "^5.0"
"gdata/vaas": "v9.0.3",
"coduo/php-humanizer": "^5.0",
"amphp/file": "dev-opcache-bug"
},
"require-dev": {
"nextcloud/ocp": "v29.0.4",
Expand Down Expand Up @@ -40,5 +41,6 @@
"platform": {
"php": "8.2"
}
}
}
},
"minimum-stability": "dev"
}
20 changes: 20 additions & 0 deletions gdata/vaas/Authentication/ClientCredentialsGrantAuthenticator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace VaasSdk\Authentication;

class ClientCredentialsGrantAuthenticator
{
private OAuth2TokenReceiver $_tokenReceiver;
public function __construct(
string $clientId,
string $clientSecret,
string $tokenEndpoint = "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token"
) {
$this->_tokenReceiver = new OAuth2TokenReceiver($tokenEndpoint, $clientId, $clientSecret);
}

public function getToken(): string
{
return $this->_tokenReceiver->GetToken();
}
}
69 changes: 69 additions & 0 deletions gdata/vaas/Authentication/OAuth2TokenReceiver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace VaasSdk\Authentication;

use Amp\Http\Client\Form;
use Amp\Http\Client\HttpClient;
use Amp\Http\Client\HttpClientBuilder;
use Amp\Http\Client\Request;
use Amp\TimeoutCancellation;
use Exception;
use VaasSdk\Exceptions\VaasAuthenticationException;

class OAuth2TokenReceiver {
private string $_tokenEndpoint;
private string $_clientId;
private string $_clientSecret;
private string $_username;
private string $_password;
private string $_grantType;
private Form $_formParams;
private HttpClient $_browser;
private int $_receiveTokenTimeout = 30;

public function __construct(
string $tokenEndpoint, string $clientId, string $clientSecret = "",
string $username = "", string $password = "")
{
$this->_browser = HttpClientBuilder::buildDefault();
$this->_tokenEndpoint = $tokenEndpoint;
$this->_clientId = $clientId;
$this->_clientSecret = $clientSecret;
$this->_username = $username;
$this->_password = $password;
$this->_grantType = $this->_clientSecret == "" ? "password" : "client_credentials";

$this->_formParams = new Form();
$this->_formParams->addField('client_id', $this->_clientId);
$this->_formParams->addField('grant_type', $this->_grantType);

switch($this->_grantType) {
case "password":
$this->_formParams->addField('username', $this->_username);
$this->_formParams->addField('password', $this->_password);
break;
case "client_credentials":
$this->_formParams->addField('client_secret', $this->_clientSecret);
break;
default:
throw new VaasAuthenticationException("Invalid grant type");
}
}

public function getToken() {
try {
$request = new Request($this->_tokenEndpoint, 'POST');
$request->addHeader('Content-Type', 'application/x-www-form-urlencoded');
$request->setBody($this->_formParams);
$response = $this->_browser->request($request, new TimeoutCancellation($this->_receiveTokenTimeout));
if ($response->getStatus() != 200) {
throw new VaasAuthenticationException($response->getReason(), $response->getStatus());
}
} catch (Exception $e) {
throw new VaasAuthenticationException($e->getMessage(), $e->getCode());
}
$body = $response->getBody()->buffer();
$response_body = json_decode($body);
return $response_body->access_token;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace VaasSdk\Authentication;

use VaasSdk\Authentication\OAuth2TokenReceiver;
use VaasSdk\Exceptions\VaasAuthenticationException;

class ResourceOwnerPasswordGrantAuthenticator {
private OAuth2TokenReceiver $_tokenReceiver;

public function __construct($clientId, $userName, $password, $tokenEndpoint) {
$this->_tokenReceiver = new OAuth2TokenReceiver($tokenEndpoint, $clientId, "", $userName, $password);
}

/**
* @throws VaasAuthenticationException
*/
public function getToken() {
return $this->_tokenReceiver->GetToken();
}
}
9 changes: 9 additions & 0 deletions gdata/vaas/Exceptions/FileDoesNotExistException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace VaasSdk\Exceptions;

use Exception;

class FileDoesNotExistException extends Exception
{
}
9 changes: 9 additions & 0 deletions gdata/vaas/Exceptions/InvalidSha256Exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace VaasSdk\Exceptions;

use Exception;

class InvalidSha256Exception extends Exception
{
}
9 changes: 9 additions & 0 deletions gdata/vaas/Exceptions/TimeoutException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace VaasSdk\Exceptions;

use Exception;

class TimeoutException extends Exception
{
}
9 changes: 9 additions & 0 deletions gdata/vaas/Exceptions/UnknownKindException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace VaasSdk\Exceptions;

use Exception;

class UnknownKindException extends Exception
{
}
9 changes: 9 additions & 0 deletions gdata/vaas/Exceptions/UnkownVerdictException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace VaasSdk\Exceptions;

use Exception;

class UnkownVerdictException extends Exception
{
}
12 changes: 12 additions & 0 deletions gdata/vaas/Exceptions/UploadFailedException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace VaasSdk\Exceptions;

use Exception;

class UploadFailedException extends Exception
{
function __construct(string $message, int $code) {
parent::__construct($message, $code);
}
}
9 changes: 9 additions & 0 deletions gdata/vaas/Exceptions/VaasAuthenticationException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace VaasSdk\Exceptions;

use Exception;

class VaasAuthenticationException extends Exception
{
}
23 changes: 23 additions & 0 deletions gdata/vaas/Exceptions/VaasClientException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace VaasSdk\Exceptions;

use Exception;

/**
* The server encountered an internal error.
* Recommended actions:
* * You may retry the request after a certain delay.
* * If the problem persists contact G DATA.
*/
class VaasClientException extends Exception
{
public function __construct(?string $message)
{
if ($message == null) {
parent::__construct("Client Error");
} else {
parent::__construct($message);
}
}
}
9 changes: 9 additions & 0 deletions gdata/vaas/Exceptions/VaasConnectionClosedException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace VaasSdk\Exceptions;

use Exception;

class VaasConnectionClosedException extends Exception
{
}
9 changes: 9 additions & 0 deletions gdata/vaas/Exceptions/VaasInvalidStateException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace VaasSdk\Exceptions;

use Exception;

class VaasInvalidStateException extends Exception
{
}
23 changes: 23 additions & 0 deletions gdata/vaas/Exceptions/VaasServerException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace VaasSdk\Exceptions;

use Exception;

/**
* The server encountered an internal error.
* Recommended actions:
* * You may retry the request after a certain delay.
* * If the problem persists contact G DATA.
*/
class VaasServerException extends Exception
{
public function __construct(?string $message)
{
if ($message == null) {
parent::__construct("Server Error");
} else {
parent::__construct($message);
}
}
}
Loading

0 comments on commit ffe60e9

Please sign in to comment.