solid-server 5.8.7 → 5.8.8-8d509db1
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-2254-1766613200322-0.json +1 -0
- package/coverage/tmp/coverage-2255-1766613179053-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 +46 -26
- 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 +573 -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_30860bb5cf6ba07e80ed7b2e7178c7ad.json +1 -0
- package/test/resources/accounts/db/oidc/op/provider.json +419 -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 +419 -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_e46bcfe080c59f5cbb53a559d6a272cb.json +1 -0
- package/test/resources/accounts-scenario/alice/db/oidc/op/provider.json +417 -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_e7fd102ec26a3dcd5916751e01a62315.json +1 -0
- package/test/resources/accounts-scenario/bob/db/oidc/op/provider.json +417 -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_0eec962830f849876695b69df76a3137.json +1 -0
- package/test/resources/accounts-scenario/charlie/db/oidc/op/provider.json +415 -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_7d536a1f8c6eb86f41261e171a8af79a.json +1 -0
- package/test/resources/accounts-strict-origin-off/alice/db/oidc/op/provider.json +419 -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_0ed30b9e076814c6f6445582302487c2.json +1 -0
- package/test/resources/accounts-strict-origin-off/bob/db/oidc/op/provider.json +419 -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,49 @@
|
|
|
1
|
+
import chai from 'chai'
|
|
2
|
+
|
|
3
|
+
import theBigUsernameBlacklistPkg from 'the-big-username-blacklist'
|
|
4
|
+
import blacklistService from '../../lib/services/blacklist-service.mjs'
|
|
5
|
+
|
|
6
|
+
const { expect } = chai
|
|
7
|
+
const blacklist = theBigUsernameBlacklistPkg.list
|
|
8
|
+
|
|
9
|
+
describe('BlacklistService', () => {
|
|
10
|
+
afterEach(() => blacklistService.reset())
|
|
11
|
+
|
|
12
|
+
describe('addWord', () => {
|
|
13
|
+
it('allows adding words', () => {
|
|
14
|
+
const numberOfBlacklistedWords = blacklistService.list.length
|
|
15
|
+
blacklistService.addWord('foo')
|
|
16
|
+
expect(blacklistService.list.length).to.equal(numberOfBlacklistedWords + 1)
|
|
17
|
+
})
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
describe('reset', () => {
|
|
21
|
+
it('will reset list of blacklisted words', () => {
|
|
22
|
+
blacklistService.addWord('foo')
|
|
23
|
+
blacklistService.reset()
|
|
24
|
+
expect(blacklistService.list.length).to.equal(blacklist.length)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('can configure service via reset', () => {
|
|
28
|
+
blacklistService.reset({
|
|
29
|
+
useTheBigUsernameBlacklist: false,
|
|
30
|
+
customBlacklistedUsernames: ['foo']
|
|
31
|
+
})
|
|
32
|
+
expect(blacklistService.list.length).to.equal(1)
|
|
33
|
+
expect(blacklistService.validate('admin')).to.equal(true)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('is a singleton', () => {
|
|
37
|
+
const instanceA = blacklistService
|
|
38
|
+
blacklistService.reset({ customBlacklistedUsernames: ['foo'] })
|
|
39
|
+
expect(instanceA.validate('foo')).to.equal(blacklistService.validate('foo'))
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
describe('validate', () => {
|
|
44
|
+
it('validates given a default list of blacklisted usernames', () => {
|
|
45
|
+
const validWords = blacklist.reduce((memo, word) => memo + (blacklistService.validate(word) ? 1 : 0), 0)
|
|
46
|
+
expect(validWords).to.equal(0)
|
|
47
|
+
})
|
|
48
|
+
})
|
|
49
|
+
})
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import chai from 'chai'
|
|
2
|
+
import sinon from 'sinon'
|
|
3
|
+
import sinonChai from 'sinon-chai'
|
|
4
|
+
|
|
5
|
+
import HttpMocks from 'node-mocks-http'
|
|
6
|
+
import theBigUsernameBlacklistPkg from 'the-big-username-blacklist'
|
|
7
|
+
|
|
8
|
+
import LDP from '../../lib/ldp.mjs'
|
|
9
|
+
import AccountManager from '../../lib/models/account-manager.mjs'
|
|
10
|
+
import SolidHost from '../../lib/models/solid-host.mjs'
|
|
11
|
+
import defaults from '../../config/defaults.mjs'
|
|
12
|
+
import { CreateAccountRequest } from '../../lib/requests/create-account-request.mjs'
|
|
13
|
+
import blacklistService from '../../lib/services/blacklist-service.mjs'
|
|
14
|
+
|
|
15
|
+
const { expect } = chai
|
|
16
|
+
chai.use(sinonChai)
|
|
17
|
+
chai.should()
|
|
18
|
+
const blacklist = theBigUsernameBlacklistPkg
|
|
19
|
+
|
|
20
|
+
describe('CreateAccountRequest', () => {
|
|
21
|
+
let host, store, accountManager
|
|
22
|
+
let session, res
|
|
23
|
+
|
|
24
|
+
beforeEach(() => {
|
|
25
|
+
host = SolidHost.from({ serverUri: 'https://example.com' })
|
|
26
|
+
store = new LDP()
|
|
27
|
+
accountManager = AccountManager.from({ host, store })
|
|
28
|
+
|
|
29
|
+
session = {}
|
|
30
|
+
res = HttpMocks.createResponse()
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
describe('constructor()', () => {
|
|
34
|
+
it('should create an instance with the given config', () => {
|
|
35
|
+
const aliceData = { username: 'alice' }
|
|
36
|
+
const userAccount = accountManager.userAccountFrom(aliceData)
|
|
37
|
+
|
|
38
|
+
const options = { accountManager, userAccount, session, response: res }
|
|
39
|
+
const request = new CreateAccountRequest(options)
|
|
40
|
+
|
|
41
|
+
expect(request.accountManager).to.equal(accountManager)
|
|
42
|
+
expect(request.userAccount).to.equal(userAccount)
|
|
43
|
+
expect(request.session).to.equal(session)
|
|
44
|
+
expect(request.response).to.equal(res)
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
describe('fromParams()', () => {
|
|
49
|
+
it('should create subclass depending on authMethod', () => {
|
|
50
|
+
let request, aliceData, req
|
|
51
|
+
|
|
52
|
+
aliceData = { username: 'alice' }
|
|
53
|
+
req = HttpMocks.createRequest({
|
|
54
|
+
app: { locals: { accountManager } }, body: aliceData, session
|
|
55
|
+
})
|
|
56
|
+
req.app.locals.authMethod = 'tls'
|
|
57
|
+
|
|
58
|
+
request = CreateAccountRequest.fromParams(req, res, accountManager)
|
|
59
|
+
expect(request).to.respondTo('generateTlsCertificate')
|
|
60
|
+
|
|
61
|
+
aliceData = { username: 'alice', password: '12345' }
|
|
62
|
+
req = HttpMocks.createRequest({
|
|
63
|
+
app: { locals: { accountManager, oidc: {} } }, body: aliceData, session
|
|
64
|
+
})
|
|
65
|
+
req.app.locals.authMethod = 'oidc'
|
|
66
|
+
request = CreateAccountRequest.fromParams(req, res, accountManager)
|
|
67
|
+
expect(request).to.not.respondTo('generateTlsCertificate')
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
describe('createAccount()', () => {
|
|
72
|
+
it('should return a 400 error if account already exists', done => {
|
|
73
|
+
const accountManager = AccountManager.from({ host })
|
|
74
|
+
const locals = { authMethod: defaults.auth, accountManager, oidc: { users: {} } }
|
|
75
|
+
const aliceData = {
|
|
76
|
+
username: 'alice', password: '1234'
|
|
77
|
+
}
|
|
78
|
+
const req = HttpMocks.createRequest({ app: { locals }, body: aliceData })
|
|
79
|
+
|
|
80
|
+
const request = CreateAccountRequest.fromParams(req, res)
|
|
81
|
+
|
|
82
|
+
accountManager.accountExists = sinon.stub().returns(Promise.resolve(true))
|
|
83
|
+
|
|
84
|
+
request.createAccount()
|
|
85
|
+
.catch(err => {
|
|
86
|
+
expect(err.status).to.equal(400)
|
|
87
|
+
done()
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
it('should return a 400 error if a username is invalid', () => {
|
|
92
|
+
const accountManager = AccountManager.from({ host })
|
|
93
|
+
const locals = { authMethod: defaults.auth, accountManager, oidc: { users: {} } }
|
|
94
|
+
|
|
95
|
+
accountManager.accountExists = sinon.stub().returns(Promise.resolve(false))
|
|
96
|
+
|
|
97
|
+
const invalidUsernames = [
|
|
98
|
+
'-',
|
|
99
|
+
'-a',
|
|
100
|
+
'a-',
|
|
101
|
+
'9-',
|
|
102
|
+
'alice--bob',
|
|
103
|
+
'alice bob',
|
|
104
|
+
'alice.bob'
|
|
105
|
+
]
|
|
106
|
+
|
|
107
|
+
let invalidUsernamesCount = 0
|
|
108
|
+
|
|
109
|
+
const requests = invalidUsernames.map((username) => {
|
|
110
|
+
const aliceData = {
|
|
111
|
+
username: username, password: '1234'
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const req = HttpMocks.createRequest({ app: { locals }, body: aliceData })
|
|
115
|
+
const request = CreateAccountRequest.fromParams(req, res)
|
|
116
|
+
|
|
117
|
+
return request.createAccount()
|
|
118
|
+
.then(() => {
|
|
119
|
+
throw new Error('should not happen')
|
|
120
|
+
})
|
|
121
|
+
.catch(err => {
|
|
122
|
+
invalidUsernamesCount++
|
|
123
|
+
expect(err.message).to.match(/Invalid username/)
|
|
124
|
+
expect(err.status).to.equal(400)
|
|
125
|
+
})
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
return Promise.all(requests)
|
|
129
|
+
.then(() => {
|
|
130
|
+
expect(invalidUsernamesCount).to.eq(invalidUsernames.length)
|
|
131
|
+
})
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
describe('Blacklisted usernames', () => {
|
|
135
|
+
const invalidUsernames = [...blacklist.list, 'foo']
|
|
136
|
+
|
|
137
|
+
before(() => {
|
|
138
|
+
const accountManager = AccountManager.from({ host })
|
|
139
|
+
accountManager.accountExists = sinon.stub().returns(Promise.resolve(false))
|
|
140
|
+
blacklistService.addWord('foo')
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
after(() => blacklistService.reset())
|
|
144
|
+
|
|
145
|
+
it('should return a 400 error if a username is blacklisted', async () => {
|
|
146
|
+
const locals = { authMethod: defaults.auth, accountManager, oidc: { users: {} } }
|
|
147
|
+
|
|
148
|
+
let invalidUsernamesCount = 0
|
|
149
|
+
|
|
150
|
+
const requests = invalidUsernames.map((username) => {
|
|
151
|
+
const req = HttpMocks.createRequest({
|
|
152
|
+
app: { locals },
|
|
153
|
+
body: { username, password: '1234' }
|
|
154
|
+
})
|
|
155
|
+
const request = CreateAccountRequest.fromParams(req, res)
|
|
156
|
+
|
|
157
|
+
return request.createAccount()
|
|
158
|
+
.then(() => {
|
|
159
|
+
throw new Error('should not happen')
|
|
160
|
+
})
|
|
161
|
+
.catch(err => {
|
|
162
|
+
invalidUsernamesCount++
|
|
163
|
+
expect(err.message).to.match(/Invalid username/)
|
|
164
|
+
expect(err.status).to.equal(400)
|
|
165
|
+
})
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
await Promise.all(requests)
|
|
169
|
+
expect(invalidUsernamesCount).to.eq(invalidUsernames.length)
|
|
170
|
+
})
|
|
171
|
+
})
|
|
172
|
+
})
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
describe('CreateOidcAccountRequest', () => {
|
|
176
|
+
const authMethod = 'oidc'
|
|
177
|
+
let host, store
|
|
178
|
+
let session, res
|
|
179
|
+
|
|
180
|
+
beforeEach(() => {
|
|
181
|
+
host = SolidHost.from({ serverUri: 'https://example.com' })
|
|
182
|
+
store = new LDP()
|
|
183
|
+
session = {}
|
|
184
|
+
res = HttpMocks.createResponse()
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
describe('fromParams()', () => {
|
|
188
|
+
it('should create an instance with the given config', () => {
|
|
189
|
+
const accountManager = AccountManager.from({ host, store })
|
|
190
|
+
const aliceData = { username: 'alice', password: '123' }
|
|
191
|
+
|
|
192
|
+
const userStore = {}
|
|
193
|
+
const req = HttpMocks.createRequest({
|
|
194
|
+
app: {
|
|
195
|
+
locals: { authMethod, oidc: { users: userStore }, accountManager }
|
|
196
|
+
},
|
|
197
|
+
body: aliceData,
|
|
198
|
+
session
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
const request = CreateAccountRequest.fromParams(req, res)
|
|
202
|
+
|
|
203
|
+
expect(request.accountManager).to.equal(accountManager)
|
|
204
|
+
expect(request.userAccount.username).to.equal('alice')
|
|
205
|
+
expect(request.session).to.equal(session)
|
|
206
|
+
expect(request.response).to.equal(res)
|
|
207
|
+
expect(request.password).to.equal(aliceData.password)
|
|
208
|
+
expect(request.userStore).to.equal(userStore)
|
|
209
|
+
})
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
describe('saveCredentialsFor()', () => {
|
|
213
|
+
it('should create a new user in the user store', () => {
|
|
214
|
+
const accountManager = AccountManager.from({ host, store })
|
|
215
|
+
const password = '12345'
|
|
216
|
+
const aliceData = { username: 'alice', password }
|
|
217
|
+
const userStore = {
|
|
218
|
+
createUser: (userAccount, password) => { return Promise.resolve() }
|
|
219
|
+
}
|
|
220
|
+
const createUserSpy = sinon.spy(userStore, 'createUser')
|
|
221
|
+
const req = HttpMocks.createRequest({
|
|
222
|
+
app: { locals: { authMethod, oidc: { users: userStore }, accountManager } },
|
|
223
|
+
body: aliceData,
|
|
224
|
+
session
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
const request = CreateAccountRequest.fromParams(req, res)
|
|
228
|
+
const userAccount = request.userAccount
|
|
229
|
+
|
|
230
|
+
return request.saveCredentialsFor(userAccount)
|
|
231
|
+
.then(() => {
|
|
232
|
+
expect(createUserSpy).to.have.been.calledWith(userAccount, password)
|
|
233
|
+
})
|
|
234
|
+
})
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
describe('sendResponse()', () => {
|
|
238
|
+
it('should respond with a 302 Redirect', () => {
|
|
239
|
+
const accountManager = AccountManager.from({ host, store })
|
|
240
|
+
const aliceData = { username: 'alice', password: '12345' }
|
|
241
|
+
const req = HttpMocks.createRequest({
|
|
242
|
+
app: { locals: { authMethod, oidc: {}, accountManager } },
|
|
243
|
+
body: aliceData,
|
|
244
|
+
session
|
|
245
|
+
})
|
|
246
|
+
const alice = accountManager.userAccountFrom(aliceData)
|
|
247
|
+
|
|
248
|
+
const request = CreateAccountRequest.fromParams(req, res)
|
|
249
|
+
|
|
250
|
+
const result = request.sendResponse(alice)
|
|
251
|
+
expect(request.response.statusCode).to.equal(302)
|
|
252
|
+
expect(result.username).to.equal('alice')
|
|
253
|
+
})
|
|
254
|
+
})
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
describe('CreateTlsAccountRequest', () => {
|
|
258
|
+
const authMethod = 'tls'
|
|
259
|
+
let host, store
|
|
260
|
+
let session, res
|
|
261
|
+
|
|
262
|
+
beforeEach(() => {
|
|
263
|
+
host = SolidHost.from({ serverUri: 'https://example.com' })
|
|
264
|
+
store = new LDP()
|
|
265
|
+
session = {}
|
|
266
|
+
res = HttpMocks.createResponse()
|
|
267
|
+
})
|
|
268
|
+
|
|
269
|
+
describe('fromParams()', () => {
|
|
270
|
+
it('should create an instance with the given config', () => {
|
|
271
|
+
const accountManager = AccountManager.from({ host, store })
|
|
272
|
+
const aliceData = { username: 'alice' }
|
|
273
|
+
const req = HttpMocks.createRequest({
|
|
274
|
+
app: { locals: { authMethod, accountManager } }, body: aliceData, session
|
|
275
|
+
})
|
|
276
|
+
|
|
277
|
+
const request = CreateAccountRequest.fromParams(req, res)
|
|
278
|
+
|
|
279
|
+
expect(request.accountManager).to.equal(accountManager)
|
|
280
|
+
expect(request.userAccount.username).to.equal('alice')
|
|
281
|
+
expect(request.session).to.equal(session)
|
|
282
|
+
expect(request.response).to.equal(res)
|
|
283
|
+
expect(request.spkac).to.equal(aliceData.spkac)
|
|
284
|
+
})
|
|
285
|
+
})
|
|
286
|
+
|
|
287
|
+
describe('saveCredentialsFor()', () => {
|
|
288
|
+
it('should call generateTlsCertificate()', () => {
|
|
289
|
+
const accountManager = AccountManager.from({ host, store })
|
|
290
|
+
const aliceData = { username: 'alice' }
|
|
291
|
+
const req = HttpMocks.createRequest({
|
|
292
|
+
app: { locals: { authMethod, accountManager } }, body: aliceData, session
|
|
293
|
+
})
|
|
294
|
+
|
|
295
|
+
const request = CreateAccountRequest.fromParams(req, res)
|
|
296
|
+
const userAccount = accountManager.userAccountFrom(aliceData)
|
|
297
|
+
|
|
298
|
+
const generateTlsCertificate = sinon.spy(request, 'generateTlsCertificate')
|
|
299
|
+
|
|
300
|
+
return request.saveCredentialsFor(userAccount)
|
|
301
|
+
.then(() => {
|
|
302
|
+
expect(generateTlsCertificate).to.have.been.calledWith(userAccount)
|
|
303
|
+
})
|
|
304
|
+
})
|
|
305
|
+
})
|
|
306
|
+
})
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
// import { createRequire } from 'module'
|
|
2
|
+
import chai from 'chai'
|
|
3
|
+
import sinon from 'sinon'
|
|
4
|
+
import dirtyChai from 'dirty-chai'
|
|
5
|
+
import sinonChai from 'sinon-chai'
|
|
6
|
+
import HttpMocks from 'node-mocks-http'
|
|
7
|
+
|
|
8
|
+
// const require = createRequire(import.meta.url)
|
|
9
|
+
// const DeleteAccountConfirmRequest = require('../../lib/requests/delete-account-confirm-request')
|
|
10
|
+
// const SolidHost = require('../../lib/models/solid-host')
|
|
11
|
+
import DeleteAccountConfirmRequest from '../../lib/requests/delete-account-confirm-request.mjs'
|
|
12
|
+
import SolidHost from '../../lib/models/solid-host.mjs'
|
|
13
|
+
|
|
14
|
+
const { expect } = chai
|
|
15
|
+
chai.use(dirtyChai)
|
|
16
|
+
chai.use(sinonChai)
|
|
17
|
+
chai.should()
|
|
18
|
+
|
|
19
|
+
describe('DeleteAccountConfirmRequest', () => {
|
|
20
|
+
sinon.spy(DeleteAccountConfirmRequest.prototype, 'error')
|
|
21
|
+
|
|
22
|
+
describe('constructor()', () => {
|
|
23
|
+
it('should initialize a request instance from options', () => {
|
|
24
|
+
const res = HttpMocks.createResponse()
|
|
25
|
+
|
|
26
|
+
const accountManager = {}
|
|
27
|
+
const userStore = {}
|
|
28
|
+
|
|
29
|
+
const options = {
|
|
30
|
+
accountManager,
|
|
31
|
+
userStore,
|
|
32
|
+
response: res,
|
|
33
|
+
token: '12345'
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const request = new DeleteAccountConfirmRequest(options)
|
|
37
|
+
|
|
38
|
+
expect(request.response).to.equal(res)
|
|
39
|
+
expect(request.token).to.equal(options.token)
|
|
40
|
+
expect(request.accountManager).to.equal(accountManager)
|
|
41
|
+
expect(request.userStore).to.equal(userStore)
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
describe('fromParams()', () => {
|
|
46
|
+
it('should return a request instance from options', () => {
|
|
47
|
+
const token = '12345'
|
|
48
|
+
const accountManager = {}
|
|
49
|
+
const userStore = {}
|
|
50
|
+
|
|
51
|
+
const req = {
|
|
52
|
+
app: { locals: { accountManager, oidc: { users: userStore } } },
|
|
53
|
+
query: { token }
|
|
54
|
+
}
|
|
55
|
+
const res = HttpMocks.createResponse()
|
|
56
|
+
|
|
57
|
+
const request = DeleteAccountConfirmRequest.fromParams(req, res)
|
|
58
|
+
|
|
59
|
+
expect(request.response).to.equal(res)
|
|
60
|
+
expect(request.token).to.equal(token)
|
|
61
|
+
expect(request.accountManager).to.equal(accountManager)
|
|
62
|
+
expect(request.userStore).to.equal(userStore)
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
describe('get()', () => {
|
|
67
|
+
const token = '12345'
|
|
68
|
+
const userStore = {}
|
|
69
|
+
const res = HttpMocks.createResponse()
|
|
70
|
+
sinon.spy(res, 'render')
|
|
71
|
+
|
|
72
|
+
it('should create an instance and render a delete account form', () => {
|
|
73
|
+
const accountManager = {
|
|
74
|
+
validateDeleteToken: sinon.stub().resolves(true)
|
|
75
|
+
}
|
|
76
|
+
const req = {
|
|
77
|
+
app: { locals: { accountManager, oidc: { users: userStore } } },
|
|
78
|
+
query: { token }
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return DeleteAccountConfirmRequest.get(req, res)
|
|
82
|
+
.then(() => {
|
|
83
|
+
expect(accountManager.validateDeleteToken)
|
|
84
|
+
.to.have.been.called()
|
|
85
|
+
expect(res.render).to.have.been.calledWith('account/delete-confirm',
|
|
86
|
+
{ token, validToken: true })
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it('should display an error message on an invalid token', () => {
|
|
91
|
+
const accountManager = {
|
|
92
|
+
validateDeleteToken: sinon.stub().throws()
|
|
93
|
+
}
|
|
94
|
+
const req = {
|
|
95
|
+
app: { locals: { accountManager, oidc: { users: userStore } } },
|
|
96
|
+
query: { token }
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return DeleteAccountConfirmRequest.get(req, res)
|
|
100
|
+
.then(() => {
|
|
101
|
+
expect(DeleteAccountConfirmRequest.prototype.error)
|
|
102
|
+
.to.have.been.called()
|
|
103
|
+
})
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
describe('post()', () => {
|
|
108
|
+
it('creates a request instance and invokes handlePost()', () => {
|
|
109
|
+
sinon.spy(DeleteAccountConfirmRequest, 'handlePost')
|
|
110
|
+
|
|
111
|
+
const token = '12345'
|
|
112
|
+
const host = SolidHost.from({ serverUri: 'https://example.com' })
|
|
113
|
+
const alice = {
|
|
114
|
+
webId: 'https://alice.example.com/#me'
|
|
115
|
+
}
|
|
116
|
+
const storedToken = { webId: alice.webId }
|
|
117
|
+
const accountManager = {
|
|
118
|
+
host,
|
|
119
|
+
userAccountFrom: sinon.stub().resolves(alice),
|
|
120
|
+
validateDeleteToken: sinon.stub().resolves(storedToken)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
accountManager.accountExists = sinon.stub().resolves(true)
|
|
124
|
+
accountManager.loadAccountRecoveryEmail = sinon.stub().resolves('alice@example.com')
|
|
125
|
+
|
|
126
|
+
const req = {
|
|
127
|
+
app: { locals: { accountManager, oidc: { users: {} } } },
|
|
128
|
+
body: { token }
|
|
129
|
+
}
|
|
130
|
+
const res = HttpMocks.createResponse()
|
|
131
|
+
|
|
132
|
+
return DeleteAccountConfirmRequest.post(req, res)
|
|
133
|
+
.then(() => {
|
|
134
|
+
expect(DeleteAccountConfirmRequest.handlePost).to.have.been.called()
|
|
135
|
+
})
|
|
136
|
+
})
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
describe('handlePost()', () => {
|
|
140
|
+
it('should display error message if validation error encountered', () => {
|
|
141
|
+
const token = '12345'
|
|
142
|
+
const userStore = {}
|
|
143
|
+
const res = HttpMocks.createResponse()
|
|
144
|
+
const accountManager = {
|
|
145
|
+
validateResetToken: sinon.stub().throws()
|
|
146
|
+
}
|
|
147
|
+
const req = {
|
|
148
|
+
app: { locals: { accountManager, oidc: { users: userStore } } },
|
|
149
|
+
query: { token }
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const request = DeleteAccountConfirmRequest.fromParams(req, res)
|
|
153
|
+
|
|
154
|
+
return DeleteAccountConfirmRequest.handlePost(request)
|
|
155
|
+
.then(() => {
|
|
156
|
+
expect(DeleteAccountConfirmRequest.prototype.error)
|
|
157
|
+
.to.have.been.called()
|
|
158
|
+
})
|
|
159
|
+
})
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
describe('validateToken()', () => {
|
|
163
|
+
it('should return false if no token is present', () => {
|
|
164
|
+
const accountManager = {
|
|
165
|
+
validateDeleteToken: sinon.stub()
|
|
166
|
+
}
|
|
167
|
+
const request = new DeleteAccountConfirmRequest({ accountManager, token: null })
|
|
168
|
+
|
|
169
|
+
return request.validateToken()
|
|
170
|
+
.then(result => {
|
|
171
|
+
expect(result).to.be.false()
|
|
172
|
+
expect(accountManager.validateDeleteToken).to.not.have.been.called()
|
|
173
|
+
})
|
|
174
|
+
})
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
describe('error()', () => {
|
|
178
|
+
it('should invoke renderForm() with the error', () => {
|
|
179
|
+
const request = new DeleteAccountConfirmRequest({})
|
|
180
|
+
request.renderForm = sinon.stub()
|
|
181
|
+
const error = new Error('error message')
|
|
182
|
+
|
|
183
|
+
request.error(error)
|
|
184
|
+
|
|
185
|
+
expect(request.renderForm).to.have.been.calledWith(error)
|
|
186
|
+
})
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
describe('deleteAccount()', () => {
|
|
190
|
+
it('should remove user from userStore and remove directories', () => {
|
|
191
|
+
const webId = 'https://alice.example.com/#me'
|
|
192
|
+
const user = { webId, id: webId }
|
|
193
|
+
const accountManager = {
|
|
194
|
+
userAccountFrom: sinon.stub().returns(user),
|
|
195
|
+
accountDirFor: sinon.stub().returns('/some/path/to/data/for/alice.example.com/')
|
|
196
|
+
}
|
|
197
|
+
const userStore = {
|
|
198
|
+
deleteUser: sinon.stub().resolves()
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const options = {
|
|
202
|
+
accountManager, userStore, newPassword: 'swordfish'
|
|
203
|
+
}
|
|
204
|
+
const request = new DeleteAccountConfirmRequest(options)
|
|
205
|
+
const tokenContents = { webId }
|
|
206
|
+
|
|
207
|
+
return request.deleteAccount(tokenContents)
|
|
208
|
+
.then(() => {
|
|
209
|
+
expect(accountManager.userAccountFrom).to.have.been.calledWith(tokenContents)
|
|
210
|
+
expect(accountManager.accountDirFor).to.have.been.calledWith(user.username)
|
|
211
|
+
expect(userStore.deleteUser).to.have.been.calledWith(user)
|
|
212
|
+
})
|
|
213
|
+
})
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
describe('renderForm()', () => {
|
|
217
|
+
it('should set response status to error status, if error exists', () => {
|
|
218
|
+
const token = '12345'
|
|
219
|
+
const response = HttpMocks.createResponse()
|
|
220
|
+
sinon.spy(response, 'render')
|
|
221
|
+
|
|
222
|
+
const options = { token, response }
|
|
223
|
+
|
|
224
|
+
const request = new DeleteAccountConfirmRequest(options)
|
|
225
|
+
|
|
226
|
+
const error = new Error('error message')
|
|
227
|
+
|
|
228
|
+
request.renderForm(error)
|
|
229
|
+
|
|
230
|
+
expect(response.render).to.have.been.calledWith('account/delete-confirm',
|
|
231
|
+
{ validToken: false, token, error: 'error message' })
|
|
232
|
+
})
|
|
233
|
+
})
|
|
234
|
+
})
|