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,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2022 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.specs = void 0;
|
|
20
|
+
const test_utils_1 = require("../test-utils");
|
|
21
|
+
const owner_1 = require("../../../../../lib-common/service-api/3nstorage/owner");
|
|
22
|
+
const async_jasmine_1 = require("../../../../libs-for-tests/async-jasmine");
|
|
23
|
+
const xhr_utils_1 = require("../../../../libs-for-tests/xhr-utils");
|
|
24
|
+
const _3nstorage_1 = require("../../../../libs-for-tests/3nstorage");
|
|
25
|
+
const requests_1 = require("../../../../shared-checks/requests");
|
|
26
|
+
const random_node_1 = require("../../../../../lib-common/random-node");
|
|
27
|
+
const url_1 = require("url");
|
|
28
|
+
const json_copy_1 = require("../../../../libs-for-tests/json-copy");
|
|
29
|
+
exports.specs = {
|
|
30
|
+
description: `Request to list object's archived versions`
|
|
31
|
+
};
|
|
32
|
+
const obj = {
|
|
33
|
+
objId: null,
|
|
34
|
+
version: 1,
|
|
35
|
+
header: (0, random_node_1.bytesSync)(100),
|
|
36
|
+
segs: (0, random_node_1.bytesSync)(573)
|
|
37
|
+
};
|
|
38
|
+
exports.specs.definition = (setup) => (() => {
|
|
39
|
+
let reqOpts;
|
|
40
|
+
let storageServer;
|
|
41
|
+
let user;
|
|
42
|
+
let sessionId;
|
|
43
|
+
(0, async_jasmine_1.beforeAllAsync)(async () => {
|
|
44
|
+
storageServer = setup().storageServer;
|
|
45
|
+
user = setup().user;
|
|
46
|
+
await storageServer.restartAndClearStorageFor(user.id);
|
|
47
|
+
sessionId = await (0, test_utils_1.startSession)(user);
|
|
48
|
+
reqOpts = {
|
|
49
|
+
url: (0, url_1.resolve)(user.storageOwnerUrl, owner_1.rootStatus.getReqUrlEnd()),
|
|
50
|
+
method: 'GET',
|
|
51
|
+
responseType: 'json',
|
|
52
|
+
sessionId
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
(0, async_jasmine_1.itAsync)('will not work outside of a valid session', async () => {
|
|
56
|
+
const opts = (0, json_copy_1.copy)(reqOpts);
|
|
57
|
+
await (0, requests_1.expectNonAcceptanceOfBadSessionId)(opts);
|
|
58
|
+
});
|
|
59
|
+
(0, async_jasmine_1.itAsync)(`shows obj status with versions' info`, async () => {
|
|
60
|
+
await (0, _3nstorage_1.saveObj)(user.storageOwnerUrl, sessionId, obj.objId, 1, obj);
|
|
61
|
+
let rep = await (0, xhr_utils_1.doBodylessRequest)(reqOpts);
|
|
62
|
+
expect(rep.status).toBe(owner_1.rootStatus.SC.ok);
|
|
63
|
+
expect(rep.data.current).toBe(1);
|
|
64
|
+
expect(rep.data.archived).toBeUndefined();
|
|
65
|
+
await (0, test_utils_1.archiveObjVer)(user, obj.objId, 1, sessionId);
|
|
66
|
+
rep = await (0, xhr_utils_1.doBodylessRequest)(reqOpts);
|
|
67
|
+
expect(rep.status).toBe(owner_1.rootStatus.SC.ok);
|
|
68
|
+
expect(rep.data.current).toBe(1);
|
|
69
|
+
expect(rep.data.archived).toContain(1);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2017, 2025 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.specs = void 0;
|
|
20
|
+
const test_utils_1 = require("../test-utils");
|
|
21
|
+
const owner_1 = require("../../../../../lib-common/service-api/3nstorage/owner");
|
|
22
|
+
const async_jasmine_1 = require("../../../../libs-for-tests/async-jasmine");
|
|
23
|
+
const xhr_utils_1 = require("../../../../libs-for-tests/xhr-utils");
|
|
24
|
+
const _3nstorage_1 = require("../../../../libs-for-tests/3nstorage");
|
|
25
|
+
const requests_1 = require("../../../../shared-checks/requests");
|
|
26
|
+
const random_node_1 = require("../../../../../lib-common/random-node");
|
|
27
|
+
const buffer_utils_1 = require("../../../../../lib-common/buffer-utils");
|
|
28
|
+
const url_1 = require("url");
|
|
29
|
+
const json_copy_1 = require("../../../../libs-for-tests/json-copy");
|
|
30
|
+
exports.specs = [];
|
|
31
|
+
const description = `Request to save non-root object`;
|
|
32
|
+
const objV1 = {
|
|
33
|
+
objId: 'aaaa',
|
|
34
|
+
version: 1,
|
|
35
|
+
header: (0, random_node_1.bytesSync)(100),
|
|
36
|
+
segs: (0, random_node_1.bytesSync)(2345)
|
|
37
|
+
};
|
|
38
|
+
const objV2 = {
|
|
39
|
+
objId: objV1.objId,
|
|
40
|
+
version: objV1.version + 1,
|
|
41
|
+
header: (0, random_node_1.bytesSync)(110),
|
|
42
|
+
segs: (0, random_node_1.bytesSync)(6543)
|
|
43
|
+
};
|
|
44
|
+
let fstReqOpts;
|
|
45
|
+
let sndReqOpts;
|
|
46
|
+
let storageServer;
|
|
47
|
+
let user;
|
|
48
|
+
let sessionId;
|
|
49
|
+
async function setupSession(setup) {
|
|
50
|
+
storageServer = setup().storageServer;
|
|
51
|
+
user = setup().user;
|
|
52
|
+
await storageServer.restartAndClearStorageFor(user.id);
|
|
53
|
+
sessionId = await (0, test_utils_1.startSession)(user);
|
|
54
|
+
fstReqOpts = {
|
|
55
|
+
url: (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentObj.firstPutReqUrlEnd(objV1.objId, { ver: 1, header: objV1.header.length })),
|
|
56
|
+
method: 'PUT',
|
|
57
|
+
responseType: 'json',
|
|
58
|
+
sessionId
|
|
59
|
+
};
|
|
60
|
+
sndReqOpts = {
|
|
61
|
+
url: (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentObj.secondPutReqUrlEnd(objV1.objId, { trans: 'some-trans', ofs: 0 })),
|
|
62
|
+
method: 'PUT',
|
|
63
|
+
responseType: 'json',
|
|
64
|
+
sessionId
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const fuzzingSpec = { description };
|
|
68
|
+
exports.specs.push(fuzzingSpec);
|
|
69
|
+
fuzzingSpec.definition = (setup) => (() => {
|
|
70
|
+
let maxChunkSize;
|
|
71
|
+
(0, async_jasmine_1.beforeEachAsync)(async () => {
|
|
72
|
+
await setupSession(setup);
|
|
73
|
+
const params = await (0, _3nstorage_1.getSessionParams)(user.storageOwnerUrl, sessionId);
|
|
74
|
+
maxChunkSize = params.maxChunkSize;
|
|
75
|
+
});
|
|
76
|
+
(0, async_jasmine_1.itAsync)('fails for object id not from bas64 url-safe alphabet', async () => {
|
|
77
|
+
const opts = (0, json_copy_1.copy)(fstReqOpts);
|
|
78
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentObj.firstPutReqUrlEnd('unknown+obj', { ver: 1, header: objV1.header.length, last: true }));
|
|
79
|
+
const rep = await (0, xhr_utils_1.doBinaryRequest)(opts, [objV1.header, objV1.segs]);
|
|
80
|
+
expect(rep.status).withContext('status for but object id').toBe(owner_1.ERR_SC.malformed);
|
|
81
|
+
});
|
|
82
|
+
(0, async_jasmine_1.itAsync)('fails write for incorrect version', async () => {
|
|
83
|
+
await (0, _3nstorage_1.saveObj)(user.storageOwnerUrl, sessionId, objV1.objId, objV1.version, objV1);
|
|
84
|
+
const opts = (0, json_copy_1.copy)(fstReqOpts);
|
|
85
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentObj.firstPutReqUrlEnd(objV1.objId, {
|
|
86
|
+
ver: objV1.version + 5, header: objV1.header.length, last: true
|
|
87
|
+
}));
|
|
88
|
+
const rep = await (0, xhr_utils_1.doBinaryRequest)(opts, [objV1.header, objV1.segs]);
|
|
89
|
+
expect(rep.status).toBe(owner_1.currentObj.SC.mismatchedObjVer);
|
|
90
|
+
expect(typeof rep.data).toBe('object');
|
|
91
|
+
expect(rep.data.current_version).toBe(objV1.version);
|
|
92
|
+
});
|
|
93
|
+
(0, async_jasmine_1.itAsync)('fails for unknown object, without create flag', async () => {
|
|
94
|
+
const opts = (0, json_copy_1.copy)(fstReqOpts);
|
|
95
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentObj.firstPutReqUrlEnd('unknown-obj', { ver: 67, header: objV1.header.length, last: true }));
|
|
96
|
+
const rep = await (0, xhr_utils_1.doBinaryRequest)(opts, [objV1.header, objV1.segs]);
|
|
97
|
+
expect(rep.status).withContext('status for unknown object').toBe(owner_1.currentObj.SC.unknownObj);
|
|
98
|
+
});
|
|
99
|
+
(0, async_jasmine_1.itAsync)('fails for unknown object, in secondary put request', async () => {
|
|
100
|
+
const opts = (0, json_copy_1.copy)(sndReqOpts);
|
|
101
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentObj.secondPutReqUrlEnd('unknown-obj', { trans: 'some-trans', ofs: 0 }));
|
|
102
|
+
const rep = await (0, xhr_utils_1.doBinaryRequest)(opts, objV1.segs);
|
|
103
|
+
expect(rep.status).withContext('status for unknown object').toBe(owner_1.currentObj.SC.unknownObj);
|
|
104
|
+
});
|
|
105
|
+
(0, async_jasmine_1.itAsync)('fails for incorrect transaction, in secondary put', async () => {
|
|
106
|
+
const repToFstReq = await (0, xhr_utils_1.doBinaryRequest)(fstReqOpts, objV1.header);
|
|
107
|
+
expect(repToFstReq.status).toBe(owner_1.currentObj.SC.okPut);
|
|
108
|
+
const trans = repToFstReq.data.transactionId + ' - unknown';
|
|
109
|
+
const opts = (0, json_copy_1.copy)(sndReqOpts);
|
|
110
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentObj.secondPutReqUrlEnd(objV1.objId, { trans, ofs: 0 }));
|
|
111
|
+
const rep = await (0, xhr_utils_1.doBinaryRequest)(opts, objV1.segs);
|
|
112
|
+
expect(rep.status).withContext('status for unknown transaction').toBe(owner_1.currentObj.SC.unknownTransaction);
|
|
113
|
+
});
|
|
114
|
+
(0, async_jasmine_1.itAsync)('will not accept bad type', async () => {
|
|
115
|
+
await (0, requests_1.expectNonAcceptanceOfBadType)(fstReqOpts, 'application/octet-stream', objV1.segs);
|
|
116
|
+
await (0, requests_1.expectNonAcceptanceOfBadType)(sndReqOpts, 'application/octet-stream', objV1.segs);
|
|
117
|
+
});
|
|
118
|
+
(0, async_jasmine_1.itAsync)('will not work outside of a valid session', async () => {
|
|
119
|
+
await (0, requests_1.expectNonAcceptanceOfBadSessionId)(fstReqOpts);
|
|
120
|
+
await (0, requests_1.expectNonAcceptanceOfBadSessionId)(sndReqOpts);
|
|
121
|
+
});
|
|
122
|
+
(0, async_jasmine_1.itAsync)('first request is limited by session parameter', async () => {
|
|
123
|
+
const opts = (0, json_copy_1.copy)(fstReqOpts);
|
|
124
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentObj.firstPutReqUrlEnd(objV1.objId, { ver: objV1.version, header: 100, last: true }));
|
|
125
|
+
await (0, requests_1.expectNonAcceptanceOfLongBody)(opts, 'application/octet-stream', maxChunkSize + 100);
|
|
126
|
+
});
|
|
127
|
+
(0, async_jasmine_1.itAsync)('second request is limited by session parameter', async () => {
|
|
128
|
+
const opts = (0, json_copy_1.copy)(fstReqOpts);
|
|
129
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentObj.firstPutReqUrlEnd(objV1.objId, { ver: objV1.version, header: objV1.header.length }));
|
|
130
|
+
const rep = await (0, xhr_utils_1.doBinaryRequest)(opts, objV1.header);
|
|
131
|
+
const trans = rep.data.transactionId;
|
|
132
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentObj.secondPutReqUrlEnd(objV1.objId, { trans, ofs: 0, last: true }));
|
|
133
|
+
await (0, requests_1.expectNonAcceptanceOfLongBody)(opts, 'application/octet-stream', maxChunkSize + 100);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
const specsForNonDiffSending = {
|
|
137
|
+
description: `${description}, non-diff version,`
|
|
138
|
+
};
|
|
139
|
+
exports.specs.push(specsForNonDiffSending);
|
|
140
|
+
specsForNonDiffSending.definition = (setup) => (() => {
|
|
141
|
+
(0, async_jasmine_1.beforeEachAsync)(() => setupSession(setup));
|
|
142
|
+
(0, async_jasmine_1.itAsync)(`writes whole object in one request`, async () => {
|
|
143
|
+
expect(await storageServer.currentObjExists(user.id, objV1.objId)).withContext('initially, there is no object').toBeFalsy();
|
|
144
|
+
// create object
|
|
145
|
+
const opts = (0, json_copy_1.copy)(fstReqOpts);
|
|
146
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentObj.firstPutReqUrlEnd(objV1.objId, {
|
|
147
|
+
ver: objV1.version, header: objV1.header.length, last: true
|
|
148
|
+
}));
|
|
149
|
+
let rep = await (0, xhr_utils_1.doBinaryRequest)(opts, [objV1.header, objV1.segs]);
|
|
150
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(owner_1.currentObj.SC.okPut);
|
|
151
|
+
expect(rep.data.transactionId).toBeUndefined();
|
|
152
|
+
expect(await storageServer.currentObjExists(user.id, objV1.objId, objV1.version, objV1)).withContext('first version of object is present on the server').toBeTruthy();
|
|
153
|
+
// upload object's next version
|
|
154
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentObj.firstPutReqUrlEnd(objV2.objId, { ver: objV2.version, header: objV2.header.length, last: true }));
|
|
155
|
+
rep = await (0, xhr_utils_1.doBinaryRequest)(opts, [objV2.header, objV2.segs]);
|
|
156
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(owner_1.currentObj.SC.okPut);
|
|
157
|
+
expect(rep.data.transactionId).toBeUndefined();
|
|
158
|
+
expect(await storageServer.currentObjExists(user.id, objV2.objId, objV2.version, objV2)).withContext('second version of object is present on the server').toBeTruthy();
|
|
159
|
+
expect(await storageServer.transactionExists(user.id, objV2.objId)).toBeFalsy();
|
|
160
|
+
// returns current version, when trying to upload incorrect version,
|
|
161
|
+
// like uploading existing version, or smaller
|
|
162
|
+
const errRep = await (0, xhr_utils_1.doBinaryRequest)(opts, [objV2.header, objV2.segs]);
|
|
163
|
+
expect(errRep.status).withContext('status for mismatched upload version').toBe(owner_1.currentObj.SC.mismatchedObjVer);
|
|
164
|
+
expect(errRep.data.current_version).withContext('current object version on server').toBe(objV2.version);
|
|
165
|
+
});
|
|
166
|
+
(0, async_jasmine_1.itAsync)(`writes object in several requests`, async () => {
|
|
167
|
+
expect(await storageServer.currentObjExists(user.id, objV1.objId)).withContext('initially, there is no object').toBeFalsy();
|
|
168
|
+
// create object
|
|
169
|
+
// first request, to start transmission
|
|
170
|
+
const opts = (0, json_copy_1.copy)(fstReqOpts);
|
|
171
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentObj.firstPutReqUrlEnd(objV1.objId, { ver: objV1.version, header: objV1.header.length }));
|
|
172
|
+
let rep = await (0, xhr_utils_1.doBinaryRequest)(opts, objV1.header);
|
|
173
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(owner_1.currentObj.SC.okPut);
|
|
174
|
+
expect(typeof rep.data.transactionId).toBe('string');
|
|
175
|
+
let transactionId = rep.data.transactionId;
|
|
176
|
+
expect(await storageServer.transactionExists(user.id, objV1.objId, transactionId)).withContext(`transaction should be open, cause not all bytes have been sent in the first request`).toBeTruthy();
|
|
177
|
+
expect(await storageServer.currentObjExists(user.id, objV1.objId, objV1.version)).withContext('upload is not complete, as transaction is not closed').toBeFalsy();
|
|
178
|
+
// following requests
|
|
179
|
+
for (let offset = 0; offset < objV1.segs.length; offset += 512) {
|
|
180
|
+
const last = ((offset + 512) >= objV1.segs.length);
|
|
181
|
+
if (last) {
|
|
182
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentObj.secondPutReqUrlEnd(objV1.objId, { trans: transactionId, ofs: offset, last: true }));
|
|
183
|
+
const chunk = objV1.segs.subarray(offset, offset + 512);
|
|
184
|
+
const rep = await (0, xhr_utils_1.doBinaryRequest)(opts, chunk);
|
|
185
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(owner_1.currentObj.SC.okPut);
|
|
186
|
+
expect(rep.data.transactionId).toBeUndefined();
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentObj.secondPutReqUrlEnd(objV1.objId, { trans: transactionId, ofs: offset }));
|
|
190
|
+
const chunk = objV1.segs.subarray(offset, offset + 512);
|
|
191
|
+
const rep = await (0, xhr_utils_1.doBinaryRequest)(opts, chunk);
|
|
192
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(owner_1.currentObj.SC.okPut);
|
|
193
|
+
expect(rep.data.transactionId).toBe(transactionId);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
expect(await storageServer.currentObjExists(user.id, objV1.objId, objV1.version, objV1)).withContext('first version of object is present on the server').toBeTruthy();
|
|
197
|
+
expect(await storageServer.transactionExists(user.id, objV1.objId)).toBeFalsy();
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
const diffVer = {
|
|
201
|
+
objId: objV1.objId,
|
|
202
|
+
version: objV1.version + 1,
|
|
203
|
+
header: (0, random_node_1.bytesSync)(111),
|
|
204
|
+
segs: (0, random_node_1.bytesSync)(1000),
|
|
205
|
+
diff: {
|
|
206
|
+
baseVersion: 1,
|
|
207
|
+
segsSize: 1200,
|
|
208
|
+
sections: [
|
|
209
|
+
[0, 25, 100],
|
|
210
|
+
[1, 0, 300],
|
|
211
|
+
[0, 125, 100],
|
|
212
|
+
[1, 300, 700]
|
|
213
|
+
]
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
const specsForDiffTransaction = {
|
|
217
|
+
description: `${description}, diff version,`
|
|
218
|
+
};
|
|
219
|
+
exports.specs.push(specsForDiffTransaction);
|
|
220
|
+
specsForDiffTransaction.definition = (setup) => (() => {
|
|
221
|
+
(0, async_jasmine_1.beforeEachAsync)(async () => {
|
|
222
|
+
await setupSession(setup);
|
|
223
|
+
// upload first object version
|
|
224
|
+
const opts = (0, json_copy_1.copy)(fstReqOpts);
|
|
225
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentObj.firstPutReqUrlEnd(objV1.objId, {
|
|
226
|
+
ver: objV1.version, header: objV1.header.length, last: true
|
|
227
|
+
}));
|
|
228
|
+
await (0, xhr_utils_1.doBinaryRequest)(opts, [objV1.header, objV1.segs]);
|
|
229
|
+
});
|
|
230
|
+
// XXX can't write general diff-ed object in one request.
|
|
231
|
+
// itAsync(`writes whole object in one request`, async () => {
|
|
232
|
+
// expect(await storageServer.currentObjExists(user.id, objV1.objId, objV1.version)).withContext('initially, there is only first version of an object').toBeTruthy();
|
|
233
|
+
// const diffBytes = utf8.pack(JSON.stringify(diffVer.diff));
|
|
234
|
+
// // upload object's next version
|
|
235
|
+
// const opts = copy(fstReqOpts);
|
|
236
|
+
// opts.url = resolveUrl(user.storageOwnerUrl, api.firstPutReqUrlEnd(
|
|
237
|
+
// diffVer.objId,
|
|
238
|
+
// { ver: diffVer.version, diff: diffBytes.length, header: diffVer.header.length, segs: diffVer.segs.length }));
|
|
239
|
+
// const rep = await doBinaryRequest<api.ReplyToPut>(opts, [ diffBytes, diffVer.header, diffVer.segs ]);
|
|
240
|
+
// expect(rep.status).withContext('status for successful writing of segments bytes').toBe(api.SC.okPut);
|
|
241
|
+
// expect(rep.data.transactionId).toBeUndefined();
|
|
242
|
+
// expect(await storageServer.currentObjExists(user.id, diffVer.objId, diffVer.version, diffVer)).withContext('second version of object is present on the server').toBeTruthy();
|
|
243
|
+
// });
|
|
244
|
+
(0, async_jasmine_1.itAsync)(`writes object in several requests`, async () => {
|
|
245
|
+
expect(await storageServer.currentObjExists(user.id, objV1.objId, objV1.version)).withContext('initially, there is only first version of an object').toBeTruthy();
|
|
246
|
+
const diffBytes = buffer_utils_1.utf8.pack(JSON.stringify(diffVer.diff));
|
|
247
|
+
// first request, to start transmission
|
|
248
|
+
const opts = (0, json_copy_1.copy)(fstReqOpts);
|
|
249
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentObj.firstPutReqUrlEnd(diffVer.objId, { ver: diffVer.version, diff: diffBytes.length, header: diffVer.header.length }));
|
|
250
|
+
let rep = await (0, xhr_utils_1.doBinaryRequest)(opts, [diffBytes, diffVer.header]);
|
|
251
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(owner_1.currentObj.SC.okPut);
|
|
252
|
+
expect(typeof rep.data.transactionId).toBe('string');
|
|
253
|
+
let transactionId = rep.data.transactionId;
|
|
254
|
+
expect(await storageServer.transactionExists(user.id, diffVer.objId, transactionId)).withContext(`transaction should be open, cause not all bytes have been sent in the first request`).toBeTruthy();
|
|
255
|
+
expect(await storageServer.currentObjExists(user.id, diffVer.objId, diffVer.version)).withContext('upload is not complete, as transaction is not closed').toBeFalsy();
|
|
256
|
+
// following requests
|
|
257
|
+
let ofs = 0;
|
|
258
|
+
for (let [isNew, dvOfs, len] of diffVer.diff.sections) {
|
|
259
|
+
if (isNew === 0) {
|
|
260
|
+
ofs += len;
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
const last = ((dvOfs + len) >= diffVer.segs.length);
|
|
264
|
+
const delta = 256;
|
|
265
|
+
for (let ofsInSection = 0; ofsInSection < len; ofsInSection += delta) {
|
|
266
|
+
const chunk = diffVer.segs.subarray(dvOfs, dvOfs + Math.min(delta, len - ofsInSection));
|
|
267
|
+
if (last && ((ofsInSection + delta) >= len)) {
|
|
268
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentObj.secondPutReqUrlEnd(diffVer.objId, { trans: transactionId, ofs, last: true }));
|
|
269
|
+
const rep = await (0, xhr_utils_1.doBinaryRequest)(opts, chunk);
|
|
270
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(owner_1.currentObj.SC.okPut);
|
|
271
|
+
expect(rep.data.transactionId).toBeUndefined();
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentObj.secondPutReqUrlEnd(diffVer.objId, { trans: transactionId, ofs }));
|
|
275
|
+
const rep = await (0, xhr_utils_1.doBinaryRequest)(opts, chunk);
|
|
276
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(owner_1.currentObj.SC.okPut);
|
|
277
|
+
expect(rep.data.transactionId).toBe(transactionId);
|
|
278
|
+
}
|
|
279
|
+
dvOfs += chunk.length;
|
|
280
|
+
ofs += chunk.length;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
expect(await storageServer.currentObjExists(user.id, diffVer.objId, diffVer.version, diffVer)).withContext('diff version of object is present on the server').toBeTruthy();
|
|
284
|
+
expect(await storageServer.transactionExists(user.id, diffVer.objId, transactionId)).toBeFalsy();
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2017, 2019, 2025 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.specs = void 0;
|
|
20
|
+
const test_utils_1 = require("../test-utils");
|
|
21
|
+
const owner_1 = require("../../../../../lib-common/service-api/3nstorage/owner");
|
|
22
|
+
const async_jasmine_1 = require("../../../../libs-for-tests/async-jasmine");
|
|
23
|
+
const xhr_utils_1 = require("../../../../libs-for-tests/xhr-utils");
|
|
24
|
+
const _3nstorage_1 = require("../../../../libs-for-tests/3nstorage");
|
|
25
|
+
const requests_1 = require("../../../../shared-checks/requests");
|
|
26
|
+
const random_node_1 = require("../../../../../lib-common/random-node");
|
|
27
|
+
const buffer_utils_1 = require("../../../../../lib-common/buffer-utils");
|
|
28
|
+
const url_1 = require("url");
|
|
29
|
+
const json_copy_1 = require("../../../../libs-for-tests/json-copy");
|
|
30
|
+
exports.specs = [];
|
|
31
|
+
const description = `Request to save root object`;
|
|
32
|
+
const objV1 = {
|
|
33
|
+
objId: 'aaaa',
|
|
34
|
+
version: 1,
|
|
35
|
+
header: (0, random_node_1.bytesSync)(100),
|
|
36
|
+
segs: (0, random_node_1.bytesSync)(2345)
|
|
37
|
+
};
|
|
38
|
+
const objV2 = {
|
|
39
|
+
objId: objV1.objId,
|
|
40
|
+
version: objV1.version + 1,
|
|
41
|
+
header: (0, random_node_1.bytesSync)(110),
|
|
42
|
+
segs: (0, random_node_1.bytesSync)(6543)
|
|
43
|
+
};
|
|
44
|
+
let fstReqOpts;
|
|
45
|
+
let sndReqOpts;
|
|
46
|
+
let storageServer;
|
|
47
|
+
let user;
|
|
48
|
+
let sessionId;
|
|
49
|
+
async function setupSession(setup) {
|
|
50
|
+
storageServer = setup().storageServer;
|
|
51
|
+
user = setup().user;
|
|
52
|
+
await storageServer.restartAndClearStorageFor(user.id);
|
|
53
|
+
sessionId = await (0, test_utils_1.startSession)(user);
|
|
54
|
+
fstReqOpts = {
|
|
55
|
+
url: (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentRootObj.firstPutReqUrlEnd({ ver: 1, header: objV1.header.length })),
|
|
56
|
+
method: 'PUT',
|
|
57
|
+
responseType: 'json',
|
|
58
|
+
sessionId
|
|
59
|
+
};
|
|
60
|
+
sndReqOpts = {
|
|
61
|
+
url: (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentRootObj.secondPutReqUrlEnd({ trans: 'some-trans', ofs: 0 })),
|
|
62
|
+
method: 'PUT',
|
|
63
|
+
responseType: 'json',
|
|
64
|
+
sessionId
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const fuzzingSpec = { description };
|
|
68
|
+
exports.specs.push(fuzzingSpec);
|
|
69
|
+
fuzzingSpec.definition = (setup) => (() => {
|
|
70
|
+
let maxChunkSize;
|
|
71
|
+
(0, async_jasmine_1.beforeEachAsync)(async () => {
|
|
72
|
+
await setupSession(setup);
|
|
73
|
+
const params = await (0, _3nstorage_1.getSessionParams)(user.storageOwnerUrl, sessionId);
|
|
74
|
+
maxChunkSize = params.maxChunkSize;
|
|
75
|
+
});
|
|
76
|
+
(0, async_jasmine_1.itAsync)('fails for incorrect transaction, in secondary put', async () => {
|
|
77
|
+
const repToFstReq = await (0, xhr_utils_1.doBinaryRequest)(fstReqOpts, objV1.header);
|
|
78
|
+
expect(repToFstReq.status).toBe(owner_1.currentRootObj.SC.okPut);
|
|
79
|
+
const trans = repToFstReq.data.transactionId + ' - unknown';
|
|
80
|
+
const opts = (0, json_copy_1.copy)(sndReqOpts);
|
|
81
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentRootObj.secondPutReqUrlEnd({ trans, ofs: 0 }));
|
|
82
|
+
const rep = await (0, xhr_utils_1.doBinaryRequest)(opts, objV1.segs);
|
|
83
|
+
expect(rep.status).withContext('status for unknown transaction').toBe(owner_1.currentRootObj.SC.unknownTransaction);
|
|
84
|
+
});
|
|
85
|
+
(0, async_jasmine_1.itAsync)('fails write for incorrect version', async () => {
|
|
86
|
+
await (0, _3nstorage_1.saveObj)(user.storageOwnerUrl, sessionId, null, objV1.version, objV1);
|
|
87
|
+
const opts = (0, json_copy_1.copy)(fstReqOpts);
|
|
88
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentRootObj.firstPutReqUrlEnd({ ver: objV1.version + 5, header: objV1.header.length }));
|
|
89
|
+
const rep = await (0, xhr_utils_1.doBinaryRequest)(opts, [objV1.header, objV1.segs]);
|
|
90
|
+
expect(rep.status).toBe(owner_1.currentRootObj.SC.mismatchedObjVer);
|
|
91
|
+
expect(typeof rep.data).toBe('object');
|
|
92
|
+
expect(rep.data.current_version).toBe(objV1.version);
|
|
93
|
+
});
|
|
94
|
+
(0, async_jasmine_1.itAsync)('will not accept bad type', async () => {
|
|
95
|
+
await (0, requests_1.expectNonAcceptanceOfBadType)(fstReqOpts, 'application/octet-stream', objV1.segs);
|
|
96
|
+
await (0, requests_1.expectNonAcceptanceOfBadType)(sndReqOpts, 'application/octet-stream', objV1.segs);
|
|
97
|
+
});
|
|
98
|
+
(0, async_jasmine_1.itAsync)('will not work outside of a valid session', async () => {
|
|
99
|
+
await (0, requests_1.expectNonAcceptanceOfBadSessionId)(fstReqOpts);
|
|
100
|
+
await (0, requests_1.expectNonAcceptanceOfBadSessionId)(sndReqOpts);
|
|
101
|
+
});
|
|
102
|
+
(0, async_jasmine_1.itAsync)('first request is limited by session parameter', async () => {
|
|
103
|
+
const opts = (0, json_copy_1.copy)(fstReqOpts);
|
|
104
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentRootObj.firstPutReqUrlEnd({ ver: objV1.version, header: 100, last: true }));
|
|
105
|
+
await (0, requests_1.expectNonAcceptanceOfLongBody)(opts, 'application/octet-stream', maxChunkSize + 100);
|
|
106
|
+
});
|
|
107
|
+
(0, async_jasmine_1.itAsync)('second request is limited by session parameter', async () => {
|
|
108
|
+
const opts = (0, json_copy_1.copy)(fstReqOpts);
|
|
109
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentRootObj.firstPutReqUrlEnd({ ver: objV1.version, header: objV1.header.length }));
|
|
110
|
+
const rep = await (0, xhr_utils_1.doBinaryRequest)(opts, objV1.header);
|
|
111
|
+
const trans = rep.data.transactionId;
|
|
112
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentRootObj.secondPutReqUrlEnd({ trans, ofs: 0, last: true }));
|
|
113
|
+
await (0, requests_1.expectNonAcceptanceOfLongBody)(opts, 'application/octet-stream', maxChunkSize + 100);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
const specsForNonDiffSending = {
|
|
117
|
+
description: `${description}, non-diff version,`
|
|
118
|
+
};
|
|
119
|
+
exports.specs.push(specsForNonDiffSending);
|
|
120
|
+
specsForNonDiffSending.definition = (setup) => (() => {
|
|
121
|
+
(0, async_jasmine_1.beforeEachAsync)(() => setupSession(setup));
|
|
122
|
+
(0, async_jasmine_1.itAsync)(`writes whole object in one request`, async () => {
|
|
123
|
+
expect(await storageServer.currentRootObjExists(user.id)).withContext('initially, there is no object').toBeFalsy();
|
|
124
|
+
// create object
|
|
125
|
+
const opts = (0, json_copy_1.copy)(fstReqOpts);
|
|
126
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentRootObj.firstPutReqUrlEnd({
|
|
127
|
+
ver: objV1.version, header: objV1.header.length, last: true
|
|
128
|
+
}));
|
|
129
|
+
let rep = await (0, xhr_utils_1.doBinaryRequest)(opts, [objV1.header, objV1.segs]);
|
|
130
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(owner_1.currentRootObj.SC.okPut);
|
|
131
|
+
expect(rep.data.transactionId).toBeUndefined();
|
|
132
|
+
expect(await storageServer.currentRootObjExists(user.id, objV1.version, objV1)).withContext('first version of object is present on the server').toBeTruthy();
|
|
133
|
+
// upload object's next version
|
|
134
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentRootObj.firstPutReqUrlEnd({
|
|
135
|
+
ver: objV2.version, header: objV2.header.length, last: true
|
|
136
|
+
}));
|
|
137
|
+
rep = await (0, xhr_utils_1.doBinaryRequest)(opts, [objV2.header, objV2.segs]);
|
|
138
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(owner_1.currentRootObj.SC.okPut);
|
|
139
|
+
expect(rep.data.transactionId).toBeUndefined();
|
|
140
|
+
expect(await storageServer.currentRootObjExists(user.id, objV2.version, objV2)).withContext('second version of object is present on the server').toBeTruthy();
|
|
141
|
+
expect(await storageServer.rootTransactionExists(user.id)).toBeFalsy();
|
|
142
|
+
// returns current version, when trying to upload incorrect version,
|
|
143
|
+
// like uploading existing version, or smaller
|
|
144
|
+
const errRep = await (0, xhr_utils_1.doBinaryRequest)(opts, [objV2.header, objV2.segs]);
|
|
145
|
+
expect(errRep.status).withContext('status for mismatched upload version').toBe(owner_1.currentRootObj.SC.mismatchedObjVer);
|
|
146
|
+
expect(errRep.data.current_version).withContext('current object version on server').toBe(objV2.version);
|
|
147
|
+
});
|
|
148
|
+
(0, async_jasmine_1.itAsync)(`writes object in several requests`, async () => {
|
|
149
|
+
expect(await storageServer.currentRootObjExists(user.id)).withContext('initially, there is no object').toBeFalsy();
|
|
150
|
+
// first request, to start transmission
|
|
151
|
+
const opts = (0, json_copy_1.copy)(fstReqOpts);
|
|
152
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentRootObj.firstPutReqUrlEnd({
|
|
153
|
+
ver: objV1.version, header: objV1.header.length
|
|
154
|
+
}));
|
|
155
|
+
let rep = await (0, xhr_utils_1.doBinaryRequest)(opts, objV1.header);
|
|
156
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(owner_1.currentRootObj.SC.okPut);
|
|
157
|
+
expect(typeof rep.data.transactionId).toBe('string');
|
|
158
|
+
let transactionId = rep.data.transactionId;
|
|
159
|
+
expect(await storageServer.rootTransactionExists(user.id, transactionId)).withContext(`transaction should be open, cause not all bytes have been sent in the first request`).toBeTruthy();
|
|
160
|
+
expect(await storageServer.currentRootObjExists(user.id, objV1.version)).withContext('upload is not complete, as transaction is not closed').toBeFalsy();
|
|
161
|
+
// following requests
|
|
162
|
+
for (let offset = 0; offset < objV1.segs.length; offset += 512) {
|
|
163
|
+
const last = ((offset + 512) >= objV1.segs.length);
|
|
164
|
+
if (last) {
|
|
165
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentRootObj.secondPutReqUrlEnd({ trans: transactionId, ofs: offset, last: true }));
|
|
166
|
+
const chunk = objV1.segs.subarray(offset, offset + 512);
|
|
167
|
+
const rep = await (0, xhr_utils_1.doBinaryRequest)(opts, chunk);
|
|
168
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(owner_1.currentRootObj.SC.okPut);
|
|
169
|
+
expect(rep.data.transactionId).toBeUndefined();
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentRootObj.secondPutReqUrlEnd({ trans: transactionId, ofs: offset }));
|
|
173
|
+
const chunk = objV1.segs.subarray(offset, offset + 512);
|
|
174
|
+
const rep = await (0, xhr_utils_1.doBinaryRequest)(opts, chunk);
|
|
175
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(owner_1.currentRootObj.SC.okPut);
|
|
176
|
+
expect(rep.data.transactionId).toBe(transactionId);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
expect(await storageServer.currentRootObjExists(user.id, objV1.version, objV1)).withContext('first version of object is present on the server').toBeTruthy();
|
|
180
|
+
expect(await storageServer.rootTransactionExists(user.id)).toBeFalsy();
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
const diffVer = {
|
|
184
|
+
objId: objV1.objId,
|
|
185
|
+
version: objV1.version + 1,
|
|
186
|
+
header: (0, random_node_1.bytesSync)(111),
|
|
187
|
+
segs: (0, random_node_1.bytesSync)(1000),
|
|
188
|
+
diff: {
|
|
189
|
+
baseVersion: 1,
|
|
190
|
+
segsSize: 1200,
|
|
191
|
+
sections: [
|
|
192
|
+
[0, 25, 100],
|
|
193
|
+
[1, 0, 300],
|
|
194
|
+
[0, 125, 100],
|
|
195
|
+
[1, 300, 700]
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
const specsForDiffTransaction = {
|
|
200
|
+
description: `${description}, diff version,`
|
|
201
|
+
};
|
|
202
|
+
exports.specs.push(specsForDiffTransaction);
|
|
203
|
+
specsForDiffTransaction.definition = (setup) => (() => {
|
|
204
|
+
(0, async_jasmine_1.beforeEachAsync)(async () => {
|
|
205
|
+
await setupSession(setup);
|
|
206
|
+
// upload first object version
|
|
207
|
+
const opts = (0, json_copy_1.copy)(fstReqOpts);
|
|
208
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentRootObj.firstPutReqUrlEnd({
|
|
209
|
+
ver: objV1.version, header: objV1.header.length, last: true
|
|
210
|
+
}));
|
|
211
|
+
await (0, xhr_utils_1.doBinaryRequest)(opts, [objV1.header, objV1.segs]);
|
|
212
|
+
});
|
|
213
|
+
// XXX can't write general diff-ed object in one request.
|
|
214
|
+
// fitAsync(`writes whole object in one request`, async () => {
|
|
215
|
+
// expect(await storageServer.currentRootObjExists(user.id, objV1.version)).withContext('initially, there is only first version of an object').toBeTruthy();
|
|
216
|
+
// const diffBytes = utf8.pack(JSON.stringify(diffVer.diff));
|
|
217
|
+
// // upload object's next version
|
|
218
|
+
// const opts = copy(fstReqOpts);
|
|
219
|
+
// opts.url = resolveUrl(user.storageOwnerUrl, api.firstPutReqUrlEnd(
|
|
220
|
+
// { ver: diffVer.version, diff: diffBytes.length, header: diffVer.header.length, segs: diffVer.segs.length }));
|
|
221
|
+
// const rep = await doBinaryRequest<api.ReplyToPut>(opts, [ diffBytes, diffVer.header, diffVer.segs ]);
|
|
222
|
+
// expect(rep.status).withContext('status for successful writing of segments bytes').toBe(api.SC.okPut);
|
|
223
|
+
// expect(rep.data.transactionId).toBeUndefined();
|
|
224
|
+
// expect(await storageServer.currentRootObjExists(user.id, diffVer.version, diffVer)).withContext('second version of object is present on the server').toBeTruthy();
|
|
225
|
+
// });
|
|
226
|
+
(0, async_jasmine_1.itAsync)(`writes object in several requests`, async () => {
|
|
227
|
+
expect(await storageServer.currentRootObjExists(user.id, objV1.version)).withContext('initially, there is only first version of an object').toBeTruthy();
|
|
228
|
+
const diffBytes = buffer_utils_1.utf8.pack(JSON.stringify(diffVer.diff));
|
|
229
|
+
// first request, to start transmission
|
|
230
|
+
const opts = (0, json_copy_1.copy)(fstReqOpts);
|
|
231
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentRootObj.firstPutReqUrlEnd({
|
|
232
|
+
ver: diffVer.version, diff: diffBytes.length,
|
|
233
|
+
header: diffVer.header.length
|
|
234
|
+
}));
|
|
235
|
+
let rep = await (0, xhr_utils_1.doBinaryRequest)(opts, [diffBytes, diffVer.header]);
|
|
236
|
+
expect(rep.status).toBe(owner_1.currentRootObj.SC.okPut, 'status for successful writing of segments bytes');
|
|
237
|
+
expect(typeof rep.data.transactionId).toBe('string');
|
|
238
|
+
let transactionId = rep.data.transactionId;
|
|
239
|
+
expect(await storageServer.rootTransactionExists(user.id, transactionId)).withContext(`transaction should be open, cause not all bytes have been sent in the first request`).toBeTruthy();
|
|
240
|
+
expect(await storageServer.currentRootObjExists(user.id, diffVer.version)).withContext('upload is not complete, as transaction is not closed').toBeFalsy();
|
|
241
|
+
// following requests
|
|
242
|
+
let ofs = 0;
|
|
243
|
+
for (let [isNew, dvOfs, len] of diffVer.diff.sections) {
|
|
244
|
+
if (isNew === 0) {
|
|
245
|
+
ofs += len;
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
const last = ((dvOfs + len) >= diffVer.segs.length);
|
|
249
|
+
const delta = 256;
|
|
250
|
+
for (let ofsInSection = 0; ofsInSection < len; ofsInSection += delta) {
|
|
251
|
+
const chunk = diffVer.segs.subarray(dvOfs, dvOfs + Math.min(delta, len - ofsInSection));
|
|
252
|
+
if (last && ((ofsInSection + delta) >= len)) {
|
|
253
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentRootObj.secondPutReqUrlEnd({
|
|
254
|
+
trans: transactionId, ofs, last: true
|
|
255
|
+
}));
|
|
256
|
+
const rep = await (0, xhr_utils_1.doBinaryRequest)(opts, chunk);
|
|
257
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(owner_1.currentRootObj.SC.okPut);
|
|
258
|
+
expect(rep.data.transactionId).toBeUndefined();
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
opts.url = (0, url_1.resolve)(user.storageOwnerUrl, owner_1.currentRootObj.secondPutReqUrlEnd({ trans: transactionId, ofs }));
|
|
262
|
+
const rep = await (0, xhr_utils_1.doBinaryRequest)(opts, chunk);
|
|
263
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(owner_1.currentRootObj.SC.okPut);
|
|
264
|
+
expect(rep.data.transactionId).toBe(transactionId);
|
|
265
|
+
}
|
|
266
|
+
dvOfs += chunk.length;
|
|
267
|
+
ofs += chunk.length;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
expect(await storageServer.currentRootObjExists(user.id, diffVer.version, diffVer)).withContext('diff version of object is present on the server').toBeTruthy();
|
|
271
|
+
expect(await storageServer.rootTransactionExists(user.id)).toBeFalsy();
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
Object.freeze(exports);
|