solid-server 5.8.6 → 5.8.8-22f4cfec
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -0
- package/CONTRIBUTING.md +0 -0
- package/CONTRIBUTORS.md +0 -0
- package/Dockerfile +0 -0
- package/LICENSE.md +0 -0
- package/README.md +0 -0
- package/bin/config.json +0 -0
- package/bin/lib/cli-utils.mjs +54 -0
- package/bin/lib/cli.mjs +44 -0
- package/bin/lib/{init.js → init.mjs} +93 -94
- package/bin/lib/{invalidUsernames.js → invalidUsernames.mjs} +136 -148
- package/bin/lib/{migrateLegacyResources.js → migrateLegacyResources.mjs} +64 -69
- package/bin/lib/{options.js → options.mjs} +379 -405
- package/bin/lib/{start.js → start.mjs} +124 -148
- package/bin/lib/{updateIndex.js → updateIndex.mjs} +55 -56
- package/bin/solid +2 -2
- package/bin/solid-test +0 -0
- package/common/css/bootstrap.min.css +6 -0
- package/common/css/solid.css +0 -0
- package/common/fonts/glyphicons-halflings-regular.eot +0 -0
- package/common/fonts/glyphicons-halflings-regular.svg +0 -0
- package/common/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/common/fonts/glyphicons-halflings-regular.woff +0 -0
- package/common/fonts/glyphicons-halflings-regular.woff2 +0 -0
- package/common/img/solid-emblem.svg +0 -0
- package/common/js/auth-buttons.js +0 -0
- package/common/js/auth-buttons.mjs +57 -0
- package/common/js/index-buttons.js +0 -0
- package/common/js/index-buttons.mjs +43 -0
- package/common/js/solid.js +0 -0
- package/common/js/solid.mjs +456 -0
- package/common/well-known/security.txt +0 -0
- package/config/defaults.js +0 -0
- package/config/defaults.mjs +22 -0
- package/config/templates/emails/delete-account.js +49 -0
- package/config/templates/emails/delete-account.mjs +31 -0
- package/config/templates/emails/invalid-username.js +30 -0
- package/config/templates/emails/invalid-username.mjs +27 -0
- package/config/templates/emails/reset-password.js +49 -0
- package/config/templates/emails/reset-password.mjs +31 -0
- package/config/templates/emails/welcome.js +39 -0
- package/config/templates/emails/welcome.mjs +23 -0
- package/config/templates/new-account/favicon.ico +0 -0
- package/config/templates/new-account/favicon.ico.acl +26 -0
- package/config/templates/new-account/profile/card$.ttl +26 -0
- package/config/templates/new-account/robots.txt +3 -0
- package/config/templates/new-account/robots.txt.acl +26 -0
- package/config/templates/new-account/settings/prefs.ttl +15 -0
- package/config/templates/new-account/settings/privateTypeIndex.ttl +4 -0
- package/config/templates/new-account/settings/publicTypeIndex.ttl +4 -0
- package/{default-templates/new-account/.meta.acl → config/templates/new-account/settings/publicTypeIndex.ttl.acl} +4 -4
- package/config/templates/new-account/settings/serverSide.ttl.acl +13 -0
- package/config/templates/new-account/settings/serverSide.ttl.inactive +12 -0
- package/config/templates/server/favicon.ico +0 -0
- package/{.well-known/.acl → config/templates/server/favicon.ico.acl} +2 -2
- package/config/templates/server/index.html +54 -0
- package/config/templates/server/robots.txt +3 -0
- package/{default-templates/server/.well-known/.acl → config/templates/server/robots.txt.acl} +2 -2
- package/config/usernames-blacklist.json +0 -0
- package/config/views/account/account-deleted.hbs +17 -0
- package/config/views/account/delete-confirm.hbs +51 -0
- package/config/views/account/delete-link-sent.hbs +17 -0
- package/config/views/account/delete.hbs +51 -0
- package/config/views/account/invalid-username.hbs +22 -0
- package/config/views/account/register-disabled.hbs +6 -0
- package/config/views/account/register-form.hbs +133 -0
- package/config/views/account/register.hbs +24 -0
- package/config/views/auth/auth-hidden-fields.hbs +8 -0
- package/config/views/auth/change-password.hbs +58 -0
- package/config/views/auth/goodbye.hbs +23 -0
- package/config/views/auth/login-required.hbs +34 -0
- package/config/views/auth/login-tls.hbs +11 -0
- package/config/views/auth/login-username-password.hbs +28 -0
- package/config/views/auth/login.hbs +55 -0
- package/config/views/auth/no-permission.hbs +29 -0
- package/config/views/auth/password-changed.hbs +27 -0
- package/config/views/auth/reset-link-sent.hbs +21 -0
- package/config/views/auth/reset-password.hbs +52 -0
- package/config/views/auth/sharing.hbs +49 -0
- package/config/views/shared/create-account.hbs +8 -0
- package/config/views/shared/error.hbs +5 -0
- package/config.json-default +0 -0
- package/coverage/tmp/coverage-2260-1766832656715-0.json +1 -0
- package/coverage/tmp/coverage-2261-1766832635310-0.json +1 -0
- package/default-templates/emails/delete-account.js +0 -0
- package/default-templates/emails/delete-account.mjs +31 -0
- package/default-templates/emails/invalid-username.js +0 -0
- package/default-templates/emails/invalid-username.mjs +27 -0
- package/default-templates/emails/reset-password.js +0 -0
- package/default-templates/emails/reset-password.mjs +31 -0
- package/default-templates/emails/welcome.js +0 -0
- package/default-templates/emails/welcome.mjs +23 -0
- package/default-templates/new-account/favicon.ico +0 -0
- package/default-templates/new-account/favicon.ico.acl +0 -0
- package/default-templates/new-account/profile/card$.ttl +0 -0
- package/default-templates/new-account/robots.txt +0 -0
- package/default-templates/new-account/robots.txt.acl +0 -0
- package/default-templates/new-account/settings/prefs.ttl +0 -0
- package/default-templates/new-account/settings/privateTypeIndex.ttl +0 -0
- package/default-templates/new-account/settings/publicTypeIndex.ttl +0 -0
- package/default-templates/new-account/settings/publicTypeIndex.ttl.acl +0 -0
- package/default-templates/new-account/settings/serverSide.ttl.acl +0 -0
- package/default-templates/new-account/settings/serverSide.ttl.inactive +0 -0
- package/default-templates/server/favicon.ico +0 -0
- package/default-templates/server/favicon.ico.acl +0 -0
- package/default-templates/server/index.html +0 -0
- package/default-templates/server/robots.txt +0 -0
- package/default-templates/server/robots.txt.acl +0 -0
- package/default-views/account/account-deleted.hbs +0 -0
- package/default-views/account/delete-confirm.hbs +0 -0
- package/default-views/account/delete-link-sent.hbs +0 -0
- package/default-views/account/delete.hbs +0 -0
- package/default-views/account/invalid-username.hbs +0 -0
- package/default-views/account/register-disabled.hbs +0 -0
- package/default-views/account/register-form.hbs +0 -0
- package/default-views/account/register.hbs +0 -0
- package/default-views/auth/auth-hidden-fields.hbs +0 -0
- package/default-views/auth/change-password.hbs +0 -0
- package/default-views/auth/goodbye.hbs +0 -0
- package/default-views/auth/login-required.hbs +0 -0
- package/default-views/auth/login-tls.hbs +0 -0
- package/default-views/auth/login-username-password.hbs +0 -0
- package/default-views/auth/login.hbs +0 -0
- package/default-views/auth/no-permission.hbs +0 -0
- package/default-views/auth/password-changed.hbs +0 -0
- package/default-views/auth/reset-link-sent.hbs +0 -0
- package/default-views/auth/reset-password.hbs +0 -0
- package/default-views/auth/sharing.hbs +0 -0
- package/default-views/shared/create-account.hbs +0 -0
- package/default-views/shared/error.hbs +0 -0
- package/docker-compose.yml +0 -0
- package/docker-image/CONTRIBUTING.md +33 -0
- package/docker-image/Makefile +32 -0
- package/docker-image/README.md +65 -0
- package/docker-image/examples/docker-compose.all-in-one.yml +76 -0
- package/docker-image/examples/docker-compose.nginx.yml +51 -0
- package/docker-image/examples/docker-compose.simple.yml +34 -0
- package/docker-image/src/Dockerfile +34 -0
- package/docker-image/src/checks.sh +56 -0
- package/docker-image/src/create-temporary-cert.sh +14 -0
- package/docker-image/src/entrypoint.sh +8 -0
- package/{common/img/.gitkeep → docker-image/test/__init__.py} +0 -0
- package/docker-image/test/conftest.py +15 -0
- package/docker-image/test/test_image_foundations.py +51 -0
- package/docker-image/test/test_non_accessible_key_cert.py +36 -0
- package/docker-image/test/test_precondition_checks.py +41 -0
- package/docker-image/test/test_solid_default_config.py +66 -0
- package/docker-image/test/test_volumes.py +55 -0
- package/docker-image/test/wait_for_container.py +8 -0
- package/docs/how-to-delete-your-account.md +0 -0
- package/docs/login-and-grant-access-to-application.md +0 -0
- package/examples/custom-error-handling.js +0 -0
- package/examples/custom-error-handling.mjs +29 -0
- package/examples/ldp-with-webid.js +0 -0
- package/examples/ldp-with-webid.mjs +12 -0
- package/examples/simple-express-app.js +0 -0
- package/examples/simple-express-app.mjs +20 -0
- package/examples/simple-ldp-server.js +0 -0
- package/examples/simple-ldp-server.mjs +8 -0
- package/favicon.ico +0 -0
- package/favicon.ico.acl +0 -0
- package/index.cjs +4 -0
- package/index.html +0 -0
- package/index.mjs +23 -0
- package/lib/{acl-checker.js → acl-checker.mjs} +13 -15
- package/lib/api/accounts/{user-accounts.js → user-accounts.mjs} +17 -16
- package/lib/api/authn/{force-user.js → force-user.mjs} +5 -4
- package/lib/api/authn/index.mjs +8 -0
- package/lib/api/authn/{webid-oidc.js → webid-oidc.mjs} +27 -20
- package/lib/api/authn/{webid-tls.js → webid-tls.mjs} +12 -11
- package/lib/api/index.mjs +7 -0
- package/lib/{capability-discovery.js → capability-discovery.mjs} +3 -6
- package/lib/common/{fs-utils.js → fs-utils.mjs} +35 -43
- package/lib/common/template-utils.mjs +29 -0
- package/lib/common/{user-utils.js → user-utils.mjs} +24 -28
- package/lib/{create-app.js → create-app.mjs} +372 -361
- package/lib/{create-server.js → create-server.mjs} +32 -11
- package/lib/debug.mjs +37 -0
- package/lib/handlers/{allow.js → allow.mjs} +79 -83
- package/lib/handlers/{auth-proxy.js → auth-proxy.mjs} +4 -5
- package/lib/handlers/{copy.js → copy.mjs} +37 -39
- package/lib/handlers/{cors-proxy.js → cors-proxy.mjs} +9 -11
- package/lib/handlers/{delete.js → delete.mjs} +20 -22
- package/lib/handlers/{error-pages.js → error-pages.mjs} +144 -212
- package/lib/handlers/{get.js → get.mjs} +254 -252
- package/lib/handlers/{index.js → index.mjs} +7 -8
- package/lib/handlers/{notify.js → notify.mjs} +8 -10
- package/lib/handlers/{options.js → options.mjs} +3 -5
- package/lib/handlers/patch/{n3-patch-parser.js → n3-patch-parser.mjs} +57 -59
- package/lib/handlers/patch/{sparql-update-parser.js → sparql-update-parser.mjs} +14 -16
- package/lib/handlers/{patch.js → patch.mjs} +241 -235
- package/lib/handlers/{post.js → post.mjs} +101 -99
- package/lib/handlers/{put.js → put.mjs} +101 -105
- package/lib/handlers/{restrict-to-top-domain.js → restrict-to-top-domain.mjs} +2 -2
- package/lib/{header.js → header.mjs} +138 -143
- package/lib/{http-error.js → http-error.mjs} +35 -34
- package/lib/{ldp-container.js → ldp-container.mjs} +10 -12
- package/lib/ldp-copy.mjs +82 -0
- package/lib/ldp-middleware.mjs +38 -0
- package/lib/{ldp.js → ldp.mjs} +286 -75
- package/lib/{lock.js → lock.mjs} +10 -10
- package/lib/{metadata.js → metadata.mjs} +11 -11
- package/lib/models/account-manager.mjs +297 -0
- package/lib/models/account-template.mjs +70 -0
- package/lib/models/authenticator.mjs +161 -0
- package/lib/models/oidc-manager.mjs +23 -0
- package/lib/models/solid-host.mjs +63 -0
- package/lib/models/user-account.mjs +50 -0
- package/lib/models/webid-tls-certificate.mjs +97 -0
- package/lib/{payment-pointer-discovery.js → payment-pointer-discovery.mjs} +5 -8
- package/lib/{rdf-notification-template.js → rdf-notification-template.mjs} +3 -5
- package/lib/requests/add-cert-request.mjs +70 -0
- package/lib/requests/auth-request.mjs +151 -0
- package/lib/requests/{create-account-request.js → create-account-request.mjs} +249 -452
- package/lib/requests/delete-account-confirm-request.mjs +85 -0
- package/lib/requests/{delete-account-request.js → delete-account-request.mjs} +73 -134
- package/lib/requests/login-request.mjs +89 -0
- package/lib/requests/{password-change-request.js → password-change-request.mjs} +132 -201
- package/lib/requests/{password-reset-email-request.js → password-reset-email-request.mjs} +123 -202
- package/lib/requests/password-reset-request.mjs +47 -0
- package/lib/requests/register-request.mjs +48 -0
- package/lib/requests/{sharing-request.js → sharing-request.mjs} +174 -261
- package/lib/{resource-mapper.js → resource-mapper.mjs} +7 -6
- package/lib/{server-config.js → server-config.mjs} +15 -20
- package/lib/services/{blacklist-service.js → blacklist-service.mjs} +36 -33
- package/lib/services/email-service.mjs +76 -0
- package/lib/services/{token-service.js → token-service.mjs} +36 -44
- package/lib/{utils.js → utils.mjs} +309 -254
- package/lib/webid/{index.js → index.mjs} +9 -13
- package/lib/webid/lib/get.mjs +31 -0
- package/lib/webid/lib/{parse.js → parse.mjs} +10 -12
- package/lib/webid/lib/verify.mjs +77 -0
- package/lib/webid/tls/generate.mjs +53 -0
- package/lib/webid/tls/index.mjs +7 -0
- package/package.json +61 -41
- package/renovate.json +0 -0
- package/robots.txt +0 -0
- package/robots.txt.acl +0 -0
- package/solid-server-5.8.8.tgz +0 -0
- package/static/account-recovery.html +0 -0
- package/static/popup-redirect.html +0 -0
- package/static/signup.html +0 -0
- package/static/signup.html.acl +0 -0
- package/test/index.mjs +168 -0
- package/test/integration/account-creation-tls-test.mjs +127 -0
- package/test/integration/account-manager-test.mjs +151 -0
- package/test/integration/account-template-test.mjs +136 -0
- package/test/integration/acl-oidc-test.mjs +1048 -0
- package/test/integration/acl-tls-test.mjs +964 -0
- package/test/integration/auth-proxy-test.mjs +144 -0
- package/test/integration/authentication-oidc-test.mjs +812 -0
- package/test/integration/authentication-oidc-with-strict-origins-turned-off-test.mjs +638 -0
- package/test/integration/capability-discovery-test.mjs +116 -0
- package/test/integration/cors-proxy-test.mjs +145 -0
- package/test/integration/errors-oidc-test.mjs +109 -0
- package/test/integration/errors-test.mjs +49 -0
- package/test/integration/formats-test.mjs +136 -0
- package/test/integration/header-test.mjs +101 -0
- package/test/integration/http-copy-test.mjs +109 -0
- package/test/integration/http-test.mjs +1197 -0
- package/test/integration/ldp-test.mjs +528 -0
- package/test/integration/oidc-manager-test.mjs +42 -0
- package/test/integration/params-test.mjs +192 -0
- package/test/integration/patch-sparql-update-test.mjs +195 -0
- package/test/integration/patch-test.mjs +590 -0
- package/test/integration/payment-pointer-test.mjs +155 -0
- package/test/integration/prep-test.mjs +314 -0
- package/test/integration/quota-test.mjs +51 -0
- package/test/integration/special-root-acl-handling-test.mjs +68 -0
- package/test/integration/validate-tts-test.mjs +57 -0
- package/test/integration/www-account-creation-oidc-test.mjs +311 -0
- package/test/keys/cert.pem +21 -0
- package/test/keys/client-cert.pem +19 -0
- package/test/keys/client-key.pem +27 -0
- package/test/keys/key.pem +27 -0
- package/test/keys/user1-cert.pem +23 -0
- package/test/keys/user1-key.pem +28 -0
- package/test/keys/user2-cert.pem +23 -0
- package/test/keys/user2-key.pem +27 -0
- package/test/mocha.opts +2 -0
- package/test/resources/Makefile +146 -0
- package/test/resources/accounts/alice.localhost/profile/card +0 -0
- package/test/resources/accounts/db/oidc/op/clients/_key_5319f8e8e4ea3214c2e92b252520d355.json +1 -0
- package/test/resources/accounts/db/oidc/op/provider.json +763 -0
- package/test/resources/accounts/db/oidc/rp/clients/_key_https%3A%2F%2Flocalhost%3A3457.json +1 -0
- package/test/resources/accounts/localhost/samplePublicContainer/nicola.jpg +0 -0
- package/test/resources/accounts/tim.localhost/hello.html +9 -0
- package/test/resources/accounts/tim.localhost/profile/card +0 -0
- package/test/resources/accounts-acl/config/templates/emails/welcome-test.js +39 -0
- package/test/resources/accounts-acl/config/templates/new-account/favicon.ico +0 -0
- package/test/resources/accounts-acl/config/templates/new-account/favicon.ico.acl +26 -0
- package/test/resources/accounts-acl/config/templates/new-account/index.html +28 -0
- package/test/resources/accounts-acl/config/templates/new-account/index.html.acl +22 -0
- package/test/resources/accounts-acl/config/templates/new-account/profile/card +27 -0
- package/{default-templates/new-account/inbox/.acl → test/resources/accounts-acl/config/templates/new-account/profile/card.acl} +5 -6
- package/test/resources/accounts-acl/config/templates/new-account/settings/prefs.ttl +9 -0
- package/test/resources/accounts-acl/config/templates/new-account/settings/privateTypeIndex.ttl +4 -0
- package/test/resources/accounts-acl/config/templates/new-account/settings/publicTypeIndex.ttl +4 -0
- package/test/resources/accounts-acl/config/templates/new-account/settings/publicTypeIndex.ttl.acl +25 -0
- package/test/resources/accounts-acl/config/templates/new-account/settings/serverSide.ttl +14 -0
- package/test/resources/accounts-acl/config/templates/server/index.html +35 -0
- package/{.acl → test/resources/accounts-acl/config/templates/server/index.html.acl} +4 -3
- package/test/resources/accounts-acl/config/views/account/register.hbs +58 -0
- package/test/resources/accounts-acl/config/views/auth/consent.hbs +49 -0
- package/test/resources/accounts-acl/config/views/auth/goodbye.hbs +20 -0
- package/test/resources/accounts-acl/config/views/auth/login-required.hbs +0 -0
- package/test/resources/accounts-acl/config/views/auth/login.hbs +51 -0
- package/test/resources/accounts-acl/config/views/auth/no-permission.hbs +0 -0
- package/test/resources/accounts-acl/db/oidc/op/clients/_key_77bb3b35edb1f3f7b887c25d1211a491.json +1 -0
- package/test/resources/accounts-acl/db/oidc/op/provider.json +763 -0
- package/test/resources/accounts-acl/db/oidc/rp/clients/_key_https%3A%2F%2Flocalhost%3A7777.json +1 -0
- package/test/resources/accounts-acl/localhost/favicon.ico +0 -0
- package/test/resources/accounts-acl/localhost/index.html +35 -0
- package/{default-templates/server/.acl → test/resources/accounts-acl/localhost/index.html.acl} +4 -3
- package/test/resources/accounts-acl/nicola.localhost/index.html +1 -0
- package/test/resources/accounts-acl/nicola.localhost/index.html.acl +10 -0
- package/test/resources/accounts-acl/quota/settings/serverSide.ttl +11 -0
- package/test/resources/accounts-acl/tim.localhost/append-acl/abc.ttl +1 -0
- package/test/resources/accounts-acl/tim.localhost/append-acl/abc.ttl.acl +8 -0
- package/test/resources/accounts-acl/tim.localhost/append-acl/abc2.ttl +1 -0
- package/test/resources/accounts-acl/tim.localhost/append-acl/abc2.ttl.acl +8 -0
- package/test/resources/accounts-acl/tim.localhost/fake-account/hello.html +9 -0
- package/test/resources/accounts-acl/tim.localhost/group/test-folder/group-listing-error.ttl +1 -0
- package/test/resources/accounts-acl/tim.localhost/group/test-folder/group-listing.ttl +14 -0
- package/test/resources/accounts-acl/tim.localhost/group/test-folder/some-other-file.txt +1 -0
- package/test/resources/accounts-acl/tim.localhost/multi-server/protected.txt +1 -0
- package/test/resources/accounts-acl/tim.localhost/multi-server/protected.txt.acl +8 -0
- package/test/resources/accounts-acl/tim.localhost/no-acl/test-file.html +1 -0
- package/test/resources/accounts-acl/tim.localhost/read-acl/deeper-tree/acls-only-on-top/example.ttl +1 -0
- package/test/resources/accounts-acl/tim.localhost/write-acl/test-file$.txt +1 -0
- package/test/resources/accounts-scenario/alice/db/oidc/op/clients/_key_9c0fd8442675a1afbe5115b9ae300c65.json +1 -0
- package/test/resources/accounts-scenario/alice/db/oidc/op/provider.json +761 -0
- package/test/resources/accounts-scenario/alice/db/oidc/rp/clients/_key_https%3A%2F%2Flocalhost%3A7000.json +1 -0
- package/test/resources/accounts-scenario/alice/private-for-alice.txt +1 -0
- package/test/resources/accounts-scenario/alice/private-for-alice.txt.acl +12 -0
- package/test/resources/accounts-scenario/alice/profile/card$.ttl +10 -0
- package/test/resources/accounts-scenario/bob/db/oidc/op/clients/_key_f15f340b6dc71b68d20eca0d7e87a972.json +1 -0
- package/test/resources/accounts-scenario/bob/db/oidc/op/provider.json +761 -0
- package/test/resources/accounts-scenario/bob/db/oidc/rp/clients/_key_https%3A%2F%2Flocalhost%3A7001.json +1 -0
- package/test/resources/accounts-scenario/bob/profile/card$.ttl +5 -0
- package/test/resources/accounts-scenario/bob/shared-with-alice.txt +1 -0
- package/test/resources/accounts-scenario/bob/shared-with-alice.txt.acl +15 -0
- package/test/resources/accounts-scenario/charlie/db/oidc/op/clients/_key_7c634dfe325475cc8750e19c72acf6d9.json +1 -0
- package/test/resources/accounts-scenario/charlie/db/oidc/op/provider.json +759 -0
- package/test/resources/accounts-scenario/charlie/db/oidc/rp/clients/_key_https%3A%2F%2Flocalhost%3A5002.json +1 -0
- package/test/resources/accounts-scenario/charlie/profile/card$.ttl +5 -0
- package/test/resources/accounts-strict-origin-off/alice/db/oidc/op/clients/_key_3f1cecaefd21253767f6e047bd9b572f.json +1 -0
- package/test/resources/accounts-strict-origin-off/alice/db/oidc/op/provider.json +763 -0
- package/test/resources/accounts-strict-origin-off/alice/db/oidc/rp/clients/_key_https%3A%2F%2Flocalhost%3A7010.json +1 -0
- package/test/resources/accounts-strict-origin-off/alice/private-for-alice.txt +1 -0
- package/test/resources/accounts-strict-origin-off/alice/private-for-alice.txt.acl +12 -0
- package/test/resources/accounts-strict-origin-off/alice/profile/card$.ttl +10 -0
- package/test/resources/accounts-strict-origin-off/bob/db/oidc/op/clients/_key_a17f603b5907c97a5fac61a2eea7ecb2.json +1 -0
- package/test/resources/accounts-strict-origin-off/bob/db/oidc/op/provider.json +763 -0
- package/test/resources/accounts-strict-origin-off/bob/db/oidc/rp/clients/_key_https%3A%2F%2Flocalhost%3A7011.json +1 -0
- package/test/resources/accounts-strict-origin-off/bob/shared-with-alice.txt +1 -0
- package/test/resources/accounts-strict-origin-off/bob/shared-with-alice.txt.acl +15 -0
- package/test/resources/acl-tls/config/templates/emails/delete-account.js +49 -0
- package/test/resources/acl-tls/config/templates/emails/invalid-username.js +30 -0
- package/test/resources/acl-tls/config/templates/emails/reset-password.js +49 -0
- package/test/resources/acl-tls/config/templates/emails/welcome.js +39 -0
- package/test/resources/acl-tls/config/templates/new-account/favicon.ico +0 -0
- package/test/resources/acl-tls/config/templates/new-account/favicon.ico.acl +26 -0
- package/test/resources/acl-tls/config/templates/new-account/profile/card$.ttl +26 -0
- package/test/resources/acl-tls/config/templates/new-account/robots.txt +3 -0
- package/test/resources/acl-tls/config/templates/new-account/robots.txt.acl +26 -0
- package/test/resources/acl-tls/config/templates/new-account/settings/prefs.ttl +15 -0
- package/test/resources/acl-tls/config/templates/new-account/settings/privateTypeIndex.ttl +4 -0
- package/test/resources/acl-tls/config/templates/new-account/settings/publicTypeIndex.ttl +4 -0
- package/test/resources/acl-tls/config/templates/new-account/settings/publicTypeIndex.ttl.acl +25 -0
- package/test/resources/acl-tls/config/templates/new-account/settings/serverSide.ttl.acl +13 -0
- package/test/resources/acl-tls/config/templates/new-account/settings/serverSide.ttl.inactive +12 -0
- package/test/resources/acl-tls/config/templates/server/favicon.ico +0 -0
- package/test/resources/acl-tls/config/templates/server/favicon.ico.acl +15 -0
- package/test/resources/acl-tls/config/templates/server/index.html +55 -0
- package/test/resources/acl-tls/config/templates/server/robots.txt +3 -0
- package/test/resources/acl-tls/config/templates/server/robots.txt.acl +15 -0
- package/test/resources/acl-tls/config/views/account/account-deleted.hbs +17 -0
- package/test/resources/acl-tls/config/views/account/delete-confirm.hbs +51 -0
- package/test/resources/acl-tls/config/views/account/delete-link-sent.hbs +17 -0
- package/test/resources/acl-tls/config/views/account/delete.hbs +51 -0
- package/test/resources/acl-tls/config/views/account/invalid-username.hbs +22 -0
- package/test/resources/acl-tls/config/views/account/register-disabled.hbs +6 -0
- package/test/resources/acl-tls/config/views/account/register-form.hbs +147 -0
- package/test/resources/acl-tls/config/views/account/register.hbs +24 -0
- package/test/resources/acl-tls/config/views/auth/auth-hidden-fields.hbs +8 -0
- package/test/resources/acl-tls/config/views/auth/change-password.hbs +58 -0
- package/test/resources/acl-tls/config/views/auth/goodbye.hbs +23 -0
- package/test/resources/acl-tls/config/views/auth/login-required.hbs +34 -0
- package/test/resources/acl-tls/config/views/auth/login-tls.hbs +11 -0
- package/test/resources/acl-tls/config/views/auth/login-username-password.hbs +28 -0
- package/test/resources/acl-tls/config/views/auth/login.hbs +55 -0
- package/test/resources/acl-tls/config/views/auth/no-permission.hbs +29 -0
- package/test/resources/acl-tls/config/views/auth/password-changed.hbs +27 -0
- package/test/resources/acl-tls/config/views/auth/reset-link-sent.hbs +21 -0
- package/test/resources/acl-tls/config/views/auth/reset-password.hbs +52 -0
- package/test/resources/acl-tls/config/views/auth/sharing.hbs +49 -0
- package/test/resources/acl-tls/config/views/shared/create-account.hbs +8 -0
- package/test/resources/acl-tls/config/views/shared/error.hbs +5 -0
- package/test/resources/acl-tls/localhost/favicon.ico +0 -0
- package/test/resources/acl-tls/localhost/favicon.ico.acl +15 -0
- package/test/resources/acl-tls/localhost/index.html +48 -0
- package/test/resources/acl-tls/localhost/robots.txt +3 -0
- package/test/resources/acl-tls/localhost/robots.txt.acl +15 -0
- package/test/resources/acl-tls/tim.localhost/append-acl/abc.ttl +1 -0
- package/test/resources/acl-tls/tim.localhost/append-acl/abc.ttl.acl +8 -0
- package/test/resources/acl-tls/tim.localhost/append-acl/abc2.ttl +1 -0
- package/test/resources/acl-tls/tim.localhost/append-acl/abc2.ttl.acl +8 -0
- package/test/resources/acl-tls/tim.localhost/fake-account/hello.html +9 -0
- package/test/resources/acl-tls/tim.localhost/no-acl/test-file.html +1 -0
- package/test/resources/acl-tls/tim.localhost/profile/card$.ttl +17 -0
- package/test/resources/acl-tls/write-acl/test-file$.ttl +1 -0
- package/test/resources/auth-proxy/index.html +0 -0
- package/test/resources/auth-proxy/index.html.acl +0 -0
- package/test/resources/config/templates/emails/delete-account.js +49 -0
- package/test/resources/config/templates/emails/delete-account.mjs +31 -0
- package/test/resources/config/templates/emails/invalid-username.js +30 -0
- package/test/resources/config/templates/emails/invalid-username.mjs +27 -0
- package/test/resources/config/templates/emails/reset-password.js +49 -0
- package/test/resources/config/templates/emails/reset-password.mjs +31 -0
- package/test/resources/config/templates/emails/welcome.js +39 -0
- package/test/resources/config/templates/emails/welcome.mjs +23 -0
- package/test/resources/config/templates/new-account/favicon.ico +0 -0
- package/test/resources/config/templates/new-account/favicon.ico.acl +26 -0
- package/test/resources/config/templates/new-account/profile/card$.ttl +26 -0
- package/test/resources/config/templates/new-account/robots.txt +3 -0
- package/test/resources/config/templates/new-account/robots.txt.acl +26 -0
- package/test/resources/config/templates/new-account/settings/prefs.ttl +15 -0
- package/test/resources/config/templates/new-account/settings/privateTypeIndex.ttl +4 -0
- package/test/resources/config/templates/new-account/settings/publicTypeIndex.ttl +4 -0
- package/test/resources/config/templates/new-account/settings/publicTypeIndex.ttl.acl +25 -0
- package/test/resources/config/templates/new-account/settings/serverSide.ttl.acl +13 -0
- package/test/resources/config/templates/new-account/settings/serverSide.ttl.inactive +12 -0
- package/test/resources/config/templates/server/favicon.ico +0 -0
- package/test/resources/config/templates/server/favicon.ico.acl +15 -0
- package/test/resources/config/templates/server/index.html +54 -0
- package/test/resources/config/templates/server/robots.txt +3 -0
- package/test/resources/config/templates/server/robots.txt.acl +15 -0
- package/test/resources/config/views/account/account-deleted.hbs +17 -0
- package/test/resources/config/views/account/delete-confirm.hbs +51 -0
- package/test/resources/config/views/account/delete-link-sent.hbs +17 -0
- package/test/resources/config/views/account/delete.hbs +51 -0
- package/test/resources/config/views/account/invalid-username.hbs +22 -0
- package/test/resources/config/views/account/register-disabled.hbs +6 -0
- package/test/resources/config/views/account/register-form.hbs +133 -0
- package/test/resources/config/views/account/register.hbs +24 -0
- package/test/resources/config/views/auth/auth-hidden-fields.hbs +8 -0
- package/test/resources/config/views/auth/change-password.hbs +58 -0
- package/test/resources/config/views/auth/goodbye.hbs +23 -0
- package/test/resources/config/views/auth/login-required.hbs +34 -0
- package/test/resources/config/views/auth/login-tls.hbs +11 -0
- package/test/resources/config/views/auth/login-username-password.hbs +28 -0
- package/test/resources/config/views/auth/login.hbs +55 -0
- package/test/resources/config/views/auth/no-permission.hbs +29 -0
- package/test/resources/config/views/auth/password-changed.hbs +27 -0
- package/test/resources/config/views/auth/reset-link-sent.hbs +21 -0
- package/test/resources/config/views/auth/reset-password.hbs +52 -0
- package/test/resources/config/views/auth/sharing.hbs +49 -0
- package/test/resources/config/views/shared/create-account.hbs +8 -0
- package/test/resources/config/views/shared/error.hbs +5 -0
- package/test/resources/empty.spatch +0 -0
- package/test/resources/errorPages/401.html +5 -0
- package/test/resources/errorPages/403.html +5 -0
- package/test/resources/errorPages/404.html +5 -0
- package/test/resources/errorPages/405.html +5 -0
- package/test/resources/errorPages/415.html +5 -0
- package/test/resources/errorPages/500.html +5 -0
- package/test/resources/example_spkac.cnf +1 -0
- package/test/resources/external-servers/example.com/jwks.json +81 -0
- package/test/resources/external-servers/example.com/openid-configuration.json +53 -0
- package/test/resources/favicon.ico +0 -0
- package/test/resources/favicon.ico.acl +15 -0
- package/test/resources/headers/index.html +0 -0
- package/test/resources/headers/public-ra +0 -0
- package/test/resources/headers/public-ra.acl +7 -0
- package/test/resources/headers/user-rw-public-r +0 -0
- package/test/resources/headers/user-rw-public-r.acl +12 -0
- package/test/resources/headers/user-rwac-public-0 +0 -0
- package/test/resources/headers/user-rwac-public-0.acl +7 -0
- package/test/resources/hello.html +3 -0
- package/test/resources/invalid1.ttl +13 -0
- package/test/resources/invalid2.ttl +9 -0
- package/test/resources/ldpatch-example-final.ttl +23 -0
- package/test/resources/ldpatch-example-initial.ttl +22 -0
- package/test/resources/ldpatch-example-patch-1.spatch +8 -0
- package/test/resources/ldpatch-example-patch-2.spatch +12 -0
- package/test/resources/ldpatch-example-patch-3.spatch +14 -0
- package/test/resources/ldpatch-example-patch.ldpatch +25 -0
- package/test/resources/ldpatch-example-patch.spatch +24 -0
- package/test/resources/lennon.jsonld +7 -0
- package/test/resources/lfs-0.sparql +9 -0
- package/test/resources/lfs-1-final.json +10 -0
- package/test/resources/lfs-1.sparql +11 -0
- package/test/resources/messaging-scenario/user1.databox.me/profile/card +21 -0
- package/test/resources/nicola.jpg +0 -0
- package/test/resources/patch/append-only.ttl +2 -0
- package/test/resources/patch/append-only.ttl.acl +6 -0
- package/test/resources/patch/favicon.ico +0 -0
- package/test/resources/patch/favicon.ico.acl +15 -0
- package/test/resources/patch/index.html +0 -0
- package/test/resources/patch/read-append.ttl +2 -0
- package/test/resources/patch/read-append.ttl.acl +6 -0
- package/test/resources/patch/read-only.ttl +2 -0
- package/test/resources/patch/read-only.ttl.acl +6 -0
- package/test/resources/patch/read-write.ttl +2 -0
- package/test/resources/patch/read-write.ttl.acl +6 -0
- package/test/resources/patch/robots.txt +3 -0
- package/test/resources/patch/robots.txt.acl +15 -0
- package/test/resources/patch/write-only.ttl +2 -0
- package/test/resources/patch/write-only.ttl.acl +6 -0
- package/test/resources/patch-1-initial.ttl +3 -0
- package/test/resources/patch-2-final.ttl +2 -0
- package/test/resources/patch-2-initial.ttl +3 -0
- package/test/resources/patch-2.spatch +2 -0
- package/test/resources/patch-2n.spatch +2 -0
- package/test/resources/patch-3-final.ttl +28 -0
- package/test/resources/patch-4-final.ttl +29 -0
- package/test/resources/patch-5-final.ttl +1 -0
- package/test/resources/patch-5-initial.ttl +3 -0
- package/test/resources/patch-5.spatch +2 -0
- package/test/resources/put-input-2.html +13 -0
- package/test/resources/put-input.txt +6 -0
- package/test/resources/robots.txt +3 -0
- package/test/resources/robots.txt.acl +15 -0
- package/test/resources/sampleContainer/blank +0 -0
- package/test/resources/sampleContainer/cert.pkcs +0 -0
- package/test/resources/sampleContainer/example.ttl.old +1 -0
- package/test/resources/sampleContainer/example1.ttl +12 -0
- package/test/resources/sampleContainer/example2.ttl +3 -0
- package/test/resources/sampleContainer/example3.ttl +7 -0
- package/test/resources/sampleContainer/example4$.ttl +7 -0
- package/test/resources/sampleContainer/filename with spaces.txt +0 -0
- package/test/resources/sampleContainer/index.html +9 -0
- package/test/resources/sampleContainer/post2.ttl +6 -0
- package/test/resources/sampleContainer/put1.ttl +13 -0
- package/test/resources/sampleContainer/solid.png +0 -0
- package/test/resources/sampleContainer/user1.pfx +0 -0
- package/test/resources/sampleContainer/user2.pfx +0 -0
- package/test/resources/sampleContainer2/example1.ttl +10 -0
- package/test/resources/sampleContainer2/example2.ttl +7 -0
- package/test/resources/timbl.jpg +0 -0
- package/test/scenarios.md +23 -0
- package/test/surface/docker/cookie/Dockerfile +6 -0
- package/test/surface/docker/cookie/app/index.js +29 -0
- package/test/surface/docker/cookie/app/package-lock.json +13 -0
- package/test/surface/docker/cookie/app/package.json +14 -0
- package/test/surface/docker/server/Dockerfile +19 -0
- package/test/surface/docker/server/config/defaults.js +10 -0
- package/test/surface/docker/server/config/templates/emails/delete-account.js +49 -0
- package/test/surface/docker/server/config/templates/emails/invalid-username.js +30 -0
- package/test/surface/docker/server/config/templates/emails/reset-password.js +49 -0
- package/test/surface/docker/server/config/templates/emails/welcome.js +39 -0
- package/test/surface/docker/server/config/templates/new-account/favicon.ico +0 -0
- package/test/surface/docker/server/config/templates/new-account/favicon.ico.acl +26 -0
- package/test/surface/docker/server/config/templates/new-account/profile/card$.ttl +26 -0
- package/test/surface/docker/server/config/templates/new-account/robots.txt +3 -0
- package/test/surface/docker/server/config/templates/new-account/robots.txt.acl +26 -0
- package/test/surface/docker/server/config/templates/new-account/settings/prefs.ttl +15 -0
- package/test/surface/docker/server/config/templates/new-account/settings/privateTypeIndex.ttl +4 -0
- package/test/surface/docker/server/config/templates/new-account/settings/publicTypeIndex.ttl +4 -0
- package/test/surface/docker/server/config/templates/new-account/settings/publicTypeIndex.ttl.acl +25 -0
- package/test/surface/docker/server/config/templates/new-account/settings/serverSide.ttl.acl +13 -0
- package/test/surface/docker/server/config/templates/new-account/settings/serverSide.ttl.inactive +12 -0
- package/test/surface/docker/server/config/templates/server/favicon.ico +0 -0
- package/test/surface/docker/server/config/templates/server/favicon.ico.acl +15 -0
- package/test/surface/docker/server/config/templates/server/index.html +55 -0
- package/test/surface/docker/server/config/templates/server/robots.txt +3 -0
- package/test/surface/docker/server/config/templates/server/robots.txt.acl +15 -0
- package/test/surface/docker/server/config/usernames-blacklist.json +4 -0
- package/test/surface/docker/server/config/views/account/account-deleted.hbs +17 -0
- package/test/surface/docker/server/config/views/account/delete-confirm.hbs +51 -0
- package/test/surface/docker/server/config/views/account/delete-link-sent.hbs +17 -0
- package/test/surface/docker/server/config/views/account/delete.hbs +51 -0
- package/test/surface/docker/server/config/views/account/invalid-username.hbs +22 -0
- package/test/surface/docker/server/config/views/account/register-disabled.hbs +6 -0
- package/test/surface/docker/server/config/views/account/register-form.hbs +147 -0
- package/test/surface/docker/server/config/views/account/register.hbs +24 -0
- package/test/surface/docker/server/config/views/auth/auth-hidden-fields.hbs +8 -0
- package/test/surface/docker/server/config/views/auth/change-password.hbs +58 -0
- package/test/surface/docker/server/config/views/auth/goodbye.hbs +23 -0
- package/test/surface/docker/server/config/views/auth/login-required.hbs +34 -0
- package/test/surface/docker/server/config/views/auth/login-tls.hbs +11 -0
- package/test/surface/docker/server/config/views/auth/login-username-password.hbs +28 -0
- package/test/surface/docker/server/config/views/auth/login.hbs +55 -0
- package/test/surface/docker/server/config/views/auth/no-permission.hbs +29 -0
- package/test/surface/docker/server/config/views/auth/password-changed.hbs +27 -0
- package/test/surface/docker/server/config/views/auth/reset-link-sent.hbs +21 -0
- package/test/surface/docker/server/config/views/auth/reset-password.hbs +52 -0
- package/test/surface/docker/server/config/views/auth/sharing.hbs +49 -0
- package/test/surface/docker/server/config/views/shared/create-account.hbs +8 -0
- package/test/surface/docker/server/config/views/shared/error.hbs +5 -0
- package/test/surface/docker/server/config.json +22 -0
- package/test/surface/docker/server/data/favicon.ico +0 -0
- package/test/surface/docker/server/data/favicon.ico.acl +26 -0
- package/test/surface/docker/server/data/index.html +48 -0
- package/test/surface/docker/server/data/profile/card$.ttl +31 -0
- package/test/surface/docker/server/data/robots.txt +3 -0
- package/test/surface/docker/server/data/robots.txt.acl +26 -0
- package/test/surface/docker/server/data/settings/prefs.ttl +15 -0
- package/test/surface/docker/server/data/settings/privateTypeIndex.ttl +4 -0
- package/test/surface/docker/server/data/settings/publicTypeIndex.ttl +4 -0
- package/test/surface/docker/server/data/settings/publicTypeIndex.ttl.acl +25 -0
- package/test/surface/docker/server/data/settings/serverSide.ttl +0 -0
- package/test/surface/docker/server/data/settings/serverSide.ttl.acl +13 -0
- package/test/surface/docker/server/data/settings/serverSide.ttl.inactive +12 -0
- package/test/surface/docker/server/env.list +4 -0
- package/test/surface/docker/solid-crud/Dockerfile +4 -0
- package/test/surface/docker/web-access-control/Dockerfile +1 -0
- package/test/surface/docker/webid-provider/Dockerfile +1 -0
- package/test/surface/run-solid-test-suite.sh +75 -0
- package/test/surface/server-env.list +5 -0
- package/test/surface/solid-crud-tests-env.list +5 -0
- package/test/surface/thirdparty-config.json +23 -0
- package/test/surface/thirdparty-env.list +6 -0
- package/test/surface/web-access-control-tests-env.list +6 -0
- package/test/surface/webid-provider-tests-env.list +4 -0
- package/test/test-helpers.mjs +63 -0
- package/test/unit/account-manager-test.mjs +610 -0
- package/test/unit/account-template-test.mjs +59 -0
- package/test/unit/acl-checker-test.mjs +51 -0
- package/test/unit/add-cert-request-test.mjs +120 -0
- package/test/unit/auth-handlers-test.mjs +108 -0
- package/test/unit/auth-proxy-test.mjs +224 -0
- package/test/unit/auth-request-test.mjs +96 -0
- package/test/unit/authenticator-test.mjs +34 -0
- package/test/unit/blacklist-service-test.mjs +49 -0
- package/test/unit/create-account-request-test.mjs +306 -0
- package/test/unit/delete-account-confirm-request-test.mjs +234 -0
- package/test/unit/delete-account-request-test.mjs +180 -0
- package/test/unit/email-service-test.mjs +166 -0
- package/test/unit/email-welcome-test.mjs +81 -0
- package/test/unit/error-pages-test.mjs +100 -0
- package/test/unit/esm-imports.test.mjs +149 -0
- package/test/unit/force-user-test.mjs +73 -0
- package/test/unit/getAvailableUrl-test.mjs +30 -0
- package/test/unit/getTrustedOrigins-test.mjs +20 -0
- package/test/unit/login-request-test.mjs +246 -0
- package/test/unit/oidc-manager-test.mjs +50 -0
- package/test/unit/password-authenticator-test.mjs +125 -0
- package/test/unit/password-change-request-test.mjs +259 -0
- package/test/unit/password-reset-email-request-test.mjs +234 -0
- package/test/unit/resource-mapper-test.mjs +673 -0
- package/test/unit/solid-host-test.mjs +119 -0
- package/test/unit/tls-authenticator-test.mjs +174 -0
- package/test/unit/token-service-test.mjs +82 -0
- package/test/unit/user-account-test.mjs +38 -0
- package/test/unit/user-accounts-api-test.mjs +59 -0
- package/test/unit/user-utils-test.mjs +64 -0
- package/test/unit/utils-test.mjs +114 -0
- package/test/utils/index.mjs +167 -0
- package/test/utils.mjs +205 -0
- package/test/validate-turtle.mjs +43 -0
- package/.github/workflows/ci.yml +0 -113
- package/.nvmrc +0 -1
- package/.snyk +0 -35
- package/bin/lib/cli-utils.js +0 -85
- package/bin/lib/cli.js +0 -39
- package/bin/solid.js +0 -3
- package/default-templates/new-account/.acl +0 -26
- package/default-templates/new-account/.meta +0 -5
- package/default-templates/new-account/.well-known/.acl +0 -19
- package/default-templates/new-account/private/.acl +0 -10
- package/default-templates/new-account/profile/.acl +0 -19
- package/default-templates/new-account/public/.acl +0 -19
- package/default-templates/new-account/settings/.acl +0 -20
- package/index.js +0 -3
- package/lib/api/authn/index.js +0 -5
- package/lib/api/index.js +0 -6
- package/lib/common/template-utils.js +0 -50
- package/lib/debug.js +0 -18
- package/lib/ldp-copy.js +0 -73
- package/lib/ldp-middleware.js +0 -40
- package/lib/models/account-manager.js +0 -604
- package/lib/models/account-template.js +0 -156
- package/lib/models/authenticator.js +0 -337
- package/lib/models/oidc-manager.js +0 -53
- package/lib/models/solid-host.js +0 -131
- package/lib/models/user-account.js +0 -113
- package/lib/models/webid-tls-certificate.js +0 -184
- package/lib/requests/add-cert-request.js +0 -138
- package/lib/requests/auth-request.js +0 -234
- package/lib/requests/delete-account-confirm-request.js +0 -170
- package/lib/requests/login-request.js +0 -205
- package/lib/services/email-service.js +0 -162
- package/lib/webid/lib/get.js +0 -27
- package/lib/webid/tls/index.js +0 -185
|
@@ -0,0 +1,1197 @@
|
|
|
1
|
+
import { fileURLToPath } from 'url'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import fs from 'fs'
|
|
4
|
+
import li from 'li'
|
|
5
|
+
import rdf from 'rdflib'
|
|
6
|
+
import { setupSupertestServer, rm } from '../utils.mjs'
|
|
7
|
+
import { assert, expect } from 'chai'
|
|
8
|
+
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
10
|
+
const __dirname = path.dirname(__filename)
|
|
11
|
+
|
|
12
|
+
const suffixAcl = '.acl'
|
|
13
|
+
const suffixMeta = '.meta'
|
|
14
|
+
const server = setupSupertestServer({
|
|
15
|
+
live: true,
|
|
16
|
+
dataBrowserPath: 'default',
|
|
17
|
+
root: path.join(__dirname, '../resources'),
|
|
18
|
+
auth: 'oidc',
|
|
19
|
+
webid: false
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new turtle test resource via an LDP PUT
|
|
24
|
+
* (located in `test-esm/resources/{resourceName}`)
|
|
25
|
+
* @method createTestResource
|
|
26
|
+
* @param resourceName {String} Resource name (should have a leading `/`)
|
|
27
|
+
* @return {Promise} Promise obj, for use with Mocha's `before()` etc
|
|
28
|
+
*/
|
|
29
|
+
function createTestResource (resourceName) {
|
|
30
|
+
return new Promise(function (resolve, reject) {
|
|
31
|
+
server.put(resourceName)
|
|
32
|
+
.set('content-type', 'text/turtle')
|
|
33
|
+
.end(function (error, res) {
|
|
34
|
+
error ? reject(error) : resolve(res)
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
describe('HTTP APIs', function () {
|
|
40
|
+
const emptyResponse = function (res) {
|
|
41
|
+
if (res.text) {
|
|
42
|
+
throw new Error('Not empty response')
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const getLink = function (res, rel) {
|
|
46
|
+
if (res.headers.link) {
|
|
47
|
+
const links = res.headers.link.split(',')
|
|
48
|
+
for (const i in links) {
|
|
49
|
+
const link = links[i]
|
|
50
|
+
const parsedLink = li.parse(link)
|
|
51
|
+
if (parsedLink[rel]) {
|
|
52
|
+
return parsedLink[rel]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return undefined
|
|
57
|
+
}
|
|
58
|
+
const hasHeader = function (rel, value) {
|
|
59
|
+
const handler = function (res) {
|
|
60
|
+
const link = getLink(res, rel)
|
|
61
|
+
if (link) {
|
|
62
|
+
if (link !== value) {
|
|
63
|
+
throw new Error('Not same value: ' + value + ' != ' + link)
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
throw new Error('header does not exist: ' + rel + ' = ' + value)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return handler
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
describe('GET Root container', function () {
|
|
73
|
+
it('should exist', function (done) {
|
|
74
|
+
server.get('/')
|
|
75
|
+
.expect(200, done)
|
|
76
|
+
})
|
|
77
|
+
it('should be a turtle file by default', function (done) {
|
|
78
|
+
server.get('/')
|
|
79
|
+
.expect('content-type', /text\/turtle/)
|
|
80
|
+
.expect(200, done)
|
|
81
|
+
})
|
|
82
|
+
it('should contain space:Storage triple', function (done) {
|
|
83
|
+
server.get('/')
|
|
84
|
+
.expect('content-type', /text\/turtle/)
|
|
85
|
+
.expect(200, done)
|
|
86
|
+
.expect((res) => {
|
|
87
|
+
const turtle = res.text
|
|
88
|
+
assert.match(turtle, /space:Storage/)
|
|
89
|
+
const kb = rdf.graph()
|
|
90
|
+
rdf.parse(turtle, kb, 'https://localhost/', 'text/turtle')
|
|
91
|
+
|
|
92
|
+
assert(kb.match(undefined,
|
|
93
|
+
rdf.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
|
|
94
|
+
rdf.namedNode('http://www.w3.org/ns/pim/space#Storage')
|
|
95
|
+
).length, 'Must contain a triple space:Storage')
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
it('should have set Link as Container/BasicContainer/Storage', function (done) {
|
|
99
|
+
server.get('/')
|
|
100
|
+
.expect('content-type', /text\/turtle/)
|
|
101
|
+
.expect('Link', /<http:\/\/www.w3.org\/ns\/ldp#BasicContainer>; rel="type"/)
|
|
102
|
+
.expect('Link', /<http:\/\/www.w3.org\/ns\/ldp#Container>; rel="type"/)
|
|
103
|
+
.expect('Link', /<http:\/\/www.w3.org\/ns\/pim\/space#Storage>; rel="type"/)
|
|
104
|
+
.expect(200, done)
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
describe('OPTIONS API', function () {
|
|
109
|
+
it('should set the proper CORS headers',
|
|
110
|
+
function (done) {
|
|
111
|
+
server.options('/')
|
|
112
|
+
.set('Origin', 'http://example.com')
|
|
113
|
+
.expect('Access-Control-Allow-Origin', 'http://example.com')
|
|
114
|
+
.expect('Access-Control-Allow-Credentials', 'true')
|
|
115
|
+
.expect('Access-Control-Allow-Methods', 'OPTIONS,HEAD,GET,PATCH,POST,PUT,DELETE')
|
|
116
|
+
.expect('Access-Control-Expose-Headers', 'Authorization, User, Location, Link, Vary, Last-Modified, ETag, Accept-Patch, Accept-Post, Accept-Put, Updates-Via, Allow, WAC-Allow, Content-Length, WWW-Authenticate, MS-Author-Via, X-Powered-By')
|
|
117
|
+
.expect(204, done)
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
describe('Accept-* headers', function () {
|
|
121
|
+
it('should be present for resources', function (done) {
|
|
122
|
+
server.options('/sampleContainer/example1.ttl')
|
|
123
|
+
.expect('Accept-Patch', 'text/n3, application/sparql-update, application/sparql-update-single-match')
|
|
124
|
+
.expect('Accept-Post', '*/*')
|
|
125
|
+
.expect('Accept-Put', '*/*')
|
|
126
|
+
.expect(204, done)
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
it('should be present for containers', function (done) {
|
|
130
|
+
server.options('/sampleContainer/')
|
|
131
|
+
.expect('Accept-Patch', 'text/n3, application/sparql-update, application/sparql-update-single-match')
|
|
132
|
+
.expect('Accept-Post', '*/*')
|
|
133
|
+
.expect('Accept-Put', '*/*')
|
|
134
|
+
.expect(204, done)
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
it('should be present for non-rdf resources', function (done) {
|
|
138
|
+
server.options('/sampleContainer/solid.png')
|
|
139
|
+
.expect('Accept-Patch', 'text/n3, application/sparql-update, application/sparql-update-single-match')
|
|
140
|
+
.expect('Accept-Post', '*/*')
|
|
141
|
+
.expect('Accept-Put', '*/*')
|
|
142
|
+
.expect(204, done)
|
|
143
|
+
})
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
it('should have an empty response', function (done) {
|
|
147
|
+
server.options('/sampleContainer/example1.ttl')
|
|
148
|
+
.expect(emptyResponse)
|
|
149
|
+
.end(done)
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
it('should return 204 on success', function (done) {
|
|
153
|
+
server.options('/sampleContainer2/example1.ttl')
|
|
154
|
+
.expect(204)
|
|
155
|
+
.end(done)
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
it('should have Access-Control-Allow-Origin', function (done) {
|
|
159
|
+
server.options('/sampleContainer2/example1.ttl')
|
|
160
|
+
.set('Origin', 'http://example.com')
|
|
161
|
+
.expect('Access-Control-Allow-Origin', 'http://example.com')
|
|
162
|
+
.end(done)
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
it('should have set acl and describedBy Links for resource',
|
|
166
|
+
function (done) {
|
|
167
|
+
server.options('/sampleContainer2/example1.ttl')
|
|
168
|
+
.expect(hasHeader('acl', 'example1.ttl' + suffixAcl))
|
|
169
|
+
.expect(hasHeader('describedBy', 'example1.ttl' + suffixMeta))
|
|
170
|
+
.end(done)
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
it('should have set Link as resource', function (done) {
|
|
174
|
+
server.options('/sampleContainer2/example1.ttl')
|
|
175
|
+
.expect('Link', /<http:\/\/www.w3.org\/ns\/ldp#Resource>; rel="type"/)
|
|
176
|
+
.end(done)
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
it('should have set Link as Container/BasicContainer on an implicit index page', function (done) {
|
|
180
|
+
server.options('/sampleContainer/')
|
|
181
|
+
.expect('Link', /<http:\/\/www.w3.org\/ns\/ldp#BasicContainer>; rel="type"/)
|
|
182
|
+
.expect('Link', /<http:\/\/www.w3.org\/ns\/ldp#Container>; rel="type"/)
|
|
183
|
+
.end(done)
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
it('should have set Link as Container/BasicContainer', function (done) {
|
|
187
|
+
server.options('/sampleContainer2/')
|
|
188
|
+
.set('Origin', 'http://example.com')
|
|
189
|
+
.expect('Link', /<http:\/\/www.w3.org\/ns\/ldp#BasicContainer>; rel="type"/)
|
|
190
|
+
.expect('Link', /<http:\/\/www.w3.org\/ns\/ldp#Container>; rel="type"/)
|
|
191
|
+
.end(done)
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
it('should have set Accept-Post for containers', function (done) {
|
|
195
|
+
server.options('/sampleContainer2/')
|
|
196
|
+
.set('Origin', 'http://example.com')
|
|
197
|
+
.expect('Accept-Post', '*/*')
|
|
198
|
+
.end(done)
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
it('should have set acl and describedBy Links for container', function (done) {
|
|
202
|
+
server.options('/sampleContainer2/')
|
|
203
|
+
.expect(hasHeader('acl', suffixAcl))
|
|
204
|
+
.expect(hasHeader('describedBy', suffixMeta))
|
|
205
|
+
.end(done)
|
|
206
|
+
})
|
|
207
|
+
})
|
|
208
|
+
|
|
209
|
+
describe('Not allowed method should return 405 and allow header', function (done) {
|
|
210
|
+
it('TRACE should return 405', function (done) {
|
|
211
|
+
server.trace('/sampleContainer2/')
|
|
212
|
+
// .expect(hasHeader('allow', 'OPTIONS, HEAD, GET, PATCH, POST, PUT, DELETE'))
|
|
213
|
+
.expect(405)
|
|
214
|
+
.end((err, res) => {
|
|
215
|
+
if (err) done(err)
|
|
216
|
+
const allow = res.headers.allow
|
|
217
|
+
console.log(allow)
|
|
218
|
+
if (allow === 'OPTIONS, HEAD, GET, PATCH, POST, PUT, DELETE') done()
|
|
219
|
+
else done(new Error('no allow header'))
|
|
220
|
+
})
|
|
221
|
+
})
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
describe('GET API', function () {
|
|
225
|
+
it('should have the same size of the file on disk', function (done) {
|
|
226
|
+
server.get('/sampleContainer/solid.png')
|
|
227
|
+
.expect(200)
|
|
228
|
+
.end(function (err, res) {
|
|
229
|
+
if (err) {
|
|
230
|
+
return done(err)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const size = fs.statSync(path.join(__dirname,
|
|
234
|
+
'../resources/sampleContainer/solid.png')).size
|
|
235
|
+
if (res.body.length !== size) {
|
|
236
|
+
return done(new Error('files are not of the same size'))
|
|
237
|
+
}
|
|
238
|
+
done()
|
|
239
|
+
})
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
it('should have Access-Control-Allow-Origin as Origin on containers', function (done) {
|
|
243
|
+
server.get('/sampleContainer2/')
|
|
244
|
+
.set('Origin', 'http://example.com')
|
|
245
|
+
.expect('content-type', /text\/turtle/)
|
|
246
|
+
.expect('Access-Control-Allow-Origin', 'http://example.com')
|
|
247
|
+
.expect(200, done)
|
|
248
|
+
})
|
|
249
|
+
it('should have Access-Control-Allow-Origin as Origin on resources',
|
|
250
|
+
function (done) {
|
|
251
|
+
server.get('/sampleContainer2/example1.ttl')
|
|
252
|
+
.set('Origin', 'http://example.com')
|
|
253
|
+
.expect('content-type', /text\/turtle/)
|
|
254
|
+
.expect('Access-Control-Allow-Origin', 'http://example.com')
|
|
255
|
+
.expect(200, done)
|
|
256
|
+
})
|
|
257
|
+
it('should have set Link as resource', function (done) {
|
|
258
|
+
server.get('/sampleContainer2/example1.ttl')
|
|
259
|
+
.expect('content-type', /text\/turtle/)
|
|
260
|
+
.expect('Link', /<http:\/\/www.w3.org\/ns\/ldp#Resource>; rel="type"/)
|
|
261
|
+
.expect(200, done)
|
|
262
|
+
})
|
|
263
|
+
it('should have set Updates-Via to use WebSockets', function (done) {
|
|
264
|
+
server.get('/sampleContainer2/example1.ttl')
|
|
265
|
+
.expect('updates-via', /wss?:\/\//)
|
|
266
|
+
.expect(200, done)
|
|
267
|
+
})
|
|
268
|
+
it('should have set acl and describedBy Links for resource',
|
|
269
|
+
function (done) {
|
|
270
|
+
server.get('/sampleContainer2/example1.ttl')
|
|
271
|
+
.expect('content-type', /text\/turtle/)
|
|
272
|
+
.expect(hasHeader('acl', 'example1.ttl' + suffixAcl))
|
|
273
|
+
.expect(hasHeader('describedBy', 'example1.ttl' + suffixMeta))
|
|
274
|
+
.end(done)
|
|
275
|
+
})
|
|
276
|
+
it('should have set Link as Container/BasicContainer', function (done) {
|
|
277
|
+
server.get('/sampleContainer2/')
|
|
278
|
+
.expect('content-type', /text\/turtle/)
|
|
279
|
+
.expect('Link', /<http:\/\/www.w3.org\/ns\/ldp#BasicContainer>; rel="type"/)
|
|
280
|
+
.expect('Link', /<http:\/\/www.w3.org\/ns\/ldp#Container>; rel="type"/)
|
|
281
|
+
.expect(200, done)
|
|
282
|
+
})
|
|
283
|
+
it('should load skin (mashlib) if resource was requested as text/html', function (done) {
|
|
284
|
+
server.get('/sampleContainer2/example1.ttl')
|
|
285
|
+
.set('Accept', 'text/html')
|
|
286
|
+
.expect('content-type', /text\/html/)
|
|
287
|
+
.expect(function (res) {
|
|
288
|
+
if (res.text.indexOf('TabulatorOutline') < 0) {
|
|
289
|
+
throw new Error('did not load the Tabulator skin by default')
|
|
290
|
+
}
|
|
291
|
+
})
|
|
292
|
+
.expect(200, done) // Can't check for 303 because of internal redirects
|
|
293
|
+
})
|
|
294
|
+
it('should NOT load data browser (mashlib) if resource is not RDF', function (done) {
|
|
295
|
+
server.get('/sampleContainer/solid.png')
|
|
296
|
+
.set('Accept', 'text/html')
|
|
297
|
+
.expect('content-type', /image\/png/)
|
|
298
|
+
.expect(200, done)
|
|
299
|
+
})
|
|
300
|
+
|
|
301
|
+
it('should NOT load data browser (mashlib) if a resource has an .html extension', function (done) {
|
|
302
|
+
server.get('/sampleContainer/index.html')
|
|
303
|
+
.set('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
|
|
304
|
+
.expect('content-type', /text\/html/)
|
|
305
|
+
.expect(200)
|
|
306
|
+
.expect((res) => {
|
|
307
|
+
if (res.text.includes('TabulatorOutline')) {
|
|
308
|
+
throw new Error('Loaded data browser though resource has an .html extension')
|
|
309
|
+
}
|
|
310
|
+
})
|
|
311
|
+
.end(done)
|
|
312
|
+
})
|
|
313
|
+
|
|
314
|
+
it('should NOT load data browser (mashlib) if directory has an index file', function (done) {
|
|
315
|
+
server.get('/sampleContainer/')
|
|
316
|
+
.set('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
|
|
317
|
+
.expect('content-type', /text\/html/)
|
|
318
|
+
.expect(200)
|
|
319
|
+
.expect((res) => {
|
|
320
|
+
if (res.text.includes('TabulatorOutline')) {
|
|
321
|
+
throw new Error('Loaded data browser though resource has an .html extension')
|
|
322
|
+
}
|
|
323
|
+
})
|
|
324
|
+
.end(done)
|
|
325
|
+
})
|
|
326
|
+
|
|
327
|
+
it('should show data browser if container was requested as text/html', function (done) {
|
|
328
|
+
server.get('/sampleContainer2/')
|
|
329
|
+
.set('Accept', 'text/html')
|
|
330
|
+
.expect('content-type', /text\/html/)
|
|
331
|
+
.expect(200, done)
|
|
332
|
+
})
|
|
333
|
+
it('should redirect to the right container URI if missing /', function (done) {
|
|
334
|
+
server.get('/sampleContainer')
|
|
335
|
+
.expect(301, done)
|
|
336
|
+
})
|
|
337
|
+
it('should return 404 for non-existent resource', function (done) {
|
|
338
|
+
server.get('/invalidfile.foo')
|
|
339
|
+
.expect(404, done)
|
|
340
|
+
})
|
|
341
|
+
it('should return 404 for non-existent container', function (done) {
|
|
342
|
+
server.get('/inexistant/')
|
|
343
|
+
.expect('Accept-Put', 'text/turtle')
|
|
344
|
+
.expect(404, done)
|
|
345
|
+
})
|
|
346
|
+
it('should return basic container link for directories', function (done) {
|
|
347
|
+
server.get('/')
|
|
348
|
+
.expect('Link', /http:\/\/www.w3.org\/ns\/ldp#BasicContainer/)
|
|
349
|
+
.expect('content-type', /text\/turtle/)
|
|
350
|
+
.expect(200, done)
|
|
351
|
+
})
|
|
352
|
+
it('should return resource link for files', function (done) {
|
|
353
|
+
server.get('/hello.html')
|
|
354
|
+
.expect('Link', /<http:\/\/www.w3.org\/ns\/ldp#Resource>; rel="type"/)
|
|
355
|
+
.expect('Content-Type', /text\/html/)
|
|
356
|
+
.expect(200, done)
|
|
357
|
+
})
|
|
358
|
+
it('should have glob support', function (done) {
|
|
359
|
+
server.get('/sampleContainer/*')
|
|
360
|
+
.expect('content-type', /text\/turtle/)
|
|
361
|
+
.expect(200)
|
|
362
|
+
.expect((res) => {
|
|
363
|
+
const kb = rdf.graph()
|
|
364
|
+
rdf.parse(res.text, kb, 'https://localhost/', 'text/turtle')
|
|
365
|
+
|
|
366
|
+
assert(kb.match(
|
|
367
|
+
rdf.namedNode('https://localhost/example1.ttl#this'),
|
|
368
|
+
rdf.namedNode('http://purl.org/dc/elements/1.1/title'),
|
|
369
|
+
rdf.literal('Test title')
|
|
370
|
+
).length, 'Must contain a triple from example1.ttl')
|
|
371
|
+
|
|
372
|
+
assert(kb.match(
|
|
373
|
+
rdf.namedNode('http://example.org/stuff/1.0/a'),
|
|
374
|
+
rdf.namedNode('http://example.org/stuff/1.0/b'),
|
|
375
|
+
rdf.literal('apple')
|
|
376
|
+
).length, 'Must contain a triple from example2.ttl')
|
|
377
|
+
|
|
378
|
+
assert(kb.match(
|
|
379
|
+
rdf.namedNode('http://example.org/stuff/1.0/a'),
|
|
380
|
+
rdf.namedNode('http://example.org/stuff/1.0/b'),
|
|
381
|
+
rdf.literal('The first line\nThe second line\n more')
|
|
382
|
+
).length, 'Must contain a triple from example3.ttl')
|
|
383
|
+
})
|
|
384
|
+
.end(done)
|
|
385
|
+
})
|
|
386
|
+
it('should have set acl and describedBy Links for container',
|
|
387
|
+
function (done) {
|
|
388
|
+
server.get('/sampleContainer2/')
|
|
389
|
+
.expect(hasHeader('acl', suffixAcl))
|
|
390
|
+
.expect(hasHeader('describedBy', suffixMeta))
|
|
391
|
+
.expect('content-type', /text\/turtle/)
|
|
392
|
+
.end(done)
|
|
393
|
+
})
|
|
394
|
+
it('should return requested index.html resource by default', function (done) {
|
|
395
|
+
server.get('/sampleContainer/index.html')
|
|
396
|
+
.set('accept', 'text/html')
|
|
397
|
+
.expect(200)
|
|
398
|
+
.expect('content-type', /text\/html/)
|
|
399
|
+
.expect(function (res) {
|
|
400
|
+
if (res.text.indexOf('<!DOCTYPE html>') < 0) {
|
|
401
|
+
throw new Error('wrong content returned for index.html')
|
|
402
|
+
}
|
|
403
|
+
})
|
|
404
|
+
.end(done)
|
|
405
|
+
})
|
|
406
|
+
it('should fallback on index.html if it exists and content-type is given',
|
|
407
|
+
function (done) {
|
|
408
|
+
server.get('/sampleContainer/')
|
|
409
|
+
.set('accept', 'text/html')
|
|
410
|
+
.expect(200)
|
|
411
|
+
.expect('content-type', /text\/html/)
|
|
412
|
+
.end(done)
|
|
413
|
+
})
|
|
414
|
+
it('should return turtle if requesting a conatiner that has index.html with conteent-type text/turtle', (done) => {
|
|
415
|
+
server.get('/sampleContainer/')
|
|
416
|
+
.set('accept', 'text/turtle')
|
|
417
|
+
.expect(200)
|
|
418
|
+
.expect('content-type', /text\/turtle/)
|
|
419
|
+
.end(done)
|
|
420
|
+
})
|
|
421
|
+
it('should return turtle if requesting a container that conatins an index.html file with a content type where some rdf format is ranked higher than html', (done) => {
|
|
422
|
+
server.get('/sampleContainer/')
|
|
423
|
+
.set('accept', 'image/*;q=0.9, */*;q=0.1, application/rdf+xml;q=0.9, application/xhtml+xml, text/xml;q=0.5, application/xml;q=0.5, text/html;q=0.9, text/plain;q=0.5, text/n3;q=1.0, text/turtle;q=1')
|
|
424
|
+
.expect(200)
|
|
425
|
+
.expect('content-type', /text\/turtle/)
|
|
426
|
+
.end(done)
|
|
427
|
+
})
|
|
428
|
+
it('should still redirect to the right container URI if missing / and HTML is requested', function (done) {
|
|
429
|
+
server.get('/sampleContainer')
|
|
430
|
+
.set('accept', 'text/html')
|
|
431
|
+
.expect('location', /\/sampleContainer\//)
|
|
432
|
+
.expect(301, done)
|
|
433
|
+
})
|
|
434
|
+
|
|
435
|
+
describe('Accept-* headers', function () {
|
|
436
|
+
it('should return 404 for non-existent resource', function (done) {
|
|
437
|
+
server.get('/invalidfile.foo')
|
|
438
|
+
.expect('Accept-Patch', 'text/n3, application/sparql-update, application/sparql-update-single-match')
|
|
439
|
+
.expect('Accept-Post', '*/*')
|
|
440
|
+
.expect('Accept-put', '*/*')
|
|
441
|
+
.expect(404, done)
|
|
442
|
+
})
|
|
443
|
+
it('Accept-Put=text/turtle for non-existent container', function (done) {
|
|
444
|
+
server.get('/inexistant/')
|
|
445
|
+
.expect('Accept-Patch', 'text/n3, application/sparql-update, application/sparql-update-single-match')
|
|
446
|
+
.expect('Accept-Post', '*/*')
|
|
447
|
+
.expect('Accept-Put', 'text/turtle')
|
|
448
|
+
.expect(404, done)
|
|
449
|
+
})
|
|
450
|
+
it('Accept-Put header do not exist for existing container', (done) => {
|
|
451
|
+
server.get('/sampleContainer/')
|
|
452
|
+
.expect(200)
|
|
453
|
+
.expect('Accept-Patch', 'text/n3, application/sparql-update, application/sparql-update-single-match')
|
|
454
|
+
.expect('Accept-Post', '*/*')
|
|
455
|
+
.expect((res) => {
|
|
456
|
+
if (res.headers['Accept-Put']) return done(new Error('Accept-Put header should not exist'))
|
|
457
|
+
})
|
|
458
|
+
.end(done)
|
|
459
|
+
})
|
|
460
|
+
})
|
|
461
|
+
})
|
|
462
|
+
|
|
463
|
+
describe('HEAD API', function () {
|
|
464
|
+
it('should return content-type application/octet-stream by default', function (done) {
|
|
465
|
+
server.head('/sampleContainer/blank')
|
|
466
|
+
.expect('Content-Type', /application\/octet-stream/)
|
|
467
|
+
.end(done)
|
|
468
|
+
})
|
|
469
|
+
it('should return content-type text/turtle for container', function (done) {
|
|
470
|
+
server.head('/sampleContainer2/')
|
|
471
|
+
.expect('Content-Type', /text\/turtle/)
|
|
472
|
+
.end(done)
|
|
473
|
+
})
|
|
474
|
+
it('should have set content-type for turtle files',
|
|
475
|
+
function (done) {
|
|
476
|
+
server.head('/sampleContainer2/example1.ttl')
|
|
477
|
+
.expect('Content-Type', /text\/turtle/)
|
|
478
|
+
.end(done)
|
|
479
|
+
})
|
|
480
|
+
it('should have set content-type for implicit turtle files',
|
|
481
|
+
function (done) {
|
|
482
|
+
server.head('/sampleContainer/example4')
|
|
483
|
+
.expect('Content-Type', /text\/turtle/)
|
|
484
|
+
.end(done)
|
|
485
|
+
})
|
|
486
|
+
it('should have set content-type for image files',
|
|
487
|
+
function (done) {
|
|
488
|
+
server.head('/sampleContainer/solid.png')
|
|
489
|
+
.expect('Content-Type', /image\/png/)
|
|
490
|
+
.end(done)
|
|
491
|
+
})
|
|
492
|
+
it('should have Access-Control-Allow-Origin as Origin', function (done) {
|
|
493
|
+
server.head('/sampleContainer2/example1.ttl')
|
|
494
|
+
.set('Origin', 'http://example.com')
|
|
495
|
+
.expect('Access-Control-Allow-Origin', 'http://example.com')
|
|
496
|
+
.expect(200, done)
|
|
497
|
+
})
|
|
498
|
+
it('should return empty response body', function (done) {
|
|
499
|
+
server.head('/patch-5-initial.ttl')
|
|
500
|
+
.expect(emptyResponse)
|
|
501
|
+
.expect(200, done)
|
|
502
|
+
})
|
|
503
|
+
it('should have set Updates-Via to use WebSockets', function (done) {
|
|
504
|
+
server.head('/sampleContainer2/example1.ttl')
|
|
505
|
+
.expect('updates-via', /wss?:\/\//)
|
|
506
|
+
.expect(200, done)
|
|
507
|
+
})
|
|
508
|
+
it('should have set Link as Resource', function (done) {
|
|
509
|
+
server.head('/sampleContainer2/example1.ttl')
|
|
510
|
+
.expect('Link', /<http:\/\/www.w3.org\/ns\/ldp#Resource>; rel="type"/)
|
|
511
|
+
.expect(200, done)
|
|
512
|
+
})
|
|
513
|
+
it('should have set acl and describedBy Links for resource',
|
|
514
|
+
function (done) {
|
|
515
|
+
server.head('/sampleContainer2/example1.ttl')
|
|
516
|
+
.expect(hasHeader('acl', 'example1.ttl' + suffixAcl))
|
|
517
|
+
.expect(hasHeader('describedBy', 'example1.ttl' + suffixMeta))
|
|
518
|
+
.end(done)
|
|
519
|
+
})
|
|
520
|
+
it('should have set Content-Type as text/turtle for Container',
|
|
521
|
+
function (done) {
|
|
522
|
+
server.head('/sampleContainer2/')
|
|
523
|
+
.expect('Content-Type', /text\/turtle/)
|
|
524
|
+
.expect(200, done)
|
|
525
|
+
})
|
|
526
|
+
it('should have set Link as Container/BasicContainer',
|
|
527
|
+
function (done) {
|
|
528
|
+
server.head('/sampleContainer2/')
|
|
529
|
+
.expect('Link', /<http:\/\/www.w3.org\/ns\/ldp#BasicContainer>; rel="type"/)
|
|
530
|
+
.expect('Link', /<http:\/\/www.w3.org\/ns\/ldp#Container>; rel="type"/)
|
|
531
|
+
.expect(200, done)
|
|
532
|
+
})
|
|
533
|
+
it('should have set acl and describedBy Links for container',
|
|
534
|
+
function (done) {
|
|
535
|
+
server.head('/sampleContainer2/')
|
|
536
|
+
.expect(hasHeader('acl', suffixAcl))
|
|
537
|
+
.expect(hasHeader('describedBy', suffixMeta))
|
|
538
|
+
.end(done)
|
|
539
|
+
})
|
|
540
|
+
})
|
|
541
|
+
|
|
542
|
+
describe('PUT API', function () {
|
|
543
|
+
const putRequestBody = fs.readFileSync(path.join(__dirname,
|
|
544
|
+
'../resources/sampleContainer/put1.ttl'), {
|
|
545
|
+
encoding: 'utf8'
|
|
546
|
+
})
|
|
547
|
+
it('should create new resource with if-none-match on non existing resource', function (done) {
|
|
548
|
+
server.put('/put-resource-1.ttl')
|
|
549
|
+
.send(putRequestBody)
|
|
550
|
+
.set('if-none-match', '*')
|
|
551
|
+
.set('content-type', 'text/plain')
|
|
552
|
+
.expect(201, done)
|
|
553
|
+
})
|
|
554
|
+
it('should fail with 412 with precondition on existing resource', function (done) {
|
|
555
|
+
server.put('/put-resource-1.ttl')
|
|
556
|
+
.send(putRequestBody)
|
|
557
|
+
.set('if-none-match', '*')
|
|
558
|
+
.set('content-type', 'text/plain')
|
|
559
|
+
.expect(412, done)
|
|
560
|
+
})
|
|
561
|
+
it('should fail with 400 if not content-type', function (done) {
|
|
562
|
+
server.put('/put-resource-1.ttl')
|
|
563
|
+
.send(putRequestBody)
|
|
564
|
+
.set('content-type', '')
|
|
565
|
+
.expect(400, done)
|
|
566
|
+
})
|
|
567
|
+
it('should create new resource and delete old path if different', function (done) {
|
|
568
|
+
server.put('/put-resource-1.ttl')
|
|
569
|
+
.send(putRequestBody)
|
|
570
|
+
.set('content-type', 'text/turtle')
|
|
571
|
+
.expect(204)
|
|
572
|
+
.end(function (err) {
|
|
573
|
+
if (err) return done(err)
|
|
574
|
+
if (fs.existsSync(path.join(__dirname, '../resources/put-resource-1.ttl$.txt'))) {
|
|
575
|
+
return done(new Error('Can read old file that should have been deleted'))
|
|
576
|
+
}
|
|
577
|
+
done()
|
|
578
|
+
})
|
|
579
|
+
})
|
|
580
|
+
it('should reject create .acl resource, if contentType not text/turtle', function (done) {
|
|
581
|
+
server.put('/put-resource-1.acl')
|
|
582
|
+
.send(putRequestBody)
|
|
583
|
+
.set('content-type', 'text/plain')
|
|
584
|
+
.expect(415, done)
|
|
585
|
+
})
|
|
586
|
+
it('should reject create .acl resource, if body is not valid turtle', function (done) {
|
|
587
|
+
server.put('/put-resource-1.acl')
|
|
588
|
+
.send('bad turtle content')
|
|
589
|
+
.set('content-type', 'text/turtle')
|
|
590
|
+
.expect(400, done)
|
|
591
|
+
})
|
|
592
|
+
it('should reject create .meta resource, if contentType not text/turtle', function (done) {
|
|
593
|
+
server.put('/.meta')
|
|
594
|
+
.send(putRequestBody)
|
|
595
|
+
.set('content-type', 'text/plain')
|
|
596
|
+
.expect(415, done)
|
|
597
|
+
})
|
|
598
|
+
it('should reject create .meta resource, if body is not valid turtle', function (done) {
|
|
599
|
+
server.put('/.meta')
|
|
600
|
+
.send(JSON.stringify({}))
|
|
601
|
+
.set('content-type', 'text/turtle')
|
|
602
|
+
.expect(400, done)
|
|
603
|
+
})
|
|
604
|
+
it('should create directories if they do not exist', function (done) {
|
|
605
|
+
server.put('/foo/bar/baz.ttl')
|
|
606
|
+
.send(putRequestBody)
|
|
607
|
+
.set('content-type', 'text/turtle')
|
|
608
|
+
.expect(hasHeader('describedBy', 'baz.ttl' + suffixMeta))
|
|
609
|
+
.expect(hasHeader('acl', 'baz.ttl' + suffixAcl))
|
|
610
|
+
.expect(201, done)
|
|
611
|
+
})
|
|
612
|
+
it('should not create a resource with percent-encoded $.ext', function (done) {
|
|
613
|
+
server.put('/foo/bar/baz%24.ttl')
|
|
614
|
+
.send(putRequestBody)
|
|
615
|
+
.set('content-type', 'text/turtle')
|
|
616
|
+
// .expect(hasHeader('describedBy', 'baz.ttl' + suffixMeta))
|
|
617
|
+
// .expect(hasHeader('acl', 'baz.ttl' + suffixAcl))
|
|
618
|
+
.expect(400, done) // 404
|
|
619
|
+
})
|
|
620
|
+
it('should create a resource without extension', function (done) {
|
|
621
|
+
server.put('/foo/bar/baz')
|
|
622
|
+
.send(putRequestBody)
|
|
623
|
+
.set('content-type', 'text/turtle')
|
|
624
|
+
.expect(hasHeader('describedBy', 'baz' + suffixMeta))
|
|
625
|
+
.expect(hasHeader('acl', 'baz' + suffixAcl))
|
|
626
|
+
.expect(201, done)
|
|
627
|
+
})
|
|
628
|
+
it('should not create a container if a document with same name exists in tree', function (done) {
|
|
629
|
+
server.put('/foo/bar/baz/')
|
|
630
|
+
.send(putRequestBody)
|
|
631
|
+
// .set('content-type', 'text/turtle')
|
|
632
|
+
// .expect(hasHeader('describedBy', suffixMeta))
|
|
633
|
+
// .expect(hasHeader('acl', suffixAcl))
|
|
634
|
+
.expect(409, done)
|
|
635
|
+
})
|
|
636
|
+
it('should not create new resource if a folder/resource with same name will exist in tree', function (done) {
|
|
637
|
+
server.put('/foo/bar/baz/baz1/test.ttl')
|
|
638
|
+
.send(putRequestBody)
|
|
639
|
+
.set('content-type', 'text/turtle')
|
|
640
|
+
.expect(hasHeader('describedBy', 'test.ttl' + suffixMeta))
|
|
641
|
+
.expect(hasHeader('acl', 'test.ttl' + suffixAcl))
|
|
642
|
+
.expect(409, done)
|
|
643
|
+
})
|
|
644
|
+
it('should return 201 when trying to put to a container without content-type',
|
|
645
|
+
function (done) {
|
|
646
|
+
server.put('/foo/bar/test/')
|
|
647
|
+
// .set('content-type', 'text/turtle')
|
|
648
|
+
.set('link', '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"')
|
|
649
|
+
.expect(201, done)
|
|
650
|
+
}
|
|
651
|
+
)
|
|
652
|
+
it('should return 204 code when trying to put to a container',
|
|
653
|
+
function (done) {
|
|
654
|
+
server.put('/foo/bar/test/')
|
|
655
|
+
.set('content-type', 'text/turtle')
|
|
656
|
+
.set('link', '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"')
|
|
657
|
+
.expect(204, done)
|
|
658
|
+
}
|
|
659
|
+
)
|
|
660
|
+
it('should return 204 when trying to put to a container without content-type',
|
|
661
|
+
function (done) {
|
|
662
|
+
server.put('/foo/bar/test/')
|
|
663
|
+
// .set('content-type', 'text/turtle')
|
|
664
|
+
.set('link', '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"')
|
|
665
|
+
.expect(204, done)
|
|
666
|
+
}
|
|
667
|
+
)
|
|
668
|
+
it('should return 204 code when trying to put to a container',
|
|
669
|
+
function (done) {
|
|
670
|
+
server.put('/foo/bar/test/')
|
|
671
|
+
.set('content-type', 'text/turtle')
|
|
672
|
+
.set('link', '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"')
|
|
673
|
+
.expect(204, done)
|
|
674
|
+
}
|
|
675
|
+
)
|
|
676
|
+
it('should return a 400 error when trying to PUT a container with a name that contains a reserved suffix',
|
|
677
|
+
function (done) {
|
|
678
|
+
server.put('/foo/bar.acl/test/')
|
|
679
|
+
.set('content-type', 'text/turtle')
|
|
680
|
+
.set('link', '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"')
|
|
681
|
+
.expect(400, done)
|
|
682
|
+
}
|
|
683
|
+
)
|
|
684
|
+
it('should return a 400 error when trying to PUT a resource with a name that contains a reserved suffix',
|
|
685
|
+
function (done) {
|
|
686
|
+
server.put('/foo/bar.acl/test.ttl')
|
|
687
|
+
.send(putRequestBody)
|
|
688
|
+
.set('content-type', 'text/turtle')
|
|
689
|
+
.set('link', '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"')
|
|
690
|
+
.expect(400, done)
|
|
691
|
+
}
|
|
692
|
+
)
|
|
693
|
+
// Cleanup
|
|
694
|
+
after(function () {
|
|
695
|
+
rm('/foo/')
|
|
696
|
+
})
|
|
697
|
+
})
|
|
698
|
+
|
|
699
|
+
describe('DELETE API', function () {
|
|
700
|
+
before(function () {
|
|
701
|
+
// Ensure all these are finished before running tests
|
|
702
|
+
return Promise.all([
|
|
703
|
+
rm('/false-file-48484848'),
|
|
704
|
+
createTestResource('/.acl'),
|
|
705
|
+
createTestResource('/profile/card'),
|
|
706
|
+
createTestResource('/delete-test-empty-container/.meta.acl'),
|
|
707
|
+
createTestResource('/put-resource-1.ttl'),
|
|
708
|
+
createTestResource('/put-resource-with-acl.ttl'),
|
|
709
|
+
createTestResource('/put-resource-with-acl.ttl.acl'),
|
|
710
|
+
createTestResource('/put-resource-with-acl.txt'),
|
|
711
|
+
createTestResource('/put-resource-with-acl.txt.acl'),
|
|
712
|
+
createTestResource('/delete-test-non-empty/test.ttl')
|
|
713
|
+
])
|
|
714
|
+
})
|
|
715
|
+
|
|
716
|
+
it('should return 405 status when deleting root folder', function (done) {
|
|
717
|
+
server.delete('/')
|
|
718
|
+
.expect(405)
|
|
719
|
+
.end((err, res) => {
|
|
720
|
+
if (err) return done(err)
|
|
721
|
+
try {
|
|
722
|
+
assert.equal(res.get('allow').includes('DELETE'), false)
|
|
723
|
+
} catch (err) {
|
|
724
|
+
return done(err)
|
|
725
|
+
}
|
|
726
|
+
done()
|
|
727
|
+
})
|
|
728
|
+
})
|
|
729
|
+
|
|
730
|
+
it('should return 405 status when deleting root acl', function (done) {
|
|
731
|
+
server.delete('/' + suffixAcl)
|
|
732
|
+
.expect(405)
|
|
733
|
+
.end((err, res) => {
|
|
734
|
+
if (err) return done(err)
|
|
735
|
+
try {
|
|
736
|
+
assert.equal(res.get('allow').includes('DELETE'), false) // ,'res methods')
|
|
737
|
+
} catch (err) {
|
|
738
|
+
return done(err)
|
|
739
|
+
}
|
|
740
|
+
done()
|
|
741
|
+
})
|
|
742
|
+
})
|
|
743
|
+
|
|
744
|
+
it('should return 405 status when deleting /profile/card', function (done) {
|
|
745
|
+
server.delete('/profile/card')
|
|
746
|
+
.expect(405)
|
|
747
|
+
.end((err, res) => {
|
|
748
|
+
if (err) return done(err)
|
|
749
|
+
try {
|
|
750
|
+
assert.equal(res.get('allow').includes('DELETE'), false) // ,'res methods')
|
|
751
|
+
} catch (err) {
|
|
752
|
+
return done(err)
|
|
753
|
+
}
|
|
754
|
+
done()
|
|
755
|
+
})
|
|
756
|
+
})
|
|
757
|
+
|
|
758
|
+
it('should return 404 status when deleting a file that does not exists',
|
|
759
|
+
function (done) {
|
|
760
|
+
server.delete('/false-file-48484848')
|
|
761
|
+
.expect(404, done)
|
|
762
|
+
})
|
|
763
|
+
|
|
764
|
+
it('should delete previously PUT file', function (done) {
|
|
765
|
+
server.delete('/put-resource-1.ttl')
|
|
766
|
+
.expect(200, done)
|
|
767
|
+
})
|
|
768
|
+
|
|
769
|
+
it('should delete previously PUT file with ACL', function (done) {
|
|
770
|
+
server.delete('/put-resource-with-acl.ttl')
|
|
771
|
+
.expect(200, done)
|
|
772
|
+
})
|
|
773
|
+
|
|
774
|
+
it('should return 404 on deleting .acl of previously deleted PUT file with ACL', function (done) {
|
|
775
|
+
server.delete('/put-resource-with-acl.ttl.acl')
|
|
776
|
+
.expect(404, done)
|
|
777
|
+
})
|
|
778
|
+
|
|
779
|
+
it('should delete previously PUT file with bad extension and with ACL', function (done) {
|
|
780
|
+
server.delete('/put-resource-with-acl.txt')
|
|
781
|
+
.expect(200, done)
|
|
782
|
+
})
|
|
783
|
+
|
|
784
|
+
it('should return 404 on deleting .acl of previously deleted PUT file with bad extension and with ACL', function (done) {
|
|
785
|
+
server.delete('/put-resource-with-acl.txt.acl')
|
|
786
|
+
.expect(404, done)
|
|
787
|
+
})
|
|
788
|
+
|
|
789
|
+
it('should fail to delete non-empty containers', function (done) {
|
|
790
|
+
server.delete('/delete-test-non-empty/')
|
|
791
|
+
.expect(409, done)
|
|
792
|
+
})
|
|
793
|
+
|
|
794
|
+
it('should delete a new and empty container - with .meta.acl', function (done) {
|
|
795
|
+
server.delete('/delete-test-empty-container/')
|
|
796
|
+
.end(() => {
|
|
797
|
+
server.get('/delete-test-empty-container/')
|
|
798
|
+
.expect(404)
|
|
799
|
+
.end(done)
|
|
800
|
+
})
|
|
801
|
+
})
|
|
802
|
+
|
|
803
|
+
after(function () {
|
|
804
|
+
// Clean up after DELETE API tests
|
|
805
|
+
rm('/profile/')
|
|
806
|
+
rm('/put-resource-1.ttl')
|
|
807
|
+
rm('/delete-test-non-empty/')
|
|
808
|
+
rm('/delete-test-empty-container/test.txt.acl')
|
|
809
|
+
rm('/delete-test-empty-container/')
|
|
810
|
+
})
|
|
811
|
+
})
|
|
812
|
+
|
|
813
|
+
describe('POST API', function () {
|
|
814
|
+
let postLocation
|
|
815
|
+
before(function () {
|
|
816
|
+
// Ensure all these are finished before running tests
|
|
817
|
+
return Promise.all([
|
|
818
|
+
createTestResource('/post-tests/put-resource'),
|
|
819
|
+
// createTestContainer('post-tests'),
|
|
820
|
+
rm('post-test-target.ttl') // ,
|
|
821
|
+
// createTestResource('/post-tests/put-resource')
|
|
822
|
+
])
|
|
823
|
+
})
|
|
824
|
+
|
|
825
|
+
const postRequest1Body = fs.readFileSync(path.join(__dirname,
|
|
826
|
+
'../resources/sampleContainer/put1.ttl'), {
|
|
827
|
+
encoding: 'utf8'
|
|
828
|
+
})
|
|
829
|
+
const postRequest2Body = fs.readFileSync(path.join(__dirname,
|
|
830
|
+
'../resources/sampleContainer/post2.ttl'), {
|
|
831
|
+
encoding: 'utf8'
|
|
832
|
+
})
|
|
833
|
+
// Capture the resource name generated by server by parsing Location: header
|
|
834
|
+
let postedResourceName
|
|
835
|
+
const getResourceName = function (res) {
|
|
836
|
+
postedResourceName = res.header.location
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
it('should create new document resource', function (done) {
|
|
840
|
+
server.post('/post-tests/')
|
|
841
|
+
.send(postRequest1Body)
|
|
842
|
+
.set('content-type', 'text/turtle')
|
|
843
|
+
.set('slug', 'post-resource-1')
|
|
844
|
+
.expect('location', /\/post-resource-1/)
|
|
845
|
+
.expect(hasHeader('describedBy', suffixMeta))
|
|
846
|
+
.expect(hasHeader('acl', suffixAcl))
|
|
847
|
+
.expect(201, done)
|
|
848
|
+
})
|
|
849
|
+
it('should create new resource even if body is empty', function (done) {
|
|
850
|
+
server.post('/post-tests/')
|
|
851
|
+
.set('slug', 'post-resource-empty')
|
|
852
|
+
.set('content-type', 'text/turtle')
|
|
853
|
+
.expect(hasHeader('describedBy', suffixMeta))
|
|
854
|
+
.expect(hasHeader('acl', suffixAcl))
|
|
855
|
+
.expect('location', /.*\.ttl/)
|
|
856
|
+
.expect(201, done)
|
|
857
|
+
})
|
|
858
|
+
it('should create container with new slug as a resource', function (done) {
|
|
859
|
+
server.post('/post-tests/')
|
|
860
|
+
.set('content-type', 'text/turtle')
|
|
861
|
+
.set('slug', 'put-resource')
|
|
862
|
+
.set('link', '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"')
|
|
863
|
+
.send(postRequest2Body)
|
|
864
|
+
.expect(201)
|
|
865
|
+
.end((err, res) => {
|
|
866
|
+
if (err) return done(err)
|
|
867
|
+
try {
|
|
868
|
+
postLocation = res.headers.location
|
|
869
|
+
// console.log('location ' + postLocation)
|
|
870
|
+
const createdDir = fs.statSync(path.join(__dirname, '../resources', postLocation.slice(0, -1)))
|
|
871
|
+
assert(createdDir.isDirectory(), 'Container should have been created')
|
|
872
|
+
} catch (err) {
|
|
873
|
+
return done(err)
|
|
874
|
+
}
|
|
875
|
+
done()
|
|
876
|
+
})
|
|
877
|
+
})
|
|
878
|
+
it('should get newly created container with new slug', function (done) {
|
|
879
|
+
console.log('location' + postLocation)
|
|
880
|
+
server.get(postLocation)
|
|
881
|
+
.expect(200, done)
|
|
882
|
+
})
|
|
883
|
+
it('should error with 403 if auxiliary resource file.acl', function (done) {
|
|
884
|
+
server.post('/post-tests/')
|
|
885
|
+
.set('slug', 'post-acl-no-content-type.acl')
|
|
886
|
+
.send(postRequest1Body)
|
|
887
|
+
.set('content-type', 'text/turtle')
|
|
888
|
+
.expect(403, done)
|
|
889
|
+
})
|
|
890
|
+
it('should error with 403 if auxiliary resource .meta', function (done) {
|
|
891
|
+
server.post('/post-tests/')
|
|
892
|
+
.set('slug', '.meta')
|
|
893
|
+
.send(postRequest1Body)
|
|
894
|
+
.set('content-type', 'text/turtle')
|
|
895
|
+
.expect(403, done)
|
|
896
|
+
})
|
|
897
|
+
it('should error with 400 if the body is empty and no content type is provided', function (done) {
|
|
898
|
+
server.post('/post-tests/')
|
|
899
|
+
.set('slug', 'post-resource-empty-fail')
|
|
900
|
+
.expect(400, done)
|
|
901
|
+
})
|
|
902
|
+
it('should error with 400 if the body is provided but there is no content-type header', function (done) {
|
|
903
|
+
server.post('/post-tests/')
|
|
904
|
+
.set('slug', 'post-resource-rdf-no-content-type')
|
|
905
|
+
.send(postRequest1Body)
|
|
906
|
+
.set('content-type', '')
|
|
907
|
+
.expect(400, done)
|
|
908
|
+
})
|
|
909
|
+
it('should create new resource even if no trailing / is in the target',
|
|
910
|
+
function (done) {
|
|
911
|
+
server.post('')
|
|
912
|
+
.send(postRequest1Body)
|
|
913
|
+
.set('content-type', 'text/turtle')
|
|
914
|
+
.set('slug', 'post-test-target')
|
|
915
|
+
.expect('location', /\/post-test-target\.ttl/)
|
|
916
|
+
.expect(hasHeader('describedBy', suffixMeta))
|
|
917
|
+
.expect(hasHeader('acl', suffixAcl))
|
|
918
|
+
.expect(201, done)
|
|
919
|
+
})
|
|
920
|
+
it('should create new resource even if slug contains invalid suffix', function (done) {
|
|
921
|
+
server.post('/post-tests/')
|
|
922
|
+
.set('slug', 'put-resource.acl.ttl')
|
|
923
|
+
.send(postRequest1Body)
|
|
924
|
+
.set('content-type', 'text-turtle')
|
|
925
|
+
.expect(hasHeader('describedBy', suffixMeta))
|
|
926
|
+
.expect(hasHeader('acl', suffixAcl))
|
|
927
|
+
.expect(201, done)
|
|
928
|
+
})
|
|
929
|
+
it('create container with recursive example', function (done) {
|
|
930
|
+
server.post('/post-tests/')
|
|
931
|
+
.set('content-type', 'text/turtle')
|
|
932
|
+
.set('slug', 'foo.bar.acl.meta')
|
|
933
|
+
.set('link', '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"')
|
|
934
|
+
.send(postRequest2Body)
|
|
935
|
+
.expect('location', /\/post-tests\/foo.bar\//)
|
|
936
|
+
.expect(201, done)
|
|
937
|
+
})
|
|
938
|
+
it('should fail return 404 if no parent container found', function (done) {
|
|
939
|
+
server.post('/hello.html/')
|
|
940
|
+
.send(postRequest1Body)
|
|
941
|
+
.set('content-type', 'text/turtle')
|
|
942
|
+
.set('slug', 'post-test-target2')
|
|
943
|
+
.expect(404, done)
|
|
944
|
+
})
|
|
945
|
+
it('should create a new slug if there is a resource with the same name',
|
|
946
|
+
function (done) {
|
|
947
|
+
server.post('/post-tests/')
|
|
948
|
+
.send(postRequest1Body)
|
|
949
|
+
.set('content-type', 'text/turtle')
|
|
950
|
+
.set('slug', 'post-resource-1')
|
|
951
|
+
.expect(201, done)
|
|
952
|
+
})
|
|
953
|
+
it('should be able to delete newly created resource', function (done) {
|
|
954
|
+
server.delete('/post-tests/post-resource-1.ttl')
|
|
955
|
+
.expect(200, done)
|
|
956
|
+
})
|
|
957
|
+
it('should create new resource without slug header', function (done) {
|
|
958
|
+
server.post('/post-tests/')
|
|
959
|
+
.send(postRequest1Body)
|
|
960
|
+
.set('content-type', 'text/turtle')
|
|
961
|
+
.expect(201)
|
|
962
|
+
.expect(getResourceName)
|
|
963
|
+
.end(done)
|
|
964
|
+
})
|
|
965
|
+
it('should be able to delete newly created resource (2)', function (done) {
|
|
966
|
+
server.delete('/' +
|
|
967
|
+
postedResourceName.replace(/https?:\/\/((127.0.0.1)|(localhost)):[0-9]*\//, ''))
|
|
968
|
+
.expect(200, done)
|
|
969
|
+
})
|
|
970
|
+
it('should create container', function (done) {
|
|
971
|
+
server.post('/post-tests/')
|
|
972
|
+
.set('content-type', 'text/turtle')
|
|
973
|
+
.set('slug', 'loans.ttl')
|
|
974
|
+
.set('link', '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"')
|
|
975
|
+
.send(postRequest2Body)
|
|
976
|
+
.expect('location', /\/post-tests\/loans.ttl\//)
|
|
977
|
+
.expect(201)
|
|
978
|
+
.end((err, res) => {
|
|
979
|
+
if (err) return done(err)
|
|
980
|
+
try {
|
|
981
|
+
postLocation = res.headers.location
|
|
982
|
+
console.log('location ' + postLocation)
|
|
983
|
+
const createdDir = fs.statSync(path.join(__dirname, '../resources', postLocation.slice(0, -1)))
|
|
984
|
+
assert(createdDir.isDirectory(), 'Container should have been created')
|
|
985
|
+
} catch (err) {
|
|
986
|
+
return done(err)
|
|
987
|
+
}
|
|
988
|
+
done()
|
|
989
|
+
})
|
|
990
|
+
})
|
|
991
|
+
it('should be able to access newly container', function (done) {
|
|
992
|
+
console.log(postLocation)
|
|
993
|
+
server.get(postLocation)
|
|
994
|
+
// .expect('content-type', /text\/turtle/)
|
|
995
|
+
.expect(200, done)
|
|
996
|
+
})
|
|
997
|
+
it('should create container', function (done) {
|
|
998
|
+
server.post('/post-tests/')
|
|
999
|
+
.set('content-type', 'text/turtle')
|
|
1000
|
+
.set('slug', 'loans.acl.meta')
|
|
1001
|
+
.set('link', '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"')
|
|
1002
|
+
.send(postRequest2Body)
|
|
1003
|
+
.expect('location', /\/post-tests\/loans\//)
|
|
1004
|
+
.expect(201)
|
|
1005
|
+
.end((err, res) => {
|
|
1006
|
+
if (err) return done(err)
|
|
1007
|
+
try {
|
|
1008
|
+
postLocation = res.headers.location
|
|
1009
|
+
assert(!postLocation.endsWith('.acl/') && !postLocation.endsWith('.meta/'), 'Container name cannot end with ".acl" or ".meta"')
|
|
1010
|
+
} catch (err) {
|
|
1011
|
+
return done(err)
|
|
1012
|
+
}
|
|
1013
|
+
done()
|
|
1014
|
+
})
|
|
1015
|
+
})
|
|
1016
|
+
it('should be able to access newly created container', function (done) {
|
|
1017
|
+
console.log(postLocation)
|
|
1018
|
+
server.get(postLocation)
|
|
1019
|
+
// .expect('content-type', /text\/turtle/)
|
|
1020
|
+
.expect(200, done)
|
|
1021
|
+
})
|
|
1022
|
+
it('should create a new slug if there is a container with same name', function (done) {
|
|
1023
|
+
server.post('/post-tests/')
|
|
1024
|
+
.send(postRequest1Body)
|
|
1025
|
+
.set('content-type', 'text/turtle')
|
|
1026
|
+
.set('slug', 'loans.ttl')
|
|
1027
|
+
.expect(201)
|
|
1028
|
+
.expect(getResourceName)
|
|
1029
|
+
.end(done)
|
|
1030
|
+
})
|
|
1031
|
+
it('should get newly created document resource with new slug', function (done) {
|
|
1032
|
+
console.log(postedResourceName)
|
|
1033
|
+
server.get(postedResourceName)
|
|
1034
|
+
.expect(200, done)
|
|
1035
|
+
})
|
|
1036
|
+
it('should create a container with a name hex decoded from the slug', (done) => {
|
|
1037
|
+
const containerName = 'Film%4011'
|
|
1038
|
+
const expectedDirName = '/post-tests/Film@11/'
|
|
1039
|
+
server.post('/post-tests/')
|
|
1040
|
+
.set('slug', containerName)
|
|
1041
|
+
.set('content-type', 'text/turtle')
|
|
1042
|
+
.set('link', '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"')
|
|
1043
|
+
.expect(201)
|
|
1044
|
+
.end((err, res) => {
|
|
1045
|
+
if (err) return done(err)
|
|
1046
|
+
try {
|
|
1047
|
+
assert.equal(res.headers.location, expectedDirName,
|
|
1048
|
+
'Uri container names should be encoded')
|
|
1049
|
+
const createdDir = fs.statSync(path.join(__dirname, '../resources', expectedDirName))
|
|
1050
|
+
assert(createdDir.isDirectory(), 'Container should have been created')
|
|
1051
|
+
} catch (err) {
|
|
1052
|
+
return done(err)
|
|
1053
|
+
}
|
|
1054
|
+
done()
|
|
1055
|
+
})
|
|
1056
|
+
})
|
|
1057
|
+
|
|
1058
|
+
describe('content-type-based file extensions', () => {
|
|
1059
|
+
// ensure the container exists
|
|
1060
|
+
before(() =>
|
|
1061
|
+
server.post('/post-tests/')
|
|
1062
|
+
.send(postRequest1Body)
|
|
1063
|
+
.set('content-type', 'text/turtle')
|
|
1064
|
+
)
|
|
1065
|
+
|
|
1066
|
+
describe('a new text/turtle document posted without slug', () => {
|
|
1067
|
+
let response
|
|
1068
|
+
before(() =>
|
|
1069
|
+
server.post('/post-tests/')
|
|
1070
|
+
.set('content-type', 'text/turtle; charset=utf-8')
|
|
1071
|
+
.then(res => { response = res })
|
|
1072
|
+
)
|
|
1073
|
+
|
|
1074
|
+
it('is assigned an URL with the .ttl extension', () => {
|
|
1075
|
+
expect(response.headers).to.have.property('location')
|
|
1076
|
+
expect(response.headers.location).to.match(/^\/post-tests\/[^./]+\.ttl$/)
|
|
1077
|
+
})
|
|
1078
|
+
})
|
|
1079
|
+
|
|
1080
|
+
describe('a new text/turtle document posted with a slug', () => {
|
|
1081
|
+
let response
|
|
1082
|
+
before(() =>
|
|
1083
|
+
server.post('/post-tests/')
|
|
1084
|
+
.set('slug', 'slug1')
|
|
1085
|
+
.set('content-type', 'text/turtle; charset=utf-8')
|
|
1086
|
+
.then(res => { response = res })
|
|
1087
|
+
)
|
|
1088
|
+
|
|
1089
|
+
it('is assigned an URL with the .ttl extension', () => {
|
|
1090
|
+
expect(response.headers).to.have.property('location', '/post-tests/slug1.ttl')
|
|
1091
|
+
})
|
|
1092
|
+
})
|
|
1093
|
+
|
|
1094
|
+
describe('a new text/html document posted without slug', () => {
|
|
1095
|
+
let response
|
|
1096
|
+
before(() =>
|
|
1097
|
+
server.post('/post-tests/')
|
|
1098
|
+
.set('content-type', 'text/html; charset=utf-8')
|
|
1099
|
+
.then(res => { response = res })
|
|
1100
|
+
)
|
|
1101
|
+
|
|
1102
|
+
it('is assigned an URL with the .html extension', () => {
|
|
1103
|
+
expect(response.headers).to.have.property('location')
|
|
1104
|
+
expect(response.headers.location).to.match(/^\/post-tests\/[^./]+\.html$/)
|
|
1105
|
+
})
|
|
1106
|
+
})
|
|
1107
|
+
|
|
1108
|
+
describe('a new text/html document posted with a slug', () => {
|
|
1109
|
+
let response
|
|
1110
|
+
before(() =>
|
|
1111
|
+
server.post('/post-tests/')
|
|
1112
|
+
.set('slug', 'slug2')
|
|
1113
|
+
.set('content-type', 'text/html; charset=utf-8')
|
|
1114
|
+
.then(res => { response = res })
|
|
1115
|
+
)
|
|
1116
|
+
|
|
1117
|
+
it('is assigned an URL with the .html extension', () => {
|
|
1118
|
+
expect(response.headers).to.have.property('location', '/post-tests/slug2.html')
|
|
1119
|
+
})
|
|
1120
|
+
})
|
|
1121
|
+
})
|
|
1122
|
+
|
|
1123
|
+
/* No, URLs are NOT ex-encoded to make filenames -- the other way around.
|
|
1124
|
+
it('should create a container with a url name', (done) => {
|
|
1125
|
+
let containerName = 'https://example.com/page'
|
|
1126
|
+
let expectedDirName = '/post-tests/https%3A%2F%2Fexample.com%2Fpage/'
|
|
1127
|
+
server.post('/post-tests/')
|
|
1128
|
+
.set('slug', containerName)
|
|
1129
|
+
.set('content-type', 'text/turtle')
|
|
1130
|
+
.set('link', '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"')
|
|
1131
|
+
.expect(201)
|
|
1132
|
+
.end((err, res) => {
|
|
1133
|
+
if (err) return done(err)
|
|
1134
|
+
try {
|
|
1135
|
+
assert.equal(res.headers.location, expectedDirName,
|
|
1136
|
+
'Uri container names should be encoded')
|
|
1137
|
+
let createdDir = fs.statSync(path.join(__dirname, 'resources', expectedDirName))
|
|
1138
|
+
assert(createdDir.isDirectory(), 'Container should have been created')
|
|
1139
|
+
} catch (err) {
|
|
1140
|
+
return done(err)
|
|
1141
|
+
}
|
|
1142
|
+
done()
|
|
1143
|
+
})
|
|
1144
|
+
})
|
|
1145
|
+
|
|
1146
|
+
it('should be able to access new url-named container', (done) => {
|
|
1147
|
+
let containerUrl = '/post-tests/https%3A%2F%2Fexample.com%2Fpage/'
|
|
1148
|
+
server.get(containerUrl)
|
|
1149
|
+
.expect('content-type', /text\/turtle/)
|
|
1150
|
+
.expect(200, done)
|
|
1151
|
+
})
|
|
1152
|
+
*/
|
|
1153
|
+
|
|
1154
|
+
after(function () {
|
|
1155
|
+
// Clean up after POST API tests
|
|
1156
|
+
return Promise.all([
|
|
1157
|
+
rm('/post-tests/put-resource'),
|
|
1158
|
+
rm('/post-tests/'),
|
|
1159
|
+
rm('post-test-target.ttl')
|
|
1160
|
+
])
|
|
1161
|
+
})
|
|
1162
|
+
})
|
|
1163
|
+
|
|
1164
|
+
describe('POST (multipart)', function () {
|
|
1165
|
+
it('should create as many files as the ones passed in multipart',
|
|
1166
|
+
function (done) {
|
|
1167
|
+
server.post('/sampleContainer/')
|
|
1168
|
+
.attach('timbl', path.join(__dirname, '../resources/timbl.jpg'))
|
|
1169
|
+
.attach('nicola', path.join(__dirname, '../resources/nicola.jpg'))
|
|
1170
|
+
.expect(200)
|
|
1171
|
+
.end(function (err) {
|
|
1172
|
+
if (err) return done(err)
|
|
1173
|
+
|
|
1174
|
+
const sizeNicola = fs.statSync(path.join(__dirname,
|
|
1175
|
+
'../resources/nicola.jpg')).size
|
|
1176
|
+
const sizeTim = fs.statSync(path.join(__dirname, '../resources/timbl.jpg')).size
|
|
1177
|
+
const sizeNicolaLocal = fs.statSync(path.join(__dirname,
|
|
1178
|
+
'../resources/sampleContainer/nicola.jpg')).size
|
|
1179
|
+
const sizeTimLocal = fs.statSync(path.join(__dirname,
|
|
1180
|
+
'../resources/sampleContainer/timbl.jpg')).size
|
|
1181
|
+
|
|
1182
|
+
if (sizeNicola === sizeNicolaLocal && sizeTim === sizeTimLocal) {
|
|
1183
|
+
return done()
|
|
1184
|
+
} else {
|
|
1185
|
+
return done(new Error('Either the size (remote/local) don\'t match or files are not stored'))
|
|
1186
|
+
}
|
|
1187
|
+
})
|
|
1188
|
+
})
|
|
1189
|
+
after(function () {
|
|
1190
|
+
// Clean up after POST (multipart) API tests
|
|
1191
|
+
return Promise.all([
|
|
1192
|
+
rm('/sampleContainer/nicola.jpg'),
|
|
1193
|
+
rm('/sampleContainer/timbl.jpg')
|
|
1194
|
+
])
|
|
1195
|
+
})
|
|
1196
|
+
})
|
|
1197
|
+
})
|