spec-3nweb-server 1.8.5 → 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/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/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,156 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2016 - 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 { beforeEachAsync, itAsync } from '../../../../libs-for-tests/async-jasmine';
|
|
19
|
+
import { SpecDescribe, TestSetup, User, msg } from '../test-utils';
|
|
20
|
+
import { doBinaryRequest, RequestOpts } from '../../../../libs-for-tests/xhr-utils';
|
|
21
|
+
import { resolve as resolveUrl } from 'url';
|
|
22
|
+
import { msgObj as api, ERR_SC } from '../../../../../lib-common/service-api/asmail/delivery';
|
|
23
|
+
import { expectNonAcceptanceOfBadSessionId, expectNonAcceptanceOfBadType, expectNonAcceptanceOfLongBody } from '../../../../shared-checks/requests';
|
|
24
|
+
import { startMsgDelivery, startMsgDeliverySession } from '../../../../libs-for-tests/asmail';
|
|
25
|
+
import { copy } from '../../../../libs-for-tests/json-copy';
|
|
26
|
+
|
|
27
|
+
export const specs: SpecDescribe = {
|
|
28
|
+
description: `Request to put message object's segments`
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const obj1 = msg.msgObjs[0];
|
|
32
|
+
const obj2 = msg.msgObjs[1];
|
|
33
|
+
|
|
34
|
+
specs.definition = (setup: () => TestSetup) => (() => {
|
|
35
|
+
|
|
36
|
+
let user2: User;
|
|
37
|
+
let deliveryUrl: string;
|
|
38
|
+
let fstReqOpts: RequestOpts;
|
|
39
|
+
let sndReqOpts: RequestOpts;
|
|
40
|
+
let maxChunkSize: number;
|
|
41
|
+
|
|
42
|
+
beforeEachAsync(async () => {
|
|
43
|
+
user2 = setup().user2;
|
|
44
|
+
deliveryUrl = await setup().asmailServer.getDeliveryUrl();
|
|
45
|
+
const sessInfo = await startMsgDelivery(deliveryUrl,
|
|
46
|
+
{ recipient: user2.id },
|
|
47
|
+
{ pid: msg.cryptoMeta.pid, objIds: [ obj1.objId, obj2.objId ] });
|
|
48
|
+
maxChunkSize = sessInfo.maxChunkSize!;
|
|
49
|
+
fstReqOpts = {
|
|
50
|
+
url: resolveUrl(deliveryUrl, api.firstPutReqUrlEnd(
|
|
51
|
+
obj1.objId, { header: obj1.header.length })),
|
|
52
|
+
method: 'PUT',
|
|
53
|
+
sessionId: sessInfo.sessionId
|
|
54
|
+
};
|
|
55
|
+
sndReqOpts = {
|
|
56
|
+
url: resolveUrl(deliveryUrl, api.secondPutReqUrlEnd(
|
|
57
|
+
obj1.objId, { ofs: 0 })),
|
|
58
|
+
method: 'PUT',
|
|
59
|
+
sessionId: sessInfo.sessionId
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
itAsync('fails for unknown object, in initial put request', async () => {
|
|
64
|
+
const opts = copy(fstReqOpts);
|
|
65
|
+
opts.url = resolveUrl(deliveryUrl, api.firstPutReqUrlEnd(
|
|
66
|
+
'unknown-obj',
|
|
67
|
+
{ header: obj1.header.length, last: true }));
|
|
68
|
+
const rep = await doBinaryRequest<any>(opts, [ obj1.header, obj1.segs ]);
|
|
69
|
+
expect(rep.status).withContext('status for unknown object').toBe(api.SC.unknownObj);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
itAsync('fails for unknown object, in secondary put request', async () => {
|
|
73
|
+
const opts = copy(sndReqOpts);
|
|
74
|
+
opts.url = resolveUrl(deliveryUrl, api.secondPutReqUrlEnd(
|
|
75
|
+
'unknown-obj', { ofs: 0, last: true }));
|
|
76
|
+
const rep = await doBinaryRequest<any>(opts, obj1.segs);
|
|
77
|
+
expect(rep.status).withContext('status for unknown object').toBe(api.SC.unknownObj);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
itAsync('will not work outside of a valid session', async () => {
|
|
81
|
+
await expectNonAcceptanceOfBadSessionId(fstReqOpts);
|
|
82
|
+
await expectNonAcceptanceOfBadSessionId(sndReqOpts);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
itAsync('first request is limited by session parameter', async () => {
|
|
86
|
+
const opts = copy(fstReqOpts);
|
|
87
|
+
opts.url = resolveUrl(deliveryUrl, api.firstPutReqUrlEnd(
|
|
88
|
+
obj1.objId, { header: 100, last: true }));
|
|
89
|
+
await expectNonAcceptanceOfLongBody(opts, 'application/octet-stream',
|
|
90
|
+
maxChunkSize+100);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
itAsync('second request is limited by session parameter', async () => {
|
|
94
|
+
const opts = copy(fstReqOpts);
|
|
95
|
+
opts.url = resolveUrl(deliveryUrl, api.firstPutReqUrlEnd(obj1.objId,
|
|
96
|
+
{ header: obj1.header.length }));
|
|
97
|
+
const rep = await doBinaryRequest<void>(opts, obj1.header);
|
|
98
|
+
opts.url = resolveUrl(deliveryUrl, api.secondPutReqUrlEnd(
|
|
99
|
+
obj1.objId, { ofs: 0 }));
|
|
100
|
+
await expectNonAcceptanceOfLongBody(opts, 'application/octet-stream',
|
|
101
|
+
maxChunkSize+100);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
itAsync(`writes whole object in one request`, async () => {
|
|
105
|
+
const opts = copy(fstReqOpts);
|
|
106
|
+
opts.url = resolveUrl(deliveryUrl, api.firstPutReqUrlEnd(obj1.objId,
|
|
107
|
+
{ header: obj1.header.length, last: true }));
|
|
108
|
+
let rep = await doBinaryRequest<void>(opts, [ obj1.header, obj1.segs ]);
|
|
109
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(api.SC.ok);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
itAsync(`writes object in several requests`, async () => {
|
|
113
|
+
// first request, to start transmission
|
|
114
|
+
const opts = copy(fstReqOpts);
|
|
115
|
+
opts.url = resolveUrl(deliveryUrl, api.firstPutReqUrlEnd(
|
|
116
|
+
obj2.objId, { header: obj2.header.length }));
|
|
117
|
+
// we send only header here, but we may send some segment bytes as well
|
|
118
|
+
const rep = await doBinaryRequest<void>(opts, obj2.header);
|
|
119
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(api.SC.ok);
|
|
120
|
+
|
|
121
|
+
// following requests
|
|
122
|
+
for (let ofs=0; ofs<obj2.segs.length; ofs+=512) {
|
|
123
|
+
const chunk = obj2.segs.subarray(ofs, ofs + 512);
|
|
124
|
+
const last = ((ofs + chunk.length) === obj2.segs.length);
|
|
125
|
+
opts.url = resolveUrl(deliveryUrl,
|
|
126
|
+
api.secondPutReqUrlEnd(obj2.objId, { ofs, last }));
|
|
127
|
+
const rep = await doBinaryRequest<void>(opts, chunk);
|
|
128
|
+
expect(rep.status).withContext('status for successful writing of segments bytes').toBe(api.SC.ok);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
itAsync(`should not work, if metadata hasn't been sent, yet`, async () => {
|
|
134
|
+
const opts = copy(fstReqOpts);
|
|
135
|
+
opts.sessionId = (await startMsgDeliverySession(
|
|
136
|
+
deliveryUrl, { recipient: user2.id })).sessionId;
|
|
137
|
+
let rep = await doBinaryRequest<void>(opts, obj1.header);
|
|
138
|
+
expect(rep.status).withContext('status for sending object bytes before sending message metadata').toBe(ERR_SC.earlyReq);
|
|
139
|
+
opts.url = sndReqOpts.url;
|
|
140
|
+
rep = await doBinaryRequest<void>(opts, obj1.header);
|
|
141
|
+
expect(rep.status).withContext('status for sending object bytes before sending message metadata').toBe(ERR_SC.earlyReq);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
itAsync('will not accept bad type', async () => {
|
|
145
|
+
await expectNonAcceptanceOfBadType(fstReqOpts, 'application/octet-stream', obj1.segs);
|
|
146
|
+
await expectNonAcceptanceOfBadType(sndReqOpts, 'application/octet-stream', obj1.segs);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
itAsync('requires messagedelivery session', async () => {
|
|
150
|
+
await expectNonAcceptanceOfBadSessionId(fstReqOpts, true);
|
|
151
|
+
await expectNonAcceptanceOfBadSessionId(sndReqOpts, true);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2017 3NSoft, 2025 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 { beforeAllAsync, itAsync } from '../../../../libs-for-tests/async-jasmine';
|
|
19
|
+
import { SpecDescribe, TestSetup, User, startSessionAndSendMsgObjs, msg } from '../test-utils';
|
|
20
|
+
import { doJsonRequest, RequestOpts } from '../../../../libs-for-tests/xhr-utils';
|
|
21
|
+
import { resolve as resolveUrl } from 'url';
|
|
22
|
+
import { sessionRestart as api } from '../../../../../lib-common/service-api/asmail/delivery';
|
|
23
|
+
import { expectNonAcceptanceOfBadJsonRequest } from '../../../../shared-checks/requests';
|
|
24
|
+
import { DeliveryInfo } from '../../../../libs-for-tests/asmail';
|
|
25
|
+
|
|
26
|
+
export const specs: SpecDescribe = {
|
|
27
|
+
description: 'Request to restart message delivery session'
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
specs.definition = (setup: () => TestSetup) => (() => {
|
|
31
|
+
|
|
32
|
+
let user2: User;
|
|
33
|
+
let initialSession: DeliveryInfo;
|
|
34
|
+
let reqOpts: RequestOpts;
|
|
35
|
+
|
|
36
|
+
beforeAllAsync(async () => {
|
|
37
|
+
user2 = setup().user2;
|
|
38
|
+
const deliveryUrl = await setup().asmailServer.getDeliveryUrl();
|
|
39
|
+
initialSession = await startSessionAndSendMsgObjs(
|
|
40
|
+
deliveryUrl, user2.id, msg);
|
|
41
|
+
reqOpts = {
|
|
42
|
+
url: resolveUrl(deliveryUrl, api.URL_END),
|
|
43
|
+
method: 'POST',
|
|
44
|
+
responseType: 'json'
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
itAsync('with ok reply returns session parameters (id, etc.)', async () => {
|
|
49
|
+
|
|
50
|
+
const req: api.Request = {
|
|
51
|
+
recipient: user2.id,
|
|
52
|
+
msgId: initialSession.msgId
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const rep = await doJsonRequest<api.Reply>(reqOpts, req);
|
|
56
|
+
expect(rep.status).withContext('successful session start status').toBe(api.SC.ok);
|
|
57
|
+
expect(typeof rep.data.sessionId).toBe('string');
|
|
58
|
+
expect(rep.data.sessionId.length).toBeGreaterThan(0);
|
|
59
|
+
expect(rep.data.maxMsgLength).toBe(initialSession.maxMsgLength);
|
|
60
|
+
expect(rep.data.maxChunkSize).toBe(initialSession.maxChunkSize);
|
|
61
|
+
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
itAsync('returns error status when recipient is unknown', async () => {
|
|
65
|
+
const req: api.Request = {
|
|
66
|
+
recipient: 'unknown user@bank.com',
|
|
67
|
+
msgId: initialSession.msgId
|
|
68
|
+
};
|
|
69
|
+
const rep = await doJsonRequest<api.Reply>(reqOpts, req);
|
|
70
|
+
expect(rep.status).withContext('status for unknown recipient').toBe(api.SC.unknownRecipient);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
itAsync(`returns error status when message is not known in delivery`,
|
|
74
|
+
async () => {
|
|
75
|
+
const req: api.Request = {
|
|
76
|
+
recipient: user2.id,
|
|
77
|
+
msgId: 'unknown message'
|
|
78
|
+
};
|
|
79
|
+
const rep = await doJsonRequest<api.Reply>(reqOpts, req);
|
|
80
|
+
expect(rep.status).withContext('status for unknown message').toBe(api.SC.unknownMsg);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
itAsync('adequately responds to fuzzing', async () => {
|
|
84
|
+
|
|
85
|
+
// bad JSON's
|
|
86
|
+
const REQ_SIZE_LIMIT = 1024;
|
|
87
|
+
const badJSONs: any[] = [ null, undefined, 1, 'string',
|
|
88
|
+
[1,2], [], { a:1, b:2 }];
|
|
89
|
+
await expectNonAcceptanceOfBadJsonRequest(reqOpts, REQ_SIZE_LIMIT,
|
|
90
|
+
badJSONs);
|
|
91
|
+
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,79 @@
|
|
|
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 { beforeAllAsync, itAsync } from '../../../../libs-for-tests/async-jasmine';
|
|
19
|
+
import { SpecDescribe, TestSetup, User } from '../test-utils';
|
|
20
|
+
import { doJsonRequest, RequestOpts } from '../../../../libs-for-tests/xhr-utils';
|
|
21
|
+
import { resolve as resolveUrl } from 'url';
|
|
22
|
+
import { sessionStart as api } from '../../../../../lib-common/service-api/asmail/delivery';
|
|
23
|
+
import { expectNonAcceptanceOfBadJsonRequest } from '../../../../shared-checks/requests';
|
|
24
|
+
|
|
25
|
+
export const specs: SpecDescribe = {
|
|
26
|
+
description: 'Request to start message delivery session'
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
specs.definition = (setup: () => TestSetup) => (() => {
|
|
30
|
+
|
|
31
|
+
let user2: User;
|
|
32
|
+
let reqOpts: RequestOpts;
|
|
33
|
+
|
|
34
|
+
beforeAllAsync(async () => {
|
|
35
|
+
user2 = setup().user2;
|
|
36
|
+
const deliveryUrl = await setup().asmailServer.getDeliveryUrl();
|
|
37
|
+
reqOpts = {
|
|
38
|
+
url: resolveUrl(deliveryUrl, api.URL_END),
|
|
39
|
+
method: 'POST',
|
|
40
|
+
responseType: 'json'
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
itAsync('with ok reply returns session parameters (id, etc.)', async () => {
|
|
45
|
+
|
|
46
|
+
const req: api.Request = {
|
|
47
|
+
recipient: user2.id
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const rep = await doJsonRequest<api.Reply>(reqOpts, req);
|
|
51
|
+
expect(rep.status).withContext('successful session start status').toBe(api.SC.ok);
|
|
52
|
+
expect(typeof rep.data.sessionId).toBe('string');
|
|
53
|
+
expect(rep.data.sessionId.length).toBeGreaterThan(0);
|
|
54
|
+
expect(typeof rep.data.maxMsgLength).toBe('number');
|
|
55
|
+
expect(rep.data.maxMsgLength).toBeGreaterThan(0);
|
|
56
|
+
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
itAsync('returns error status when recipient is unknown', async () => {
|
|
60
|
+
const req: api.Request = { recipient: 'unknown user@bank.com' };
|
|
61
|
+
const rep = await doJsonRequest<api.Reply>(reqOpts, req);
|
|
62
|
+
expect(rep.status).withContext('status for unknown recipient').toBe(api.SC.unknownRecipient);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
itAsync('adequately responds to fuzzing', async () => {
|
|
66
|
+
|
|
67
|
+
// bad JSON's
|
|
68
|
+
const REQ_SIZE_LIMIT = 1024;
|
|
69
|
+
const badJSONs: any[] = [ null, undefined, 1, 'string',
|
|
70
|
+
[1,2], [], { a:1, b:2 }];
|
|
71
|
+
await expectNonAcceptanceOfBadJsonRequest(reqOpts, REQ_SIZE_LIMIT,
|
|
72
|
+
badJSONs);
|
|
73
|
+
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2017 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 { ASMailComponent } from '../../../libs-for-tests/server-components/asmail';
|
|
19
|
+
import { User } from '../../../libs-for-tests/mailerid';
|
|
20
|
+
import { GenericSpecDescribe } from '../../../libs-for-tests/spec-assembly';
|
|
21
|
+
import { bytesSync as randomBytes } from '../../../../lib-common/random-node';
|
|
22
|
+
import { Msg, Obj, DeliveryInfo, startMsgDelivery, sendMsgObj } from '../../../libs-for-tests/asmail';
|
|
23
|
+
|
|
24
|
+
export { ASMailComponent }
|
|
25
|
+
from '../../../libs-for-tests/server-components/asmail';
|
|
26
|
+
export { User } from '../../../libs-for-tests/mailerid';
|
|
27
|
+
|
|
28
|
+
export interface TestSetup {
|
|
29
|
+
asmailServer: ASMailComponent;
|
|
30
|
+
user1: User;
|
|
31
|
+
user2: User;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type SpecDescribe = GenericSpecDescribe<TestSetup>;
|
|
35
|
+
|
|
36
|
+
export const obj1: Obj = {
|
|
37
|
+
objId: 'aaaa',
|
|
38
|
+
header: randomBytes(100),
|
|
39
|
+
segs: randomBytes(573)
|
|
40
|
+
};
|
|
41
|
+
export const obj2: Obj = {
|
|
42
|
+
objId: 'bbbb',
|
|
43
|
+
header: randomBytes(100),
|
|
44
|
+
segs: randomBytes(20*1024 + 7)
|
|
45
|
+
};
|
|
46
|
+
export const msg: Msg = {
|
|
47
|
+
cryptoMeta: { pid: 'xxxx' },
|
|
48
|
+
msgObjs: [ obj1, obj2 ]
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export async function startSessionAndSendMsgObjs(deliveryUrl: string,
|
|
52
|
+
recipient: string, msg: Msg): Promise<DeliveryInfo> {
|
|
53
|
+
const sessInfo = await startMsgDelivery(deliveryUrl,
|
|
54
|
+
{ recipient },
|
|
55
|
+
{ pid: msg.cryptoMeta.pid,
|
|
56
|
+
objIds: [ msg.msgObjs[0].objId, msg.msgObjs[1].objId ] });
|
|
57
|
+
await sendMsgObj(deliveryUrl, sessInfo.sessionId, msg.msgObjs[0],
|
|
58
|
+
sessInfo.maxChunkSize);
|
|
59
|
+
await sendMsgObj(deliveryUrl, sessInfo.sessionId, msg.msgObjs[1],
|
|
60
|
+
sessInfo.maxChunkSize);
|
|
61
|
+
return sessInfo;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2016 - 2017 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
|
+
|
|
19
|
+
import { afterAllAsync, beforeAllAsync } from '../../libs-for-tests/async-jasmine';
|
|
20
|
+
import { ASMailComponent } from '../../libs-for-tests/server-components/asmail';
|
|
21
|
+
import { User } from '../../libs-for-tests/mailerid';
|
|
22
|
+
import { p } from '../../../lib-common/service-api/asmail/config';
|
|
23
|
+
import { setInboxParams, generateInitPubKey } from '../../libs-for-tests/asmail';
|
|
24
|
+
import { join as joinPaths } from 'path';
|
|
25
|
+
import { addSpecsFrom } from '../../libs-for-tests/spec-assembly';
|
|
26
|
+
|
|
27
|
+
const SPECS_FOLDER = joinPaths(__dirname, './delivery/specs');
|
|
28
|
+
|
|
29
|
+
describe('ASMail delivery service', () => {
|
|
30
|
+
|
|
31
|
+
let asmailServer: ASMailComponent;
|
|
32
|
+
const midServiceDomain = 'localhost';
|
|
33
|
+
const signupDomains = [ 'company.inc', 'personal.net' ];
|
|
34
|
+
let user1: User;
|
|
35
|
+
let user2: User;
|
|
36
|
+
|
|
37
|
+
beforeAllAsync(async () => {
|
|
38
|
+
asmailServer = new ASMailComponent(signupDomains, midServiceDomain);
|
|
39
|
+
await asmailServer.start();
|
|
40
|
+
user1 = await asmailServer.addUser(`Bob Johnson @${signupDomains[0]}`);
|
|
41
|
+
user2 = await asmailServer.addUser(`William Young @${signupDomains[1]}`);
|
|
42
|
+
const user2Params = <any> {};
|
|
43
|
+
user2Params[p.initPubKey.URL_END] = await generateInitPubKey(
|
|
44
|
+
asmailServer.midUrl, user2
|
|
45
|
+
);
|
|
46
|
+
await setInboxParams(asmailServer.asmailUrl, user2, user2Params);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
afterAllAsync(async () => {
|
|
50
|
+
await asmailServer.stop();
|
|
51
|
+
asmailServer = (undefined as any);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
addSpecsFrom(SPECS_FOLDER, () => ({ asmailServer, user1, user2 }));
|
|
55
|
+
|
|
56
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 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 { beforeEachAsync, itAsync } from '../../../../libs-for-tests/async-jasmine';
|
|
19
|
+
import { SpecDescribe, TestSetup, User, msg, ASMailComponent, startSession, sendMsg } from '../test-utils';
|
|
20
|
+
import { openSocket } from '../../../../libs-for-tests/ws-utils';
|
|
21
|
+
import { sleep } from '../../../../../lib-common/processes';
|
|
22
|
+
import { makeSubscriber } from '../../../../../lib-common/ipc/ws-ipc';
|
|
23
|
+
import { msgRecievedCompletely, wsEventChannel as api, ERR_SC } from '../../../../../lib-common/service-api/asmail/retrieval';
|
|
24
|
+
import { Observable } from 'rxjs';
|
|
25
|
+
|
|
26
|
+
export const specs: SpecDescribe = {
|
|
27
|
+
description: `is an event emitter`
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
specs.definition = (setup: () => TestSetup) => (() => {
|
|
31
|
+
|
|
32
|
+
let asmailServer: ASMailComponent;
|
|
33
|
+
let wsUrl: string;
|
|
34
|
+
let deliveryUrl: string;
|
|
35
|
+
let user1: User;
|
|
36
|
+
let sessionId: string;
|
|
37
|
+
|
|
38
|
+
beforeEachAsync(async () => {
|
|
39
|
+
asmailServer = setup().asmailServer;
|
|
40
|
+
const retrievalUrl = await asmailServer.getRetrievalUrl();
|
|
41
|
+
wsUrl = `wss${retrievalUrl.substring(5)}${api.URL_END}`;
|
|
42
|
+
deliveryUrl = await asmailServer.getDeliveryUrl();
|
|
43
|
+
user1 = setup().user1;
|
|
44
|
+
sessionId = await startSession(user1, retrievalUrl);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
itAsync(`requires session to open web socket`, async () => {
|
|
48
|
+
|
|
49
|
+
let rep = await openSocket(wsUrl, 'invalid session id');
|
|
50
|
+
expect(rep.status).withContext('status for missing authorized session').toBe(ERR_SC.needAuth);
|
|
51
|
+
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
itAsync(`emits event on completion of message reception`, async () => {
|
|
55
|
+
|
|
56
|
+
let rep = await openSocket(wsUrl, sessionId);
|
|
57
|
+
expect(rep.status).toBe(api.SC.ok);
|
|
58
|
+
|
|
59
|
+
const eventSrc = makeSubscriber(rep.data, undefined);
|
|
60
|
+
|
|
61
|
+
const eventPromise = (Observable.create(
|
|
62
|
+
obs => eventSrc.subscribe<msgRecievedCompletely.Event>(
|
|
63
|
+
msgRecievedCompletely.EVENT_NAME, obs)) as Observable<msgRecievedCompletely.Event>)
|
|
64
|
+
.take(1)
|
|
65
|
+
.toPromise();
|
|
66
|
+
|
|
67
|
+
// give some time for subscription to occur
|
|
68
|
+
await sleep(10);
|
|
69
|
+
|
|
70
|
+
const msgId = await sendMsg(deliveryUrl, user1.id, msg);
|
|
71
|
+
|
|
72
|
+
const event = await eventPromise;
|
|
73
|
+
expect(typeof event).toBe('object');
|
|
74
|
+
expect(event.msgId).withContext(`message reception completion event should give a respective message id`).toBe(msgId);
|
|
75
|
+
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
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 { beforeEachAsync, itAsync } from '../../../../libs-for-tests/async-jasmine';
|
|
19
|
+
import { SpecDescribe, TestSetup, User, msg, ASMailComponent, startSession, sendMsg } from '../test-utils';
|
|
20
|
+
import { resolve as resolveUrl } from 'url';
|
|
21
|
+
import { msgMetadata as api } from '../../../../../lib-common/service-api/asmail/retrieval';
|
|
22
|
+
import { RequestOpts, doBodylessRequest } from '../../../../libs-for-tests/xhr-utils';
|
|
23
|
+
import { expectNonAcceptanceOfBadSessionId } from '../../../../shared-checks/requests';
|
|
24
|
+
import { copy } from '../../../../libs-for-tests/json-copy';
|
|
25
|
+
|
|
26
|
+
export const specs: SpecDescribe = {
|
|
27
|
+
description: `Request to get message meta`
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
specs.definition = (setup: () => TestSetup) => (() => {
|
|
31
|
+
|
|
32
|
+
let asmailServer: ASMailComponent;
|
|
33
|
+
let retrievalUrl: string;
|
|
34
|
+
let deliveryUrl: string;
|
|
35
|
+
let user1: User;
|
|
36
|
+
let reqOpts: RequestOpts
|
|
37
|
+
|
|
38
|
+
beforeEachAsync(async () => {
|
|
39
|
+
asmailServer = setup().asmailServer;
|
|
40
|
+
retrievalUrl = await asmailServer.getRetrievalUrl();
|
|
41
|
+
deliveryUrl = await asmailServer.getDeliveryUrl();
|
|
42
|
+
user1 = setup().user1;
|
|
43
|
+
const sessionId = await startSession(user1, retrievalUrl);
|
|
44
|
+
reqOpts = {
|
|
45
|
+
url: resolveUrl(retrievalUrl, api.genUrlEnd('some-msg')),
|
|
46
|
+
method: 'GET',
|
|
47
|
+
responseType: 'json',
|
|
48
|
+
sessionId
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
itAsync('returns message metadata', async () => {
|
|
53
|
+
const msgId = await sendMsg(deliveryUrl, user1.id, msg);
|
|
54
|
+
|
|
55
|
+
const opts = copy(reqOpts);
|
|
56
|
+
opts.url = resolveUrl(retrievalUrl, api.genUrlEnd(msgId));
|
|
57
|
+
|
|
58
|
+
const rep = await doBodylessRequest<api.Reply>(opts);
|
|
59
|
+
expect(rep.status).withContext('status for successfully found message').toBe(api.SC.ok);
|
|
60
|
+
expect(rep.data.authSender).toBeFalsy();
|
|
61
|
+
expect(typeof rep.data.deliveryStart).toBe('number');
|
|
62
|
+
expect(typeof rep.data.deliveryCompletion).toBe('number');
|
|
63
|
+
expect(rep.data.deliveryStart).not.toBeGreaterThan(
|
|
64
|
+
rep.data.deliveryCompletion!);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
itAsync(`returns an error when message is unknown`, async () => {
|
|
68
|
+
const opts = copy(reqOpts);
|
|
69
|
+
opts.url = resolveUrl(retrievalUrl, api.genUrlEnd(
|
|
70
|
+
'unknown-message'));
|
|
71
|
+
const rep = await doBodylessRequest<api.Reply>(opts);
|
|
72
|
+
expect(rep.status).withContext('status for unknown message').toBe(api.SC.unknownMsg);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
itAsync(`requires open session`, async () => {
|
|
76
|
+
const opts = copy(reqOpts);
|
|
77
|
+
await expectNonAcceptanceOfBadSessionId(opts);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
});
|