Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add solid-crud tests #20

Merged
merged 32 commits into from
Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
4672c4b
Build and run solid-crud tests
michielbdejong Oct 19, 2020
b04e577
skip webid-provider tests that currently still fail in master
michielbdejong Oct 19, 2020
6416a47
Run solid-crud-tests as per https://github.com/solid/solid-crud-tests…
michielbdejong Oct 23, 2020
2afd2f1
load env.list from pdsinterop/test-suites
michielbdejong Oct 23, 2020
5c72a56
add specific storage url
ylebre Oct 26, 2020
5545031
adding storage controller
ylebre Oct 26, 2020
4a43e9a
typofix
ylebre Oct 26, 2020
a9fbbfd
added solid-crud in composer
ylebre Oct 28, 2020
d982d3f
adding websocket for pubsub
ylebre Oct 31, 2020
befc5cb
make sure the config dir is writable for apache
ylebre Nov 2, 2020
a2384d8
Merge remote-tracking branch 'origin/master' into add-solid-crud-tests
ylebre Nov 2, 2020
b8a03dd
Merge branch 'add-solid-crud-tests' of https://github.com/pdsinterop/…
ylebre Nov 2, 2020
111215b
merging from master
ylebre Nov 2, 2020
dbda405
do create testnet
ylebre Nov 2, 2020
7aa57e0
use proper routing for the resource server
ylebre Nov 4, 2020
17cd937
Merge branch 'add-solid-crud-tests' of https://github.com/pdsinterop/…
ylebre Nov 4, 2020
23596a4
moving websocket to own repo
ylebre Nov 4, 2020
d318211
added php-solid-pubsub-server docker container
poef Nov 4, 2020
050822f
Merge branch 'add-solid-crud-tests' of https://github.com/pdsinterop/…
poef Nov 4, 2020
0def9d5
integration with flysystem rdf content negotiation
ylebre Nov 4, 2020
62fcbec
Merge branch 'add-solid-crud-tests' of https://github.com/pdsinterop/…
ylebre Nov 4, 2020
5a01237
use servername instead of hardcoded value
ylebre Nov 5, 2020
f970766
Fix docker logs command in run-solid-test-suite.sh
michielbdejong Nov 5, 2020
796bf68
chown all of /app in Dockerfile
michielbdejong Nov 5, 2020
6544379
use solid-crud Dockerfile from solid/test-suite
michielbdejong Nov 5, 2020
3c820b2
no caching
ylebre Nov 9, 2020
0077976
cleanup after running
ylebre Nov 9, 2020
13e13e8
Re-enable webid-provider tests
michielbdejong Nov 9, 2020
9ef50d3
Fix cookie-getter
michielbdejong Nov 9, 2020
d35af0b
Merge branch 'add-solid-crud-tests' of github.com:pdsinterop/php-soli…
michielbdejong Nov 9, 2020
dee5e80
Use own cookie-getter
michielbdejong Nov 9, 2020
ed9d972
Merge branch 'master' into add-solid-crud-tests
michielbdejong Nov 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion run-solid-test-suite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions src/Controller/StorageController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php declare(strict_types=1);

namespace Pdsinterop\Solid\Controller;

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

class StorageController extends ServerController
{
final public function __invoke(ServerRequestInterface $request, array $args): ResponseInterface
{
$body = <<< EOF
@prefix : <#>.
@prefix inbox: <>.
@prefix ldp: <http://www.w3.org/ns/ldp#>.
@prefix terms: <http://purl.org/dc/terms/>.
@prefix XML: <http://www.w3.org/2001/XMLSchema#>.
@prefix st: <http://www.w3.org/ns/posix/stat#>.

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");
}
}
4 changes: 2 additions & 2 deletions tests/fixtures/foaf.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
>
<foaf:Person rdf:ID="me">
<ldp:inbox rdf:resource="/inbox/"/>
<solid:account rdf:resource="/"/>
<space:storage rdf:resource="/"/>
<solid:account rdf:resource="/account/"/>
<space:storage rdf:resource="/storage/"/>
<solid:privateTypeIndex rdf:resource="/settings/privateTypeIndex.ttl"/>
<solid:publicTypeIndex rdf:resource="/settings/publicTypeIndex.ttl"/>
<space:preferencesFile rdf:resource="/settings/preferencesFile.ttl"/>
Expand Down
38 changes: 28 additions & 10 deletions web/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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);

Expand All @@ -85,20 +104,18 @@
$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);
});

$controllers = [
AddSlashToPathController::class,
ApprovalController::class,
ApprovalController::class,
AuthorizeController::class,
CardController::class,
CorsController::class,
HandleApprovalController::class,
HandleApprovalController::class,
HelloWorldController::class,
HttpToHttpsController::class,
JwksController::class,
Expand All @@ -107,7 +124,8 @@
OpenidController::class,
ProfileController::class,
RegisterController::class,
TokenController::class,
StorageController::class,
TokenController::class,
];

$traits = [
Expand Down Expand Up @@ -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',
Expand All @@ -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);
Expand Down