solid-server 5.8.7 → 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.js → get.mjs} +31 -35
- 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 +60 -40
- 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/tls/index.js +0 -185
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/* eslint-disable no-unused-expressions */
|
|
2
|
+
import { describe, it, before } from 'mocha'
|
|
3
|
+
import { expect } from 'chai'
|
|
4
|
+
import SolidHost from '../../lib/models/solid-host.mjs'
|
|
5
|
+
import defaults from '../../config/defaults.mjs'
|
|
6
|
+
|
|
7
|
+
describe('SolidHost', () => {
|
|
8
|
+
describe('from()', () => {
|
|
9
|
+
it('should init with provided params', () => {
|
|
10
|
+
const config = {
|
|
11
|
+
port: 3000,
|
|
12
|
+
serverUri: 'https://localhost:3000',
|
|
13
|
+
live: true,
|
|
14
|
+
root: '/data/solid/',
|
|
15
|
+
multiuser: true,
|
|
16
|
+
webid: true
|
|
17
|
+
}
|
|
18
|
+
const host = SolidHost.from(config)
|
|
19
|
+
|
|
20
|
+
expect(host.port).to.equal(3000)
|
|
21
|
+
expect(host.serverUri).to.equal('https://localhost:3000')
|
|
22
|
+
expect(host.hostname).to.equal('localhost')
|
|
23
|
+
expect(host.live).to.be.true
|
|
24
|
+
expect(host.root).to.equal('/data/solid/')
|
|
25
|
+
expect(host.multiuser).to.be.true
|
|
26
|
+
expect(host.webid).to.be.true
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('should init to default port and serverUri values', () => {
|
|
30
|
+
const host = SolidHost.from({})
|
|
31
|
+
expect(host.port).to.equal(defaults.port)
|
|
32
|
+
expect(host.serverUri).to.equal(defaults.serverUri)
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
describe('accountUriFor()', () => {
|
|
37
|
+
it('should compose an account uri for an account name', () => {
|
|
38
|
+
const config = {
|
|
39
|
+
serverUri: 'https://test.local'
|
|
40
|
+
}
|
|
41
|
+
const host = SolidHost.from(config)
|
|
42
|
+
|
|
43
|
+
expect(host.accountUriFor('alice')).to.equal('https://alice.test.local')
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('should throw an error if no account name is passed in', () => {
|
|
47
|
+
const host = SolidHost.from()
|
|
48
|
+
expect(() => { host.accountUriFor() }).to.throw(TypeError)
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
describe('allowsSessionFor()', () => {
|
|
53
|
+
let host
|
|
54
|
+
before(() => {
|
|
55
|
+
host = SolidHost.from({
|
|
56
|
+
serverUri: 'https://test.local'
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('should allow an empty userId and origin', () => {
|
|
61
|
+
expect(host.allowsSessionFor('', '', [])).to.be.true
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('should allow a userId with empty origin', () => {
|
|
65
|
+
expect(host.allowsSessionFor('https://user.own/profile/card#me', '', [])).to.be.true
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('should allow a userId with the user subdomain as origin', () => {
|
|
69
|
+
expect(host.allowsSessionFor('https://user.own/profile/card#me', 'https://user.own', [])).to.be.true
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('should allow a userId with the server domain as origin', () => {
|
|
73
|
+
expect(host.allowsSessionFor('https://user.own/profile/card#me', 'https://test.local', [])).to.be.true
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
it('should allow a userId with a server subdomain as origin', () => {
|
|
77
|
+
expect(host.allowsSessionFor('https://user.own/profile/card#me', 'https://other.test.local', [])).to.be.true
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it('should disallow a userId from a different domain', () => {
|
|
81
|
+
expect(host.allowsSessionFor('https://user.own/profile/card#me', 'https://other.remote', [])).to.be.false
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('should allow user from a trusted domain', () => {
|
|
85
|
+
expect(host.allowsSessionFor('https://user.own/profile/card#me', 'https://other.remote', ['https://other.remote'])).to.be.true
|
|
86
|
+
})
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
describe('cookieDomain getter', () => {
|
|
90
|
+
it('should return null for single-part domains (localhost)', () => {
|
|
91
|
+
const host = SolidHost.from({
|
|
92
|
+
serverUri: 'https://localhost:8443'
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
expect(host.cookieDomain).to.be.null
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it('should return a cookie domain for multi-part domains', () => {
|
|
99
|
+
const host = SolidHost.from({
|
|
100
|
+
serverUri: 'https://example.com:8443'
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
expect(host.cookieDomain).to.equal('.example.com')
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
describe('authEndpoint getter', () => {
|
|
108
|
+
it('should return an /authorize url object', () => {
|
|
109
|
+
const host = SolidHost.from({
|
|
110
|
+
serverUri: 'https://localhost:8443'
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
const authUrl = host.authEndpoint
|
|
114
|
+
|
|
115
|
+
expect(authUrl.host).to.equal('localhost:8443')
|
|
116
|
+
expect(authUrl.pathname).to.equal('/authorize')
|
|
117
|
+
})
|
|
118
|
+
})
|
|
119
|
+
})
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import chai from 'chai'
|
|
2
|
+
import sinon from 'sinon'
|
|
3
|
+
import sinonChai from 'sinon-chai'
|
|
4
|
+
import dirtyChai from 'dirty-chai'
|
|
5
|
+
import chaiAsPromised from 'chai-as-promised'
|
|
6
|
+
|
|
7
|
+
import { TlsAuthenticator } from '../../lib/models/authenticator.mjs'
|
|
8
|
+
import SolidHost from '../../lib/models/solid-host.mjs'
|
|
9
|
+
import AccountManager from '../../lib/models/account-manager.mjs'
|
|
10
|
+
|
|
11
|
+
const { expect } = chai
|
|
12
|
+
chai.use(sinonChai)
|
|
13
|
+
chai.use(dirtyChai)
|
|
14
|
+
chai.use(chaiAsPromised)
|
|
15
|
+
chai.should()
|
|
16
|
+
|
|
17
|
+
const host = SolidHost.from({ serverUri: 'https://example.com' })
|
|
18
|
+
const accountManager = AccountManager.from({ host, multiuser: true })
|
|
19
|
+
|
|
20
|
+
describe('TlsAuthenticator', () => {
|
|
21
|
+
describe('fromParams()', () => {
|
|
22
|
+
const req = {
|
|
23
|
+
connection: {}
|
|
24
|
+
}
|
|
25
|
+
const options = { accountManager }
|
|
26
|
+
|
|
27
|
+
it('should return a TlsAuthenticator instance', () => {
|
|
28
|
+
const tlsAuth = TlsAuthenticator.fromParams(req, options)
|
|
29
|
+
|
|
30
|
+
expect(tlsAuth.accountManager).to.equal(accountManager)
|
|
31
|
+
expect(tlsAuth.connection).to.equal(req.connection)
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
describe('findValidUser()', () => {
|
|
36
|
+
const webId = 'https://alice.example.com/#me'
|
|
37
|
+
const certificate = { uri: webId }
|
|
38
|
+
const connection = {
|
|
39
|
+
renegotiate: sinon.stub().yields(),
|
|
40
|
+
getPeerCertificate: sinon.stub().returns(certificate)
|
|
41
|
+
}
|
|
42
|
+
const options = { accountManager, connection }
|
|
43
|
+
|
|
44
|
+
const tlsAuth = new TlsAuthenticator(options)
|
|
45
|
+
|
|
46
|
+
tlsAuth.extractWebId = sinon.stub().resolves(webId)
|
|
47
|
+
sinon.spy(tlsAuth, 'renegotiateTls')
|
|
48
|
+
sinon.spy(tlsAuth, 'loadUser')
|
|
49
|
+
|
|
50
|
+
return tlsAuth.findValidUser()
|
|
51
|
+
.then(validUser => {
|
|
52
|
+
expect(tlsAuth.renegotiateTls).to.have.been.called()
|
|
53
|
+
expect(connection.getPeerCertificate).to.have.been.called()
|
|
54
|
+
expect(tlsAuth.extractWebId).to.have.been.calledWith(certificate)
|
|
55
|
+
expect(tlsAuth.loadUser).to.have.been.calledWith(webId)
|
|
56
|
+
|
|
57
|
+
expect(validUser.webId).to.equal(webId)
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
describe('renegotiateTls()', () => {
|
|
62
|
+
it('should reject if an error occurs while renegotiating', () => {
|
|
63
|
+
const connection = {
|
|
64
|
+
renegotiate: sinon.stub().yields(new Error('Error renegotiating'))
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const tlsAuth = new TlsAuthenticator({ connection })
|
|
68
|
+
|
|
69
|
+
expect(tlsAuth.renegotiateTls()).to.be.rejectedWith(/Error renegotiating/)
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('should resolve if no error occurs', () => {
|
|
73
|
+
const connection = {
|
|
74
|
+
renegotiate: sinon.stub().yields(null)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const tlsAuth = new TlsAuthenticator({ connection })
|
|
78
|
+
|
|
79
|
+
expect(tlsAuth.renegotiateTls()).to.be.fulfilled()
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
describe('getCertificate()', () => {
|
|
84
|
+
it('should throw on a non-existent certificate', () => {
|
|
85
|
+
const connection = {
|
|
86
|
+
getPeerCertificate: sinon.stub().returns(null)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const tlsAuth = new TlsAuthenticator({ connection })
|
|
90
|
+
|
|
91
|
+
expect(() => tlsAuth.getCertificate()).to.throw(/No client certificate detected/)
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
it('should throw on an empty certificate', () => {
|
|
95
|
+
const connection = {
|
|
96
|
+
getPeerCertificate: sinon.stub().returns({})
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const tlsAuth = new TlsAuthenticator({ connection })
|
|
100
|
+
|
|
101
|
+
expect(() => tlsAuth.getCertificate()).to.throw(/No client certificate detected/)
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
it('should return a certificate if no error occurs', () => {
|
|
105
|
+
const certificate = { uri: 'https://alice.example.com/#me' }
|
|
106
|
+
const connection = {
|
|
107
|
+
getPeerCertificate: sinon.stub().returns(certificate)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const tlsAuth = new TlsAuthenticator({ connection })
|
|
111
|
+
|
|
112
|
+
expect(tlsAuth.getCertificate()).to.equal(certificate)
|
|
113
|
+
})
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
describe('extractWebId()', () => {
|
|
117
|
+
it('should reject if an error occurs verifying certificate', () => {
|
|
118
|
+
const tlsAuth = new TlsAuthenticator({})
|
|
119
|
+
|
|
120
|
+
tlsAuth.verifyWebId = sinon.stub().yields(new Error('Error processing certificate'))
|
|
121
|
+
|
|
122
|
+
expect(tlsAuth.extractWebId()).to.be.rejectedWith(/Error processing certificate/)
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
it('should resolve with a verified web id', () => {
|
|
126
|
+
const tlsAuth = new TlsAuthenticator({})
|
|
127
|
+
|
|
128
|
+
const webId = 'https://alice.example.com/#me'
|
|
129
|
+
tlsAuth.verifyWebId = sinon.stub().yields(null, webId)
|
|
130
|
+
|
|
131
|
+
const certificate = { uri: webId }
|
|
132
|
+
|
|
133
|
+
expect(tlsAuth.extractWebId(certificate)).to.become(webId)
|
|
134
|
+
})
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
describe('loadUser()', () => {
|
|
138
|
+
it('should return a user instance if the webid is local', () => {
|
|
139
|
+
const tlsAuth = new TlsAuthenticator({ accountManager })
|
|
140
|
+
|
|
141
|
+
const webId = 'https://alice.example.com/#me'
|
|
142
|
+
|
|
143
|
+
const user = tlsAuth.loadUser(webId)
|
|
144
|
+
|
|
145
|
+
expect(user.username).to.equal('alice')
|
|
146
|
+
expect(user.webId).to.equal(webId)
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
it('should return a user instance if external user and this server is authorized provider', () => {
|
|
150
|
+
const tlsAuth = new TlsAuthenticator({ accountManager })
|
|
151
|
+
|
|
152
|
+
const externalWebId = 'https://alice.someothersite.com#me'
|
|
153
|
+
|
|
154
|
+
tlsAuth.discoverProviderFor = sinon.stub().resolves('https://example.com')
|
|
155
|
+
|
|
156
|
+
const user = tlsAuth.loadUser(externalWebId)
|
|
157
|
+
|
|
158
|
+
expect(user.username).to.equal(externalWebId)
|
|
159
|
+
expect(user.webId).to.equal(externalWebId)
|
|
160
|
+
})
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
describe('verifyWebId()', () => {
|
|
164
|
+
it('should yield an error if no cert is given', done => {
|
|
165
|
+
const tlsAuth = new TlsAuthenticator({})
|
|
166
|
+
|
|
167
|
+
tlsAuth.verifyWebId(null, (error) => {
|
|
168
|
+
expect(error.message).to.equal('No certificate given')
|
|
169
|
+
|
|
170
|
+
done()
|
|
171
|
+
})
|
|
172
|
+
})
|
|
173
|
+
})
|
|
174
|
+
})
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { describe, it } from 'mocha'
|
|
2
|
+
import chai from 'chai'
|
|
3
|
+
import dirtyChai from 'dirty-chai'
|
|
4
|
+
import TokenService from '../../lib/services/token-service.mjs'
|
|
5
|
+
|
|
6
|
+
const { expect } = chai
|
|
7
|
+
chai.use(dirtyChai)
|
|
8
|
+
chai.should()
|
|
9
|
+
|
|
10
|
+
describe('TokenService', () => {
|
|
11
|
+
describe('constructor()', () => {
|
|
12
|
+
it('should init with an empty tokens store', () => {
|
|
13
|
+
const service = new TokenService()
|
|
14
|
+
|
|
15
|
+
expect(service.tokens).to.exist()
|
|
16
|
+
})
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
describe('generate()', () => {
|
|
20
|
+
it('should generate a new token and return a token key', () => {
|
|
21
|
+
const service = new TokenService()
|
|
22
|
+
|
|
23
|
+
const token = service.generate('test')
|
|
24
|
+
const value = service.tokens.test[token]
|
|
25
|
+
|
|
26
|
+
expect(token).to.exist()
|
|
27
|
+
expect(value).to.have.property('exp')
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
describe('verify()', () => {
|
|
32
|
+
it('should return false for expired tokens', () => {
|
|
33
|
+
const service = new TokenService()
|
|
34
|
+
|
|
35
|
+
const token = service.generate('foo')
|
|
36
|
+
|
|
37
|
+
service.tokens.foo[token].exp = new Date(Date.now() - 1000)
|
|
38
|
+
|
|
39
|
+
expect(service.verify('foo', token)).to.be.false()
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('should return the token value for valid tokens', () => {
|
|
43
|
+
const service = new TokenService()
|
|
44
|
+
|
|
45
|
+
const token = service.generate('bar')
|
|
46
|
+
const value = service.verify('bar', token)
|
|
47
|
+
|
|
48
|
+
expect(value).to.exist()
|
|
49
|
+
expect(value).to.have.property('exp')
|
|
50
|
+
expect(value.exp).to.be.greaterThan(new Date())
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('should throw error for invalid token domain', () => {
|
|
54
|
+
const service = new TokenService()
|
|
55
|
+
|
|
56
|
+
const token = service.generate('valid')
|
|
57
|
+
|
|
58
|
+
expect(() => service.verify('invalid', token)).to.throw('Invalid domain for tokens: invalid')
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('should return false for non-existent tokens', () => {
|
|
62
|
+
const service = new TokenService()
|
|
63
|
+
|
|
64
|
+
// First create the domain
|
|
65
|
+
service.generate('foo')
|
|
66
|
+
|
|
67
|
+
expect(service.verify('foo', 'nonexistent')).to.be.false()
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
describe('remove()', () => {
|
|
72
|
+
it('should remove specific tokens', () => {
|
|
73
|
+
const service = new TokenService()
|
|
74
|
+
|
|
75
|
+
const token = service.generate('test')
|
|
76
|
+
|
|
77
|
+
service.remove('test', token)
|
|
78
|
+
|
|
79
|
+
expect(service.tokens.test).to.not.have.property(token)
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
})
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* eslint-disable no-unused-expressions */
|
|
2
|
+
import { describe, it } from 'mocha'
|
|
3
|
+
import { expect } from 'chai'
|
|
4
|
+
import UserAccount from '../../lib/models/user-account.mjs'
|
|
5
|
+
|
|
6
|
+
describe('UserAccount', () => {
|
|
7
|
+
describe('from()', () => {
|
|
8
|
+
it('initializes the object with passed in options', () => {
|
|
9
|
+
const options = {
|
|
10
|
+
username: 'alice',
|
|
11
|
+
webId: 'https://alice.com/#me',
|
|
12
|
+
name: 'Alice',
|
|
13
|
+
email: 'alice@alice.com'
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const account = UserAccount.from(options)
|
|
17
|
+
expect(account.username).to.equal(options.username)
|
|
18
|
+
expect(account.webId).to.equal(options.webId)
|
|
19
|
+
expect(account.name).to.equal(options.name)
|
|
20
|
+
expect(account.email).to.equal(options.email)
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
describe('id getter', () => {
|
|
25
|
+
it('should return null if webId is null', () => {
|
|
26
|
+
const account = new UserAccount()
|
|
27
|
+
|
|
28
|
+
expect(account.id).to.be.null
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('should return the WebID uri minus the protocol and slashes', () => {
|
|
32
|
+
const webId = 'https://alice.example.com/profile/card#me'
|
|
33
|
+
const account = new UserAccount({ webId })
|
|
34
|
+
|
|
35
|
+
expect(account.id).to.equal('alice.example.com/profile/card#me')
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
})
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import chai from 'chai'
|
|
2
|
+
import { fileURLToPath } from 'url'
|
|
3
|
+
import { dirname, join } from 'path'
|
|
4
|
+
import HttpMocks from 'node-mocks-http'
|
|
5
|
+
import LDP from '../../lib/ldp.mjs'
|
|
6
|
+
import SolidHost from '../../lib/models/solid-host.mjs'
|
|
7
|
+
import AccountManager from '../../lib/models/account-manager.mjs'
|
|
8
|
+
import ResourceMapper from '../../lib/resource-mapper.mjs'
|
|
9
|
+
|
|
10
|
+
import * as api from '../../lib/api/accounts/user-accounts.mjs'
|
|
11
|
+
|
|
12
|
+
const { expect } = chai
|
|
13
|
+
chai.should()
|
|
14
|
+
|
|
15
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
16
|
+
|
|
17
|
+
const testAccountsDir = join(__dirname, '..', '..', 'test', 'resources', 'accounts')
|
|
18
|
+
|
|
19
|
+
let host
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
host = SolidHost.from({ serverUri: 'https://example.com' })
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
describe('api/accounts/user-accounts', () => {
|
|
26
|
+
describe('newCertificate()', () => {
|
|
27
|
+
describe('in multi user mode', () => {
|
|
28
|
+
const multiuser = true
|
|
29
|
+
const resourceMapper = new ResourceMapper({
|
|
30
|
+
rootUrl: 'https://localhost:8443/',
|
|
31
|
+
includeHost: multiuser,
|
|
32
|
+
rootPath: testAccountsDir
|
|
33
|
+
})
|
|
34
|
+
const store = new LDP({ multiuser, resourceMapper })
|
|
35
|
+
|
|
36
|
+
it('should throw a 400 error if spkac param is missing', done => {
|
|
37
|
+
const options = { host, store, multiuser, authMethod: 'oidc' }
|
|
38
|
+
const accountManager = AccountManager.from(options)
|
|
39
|
+
|
|
40
|
+
const req = {
|
|
41
|
+
body: {
|
|
42
|
+
webid: 'https://alice.example.com/#me'
|
|
43
|
+
},
|
|
44
|
+
session: { userId: 'https://alice.example.com/#me' },
|
|
45
|
+
get: () => { return 'https://example.com' }
|
|
46
|
+
}
|
|
47
|
+
const res = HttpMocks.createResponse()
|
|
48
|
+
|
|
49
|
+
const newCertificate = api.newCertificate(accountManager)
|
|
50
|
+
|
|
51
|
+
newCertificate(req, res, (err) => {
|
|
52
|
+
expect(err.status).to.equal(400)
|
|
53
|
+
expect(err.message).to.equal('Missing spkac parameter')
|
|
54
|
+
done()
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
})
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as userUtils from '../../lib/common/user-utils.mjs'
|
|
2
|
+
import $rdf from 'rdflib'
|
|
3
|
+
import chai from 'chai'
|
|
4
|
+
|
|
5
|
+
const { expect } = chai
|
|
6
|
+
|
|
7
|
+
describe('user-utils', () => {
|
|
8
|
+
describe('getName', () => {
|
|
9
|
+
let ldp
|
|
10
|
+
const webId = 'http://test#me'
|
|
11
|
+
const name = 'NAME'
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
const store = $rdf.graph()
|
|
15
|
+
store.add($rdf.sym(webId), $rdf.sym('http://www.w3.org/2006/vcard/ns#fn'), $rdf.lit(name))
|
|
16
|
+
ldp = { fetchGraph: () => Promise.resolve(store) }
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('should return name from graph', async () => {
|
|
20
|
+
const returnedName = await userUtils.getName(webId, ldp.fetchGraph)
|
|
21
|
+
expect(returnedName).to.equal(name)
|
|
22
|
+
})
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
describe('getWebId', () => {
|
|
26
|
+
let fetchGraph
|
|
27
|
+
const webId = 'https://test.localhost:8443/profile/card#me'
|
|
28
|
+
const suffixMeta = '.meta'
|
|
29
|
+
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
fetchGraph = () => Promise.resolve(`<${webId}> <http://www.w3.org/ns/solid/terms#account> </>.`)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('should return webId from meta file', async () => {
|
|
35
|
+
const returnedWebId = await userUtils.getWebId('foo', 'https://bar/', suffixMeta, fetchGraph)
|
|
36
|
+
expect(returnedWebId).to.equal(webId)
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
describe('isValidUsername', () => {
|
|
41
|
+
it('should accect valid usernames', () => {
|
|
42
|
+
const usernames = [
|
|
43
|
+
'foo',
|
|
44
|
+
'bar'
|
|
45
|
+
]
|
|
46
|
+
const validUsernames = usernames.filter(username => userUtils.isValidUsername(username))
|
|
47
|
+
expect(validUsernames.length).to.equal(usernames.length)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('should not accect invalid usernames', () => {
|
|
51
|
+
const usernames = [
|
|
52
|
+
'-',
|
|
53
|
+
'-a',
|
|
54
|
+
'a-',
|
|
55
|
+
'9-',
|
|
56
|
+
'alice--bob',
|
|
57
|
+
'alice bob',
|
|
58
|
+
'alice.bob'
|
|
59
|
+
]
|
|
60
|
+
const validUsernames = usernames.filter(username => userUtils.isValidUsername(username))
|
|
61
|
+
expect(validUsernames.length).to.equal(0)
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
})
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { describe, it } from 'mocha'
|
|
2
|
+
import { assert } from 'chai'
|
|
3
|
+
import fetch from 'node-fetch'
|
|
4
|
+
|
|
5
|
+
import * as utils from '../../lib/utils.mjs'
|
|
6
|
+
const { Headers } = fetch
|
|
7
|
+
|
|
8
|
+
const {
|
|
9
|
+
pathBasename,
|
|
10
|
+
stripLineEndings,
|
|
11
|
+
debrack,
|
|
12
|
+
fullUrlForReq,
|
|
13
|
+
getContentType
|
|
14
|
+
} = utils
|
|
15
|
+
|
|
16
|
+
describe('Utility functions', function () {
|
|
17
|
+
describe('pathBasename', function () {
|
|
18
|
+
it('should return bar as relative path for /foo/bar', function () {
|
|
19
|
+
assert.equal(pathBasename('/foo/bar'), 'bar')
|
|
20
|
+
})
|
|
21
|
+
it('should return empty as relative path for /foo/', function () {
|
|
22
|
+
assert.equal(pathBasename('/foo/'), '')
|
|
23
|
+
})
|
|
24
|
+
it('should return empty as relative path for /', function () {
|
|
25
|
+
assert.equal(pathBasename('/'), '')
|
|
26
|
+
})
|
|
27
|
+
it('should return empty as relative path for empty path', function () {
|
|
28
|
+
assert.equal(pathBasename(''), '')
|
|
29
|
+
})
|
|
30
|
+
it('should return empty as relative path for undefined path', function () {
|
|
31
|
+
assert.equal(pathBasename(undefined), '')
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
describe('stripLineEndings()', () => {
|
|
36
|
+
it('should pass through falsy string arguments', () => {
|
|
37
|
+
assert.equal(stripLineEndings(''), '')
|
|
38
|
+
assert.equal(stripLineEndings(null), null)
|
|
39
|
+
assert.equal(stripLineEndings(undefined), undefined)
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('should remove line-endings characters', () => {
|
|
43
|
+
let str = '123\n456'
|
|
44
|
+
assert.equal(stripLineEndings(str), '123456')
|
|
45
|
+
|
|
46
|
+
str = `123
|
|
47
|
+
456`
|
|
48
|
+
assert.equal(stripLineEndings(str), '123456')
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
describe('debrack()', () => {
|
|
53
|
+
it('should return null if no string is passed', () => {
|
|
54
|
+
assert.equal(debrack(), null)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('should return the string if no brackets are present', () => {
|
|
58
|
+
assert.equal(debrack('test string'), 'test string')
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('should return the string if less than 2 chars long', () => {
|
|
62
|
+
assert.equal(debrack(''), '')
|
|
63
|
+
assert.equal(debrack('<'), '<')
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it('should remove brackets if wrapping the string', () => {
|
|
67
|
+
assert.equal(debrack('<test string>'), 'test string')
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
describe('fullUrlForReq()', () => {
|
|
72
|
+
it('should extract a fully-qualified url from an Express request', () => {
|
|
73
|
+
const req = {
|
|
74
|
+
protocol: 'https:',
|
|
75
|
+
get: (host) => 'example.com',
|
|
76
|
+
baseUrl: '/',
|
|
77
|
+
path: '/resource1',
|
|
78
|
+
query: { sort: 'desc' }
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
assert.equal(fullUrlForReq(req), 'https://example.com/resource1?sort=desc')
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
describe('getContentType()', () => {
|
|
86
|
+
describe('for Express headers', () => {
|
|
87
|
+
it('should not default', () => {
|
|
88
|
+
assert.equal(getContentType({}), '')
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
it('should get a basic content type', () => {
|
|
92
|
+
assert.equal(getContentType({ 'content-type': 'text/html' }), 'text/html')
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it('should get a content type without its charset', () => {
|
|
96
|
+
assert.equal(getContentType({ 'content-type': 'text/html; charset=us-ascii' }), 'text/html')
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
describe('for Fetch API headers', () => {
|
|
101
|
+
it('should not default', () => {
|
|
102
|
+
assert.equal(getContentType(new Headers({})), '')
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
it('should get a basic content type', () => {
|
|
106
|
+
assert.equal(getContentType(new Headers({ 'content-type': 'text/html' })), 'text/html')
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
it('should get a content type without its charset', () => {
|
|
110
|
+
assert.equal(getContentType(new Headers({ 'content-type': 'text/html; charset=us-ascii' })), 'text/html')
|
|
111
|
+
})
|
|
112
|
+
})
|
|
113
|
+
})
|
|
114
|
+
})
|