spec-3nweb-server 1.8.4 → 1.8.6
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/routes/owner/archive-obj-version.js +2 -2
- package/build/3nstorage/routes/owner/cancel-trans.js +2 -2
- package/build/3nstorage/routes/owner/delete-obj.js +2 -2
- package/build/3nstorage/routes/owner/get-current-obj.js +3 -4
- package/build/3nstorage/routes/owner/param-setter.js +2 -6
- package/build/asmail/routes/config/param-setter.js +2 -2
- package/build/asmail/routes/delivery/finalize-delivery.js +2 -2
- package/build/asmail/routes/delivery/put-obj.js +2 -2
- package/build/asmail/routes/delivery/sender-authorization.js +2 -2
- package/build/asmail/routes/retrieval/remove-message.js +2 -2
- package/build/cli/signup-cmd.js +0 -1
- package/build/lib-server/routes/sessions/close.js +2 -2
- package/build/lib-server/routes/sessions/mid-auth.js +2 -5
- package/build/main.js +12 -15
- package/build/mock/tls-options.js +46 -44
- package/build/signup/routes/add.js +4 -4
- 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/routes/owner/archive-obj-version.ts +73 -0
- package/ts-code/3nstorage/routes/owner/cancel-trans.ts +58 -0
- package/ts-code/3nstorage/routes/owner/delete-obj.ts +103 -0
- package/ts-code/3nstorage/routes/owner/get-archived-obj-ver.ts +111 -0
- package/ts-code/3nstorage/routes/owner/get-current-obj.ts +122 -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 +284 -0
- package/ts-code/3nstorage/routes/owner/session-params.ts +49 -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/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 +50 -0
- package/ts-code/asmail/routes/delivery/pre-flight.ts +132 -0
- package/ts-code/asmail/routes/delivery/provide-recipient-pubkey.ts +58 -0
- package/ts-code/asmail/routes/delivery/put-metadata.ts +94 -0
- package/ts-code/asmail/routes/delivery/put-obj.ts +166 -0
- package/ts-code/asmail/routes/delivery/restart-session.ts +130 -0
- package/ts-code/asmail/routes/delivery/sender-authorization.ts +81 -0
- package/ts-code/asmail/routes/delivery/start-session.ts +151 -0
- package/ts-code/asmail/routes/retrieval/get-message-meta.ts +53 -0
- package/ts-code/asmail/routes/retrieval/get-message-obj.ts +109 -0
- package/ts-code/asmail/routes/retrieval/list-messages.ts +70 -0
- package/ts-code/asmail/routes/retrieval/remove-message.ts +47 -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,329 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2017, 2019, 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 { currentRootObj as api } from '../../../../../lib-common/service-api/3nstorage/owner';
|
|
20
|
+
import { beforeEachAsync, itAsync } from '../../../../libs-for-tests/async-jasmine';
|
|
21
|
+
import { RequestOpts, doBinaryRequest } from '../../../../libs-for-tests/xhr-utils';
|
|
22
|
+
import { Obj, getSessionParams, saveObj } from '../../../../libs-for-tests/3nstorage';
|
|
23
|
+
import { expectNonAcceptanceOfBadSessionId, expectNonAcceptanceOfBadType, expectNonAcceptanceOfLongBody } from '../../../../shared-checks/requests';
|
|
24
|
+
import { bytesSync as randomBytes } from '../../../../../lib-common/random-node';
|
|
25
|
+
import { utf8 } from '../../../../../lib-common/buffer-utils';
|
|
26
|
+
import { resolve as resolveUrl } from 'url';
|
|
27
|
+
import { copy } from '../../../../libs-for-tests/json-copy';
|
|
28
|
+
|
|
29
|
+
export const specs: SpecDescribe[] = [];
|
|
30
|
+
|
|
31
|
+
const description = `Request to save root object`;
|
|
32
|
+
|
|
33
|
+
const objV1: Obj = {
|
|
34
|
+
objId: 'aaaa',
|
|
35
|
+
version: 1,
|
|
36
|
+
header: randomBytes(100),
|
|
37
|
+
segs: randomBytes(2345)
|
|
38
|
+
};
|
|
39
|
+
const objV2: Obj = {
|
|
40
|
+
objId: objV1.objId,
|
|
41
|
+
version: objV1.version + 1,
|
|
42
|
+
header: randomBytes(110),
|
|
43
|
+
segs: randomBytes(6543)
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
let fstReqOpts: RequestOpts;
|
|
47
|
+
let sndReqOpts: RequestOpts;
|
|
48
|
+
let storageServer: StorageComponent;
|
|
49
|
+
let user: User;
|
|
50
|
+
let sessionId: string;
|
|
51
|
+
|
|
52
|
+
async function setupSession(setup: () => TestSetup): Promise<void> {
|
|
53
|
+
storageServer = setup().storageServer;
|
|
54
|
+
user = setup().user;
|
|
55
|
+
await storageServer.restartAndClearStorageFor(user.id);
|
|
56
|
+
sessionId = await startSession(user);
|
|
57
|
+
fstReqOpts = {
|
|
58
|
+
url: resolveUrl(user.storageOwnerUrl, api.firstPutReqUrlEnd(
|
|
59
|
+
{ ver: 1, header: objV1.header.length })),
|
|
60
|
+
method: 'PUT',
|
|
61
|
+
responseType: 'json',
|
|
62
|
+
sessionId
|
|
63
|
+
};
|
|
64
|
+
sndReqOpts = {
|
|
65
|
+
url: resolveUrl(user.storageOwnerUrl, api.secondPutReqUrlEnd(
|
|
66
|
+
{ trans: 'some-trans', ofs: 0 })),
|
|
67
|
+
method: 'PUT',
|
|
68
|
+
responseType: 'json',
|
|
69
|
+
sessionId
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const fuzzingSpec: SpecDescribe = { description };
|
|
74
|
+
specs.push(fuzzingSpec);
|
|
75
|
+
fuzzingSpec.definition = (setup: () => TestSetup) => (() => {
|
|
76
|
+
|
|
77
|
+
let maxChunkSize: number;
|
|
78
|
+
|
|
79
|
+
beforeEachAsync(async () => {
|
|
80
|
+
await setupSession(setup);
|
|
81
|
+
const params = await getSessionParams(user.storageOwnerUrl, sessionId);
|
|
82
|
+
maxChunkSize = params.maxChunkSize;
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
itAsync('fails for incorrect transaction, in secondary put', async () => {
|
|
86
|
+
const repToFstReq = await doBinaryRequest<api.ReplyToPut>(
|
|
87
|
+
fstReqOpts, objV1.header);
|
|
88
|
+
expect(repToFstReq.status).toBe(api.SC.okPut);
|
|
89
|
+
const trans = repToFstReq.data.transactionId + ' - unknown';
|
|
90
|
+
const opts = copy(sndReqOpts);
|
|
91
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.secondPutReqUrlEnd(
|
|
92
|
+
{ trans, ofs: 0 }));
|
|
93
|
+
const rep = await doBinaryRequest<any>(opts, objV1.segs);
|
|
94
|
+
expect(rep.status).withContext('status for unknown transaction').toBe(api.SC.unknownTransaction);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
itAsync('fails write for incorrect version', async () => {
|
|
98
|
+
await saveObj(
|
|
99
|
+
user.storageOwnerUrl, sessionId, null, objV1.version, objV1);
|
|
100
|
+
const opts = copy(fstReqOpts);
|
|
101
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.firstPutReqUrlEnd(
|
|
102
|
+
{ ver: objV1.version + 5, header: objV1.header.length }));
|
|
103
|
+
const rep = await doBinaryRequest<api.MismatchedObjVerReply>(
|
|
104
|
+
opts, [ objV1.header, objV1.segs ]);
|
|
105
|
+
expect(rep.status).toBe(api.SC.mismatchedObjVer);
|
|
106
|
+
expect(typeof rep.data).toBe('object');
|
|
107
|
+
expect(rep.data.current_version).toBe(objV1.version);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
itAsync('will not accept bad type', async () => {
|
|
111
|
+
await expectNonAcceptanceOfBadType(fstReqOpts, 'application/octet-stream', objV1.segs);
|
|
112
|
+
await expectNonAcceptanceOfBadType(sndReqOpts, 'application/octet-stream', objV1.segs);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
itAsync('will not work outside of a valid session', async () => {
|
|
116
|
+
await expectNonAcceptanceOfBadSessionId(fstReqOpts);
|
|
117
|
+
await expectNonAcceptanceOfBadSessionId(sndReqOpts);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
itAsync('first request is limited by session parameter', async () => {
|
|
121
|
+
const opts = copy(fstReqOpts);
|
|
122
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.firstPutReqUrlEnd(
|
|
123
|
+
{ ver: objV1.version, header: 100, last: true }));
|
|
124
|
+
await expectNonAcceptanceOfLongBody(opts, 'application/octet-stream',
|
|
125
|
+
maxChunkSize+100);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
itAsync('second request is limited by session parameter', async () => {
|
|
129
|
+
const opts = copy(fstReqOpts);
|
|
130
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.firstPutReqUrlEnd(
|
|
131
|
+
{ ver: objV1.version, header: objV1.header.length }));
|
|
132
|
+
const rep = await doBinaryRequest<api.ReplyToPut>(opts, objV1.header);
|
|
133
|
+
const trans = rep.data.transactionId!;
|
|
134
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.secondPutReqUrlEnd(
|
|
135
|
+
{ trans, ofs: 0, last: true }));
|
|
136
|
+
await expectNonAcceptanceOfLongBody(opts, 'application/octet-stream',
|
|
137
|
+
maxChunkSize+100);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const specsForNonDiffSending: SpecDescribe = {
|
|
143
|
+
description: `${description}, non-diff version,`
|
|
144
|
+
};
|
|
145
|
+
specs.push(specsForNonDiffSending);
|
|
146
|
+
specsForNonDiffSending.definition = (setup: () => TestSetup) => (() => {
|
|
147
|
+
|
|
148
|
+
beforeEachAsync(() => setupSession(setup));
|
|
149
|
+
|
|
150
|
+
itAsync(`writes whole object in one request`, async () => {
|
|
151
|
+
expect(await storageServer.currentRootObjExists(user.id)).withContext('initially, there is no object').toBeFalsy();
|
|
152
|
+
|
|
153
|
+
// create object
|
|
154
|
+
const opts = copy(fstReqOpts);
|
|
155
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.firstPutReqUrlEnd({
|
|
156
|
+
ver: objV1.version, header: objV1.header.length, last: true
|
|
157
|
+
}));
|
|
158
|
+
let rep = await doBinaryRequest<api.ReplyToPut>(
|
|
159
|
+
opts, [ objV1.header, objV1.segs ]);
|
|
160
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(api.SC.okPut);
|
|
161
|
+
expect(rep.data.transactionId).toBeUndefined();
|
|
162
|
+
expect(await storageServer.currentRootObjExists(user.id, objV1.version, objV1)).withContext('first version of object is present on the server').toBeTruthy();
|
|
163
|
+
|
|
164
|
+
// upload object's next version
|
|
165
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.firstPutReqUrlEnd({
|
|
166
|
+
ver: objV2.version, header: objV2.header.length, last: true
|
|
167
|
+
}));
|
|
168
|
+
rep = await doBinaryRequest<api.ReplyToPut>(
|
|
169
|
+
opts, [ objV2.header, objV2.segs ]);
|
|
170
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(api.SC.okPut);
|
|
171
|
+
expect(rep.data.transactionId).toBeUndefined();
|
|
172
|
+
expect(await storageServer.currentRootObjExists(user.id, objV2.version, objV2)).withContext('second version of object is present on the server').toBeTruthy();
|
|
173
|
+
expect(await storageServer.rootTransactionExists(user.id)).toBeFalsy();
|
|
174
|
+
|
|
175
|
+
// returns current version, when trying to upload incorrect version,
|
|
176
|
+
// like uploading existing version, or smaller
|
|
177
|
+
const errRep = await doBinaryRequest<api.MismatchedObjVerReply>(opts, [ objV2.header, objV2.segs ]);
|
|
178
|
+
expect(errRep.status).withContext('status for mismatched upload version').toBe(api.SC.mismatchedObjVer);
|
|
179
|
+
expect(errRep.data.current_version).withContext('current object version on server').toBe(objV2.version);
|
|
180
|
+
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
itAsync(`writes object in several requests`, async () => {
|
|
184
|
+
expect(await storageServer.currentRootObjExists(user.id)).withContext('initially, there is no object').toBeFalsy();
|
|
185
|
+
|
|
186
|
+
// first request, to start transmission
|
|
187
|
+
const opts = copy(fstReqOpts);
|
|
188
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.firstPutReqUrlEnd({
|
|
189
|
+
ver: objV1.version, header: objV1.header.length
|
|
190
|
+
}));
|
|
191
|
+
let rep = await doBinaryRequest<api.ReplyToPut>(opts, objV1.header);
|
|
192
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(api.SC.okPut);
|
|
193
|
+
expect(typeof rep.data.transactionId).toBe('string');
|
|
194
|
+
let transactionId = rep.data.transactionId!;
|
|
195
|
+
expect(await storageServer.rootTransactionExists(user.id, transactionId)).withContext(`transaction should be open, cause not all bytes have been sent in the first request`).toBeTruthy();
|
|
196
|
+
expect(await storageServer.currentRootObjExists(user.id, objV1.version)).withContext('upload is not complete, as transaction is not closed').toBeFalsy();
|
|
197
|
+
|
|
198
|
+
// following requests
|
|
199
|
+
for (let offset=0; offset<objV1.segs.length; offset+=512) {
|
|
200
|
+
const last = ((offset + 512) >= objV1.segs.length);
|
|
201
|
+
if (last) {
|
|
202
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.secondPutReqUrlEnd(
|
|
203
|
+
{ trans: transactionId, ofs: offset, last: true }));
|
|
204
|
+
const chunk = objV1.segs.subarray(offset, offset + 512);
|
|
205
|
+
const rep = await doBinaryRequest<api.ReplyToPut>(opts, chunk);
|
|
206
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(api.SC.okPut);
|
|
207
|
+
expect(rep.data.transactionId).toBeUndefined();
|
|
208
|
+
} else {
|
|
209
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.secondPutReqUrlEnd(
|
|
210
|
+
{ trans: transactionId, ofs: offset }));
|
|
211
|
+
const chunk = objV1.segs.subarray(offset, offset + 512);
|
|
212
|
+
const rep = await doBinaryRequest<api.ReplyToPut>(opts, chunk);
|
|
213
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(api.SC.okPut);
|
|
214
|
+
expect(rep.data.transactionId).toBe(transactionId);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
expect(await storageServer.currentRootObjExists(user.id, objV1.version, objV1)).withContext('first version of object is present on the server').toBeTruthy();
|
|
218
|
+
expect(await storageServer.rootTransactionExists(user.id)).toBeFalsy();
|
|
219
|
+
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
const diffVer: Obj = {
|
|
225
|
+
objId: objV1.objId,
|
|
226
|
+
version: objV1.version + 1,
|
|
227
|
+
header: randomBytes(111),
|
|
228
|
+
segs: randomBytes(1000),
|
|
229
|
+
diff: {
|
|
230
|
+
baseVersion: 1,
|
|
231
|
+
segsSize: 1200,
|
|
232
|
+
sections: [
|
|
233
|
+
[ 0, 25, 100 ],
|
|
234
|
+
[ 1, 0, 300 ],
|
|
235
|
+
[ 0, 125, 100 ],
|
|
236
|
+
[ 1, 300, 700 ] ]
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
const specsForDiffTransaction: SpecDescribe = {
|
|
241
|
+
description: `${description}, diff version,`
|
|
242
|
+
};
|
|
243
|
+
specs.push(specsForDiffTransaction);
|
|
244
|
+
specsForDiffTransaction.definition = (setup: () => TestSetup) => (() => {
|
|
245
|
+
|
|
246
|
+
beforeEachAsync(async () => {
|
|
247
|
+
await setupSession(setup);
|
|
248
|
+
// upload first object version
|
|
249
|
+
const opts = copy(fstReqOpts);
|
|
250
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.firstPutReqUrlEnd({
|
|
251
|
+
ver: objV1.version, header: objV1.header.length, last: true
|
|
252
|
+
}));
|
|
253
|
+
await doBinaryRequest<api.ReplyToPut>(opts, [ objV1.header, objV1.segs ]);
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
// XXX can't write general diff-ed object in one request.
|
|
257
|
+
// fitAsync(`writes whole object in one request`, async () => {
|
|
258
|
+
// expect(await storageServer.currentRootObjExists(user.id, objV1.version)).withContext('initially, there is only first version of an object').toBeTruthy();
|
|
259
|
+
|
|
260
|
+
// const diffBytes = utf8.pack(JSON.stringify(diffVer.diff));
|
|
261
|
+
|
|
262
|
+
// // upload object's next version
|
|
263
|
+
// const opts = copy(fstReqOpts);
|
|
264
|
+
// opts.url = resolveUrl(user.storageOwnerUrl, api.firstPutReqUrlEnd(
|
|
265
|
+
// { ver: diffVer.version, diff: diffBytes.length, header: diffVer.header.length, segs: diffVer.segs.length }));
|
|
266
|
+
// const rep = await doBinaryRequest<api.ReplyToPut>(opts, [ diffBytes, diffVer.header, diffVer.segs ]);
|
|
267
|
+
// expect(rep.status).withContext('status for successful writing of segments bytes').toBe(api.SC.okPut);
|
|
268
|
+
// expect(rep.data.transactionId).toBeUndefined();
|
|
269
|
+
// expect(await storageServer.currentRootObjExists(user.id, diffVer.version, diffVer)).withContext('second version of object is present on the server').toBeTruthy();
|
|
270
|
+
|
|
271
|
+
// });
|
|
272
|
+
|
|
273
|
+
itAsync(`writes object in several requests`, async () => {
|
|
274
|
+
expect(await storageServer.currentRootObjExists(user.id, objV1.version)).withContext('initially, there is only first version of an object').toBeTruthy();
|
|
275
|
+
|
|
276
|
+
const diffBytes = utf8.pack(JSON.stringify(diffVer.diff));
|
|
277
|
+
|
|
278
|
+
// first request, to start transmission
|
|
279
|
+
const opts = copy(fstReqOpts);
|
|
280
|
+
opts.url = resolveUrl(user.storageOwnerUrl, api.firstPutReqUrlEnd({
|
|
281
|
+
ver: diffVer.version, diff: diffBytes.length,
|
|
282
|
+
header: diffVer.header.length
|
|
283
|
+
}));
|
|
284
|
+
let rep = await doBinaryRequest<api.ReplyToPut>(opts, [ diffBytes, diffVer.header ]);
|
|
285
|
+
expect(rep.status).toBe(api.SC.okPut, 'status for successful writing of segments bytes');
|
|
286
|
+
expect(typeof rep.data.transactionId).toBe('string');
|
|
287
|
+
let transactionId = rep.data.transactionId!;
|
|
288
|
+
expect(await storageServer.rootTransactionExists(user.id, transactionId)).withContext(`transaction should be open, cause not all bytes have been sent in the first request`).toBeTruthy();
|
|
289
|
+
expect(await storageServer.currentRootObjExists(user.id, diffVer.version)).withContext('upload is not complete, as transaction is not closed').toBeFalsy();
|
|
290
|
+
|
|
291
|
+
// following requests
|
|
292
|
+
let ofs = 0;
|
|
293
|
+
for (let [ isNew, dvOfs, len ] of diffVer.diff!.sections) {
|
|
294
|
+
if (isNew === 0) {
|
|
295
|
+
ofs += len;
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
const last = ((dvOfs + len) >= diffVer.segs.length);
|
|
299
|
+
const delta = 256;
|
|
300
|
+
for (let ofsInSection=0; ofsInSection<len; ofsInSection+=delta) {
|
|
301
|
+
const chunk = diffVer.segs.subarray(
|
|
302
|
+
dvOfs, dvOfs + Math.min(delta, len-ofsInSection));
|
|
303
|
+
if (last && ((ofsInSection+delta) >= len)) {
|
|
304
|
+
opts.url = resolveUrl(user.storageOwnerUrl,
|
|
305
|
+
api.secondPutReqUrlEnd({
|
|
306
|
+
trans: transactionId, ofs, last: true
|
|
307
|
+
}));
|
|
308
|
+
const rep = await doBinaryRequest<api.ReplyToPut>(opts, chunk);
|
|
309
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(api.SC.okPut);
|
|
310
|
+
expect(rep.data.transactionId).toBeUndefined();
|
|
311
|
+
} else {
|
|
312
|
+
opts.url = resolveUrl(user.storageOwnerUrl,
|
|
313
|
+
api.secondPutReqUrlEnd({ trans: transactionId, ofs }));
|
|
314
|
+
const rep = await doBinaryRequest<api.ReplyToPut>(opts, chunk);
|
|
315
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(api.SC.okPut);
|
|
316
|
+
expect(rep.data.transactionId).toBe(transactionId);
|
|
317
|
+
}
|
|
318
|
+
dvOfs += chunk.length;
|
|
319
|
+
ofs += chunk.length;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
expect(await storageServer.currentRootObjExists(user.id, diffVer.version, diffVer)).withContext('diff version of object is present on the server').toBeTruthy();
|
|
323
|
+
expect(await storageServer.rootTransactionExists(user.id)).toBeFalsy();
|
|
324
|
+
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,86 @@
|
|
|
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 { cancelRootTransaction as api, currentRootObj as rootApi } from '../../../../../lib-common/service-api/3nstorage/owner';
|
|
20
|
+
import { beforeAllAsync, itAsync } from '../../../../libs-for-tests/async-jasmine';
|
|
21
|
+
import { RequestOpts, doBodylessRequest, doBinaryRequest } from '../../../../libs-for-tests/xhr-utils';
|
|
22
|
+
import { Obj } from '../../../../libs-for-tests/3nstorage';
|
|
23
|
+
import { expectNonAcceptanceOfBadSessionId, expectNonAcceptanceOfNonEmptyBody } from '../../../../shared-checks/requests';
|
|
24
|
+
import { bytesSync as randomBytes } from '../../../../../lib-common/random-node';
|
|
25
|
+
import { resolve as resolveUrl } from 'url';
|
|
26
|
+
|
|
27
|
+
export const specs: SpecDescribe = {
|
|
28
|
+
description: 'Request to cancel root object transaction'
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const obj: Obj = {
|
|
32
|
+
objId: (null as any),
|
|
33
|
+
version: 1,
|
|
34
|
+
header: randomBytes(100),
|
|
35
|
+
segs: randomBytes(573)
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
specs.definition = (setup: () => TestSetup) => (() => {
|
|
39
|
+
|
|
40
|
+
let reqOpts: RequestOpts
|
|
41
|
+
let storageServer: StorageComponent;
|
|
42
|
+
let user: User;
|
|
43
|
+
let transactionId: string;
|
|
44
|
+
|
|
45
|
+
beforeAllAsync(async () => {
|
|
46
|
+
storageServer = setup().storageServer;
|
|
47
|
+
user = setup().user;
|
|
48
|
+
await storageServer.restartAndClearStorageFor(user.id);
|
|
49
|
+
const sessionId = await startSession(user);
|
|
50
|
+
const fstReqOpts: RequestOpts = {
|
|
51
|
+
url: resolveUrl(user.storageOwnerUrl, rootApi.firstPutReqUrlEnd({
|
|
52
|
+
ver: 1, header: obj.header.length
|
|
53
|
+
})),
|
|
54
|
+
method: 'PUT',
|
|
55
|
+
sessionId
|
|
56
|
+
};
|
|
57
|
+
const fstRep = await doBinaryRequest<rootApi.ReplyToPut>(
|
|
58
|
+
fstReqOpts, obj.header);
|
|
59
|
+
transactionId = fstRep.data.transactionId!;
|
|
60
|
+
reqOpts = {
|
|
61
|
+
url: resolveUrl(user.storageOwnerUrl, api.getReqUrlEnd(transactionId)),
|
|
62
|
+
method: 'POST',
|
|
63
|
+
sessionId
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
itAsync('cancels root object transaction', async () => {
|
|
68
|
+
expect(await storageServer.currentRootObjExists(user.id)).withContext('initially, there is no root object').toBeFalsy();
|
|
69
|
+
expect(await storageServer.rootTransactionExists(user.id)).withContext('initially, there is a started transaction').toBeTruthy();
|
|
70
|
+
|
|
71
|
+
const rep = await doBodylessRequest<void>(reqOpts);
|
|
72
|
+
expect(rep.status).withContext('status for normal transaction cancelation').toBe(api.SC.ok);
|
|
73
|
+
expect(await storageServer.rootTransactionExists(user.id)).withContext('transaction should not exist, as it has been cancelled.').toBeFalsy();
|
|
74
|
+
expect(await storageServer.currentRootObjExists(user.id, 1, obj)).withContext('object is not created, cause transaction has been cancelled').toBeFalsy();
|
|
75
|
+
|
|
76
|
+
// XXX split out fuzzing requests
|
|
77
|
+
|
|
78
|
+
await expectNonAcceptanceOfNonEmptyBody(reqOpts);
|
|
79
|
+
|
|
80
|
+
await expectNonAcceptanceOfBadSessionId(reqOpts);
|
|
81
|
+
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// XXX add cancelation with unknown transaction id (repeat request)
|
|
85
|
+
|
|
86
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
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 { cancelTransaction as api, currentObj as objApi } from '../../../../../lib-common/service-api/3nstorage/owner';
|
|
20
|
+
import { beforeAllAsync, itAsync } from '../../../../libs-for-tests/async-jasmine';
|
|
21
|
+
import { RequestOpts, doBodylessRequest, doBinaryRequest } from '../../../../libs-for-tests/xhr-utils';
|
|
22
|
+
import { Obj } from '../../../../libs-for-tests/3nstorage';
|
|
23
|
+
import { expectNonAcceptanceOfBadSessionId, expectNonAcceptanceOfNonEmptyBody } from '../../../../shared-checks/requests';
|
|
24
|
+
import { bytesSync as randomBytes } from '../../../../../lib-common/random-node';
|
|
25
|
+
import { resolve as resolveUrl } from 'url';
|
|
26
|
+
|
|
27
|
+
export const specs: SpecDescribe = {
|
|
28
|
+
description: 'Request to cancel non-root object transaction'
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const obj: Obj = {
|
|
32
|
+
objId: 'aaaa',
|
|
33
|
+
version: 1,
|
|
34
|
+
header: randomBytes(100),
|
|
35
|
+
segs: randomBytes(573)
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
specs.definition = (setup: () => TestSetup) => (() => {
|
|
39
|
+
|
|
40
|
+
let reqOpts: RequestOpts
|
|
41
|
+
let storageServer: StorageComponent;
|
|
42
|
+
let user: User;
|
|
43
|
+
let transactionId: string;
|
|
44
|
+
|
|
45
|
+
beforeAllAsync(async () => {
|
|
46
|
+
storageServer = setup().storageServer;
|
|
47
|
+
user = setup().user;
|
|
48
|
+
await storageServer.restartAndClearStorageFor(user.id);
|
|
49
|
+
const sessionId = await startSession(user);
|
|
50
|
+
const fstReqOpts: RequestOpts = {
|
|
51
|
+
url: resolveUrl(user.storageOwnerUrl, objApi.firstPutReqUrlEnd(
|
|
52
|
+
obj.objId, { ver: 1, header: obj.header.length })),
|
|
53
|
+
method: 'PUT',
|
|
54
|
+
sessionId
|
|
55
|
+
};
|
|
56
|
+
const fstRep = await doBinaryRequest<objApi.ReplyToPut>(
|
|
57
|
+
fstReqOpts, obj.header);
|
|
58
|
+
transactionId = fstRep.data.transactionId!;
|
|
59
|
+
reqOpts = {
|
|
60
|
+
url: resolveUrl(user.storageOwnerUrl, api.getReqUrlEnd(obj.objId, transactionId)),
|
|
61
|
+
method: 'POST',
|
|
62
|
+
sessionId: sessionId
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
itAsync('cancels object transaction', async () => {
|
|
67
|
+
expect(await storageServer.currentObjExists(user.id, obj.objId)).withContext('initially, there is no object').toBeFalsy();
|
|
68
|
+
expect(await storageServer.transactionExists(user.id, obj.objId)).withContext('initially, there is a started transaction').toBeTruthy();
|
|
69
|
+
|
|
70
|
+
// normal reply
|
|
71
|
+
const rep = await doBodylessRequest<void>(reqOpts);
|
|
72
|
+
expect(rep.status).withContext('status for normal transaction completion').toBe(api.SC.ok);
|
|
73
|
+
expect(await storageServer.transactionExists(user.id, obj.objId)).withContext('transaction should not be present, as it has been completed').toBeFalsy();
|
|
74
|
+
expect(await storageServer.currentObjExists(user.id, obj.objId, 1, obj)).withContext('object is not created, cause transaction has been cancelled').toBeFalsy();
|
|
75
|
+
|
|
76
|
+
// XXX split out fuzzing requests
|
|
77
|
+
|
|
78
|
+
await expectNonAcceptanceOfNonEmptyBody(reqOpts);
|
|
79
|
+
|
|
80
|
+
await expectNonAcceptanceOfBadSessionId(reqOpts);
|
|
81
|
+
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// XXX add cancelation with unknown object id, and unknown transaction id
|
|
85
|
+
|
|
86
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2016, 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 { User, doMailerIdLogin } from '../../../libs-for-tests/mailerid';
|
|
19
|
+
import { resolve as resolveUrl } from 'url';
|
|
20
|
+
import * as api from '../../../../lib-common/service-api/3nstorage/owner';
|
|
21
|
+
import { StorageComponent } from '../../../libs-for-tests/server-components/3nstorage';
|
|
22
|
+
import { GenericSpecDescribe } from '../../../libs-for-tests/spec-assembly';
|
|
23
|
+
import { doBodylessRequest } from '../../../libs-for-tests/xhr-utils';
|
|
24
|
+
import { assert } from '../../../libs-for-tests/assert';
|
|
25
|
+
|
|
26
|
+
export { User } from '../../../libs-for-tests/mailerid';
|
|
27
|
+
export { StorageComponent } from '../../../libs-for-tests/server-components/3nstorage';
|
|
28
|
+
|
|
29
|
+
export interface TestSetup {
|
|
30
|
+
user: User;
|
|
31
|
+
storageServer: StorageComponent;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type SpecDescribe = GenericSpecDescribe<TestSetup>;
|
|
35
|
+
|
|
36
|
+
export async function startSession(user: User): Promise<string> {
|
|
37
|
+
return await doMailerIdLogin(
|
|
38
|
+
resolveUrl(user.storageOwnerUrl, api.midLogin.URL_PART),
|
|
39
|
+
user
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function getObjStatus(
|
|
44
|
+
user: User, objId: string|null, sessionId: string
|
|
45
|
+
): Promise<api.ObjStatus> {
|
|
46
|
+
const rep = await doBodylessRequest<api.ObjStatus>({
|
|
47
|
+
url: resolveUrl(user.storageOwnerUrl, (objId ?
|
|
48
|
+
api.objStatus.getReqUrlEnd(objId) : api.rootStatus.getReqUrlEnd())
|
|
49
|
+
),
|
|
50
|
+
method: 'GET',
|
|
51
|
+
sessionId,
|
|
52
|
+
responseType: 'json'
|
|
53
|
+
});
|
|
54
|
+
assert(rep.status === api.objStatus.SC.ok, `Unexpected status ${rep.status} with data ${rep.data}, when listing archived versions of object ${objId}`);
|
|
55
|
+
return rep.data;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export async function archiveObjVer(
|
|
59
|
+
user: User, objId: string|null, version: number, sessionId: string
|
|
60
|
+
): Promise<void> {
|
|
61
|
+
const rep = await doBodylessRequest<void>({
|
|
62
|
+
url: resolveUrl(user.storageOwnerUrl, (objId ?
|
|
63
|
+
api.archiveObj.postAndDelReqUrlEnd(objId, version) :
|
|
64
|
+
api.archiveRoot.postAndDelReqUrlEnd(version))),
|
|
65
|
+
method: 'POST',
|
|
66
|
+
sessionId
|
|
67
|
+
});
|
|
68
|
+
assert(rep.status === api.archiveObj.SC.okPost, `Unexpected status ${rep.status} with data ${rep.data}, when archiving version ${version} of object ${objId}`);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
Object.freeze(exports);
|