spec-3nweb-server 1.8.5 → 1.8.7
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/.gitlab-ci-linux.yml +50 -0
- package/.gitlab-ci-mac.yml +29 -0
- package/.gitlab-ci-windows.yml +29 -0
- package/.gitlab-ci.yml +63 -0
- package/build/3nstorage/resources/store.d.ts +2 -2
- package/build/3nstorage/resources/store.js +1 -1
- package/build/3nstorage/resources/users.d.ts +3 -3
- package/build/3nstorage/resources/users.js +1 -1
- package/build/3nstorage/resources/utils.d.ts +6 -0
- package/build/3nstorage/resources/utils.js +41 -0
- package/build/3nstorage/routes/owner/archive-obj-version.js +8 -10
- package/build/3nstorage/routes/owner/cancel-trans.js +5 -4
- package/build/3nstorage/routes/owner/delete-obj.js +7 -8
- package/build/3nstorage/routes/owner/get-archived-obj-ver.js +11 -13
- package/build/3nstorage/routes/owner/get-current-obj.js +7 -6
- package/build/3nstorage/routes/owner/get-obj-status.js +8 -8
- package/build/3nstorage/routes/owner/put-current-obj.js +25 -55
- package/build/3nstorage/routes/owner/session-params.js +2 -0
- package/build/asmail/resources/utils.d.ts +6 -0
- package/build/asmail/resources/utils.js +36 -0
- package/build/asmail/routes/delivery/finalize-delivery.js +3 -2
- package/build/asmail/routes/delivery/pre-flight.js +9 -26
- package/build/asmail/routes/delivery/provide-recipient-pubkey.js +4 -3
- package/build/asmail/routes/delivery/put-metadata.js +13 -21
- package/build/asmail/routes/delivery/put-obj.js +19 -25
- package/build/asmail/routes/delivery/restart-session.d.ts +4 -8
- package/build/asmail/routes/delivery/restart-session.js +10 -23
- package/build/asmail/routes/delivery/sender-authorization.js +5 -5
- package/build/asmail/routes/delivery/start-session.js +9 -24
- package/build/asmail/routes/retrieval/get-message-meta.js +4 -7
- package/build/asmail/routes/retrieval/get-message-obj.js +10 -7
- package/build/asmail/routes/retrieval/list-messages.js +4 -4
- package/build/asmail/routes/retrieval/remove-message.js +3 -2
- package/build/mock/tls-options.js +46 -44
- package/build/tests/admin-proto/signup.d.ts +1 -0
- package/build/tests/admin-proto/signup.js +235 -0
- package/build/tests/jasmine.d.ts +1 -0
- package/build/tests/jasmine.js +32 -0
- package/build/tests/libs-for-tests/3nstorage.d.ts +22 -0
- package/build/tests/libs-for-tests/3nstorage.js +123 -0
- package/build/tests/libs-for-tests/asmail.d.ts +22 -0
- package/build/tests/libs-for-tests/asmail.js +179 -0
- package/build/tests/libs-for-tests/assert.d.ts +1 -0
- package/build/tests/libs-for-tests/assert.js +26 -0
- package/build/tests/libs-for-tests/async-jasmine.d.ts +7 -0
- package/build/tests/libs-for-tests/async-jasmine.js +77 -0
- package/build/tests/libs-for-tests/bytes-equal.d.ts +1 -0
- package/build/tests/libs-for-tests/bytes-equal.js +34 -0
- package/build/tests/libs-for-tests/json-copy.d.ts +1 -0
- package/build/tests/libs-for-tests/json-copy.js +45 -0
- package/build/tests/libs-for-tests/json-equal.d.ts +4 -0
- package/build/tests/libs-for-tests/json-equal.js +67 -0
- package/build/tests/libs-for-tests/mailerid.d.ts +13 -0
- package/build/tests/libs-for-tests/mailerid.js +114 -0
- package/build/tests/libs-for-tests/pkl.d.ts +28 -0
- package/build/tests/libs-for-tests/pkl.js +89 -0
- package/build/tests/libs-for-tests/server-components/3nstorage.d.ts +20 -0
- package/build/tests/libs-for-tests/server-components/3nstorage.js +200 -0
- package/build/tests/libs-for-tests/server-components/admin.d.ts +6 -0
- package/build/tests/libs-for-tests/server-components/admin.js +43 -0
- package/build/tests/libs-for-tests/server-components/asmail.d.ts +16 -0
- package/build/tests/libs-for-tests/server-components/asmail.js +143 -0
- package/build/tests/libs-for-tests/server-components/component.d.ts +13 -0
- package/build/tests/libs-for-tests/server-components/component.js +77 -0
- package/build/tests/libs-for-tests/server-components/mailerid.d.ts +10 -0
- package/build/tests/libs-for-tests/server-components/mailerid.js +103 -0
- package/build/tests/libs-for-tests/server-runner.d.ts +15 -0
- package/build/tests/libs-for-tests/server-runner.js +69 -0
- package/build/tests/libs-for-tests/spec-assembly.d.ts +6 -0
- package/build/tests/libs-for-tests/spec-assembly.js +55 -0
- package/build/tests/libs-for-tests/ws-utils.d.ts +3 -0
- package/build/tests/libs-for-tests/ws-utils.js +59 -0
- package/build/tests/libs-for-tests/xhr-utils.d.ts +61 -0
- package/build/tests/libs-for-tests/xhr-utils.js +154 -0
- package/build/tests/protocols/3nstorage/owner/specs/archive-obj-ver.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/archive-obj-ver.js +84 -0
- package/build/tests/protocols/3nstorage/owner/specs/archive-root-ver.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/archive-root-ver.js +78 -0
- package/build/tests/protocols/3nstorage/owner/specs/delete-archive-obj-ver.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/delete-archive-obj-ver.js +83 -0
- package/build/tests/protocols/3nstorage/owner/specs/delete-archive-root-ver.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/delete-archive-root-ver.js +77 -0
- package/build/tests/protocols/3nstorage/owner/specs/delete-obj.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/delete-obj.js +75 -0
- package/build/tests/protocols/3nstorage/owner/specs/events.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/events.js +91 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-current-obj.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-current-obj.js +269 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-current-root.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-current-root.js +262 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-obj-status.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-obj-status.js +79 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-root-status.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-root-status.js +72 -0
- package/build/tests/protocols/3nstorage/owner/specs/put-current-obj.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/put-current-obj.js +287 -0
- package/build/tests/protocols/3nstorage/owner/specs/put-current-root.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/put-current-root.js +274 -0
- package/build/tests/protocols/3nstorage/owner/specs/trans-cancel-root.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/trans-cancel-root.js +73 -0
- package/build/tests/protocols/3nstorage/owner/specs/trans-cancel.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/trans-cancel.js +72 -0
- package/build/tests/protocols/3nstorage/owner/test-utils.d.ts +14 -0
- package/build/tests/protocols/3nstorage/owner/test-utils.js +54 -0
- package/build/tests/protocols/3nstorage/owner.d.ts +1 -0
- package/build/tests/protocols/3nstorage/owner.js +138 -0
- package/build/tests/protocols/asmail/config.d.ts +1 -0
- package/build/tests/protocols/asmail/config.js +117 -0
- package/build/tests/protocols/asmail/delivery/specs/finalize-delivery.d.ts +2 -0
- package/build/tests/protocols/asmail/delivery/specs/finalize-delivery.js +60 -0
- package/build/tests/protocols/asmail/delivery/specs/provide-recipient-pubkey.d.ts +2 -0
- package/build/tests/protocols/asmail/delivery/specs/provide-recipient-pubkey.js +68 -0
- package/build/tests/protocols/asmail/delivery/specs/put-metadata.d.ts +2 -0
- package/build/tests/protocols/asmail/delivery/specs/put-metadata.js +83 -0
- package/build/tests/protocols/asmail/delivery/specs/put-obj.d.ts +2 -0
- package/build/tests/protocols/asmail/delivery/specs/put-obj.js +123 -0
- package/build/tests/protocols/asmail/delivery/specs/restart-session.d.ts +2 -0
- package/build/tests/protocols/asmail/delivery/specs/restart-session.js +79 -0
- package/build/tests/protocols/asmail/delivery/specs/start-session.d.ts +2 -0
- package/build/tests/protocols/asmail/delivery/specs/start-session.js +64 -0
- package/build/tests/protocols/asmail/delivery/test-utils.d.ts +16 -0
- package/build/tests/protocols/asmail/delivery/test-utils.js +46 -0
- package/build/tests/protocols/asmail/delivery.d.ts +1 -0
- package/build/tests/protocols/asmail/delivery.js +46 -0
- package/build/tests/protocols/asmail/retrieval/specs/events.d.ts +2 -0
- package/build/tests/protocols/asmail/retrieval/specs/events.js +62 -0
- package/build/tests/protocols/asmail/retrieval/specs/get-message-meta.d.ts +2 -0
- package/build/tests/protocols/asmail/retrieval/specs/get-message-meta.js +70 -0
- package/build/tests/protocols/asmail/retrieval/specs/get-message-obj.d.ts +2 -0
- package/build/tests/protocols/asmail/retrieval/specs/get-message-obj.js +166 -0
- package/build/tests/protocols/asmail/retrieval/specs/list-messages.d.ts +2 -0
- package/build/tests/protocols/asmail/retrieval/specs/list-messages.js +96 -0
- package/build/tests/protocols/asmail/retrieval/specs/remove-message.d.ts +2 -0
- package/build/tests/protocols/asmail/retrieval/specs/remove-message.js +66 -0
- package/build/tests/protocols/asmail/retrieval/test-utils.d.ts +17 -0
- package/build/tests/protocols/asmail/retrieval/test-utils.js +46 -0
- package/build/tests/protocols/asmail/retrieval.d.ts +1 -0
- package/build/tests/protocols/asmail/retrieval.js +92 -0
- package/build/tests/protocols/mailerid.d.ts +1 -0
- package/build/tests/protocols/mailerid.js +210 -0
- package/build/tests/shared-checks/check-mid-login.d.ts +2 -0
- package/build/tests/shared-checks/check-mid-login.js +131 -0
- package/build/tests/shared-checks/requests.d.ts +20 -0
- package/build/tests/shared-checks/requests.js +123 -0
- package/package.json +1 -1
- package/packing/create-deb.sh +57 -0
- package/packing/deb/lib/systemd/system/3nweb.service +11 -0
- package/packing/deb/postinst +44 -0
- package/packing/deb/usr/share/doc/3nweb-server/conf-for-postinstall.yaml +19 -0
- package/packing/deb/usr/share/doc/3nweb-server/copyright +22 -0
- package/publish-task.sh +10 -0
- package/push-to-github.sh +105 -0
- package/ts-code/3nstorage/3nstorage-app.ts +99 -0
- package/ts-code/3nstorage/owner.ts +178 -0
- package/ts-code/3nstorage/resources/sessions.ts +37 -0
- package/ts-code/3nstorage/resources/store.ts +896 -0
- package/ts-code/3nstorage/resources/users.ts +258 -0
- package/ts-code/3nstorage/resources/utils.ts +45 -0
- package/ts-code/3nstorage/routes/owner/archive-obj-version.ts +71 -0
- package/ts-code/3nstorage/routes/owner/cancel-trans.ts +60 -0
- package/ts-code/3nstorage/routes/owner/delete-obj.ts +99 -0
- package/ts-code/3nstorage/routes/owner/get-archived-obj-ver.ts +109 -0
- package/ts-code/3nstorage/routes/owner/get-current-obj.ts +124 -0
- package/ts-code/3nstorage/routes/owner/get-obj-status.ts +55 -0
- package/ts-code/3nstorage/routes/owner/param-getter.ts +51 -0
- package/ts-code/3nstorage/routes/owner/param-setter.ts +50 -0
- package/ts-code/3nstorage/routes/owner/put-current-obj.ts +257 -0
- package/ts-code/3nstorage/routes/owner/session-params.ts +50 -0
- package/ts-code/3nstorage/shared.ts +43 -0
- package/ts-code/asmail/asmail-app.ts +91 -0
- package/ts-code/asmail/config.ts +96 -0
- package/ts-code/asmail/delivery.ts +94 -0
- package/ts-code/asmail/resources/delivery-sessions.ts +118 -0
- package/ts-code/asmail/resources/inbox.ts +696 -0
- package/ts-code/asmail/resources/recipients.ts +495 -0
- package/ts-code/asmail/resources/sessions.ts +37 -0
- package/ts-code/asmail/resources/utils.ts +41 -0
- package/ts-code/asmail/retrieval.ts +96 -0
- package/ts-code/asmail/routes/config/param-getter.ts +49 -0
- package/ts-code/asmail/routes/config/param-setter.ts +49 -0
- package/ts-code/asmail/routes/delivery/finalize-delivery.ts +51 -0
- package/ts-code/asmail/routes/delivery/pre-flight.ts +118 -0
- package/ts-code/asmail/routes/delivery/provide-recipient-pubkey.ts +58 -0
- package/ts-code/asmail/routes/delivery/put-metadata.ts +85 -0
- package/ts-code/asmail/routes/delivery/put-obj.ts +152 -0
- package/ts-code/asmail/routes/delivery/restart-session.ts +117 -0
- package/ts-code/asmail/routes/delivery/sender-authorization.ts +81 -0
- package/ts-code/asmail/routes/delivery/start-session.ts +136 -0
- package/ts-code/asmail/routes/retrieval/get-message-meta.ts +50 -0
- package/ts-code/asmail/routes/retrieval/get-message-obj.ts +106 -0
- package/ts-code/asmail/routes/retrieval/list-messages.ts +68 -0
- package/ts-code/asmail/routes/retrieval/remove-message.ts +48 -0
- package/ts-code/cli/index.ts +82 -0
- package/ts-code/cli/run-cmd.ts +81 -0
- package/ts-code/cli/show-sample-config.ts +78 -0
- package/ts-code/cli/signup-cmd.ts +229 -0
- package/ts-code/cli/user-cmd.ts +68 -0
- package/ts-code/cli/utils.ts +105 -0
- package/ts-code/config/default-confs.ts +22 -0
- package/ts-code/config/from-yaml.ts +35 -0
- package/ts-code/config/letsencrypt.ts +77 -0
- package/ts-code/config/signup.ts +137 -0
- package/ts-code/lib-common/admin-api/signup.ts +120 -0
- package/ts-code/lib-common/assert.ts +22 -0
- package/ts-code/lib-common/async-fs-node.ts +656 -0
- package/ts-code/lib-common/buffer-utils.ts +124 -0
- package/ts-code/lib-common/byte-streaming/common.ts +166 -0
- package/ts-code/lib-common/bytes-equal.ts +25 -0
- package/ts-code/lib-common/canonical-address.ts +92 -0
- package/ts-code/lib-common/exceptions/error.ts +44 -0
- package/ts-code/lib-common/exceptions/file.ts +84 -0
- package/ts-code/lib-common/exceptions/http.ts +69 -0
- package/ts-code/lib-common/ipc/generic-ipc.ts +750 -0
- package/ts-code/lib-common/ipc/ws-ipc.ts +117 -0
- package/ts-code/lib-common/json-equal.ts +55 -0
- package/ts-code/lib-common/json-utils.ts +130 -0
- package/ts-code/lib-common/jwkeys.ts +246 -0
- package/ts-code/lib-common/map-of-sets.ts +60 -0
- package/ts-code/lib-common/mid-sigs-NaCl-Ed.ts +677 -0
- package/ts-code/lib-common/objs-on-disk/file-layout.ts +480 -0
- package/ts-code/lib-common/objs-on-disk/obj-file.ts +325 -0
- package/ts-code/lib-common/objs-on-disk/utils.ts +201 -0
- package/ts-code/lib-common/objs-on-disk/v1-obj-file-format.ts +329 -0
- package/ts-code/lib-common/processes.ts +501 -0
- package/ts-code/lib-common/random-node.ts +79 -0
- package/ts-code/lib-common/service-api/3nstorage/owner.ts +559 -0
- package/ts-code/lib-common/service-api/3nstorage/root-route.ts +22 -0
- package/ts-code/lib-common/service-api/asmail/config.ts +144 -0
- package/ts-code/lib-common/service-api/asmail/delivery.ts +250 -0
- package/ts-code/lib-common/service-api/asmail/retrieval.ts +238 -0
- package/ts-code/lib-common/service-api/asmail/root-route.ts +22 -0
- package/ts-code/lib-common/service-api/ipc-api.ts +44 -0
- package/ts-code/lib-common/service-api/locker.ts +44 -0
- package/ts-code/lib-common/service-api/mailer-id/login.ts +80 -0
- package/ts-code/lib-common/service-api/mailer-id/provisioning.ts +64 -0
- package/ts-code/lib-common/service-api/mailer-id/root-route.ts +25 -0
- package/ts-code/lib-common/service-api/pub-key-login.ts +75 -0
- package/ts-code/lib-common/service-api/web-socket-base.ts +87 -0
- package/ts-code/lib-common/session-encryptor.ts +54 -0
- package/ts-code/lib-common/time-window-cache.ts +74 -0
- package/ts-code/lib-common/transferable.d.ts +30 -0
- package/ts-code/lib-server/conf-util.ts +35 -0
- package/ts-code/lib-server/mid-access.ts +45 -0
- package/ts-code/lib-server/middleware/body-parsers.ts +248 -0
- package/ts-code/lib-server/middleware/error-handler.ts +79 -0
- package/ts-code/lib-server/pkl-access.ts +46 -0
- package/ts-code/lib-server/resources/dns.ts +151 -0
- package/ts-code/lib-server/resources/mailerid-authorizer.ts +115 -0
- package/ts-code/lib-server/resources/mem-backed-sessions-factory.ts +132 -0
- package/ts-code/lib-server/resources/server-data-folders.ts +160 -0
- package/ts-code/lib-server/resources/server-key-for-pkl-challenge.ts +41 -0
- package/ts-code/lib-server/resources/sessions.ts +232 -0
- package/ts-code/lib-server/resources/user-files.ts +147 -0
- package/ts-code/lib-server/routes/pub-key-login/complete-exchange.ts +63 -0
- package/ts-code/lib-server/routes/pub-key-login/start-exchange.ts +189 -0
- package/ts-code/lib-server/routes/sessions/close.ts +27 -0
- package/ts-code/lib-server/routes/sessions/mid-auth.ts +77 -0
- package/ts-code/lib-server/routes/sessions/start.ts +116 -0
- package/ts-code/lib-server/web-sockets/app.ts +339 -0
- package/ts-code/lib-server/web-sockets/server-events.ts +63 -0
- package/ts-code/lib.ts +29 -0
- package/ts-code/locker/locker-app.ts +60 -0
- package/ts-code/locker/resources/lockers.ts +17 -0
- package/ts-code/locker/resources/sessions.ts +37 -0
- package/ts-code/locker/routes/create-locker.ts +47 -0
- package/ts-code/mailerId/mailerId-app.ts +107 -0
- package/ts-code/mailerId/resources/certifier.ts +181 -0
- package/ts-code/mailerId/resources/sessions.ts +44 -0
- package/ts-code/mailerId/resources/users.ts +88 -0
- package/ts-code/mailerId/routes/certify.ts +68 -0
- package/ts-code/main.ts +304 -0
- package/ts-code/mock/dns.ts +106 -0
- package/ts-code/mock/mock-as-child-proc.ts +130 -0
- package/ts-code/mock/node-child-ipc.ts +69 -0
- package/ts-code/mock/run-in-proc.ts +111 -0
- package/ts-code/mock/tls-options.ts +73 -0
- package/ts-code/services.ts +138 -0
- package/ts-code/signup/resources/users.ts +429 -0
- package/ts-code/signup/routes/add.ts +65 -0
- package/ts-code/signup/routes/get-available-addresses.ts +49 -0
- package/ts-code/signup/routes/get-available-domains.ts +45 -0
- package/ts-code/signup/signup-app.ts +54 -0
- package/ts-code/signup/signup-tokens.ts +148 -0
- package/ts-code/tests/admin-proto/signup.ts +277 -0
- package/ts-code/tests/jasmine.ts +37 -0
- package/ts-code/tests/libs-for-tests/3nstorage.ts +144 -0
- package/ts-code/tests/libs-for-tests/asmail.ts +220 -0
- package/ts-code/tests/libs-for-tests/assert.ts +22 -0
- package/ts-code/tests/libs-for-tests/async-jasmine.ts +89 -0
- package/ts-code/tests/libs-for-tests/bytes-equal.ts +25 -0
- package/ts-code/tests/libs-for-tests/json-copy.ts +38 -0
- package/ts-code/tests/libs-for-tests/json-equal.ts +55 -0
- package/ts-code/tests/libs-for-tests/mailerid.ts +123 -0
- package/ts-code/tests/libs-for-tests/pkl.ts +127 -0
- package/ts-code/tests/libs-for-tests/server-components/3nstorage.ts +206 -0
- package/ts-code/tests/libs-for-tests/server-components/admin.ts +49 -0
- package/ts-code/tests/libs-for-tests/server-components/asmail.ts +152 -0
- package/ts-code/tests/libs-for-tests/server-components/component.ts +90 -0
- package/ts-code/tests/libs-for-tests/server-components/mailerid.ts +114 -0
- package/ts-code/tests/libs-for-tests/server-runner.ts +82 -0
- package/ts-code/tests/libs-for-tests/spec-assembly.ts +60 -0
- package/ts-code/tests/libs-for-tests/ws-utils.ts +61 -0
- package/ts-code/tests/libs-for-tests/xhr-utils.ts +179 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/archive-obj-ver.ts +100 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/archive-root-ver.ts +91 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/delete-archive-obj-ver.ts +99 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/delete-archive-root-ver.ts +90 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/delete-obj.ts +84 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/events.ts +125 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/get-current-obj.ts +298 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/get-current-root.ts +290 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/get-obj-status.ts +88 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/get-root-status.ts +80 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/put-current-obj.ts +366 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/put-current-root.ts +329 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/trans-cancel-root.ts +86 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/trans-cancel.ts +86 -0
- package/ts-code/tests/protocols/3nstorage/owner/test-utils.ts +72 -0
- package/ts-code/tests/protocols/3nstorage/owner.ts +198 -0
- package/ts-code/tests/protocols/asmail/config.ts +172 -0
- package/ts-code/tests/protocols/asmail/delivery/specs/finalize-delivery.ts +69 -0
- package/ts-code/tests/protocols/asmail/delivery/specs/provide-recipient-pubkey.ts +88 -0
- package/ts-code/tests/protocols/asmail/delivery/specs/put-metadata.ts +102 -0
- package/ts-code/tests/protocols/asmail/delivery/specs/put-obj.ts +156 -0
- package/ts-code/tests/protocols/asmail/delivery/specs/restart-session.ts +97 -0
- package/ts-code/tests/protocols/asmail/delivery/specs/start-session.ts +79 -0
- package/ts-code/tests/protocols/asmail/delivery/test-utils.ts +64 -0
- package/ts-code/tests/protocols/asmail/delivery.ts +56 -0
- package/ts-code/tests/protocols/asmail/retrieval/specs/events.ts +78 -0
- package/ts-code/tests/protocols/asmail/retrieval/specs/get-message-meta.ts +80 -0
- package/ts-code/tests/protocols/asmail/retrieval/specs/get-message-obj.ts +197 -0
- package/ts-code/tests/protocols/asmail/retrieval/specs/list-messages.ts +110 -0
- package/ts-code/tests/protocols/asmail/retrieval/specs/remove-message.ts +74 -0
- package/ts-code/tests/protocols/asmail/retrieval/test-utils.ts +60 -0
- package/ts-code/tests/protocols/asmail/retrieval.ts +115 -0
- package/ts-code/tests/protocols/mailerid.ts +271 -0
- package/ts-code/tests/shared-checks/check-mid-login.ts +164 -0
- package/ts-code/tests/shared-checks/requests.ts +135 -0
- package/ts-code/tsconfig.json +11 -0
- package/ts-code/web3n.d.ts +1068 -0
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2016 - 2017, 2025 3NSoft Inc.
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
7
|
+
version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful, but
|
|
10
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
See the GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License along with
|
|
15
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { startSession, SpecDescribe, TestSetup, User, StorageComponent } from '../test-utils';
|
|
19
|
+
import { HTTP_HEADER, ERR_SC, currentRootObj as api } from '../../../../../lib-common/service-api/3nstorage/owner';
|
|
20
|
+
import { beforeAllAsync, itAsync } from '../../../../libs-for-tests/async-jasmine';
|
|
21
|
+
import { RequestOpts, doBodylessRequest, Reply } from '../../../../libs-for-tests/xhr-utils';
|
|
22
|
+
import { Obj, saveObj } from '../../../../libs-for-tests/3nstorage';
|
|
23
|
+
import { expectNonAcceptanceOfBadSessionId } from '../../../../shared-checks/requests';
|
|
24
|
+
import { bytesSync as randomBytes } from '../../../../../lib-common/random-node';
|
|
25
|
+
import { resolve as resolveUrl } from 'url';
|
|
26
|
+
import { copy } from '../../../../libs-for-tests/json-copy';
|
|
27
|
+
import { bytesEqual } from '../../../../libs-for-tests/bytes-equal';
|
|
28
|
+
|
|
29
|
+
export const specs: SpecDescribe[] = [];
|
|
30
|
+
|
|
31
|
+
const description = 'Request to get current root object';
|
|
32
|
+
|
|
33
|
+
const obj: Obj = {
|
|
34
|
+
objId: null as any,
|
|
35
|
+
version: 1,
|
|
36
|
+
header: randomBytes(100),
|
|
37
|
+
segs: randomBytes(2345)
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
let reqOpts: RequestOpts
|
|
41
|
+
let storageServer: StorageComponent;
|
|
42
|
+
let user: User;
|
|
43
|
+
let sessionId: string;
|
|
44
|
+
|
|
45
|
+
async function setStage(setup: () => TestSetup): Promise<void> {
|
|
46
|
+
storageServer = setup().storageServer;
|
|
47
|
+
user = setup().user;
|
|
48
|
+
await storageServer.restartAndClearStorageFor(user.id);
|
|
49
|
+
sessionId = await startSession(user);
|
|
50
|
+
await saveObj(user.storageOwnerUrl, sessionId, obj.objId, 1, obj);
|
|
51
|
+
reqOpts = {
|
|
52
|
+
url: resolveUrl(
|
|
53
|
+
user.storageOwnerUrl, api.getReqUrlEnd({ header: true })),
|
|
54
|
+
method: 'GET',
|
|
55
|
+
sessionId,
|
|
56
|
+
responseType: 'arraybuffer',
|
|
57
|
+
responseHeaders: [
|
|
58
|
+
HTTP_HEADER.objSegmentsLength, HTTP_HEADER.objVersion,
|
|
59
|
+
HTTP_HEADER.objHeaderLength ]
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function checkReplyExpectation(
|
|
64
|
+
rep: Reply<Uint8Array>, obj: Obj, headerPresent: boolean,
|
|
65
|
+
expectedSegsBytes: Uint8Array
|
|
66
|
+
): void {
|
|
67
|
+
// status
|
|
68
|
+
expect(rep.status).withContext('status for returned bytes').toBe(api.SC.okGet);
|
|
69
|
+
|
|
70
|
+
// version header
|
|
71
|
+
expect(parseInt(rep.headers!.get(HTTP_HEADER.objVersion)!)).withContext('object version must be given in the reply header').toBe(obj.version);
|
|
72
|
+
|
|
73
|
+
// object's header length http header
|
|
74
|
+
const headerLen = obj.header.length;
|
|
75
|
+
if (headerPresent) {
|
|
76
|
+
expect(parseInt(rep.headers!.get(HTTP_HEADER.objHeaderLength)!)).withContext('object header size must be given in the reply header').toBe(headerLen);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// segments length header
|
|
80
|
+
const segsLen = (obj.diff ? obj.diff.segsSize : obj.segs.length);
|
|
81
|
+
expect(parseInt(rep.headers!.get(HTTP_HEADER.objSegmentsLength)!)).withContext('object segments size must be given in the reply header').toBe(segsLen);
|
|
82
|
+
|
|
83
|
+
// check body
|
|
84
|
+
if (headerPresent) {
|
|
85
|
+
expect(bytesEqual(rep.data.subarray(0, headerLen), obj.header)).withContext('reply should have header bytes at the front').toBe(true);
|
|
86
|
+
expect(bytesEqual(rep.data.subarray(headerLen), expectedSegsBytes)).withContext('reply should have proper segments bytes, following header bytes').toBe(true);
|
|
87
|
+
} else {
|
|
88
|
+
expect(bytesEqual(rep.data, expectedSegsBytes)).withContext('reply should have proper segments bytes').toBe(true);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const readSimpleObjVersion: SpecDescribe = { description };
|
|
93
|
+
specs.push(readSimpleObjVersion);
|
|
94
|
+
readSimpleObjVersion.definition = (setup: () => TestSetup) => (() => {
|
|
95
|
+
|
|
96
|
+
beforeAllAsync(() => setStage(setup));
|
|
97
|
+
|
|
98
|
+
itAsync('will not work outside of a valid session', async () => {
|
|
99
|
+
const opts = copy(reqOpts);
|
|
100
|
+
await expectNonAcceptanceOfBadSessionId(opts);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
itAsync('will not accept bad parameters', async () => {
|
|
104
|
+
const opts = copy(reqOpts);
|
|
105
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.getReqUrlEnd({ ofs: -34 }));
|
|
106
|
+
let rep = await doBodylessRequest<Uint8Array>(opts);
|
|
107
|
+
expect(rep.status).toBe(ERR_SC.malformed);
|
|
108
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.getReqUrlEnd({ limit: -34 }));
|
|
109
|
+
rep = await doBodylessRequest<Uint8Array>(opts);
|
|
110
|
+
expect(rep.status).toBe(ERR_SC.malformed);
|
|
111
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.getReqUrlEnd({ ofs: 10, limit: 0 }));
|
|
112
|
+
rep = await doBodylessRequest<Uint8Array>(opts);
|
|
113
|
+
expect(rep.status).toBe(ERR_SC.malformed);
|
|
114
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.getReqUrlEnd({ header: true, ofs: 10 }));
|
|
115
|
+
rep = await doBodylessRequest<Uint8Array>(opts);
|
|
116
|
+
expect(rep.status).toBe(ERR_SC.malformed);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
itAsync('returns header and all segments', async () => {
|
|
120
|
+
expect(await storageServer.currentRootObjExists(user.id, obj.version, obj)).withContext('object must be in serve\'s store').toBe(true);
|
|
121
|
+
const opts = copy(reqOpts);
|
|
122
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.getReqUrlEnd({ header: true }));
|
|
123
|
+
const rep = await doBodylessRequest<Uint8Array>(opts);
|
|
124
|
+
checkReplyExpectation(rep, obj, true, obj.segs);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
itAsync('returns header without segments', async () => {
|
|
128
|
+
expect(await storageServer.currentRootObjExists(user.id, obj.version, obj)).withContext('object must be in serve\'s store').toBe(true);
|
|
129
|
+
const opts = copy(reqOpts);
|
|
130
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.getReqUrlEnd({ header: true, limit: 0 }));
|
|
131
|
+
const rep = await doBodylessRequest<Uint8Array>(opts);
|
|
132
|
+
checkReplyExpectation(rep, obj, true, new Uint8Array(0));
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
itAsync('returns all segments without header', async () => {
|
|
136
|
+
expect(await storageServer.currentRootObjExists(user.id, obj.version, obj)).withContext('object must be in serve\'s store').toBe(true);
|
|
137
|
+
const opts = copy(reqOpts);
|
|
138
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.getReqUrlEnd());
|
|
139
|
+
const rep = await doBodylessRequest<Uint8Array>(opts);
|
|
140
|
+
checkReplyExpectation(rep, obj, false, obj.segs);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
itAsync('returns chunk, when offset and limit are given', async () => {
|
|
144
|
+
const opts = copy(reqOpts);
|
|
145
|
+
// with non-overflowing limit
|
|
146
|
+
for (let offset=0; offset<=obj.segs.length; offset+=512) {
|
|
147
|
+
const chunkLen = Math.min(512, obj.segs.length - offset);
|
|
148
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.getReqUrlEnd({ ofs: offset, limit: chunkLen }));
|
|
149
|
+
const rep = await doBodylessRequest<Uint8Array>(opts);
|
|
150
|
+
checkReplyExpectation(rep, obj, false, obj.segs.subarray(offset, offset+chunkLen));
|
|
151
|
+
}
|
|
152
|
+
// with overflowing limit
|
|
153
|
+
const offset = obj.segs.length - 100;
|
|
154
|
+
const requestedLen = 300
|
|
155
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.getReqUrlEnd({ ofs: offset, limit: requestedLen }));
|
|
156
|
+
const rep = await doBodylessRequest<Uint8Array>(opts);
|
|
157
|
+
checkReplyExpectation(rep, obj, false, obj.segs.subarray(offset));
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
itAsync('reads segments from start, when offset is not given', async () => {
|
|
161
|
+
const opts = copy(reqOpts);
|
|
162
|
+
// with non-overflowing length
|
|
163
|
+
const chunkLen = 512;
|
|
164
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.getReqUrlEnd({ limit: chunkLen }));
|
|
165
|
+
let rep = await doBodylessRequest<Uint8Array>(opts);
|
|
166
|
+
checkReplyExpectation(rep, obj, false, obj.segs.subarray(0, chunkLen));
|
|
167
|
+
// with overflowing length
|
|
168
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.getReqUrlEnd({ limit: obj.segs.length+300 }));
|
|
169
|
+
rep = await doBodylessRequest<Uint8Array>(opts);
|
|
170
|
+
checkReplyExpectation(rep, obj, false, obj.segs);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
itAsync('reads segments to the end, when limit is not given', async () => {
|
|
174
|
+
const opts = copy(reqOpts);
|
|
175
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.getReqUrlEnd({ ofs: 1234 }));
|
|
176
|
+
const rep = await doBodylessRequest<Uint8Array>(opts);
|
|
177
|
+
checkReplyExpectation(rep, obj, false, obj.segs.subarray(1234));
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
itAsync('no-bytes read', async () => {
|
|
181
|
+
const opts = copy(reqOpts);
|
|
182
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.getReqUrlEnd({ ofs: obj.segs.length, limit: 500 }));
|
|
183
|
+
const rep = await doBodylessRequest<Uint8Array>(opts);
|
|
184
|
+
checkReplyExpectation(rep, obj, false, new Uint8Array(0));
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
const diffVer: Obj = {
|
|
190
|
+
objId: null as any,
|
|
191
|
+
version: obj.version + 1,
|
|
192
|
+
header: randomBytes(111),
|
|
193
|
+
segs: randomBytes(1000),
|
|
194
|
+
diff: {
|
|
195
|
+
baseVersion: obj.version,
|
|
196
|
+
segsSize: 2000,
|
|
197
|
+
sections: [
|
|
198
|
+
[ 0, 25, 500 ],
|
|
199
|
+
[ 1, 0, 300 ],
|
|
200
|
+
[ 0, 525, 500 ],
|
|
201
|
+
[ 1, 300, 700 ] ]
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
function combineDiffSegs(baseSegs: Uint8Array, diffObj: Obj): Uint8Array {
|
|
206
|
+
if (!diffObj.diff) { throw new Error(`object has no diff`); }
|
|
207
|
+
const combined = Buffer.alloc(diffObj.diff.segsSize);
|
|
208
|
+
let offset = 0;
|
|
209
|
+
for (const s of diffObj.diff.sections) {
|
|
210
|
+
const src = ((s[0] === 0) ? baseSegs : diffObj.segs);
|
|
211
|
+
const chunk = src.subarray(s[1], s[1]+s[2]);
|
|
212
|
+
if (chunk.length !== s[2]) { throw new Error(
|
|
213
|
+
'Given DiffInfo incorrectly references chunks of segments'); }
|
|
214
|
+
combined.set(chunk, offset);
|
|
215
|
+
offset += s[2];
|
|
216
|
+
}
|
|
217
|
+
if (offset !== diffObj.diff.segsSize) { throw new Error(
|
|
218
|
+
'Given DiffInfo states incorrect segments length'); }
|
|
219
|
+
return combined;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const accessDiffedObjVersion: SpecDescribe = {
|
|
223
|
+
description: `${description}, access to version, saved as a diff, is the same, as to version saved as a whole`
|
|
224
|
+
};
|
|
225
|
+
specs.push(accessDiffedObjVersion);
|
|
226
|
+
accessDiffedObjVersion.definition = (setup: () => TestSetup) => (() => {
|
|
227
|
+
|
|
228
|
+
beforeAllAsync(async () => {
|
|
229
|
+
await setStage(setup);
|
|
230
|
+
await saveObj(
|
|
231
|
+
user.storageOwnerUrl, sessionId,
|
|
232
|
+
diffVer.objId, diffVer.version, diffVer);
|
|
233
|
+
reqOpts = {
|
|
234
|
+
url: resolveUrl(user.storageOwnerUrl, api.getReqUrlEnd({ header: true })),
|
|
235
|
+
method: 'GET',
|
|
236
|
+
sessionId,
|
|
237
|
+
responseType: 'arraybuffer',
|
|
238
|
+
responseHeaders: [
|
|
239
|
+
HTTP_HEADER.objSegmentsLength, HTTP_HEADER.objVersion,
|
|
240
|
+
HTTP_HEADER.objHeaderLength ]
|
|
241
|
+
};
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
itAsync('returns header and all segments', async () => {
|
|
245
|
+
expect(await storageServer.currentRootObjExists(user.id, diffVer.version, diffVer)).withContext(`object must be in serve's store`).toBe(true);
|
|
246
|
+
const opts = copy(reqOpts);
|
|
247
|
+
const combinedBytes = combineDiffSegs(obj.segs, diffVer);
|
|
248
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.getReqUrlEnd({ header: true }));
|
|
249
|
+
const rep = await doBodylessRequest<Uint8Array>(opts);
|
|
250
|
+
checkReplyExpectation(rep, diffVer, true, combinedBytes);
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
itAsync('returns header without segments', async () => {
|
|
254
|
+
expect(await storageServer.currentRootObjExists(user.id, diffVer.version, diffVer)).withContext(`object must be in serve's store`).toBe(true);
|
|
255
|
+
const opts = copy(reqOpts);
|
|
256
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.getReqUrlEnd({ header: true, limit: 0 }));
|
|
257
|
+
const rep = await doBodylessRequest<Uint8Array>(opts);
|
|
258
|
+
checkReplyExpectation(rep, diffVer, true, new Uint8Array(0));
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
itAsync('returns all segments without header', async () => {
|
|
262
|
+
expect(await storageServer.currentRootObjExists(user.id, diffVer.version, diffVer)).withContext(`object must be in serve's store`).toBe(true);
|
|
263
|
+
const opts = copy(reqOpts);
|
|
264
|
+
const combinedBytes = combineDiffSegs(obj.segs, diffVer);
|
|
265
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.getReqUrlEnd());
|
|
266
|
+
const rep = await doBodylessRequest<Uint8Array>(opts);
|
|
267
|
+
checkReplyExpectation(rep, diffVer, false, combinedBytes);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
itAsync('returns chunk, when offset and limit are given', async () => {
|
|
271
|
+
const opts = copy(reqOpts);
|
|
272
|
+
const combinedBytes = combineDiffSegs(obj.segs, diffVer);
|
|
273
|
+
// with non-overflowing length
|
|
274
|
+
for (let offset=0; offset<=diffVer.diff!.segsSize; offset+=512) {
|
|
275
|
+
const chunkLen = Math.min(512, diffVer.diff!.segsSize - offset);
|
|
276
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.getReqUrlEnd({ ofs: offset, limit: chunkLen }));
|
|
277
|
+
const rep = await doBodylessRequest<Uint8Array>(opts);
|
|
278
|
+
checkReplyExpectation(rep, diffVer, false, combinedBytes.subarray(offset, offset+chunkLen));
|
|
279
|
+
}
|
|
280
|
+
// with overflowing length
|
|
281
|
+
const offset = combinedBytes.length - 100;
|
|
282
|
+
const requestedLen = 300
|
|
283
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.getReqUrlEnd({ ofs: offset, limit: requestedLen }));
|
|
284
|
+
const rep = await doBodylessRequest<Uint8Array>(opts);
|
|
285
|
+
checkReplyExpectation(rep, diffVer, false, combinedBytes.subarray(offset));
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2022 3NSoft Inc.
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
7
|
+
version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful, but
|
|
10
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
See the GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License along with
|
|
15
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { startSession, SpecDescribe, TestSetup, User, StorageComponent, archiveObjVer } from '../test-utils';
|
|
19
|
+
import { objStatus as api, ObjStatus } from '../../../../../lib-common/service-api/3nstorage/owner';
|
|
20
|
+
import { beforeAllAsync, itAsync } from '../../../../libs-for-tests/async-jasmine';
|
|
21
|
+
import { RequestOpts, doBodylessRequest } from '../../../../libs-for-tests/xhr-utils';
|
|
22
|
+
import { Obj, saveObj } from '../../../../libs-for-tests/3nstorage';
|
|
23
|
+
import { expectNonAcceptanceOfBadSessionId } from '../../../../shared-checks/requests';
|
|
24
|
+
import { bytesSync as randomBytes } from '../../../../../lib-common/random-node';
|
|
25
|
+
import { resolve as resolveUrl } from 'url';
|
|
26
|
+
import { copy } from '../../../../libs-for-tests/json-copy';
|
|
27
|
+
|
|
28
|
+
export const specs: SpecDescribe = {
|
|
29
|
+
description: `Request to list object's archived versions`
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const obj: Obj = {
|
|
33
|
+
objId: 'aaaa',
|
|
34
|
+
version: 1,
|
|
35
|
+
header: randomBytes(100),
|
|
36
|
+
segs: randomBytes(573)
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
specs.definition = (setup: () => TestSetup) => (() => {
|
|
40
|
+
|
|
41
|
+
let reqOpts: RequestOpts
|
|
42
|
+
let storageServer: StorageComponent;
|
|
43
|
+
let user: User;
|
|
44
|
+
let sessionId: string;
|
|
45
|
+
|
|
46
|
+
beforeAllAsync(async () => {
|
|
47
|
+
storageServer = setup().storageServer;
|
|
48
|
+
user = setup().user;
|
|
49
|
+
await storageServer.restartAndClearStorageFor(user.id);
|
|
50
|
+
sessionId = await startSession(user);
|
|
51
|
+
reqOpts = {
|
|
52
|
+
url: resolveUrl(user.storageOwnerUrl, api.getReqUrlEnd(obj.objId)),
|
|
53
|
+
method: 'GET',
|
|
54
|
+
responseType: 'json',
|
|
55
|
+
sessionId
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
itAsync('will not work outside of a valid session', async () => {
|
|
60
|
+
const opts = copy(reqOpts);
|
|
61
|
+
await expectNonAcceptanceOfBadSessionId(opts);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
itAsync('fails when object does not exist', async () => {
|
|
65
|
+
const unknownObj = 'unknown-obj';
|
|
66
|
+
const opts = copy(reqOpts);
|
|
67
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.getReqUrlEnd(unknownObj));
|
|
68
|
+
const rep = await doBodylessRequest(opts);
|
|
69
|
+
expect(rep.status).toBe(api.SC.unknownObj);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
itAsync(`shows obj status with versions' info`, async () => {
|
|
73
|
+
await saveObj(user.storageOwnerUrl, sessionId, obj.objId, 1, obj);
|
|
74
|
+
let rep = await doBodylessRequest<ObjStatus>(reqOpts);
|
|
75
|
+
expect(rep.status).toBe(api.SC.ok);
|
|
76
|
+
expect(rep.data.current).toBe(1);
|
|
77
|
+
expect(rep.data.archived).toBeUndefined();
|
|
78
|
+
await archiveObjVer(user, obj.objId, 1, sessionId);
|
|
79
|
+
rep = await doBodylessRequest<ObjStatus>(reqOpts);
|
|
80
|
+
expect(rep.status).toBe(api.SC.ok);
|
|
81
|
+
expect(rep.data.current).toBe(1);
|
|
82
|
+
expect(rep.data.archived).toContain(1);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2022 3NSoft Inc.
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
7
|
+
version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful, but
|
|
10
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
See the GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License along with
|
|
15
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { startSession, SpecDescribe, TestSetup, User, StorageComponent, archiveObjVer } from '../test-utils';
|
|
19
|
+
import { rootStatus as api, ObjStatus } from '../../../../../lib-common/service-api/3nstorage/owner';
|
|
20
|
+
import { beforeAllAsync, itAsync } from '../../../../libs-for-tests/async-jasmine';
|
|
21
|
+
import { RequestOpts, doBodylessRequest } from '../../../../libs-for-tests/xhr-utils';
|
|
22
|
+
import { Obj, saveObj } from '../../../../libs-for-tests/3nstorage';
|
|
23
|
+
import { expectNonAcceptanceOfBadSessionId } from '../../../../shared-checks/requests';
|
|
24
|
+
import { bytesSync as randomBytes } from '../../../../../lib-common/random-node';
|
|
25
|
+
import { resolve as resolveUrl } from 'url';
|
|
26
|
+
import { copy } from '../../../../libs-for-tests/json-copy';
|
|
27
|
+
|
|
28
|
+
export const specs: SpecDescribe = {
|
|
29
|
+
description: `Request to list object's archived versions`
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const obj: Obj = {
|
|
33
|
+
objId: null as any,
|
|
34
|
+
version: 1,
|
|
35
|
+
header: randomBytes(100),
|
|
36
|
+
segs: randomBytes(573)
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
specs.definition = (setup: () => TestSetup) => (() => {
|
|
40
|
+
|
|
41
|
+
let reqOpts: RequestOpts
|
|
42
|
+
let storageServer: StorageComponent;
|
|
43
|
+
let user: User;
|
|
44
|
+
let sessionId: string;
|
|
45
|
+
|
|
46
|
+
beforeAllAsync(async () => {
|
|
47
|
+
storageServer = setup().storageServer;
|
|
48
|
+
user = setup().user;
|
|
49
|
+
await storageServer.restartAndClearStorageFor(user.id);
|
|
50
|
+
sessionId = await startSession(user);
|
|
51
|
+
reqOpts = {
|
|
52
|
+
url: resolveUrl(user.storageOwnerUrl, api.getReqUrlEnd()),
|
|
53
|
+
method: 'GET',
|
|
54
|
+
responseType: 'json',
|
|
55
|
+
sessionId
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
itAsync('will not work outside of a valid session', async () => {
|
|
60
|
+
const opts = copy(reqOpts);
|
|
61
|
+
await expectNonAcceptanceOfBadSessionId(opts);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
itAsync(`shows obj status with versions' info`, async () => {
|
|
65
|
+
await saveObj(user.storageOwnerUrl, sessionId, obj.objId, 1, obj);
|
|
66
|
+
let rep = await doBodylessRequest<ObjStatus>(reqOpts);
|
|
67
|
+
expect(rep.status).toBe(api.SC.ok);
|
|
68
|
+
expect(rep.data.current).toBe(1);
|
|
69
|
+
expect(rep.data.archived).toBeUndefined();
|
|
70
|
+
await archiveObjVer(user, obj.objId, 1, sessionId);
|
|
71
|
+
rep = await doBodylessRequest<ObjStatus>(reqOpts);
|
|
72
|
+
expect(rep.status).toBe(api.SC.ok);
|
|
73
|
+
expect(rep.data.current).toBe(1);
|
|
74
|
+
expect(rep.data.archived).toContain(1);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
Object.freeze(exports);
|