diff --git a/Dockerfile b/Dockerfile index 656d963..c5e8060 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,5 +19,5 @@ ADD . /app WORKDIR /app RUN php /install/composer.phar install --no-dev --prefer-dist COPY site.conf /etc/apache2/sites-enabled/site.conf -RUN chown www-data /app/config +RUN chown -R www-data:www-data /app EXPOSE 443 diff --git a/run-solid-test-suite.sh b/run-solid-test-suite.sh index fce779d..48460a9 100755 --- a/run-solid-test-suite.sh +++ b/run-solid-test-suite.sh @@ -36,7 +36,7 @@ export COOKIE="`docker run --rm --cap-add=SYS_ADMIN --network=testnet -e SERVER_ echo "Running webid-provider tests with cookie $COOKIE" docker run --rm --network=testnet --env COOKIE="$COOKIE" --env-file /tmp/env-vars-for-test-image.list webid-provider -# docker run --rm --network=testnet --env-file /tmp/env-vars-for-test-image.list solid-crud +docker run --rm --network=testnet --env-file /tmp/env-vars-for-test-image.list solid-crud rm /tmp/env-vars-for-test-image.list docker stop server docker rm server diff --git a/src/Controller/StorageController.php b/src/Controller/StorageController.php new file mode 100644 index 0000000..d54c0a9 --- /dev/null +++ b/src/Controller/StorageController.php @@ -0,0 +1,32 @@ +. +@prefix inbox: <>. +@prefix ldp: . +@prefix terms: . +@prefix XML: . +@prefix st: . + +inbox: + a ldp:BasicContainer, ldp:Container, ldp:Resource; + terms:modified "2019-12-20T14:52:54Z"^^XML:dateTime; + st:mtime 1576853574.389; + st:size 4096. +EOF; + $response = $this->getResponse(); + + $response->getBody()->write($body); + return $response + ->withHeader("Content-type", "text/turtle"); + } +} diff --git a/tests/fixtures/foaf.rdf b/tests/fixtures/foaf.rdf index 86a1100..8816349 100644 --- a/tests/fixtures/foaf.rdf +++ b/tests/fixtures/foaf.rdf @@ -9,8 +9,8 @@ > - - + + diff --git a/web/index.php b/web/index.php index 047c3b4..81b2ece 100644 --- a/web/index.php +++ b/web/index.php @@ -16,7 +16,6 @@ use League\Route\Http\Exception\NotFoundException; use League\Route\Router; use League\Route\Strategy\ApplicationStrategy; - use Pdsinterop\Solid\Controller\AddSlashToPathController; use Pdsinterop\Solid\Controller\ApprovalController; use Pdsinterop\Solid\Controller\AuthorizeController; @@ -32,6 +31,7 @@ use Pdsinterop\Solid\Controller\Profile\ProfileController; use Pdsinterop\Solid\Controller\RegisterController; use Pdsinterop\Solid\Controller\ResourceController; +use Pdsinterop\Solid\Controller\StorageController; use Pdsinterop\Solid\Controller\TokenController; use Pdsinterop\Solid\Resources\Server as ResourceServer; @@ -55,21 +55,40 @@ $container->add(ServerRequestInterface::class, Request::class); $container->add(ResponseInterface::class, Response::class); +/* $adapter = new \League\Flysystem\Adapter\Local(__DIR__ . '/../tests/fixtures'); $filesystem = new \League\Flysystem\Filesystem($adapter); $graph = new \EasyRdf_Graph(); $plugin = new \Pdsinterop\Rdf\Flysystem\Plugin\ReadRdf($graph); $filesystem->addPlugin($plugin); +*/ -$container->share(FilesystemInterface::class, function () { +$container->share(FilesystemInterface::class, function () use ($request) { // @FIXME: Filesystem root and the $adapter should be configurable. // Implement this with `$filesystem = \MJRider\FlysystemFactory\create(getenv('STORAGE_ENDPOINT'));` $filesystemRoot = __DIR__ . '/../tests/fixtures'; $adapter = new \League\Flysystem\Adapter\Local($filesystemRoot); - $filesystem = new \League\Flysystem\Filesystem($adapter); $graph = new \EasyRdf_Graph(); + + // Create Formats objects + $formats = new \Pdsinterop\Rdf\Formats(); + + $serverUri = "https://" . $request->getServerParams()["SERVER_NAME"] . $request->getServerParams()["REQUEST_URI"]; // FIXME: doublecheck that this is the correct url; + + // Create the RDF Adapter + $rdfAdapter = new \Pdsinterop\Rdf\Flysystem\Adapter\Rdf( + $adapter, + $graph, + $formats, + $serverUri + ); + + $filesystem = new \League\Flysystem\Filesystem($rdfAdapter); + + $filesystem->addPlugin(new \Pdsinterop\Rdf\Flysystem\Plugin\AsMime($formats)); + $plugin = new \Pdsinterop\Rdf\Flysystem\Plugin\ReadRdf($graph); $filesystem->addPlugin($plugin); @@ -85,8 +104,6 @@ $container->add(ResourceController::class, function () use ($container) { $filesystem = $container-> get(FilesystemInterface::class); - require_once __DIR__ . '/../lib/solid-crud/src/Server.php'; - $server = new ResourceServer($filesystem, new Response()); return new ResourceController($server); @@ -94,11 +111,11 @@ $controllers = [ AddSlashToPathController::class, - ApprovalController::class, + ApprovalController::class, AuthorizeController::class, CardController::class, CorsController::class, - HandleApprovalController::class, + HandleApprovalController::class, HelloWorldController::class, HttpToHttpsController::class, JwksController::class, @@ -107,7 +124,8 @@ OpenidController::class, ProfileController::class, RegisterController::class, - TokenController::class, + StorageController::class, + TokenController::class, ]; $traits = [ @@ -160,8 +178,7 @@ $router->map('POST', '/sharing/{clientId}/', HandleApprovalController::class)->setScheme($scheme); $router->map('POST', '/token', TokenController::class)->setScheme($scheme); $router->map('POST', '/token/', TokenController::class)->setScheme($scheme); - -$router->group('/data', static function (\League\Route\RouteGroup $group) { +$router->group('/storage', static function (\League\Route\RouteGroup $group) { $methods = [ 'DELETE', 'GET', @@ -174,6 +191,7 @@ array_walk($methods, static function ($method) use (&$group) { $group->map($method, '/', AddSlashToPathController::class); +// $group->map($method, '//', StorageController::class); $group->map($method, '{path:.*}', ResourceController::class); }); })->setScheme($scheme);