impeditmaiores 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.prettierignore +2 -0
- package/.travis.yml +35 -0
- package/.vscode/launch.json +24 -0
- package/.vscode/settings.json +3 -0
- package/codecov.yml +7 -0
- package/demos/ago-node-cli/README.md +29 -0
- package/demos/ago-node-cli/ago.js +33 -0
- package/demos/ago-node-cli/index.js +11 -0
- package/demos/ago-node-cli/lib/item-export-command.js +48 -0
- package/demos/ago-node-cli/lib/item-search-command.js +35 -0
- package/demos/ago-node-cli/package-lock.json +152 -0
- package/demos/ago-node-cli/package.json +30 -0
- package/demos/attachments/README.md +5 -0
- package/demos/attachments/index.html +165 -0
- package/demos/attachments/package-lock.json +182 -0
- package/demos/attachments/package.json +18 -0
- package/demos/batch-geocoder-node/NYC_Restaurant_Inspection_Results.csv +100 -0
- package/demos/batch-geocoder-node/README.md +15 -0
- package/demos/batch-geocoder-node/batch-geocode.js +115 -0
- package/demos/batch-geocoder-node/config-template.js +18 -0
- package/demos/batch-geocoder-node/package-lock.json +81 -0
- package/demos/batch-geocoder-node/package.json +37 -0
- package/demos/express/README.md +15 -0
- package/demos/express/config.json.template +3 -0
- package/demos/express/package-lock.json +413 -0
- package/demos/express/package.json +18 -0
- package/demos/express/server.js +33 -0
- package/demos/feature-service-browser/README.md +6 -0
- package/demos/feature-service-browser/index.html +122 -0
- package/demos/feature-service-browser/package-lock.json +182 -0
- package/demos/feature-service-browser/package.json +18 -0
- package/demos/geocoder-browser/README.md +10 -0
- package/demos/geocoder-browser/config.js.template +1 -0
- package/demos/geocoder-browser/index.html +131 -0
- package/demos/geocoder-browser/package-lock.json +182 -0
- package/demos/geocoder-browser/package.json +19 -0
- package/demos/geocoder-browser/post-sign-in.html +25 -0
- package/demos/jsapi-integration/README.md +25 -0
- package/demos/jsapi-integration/config.js +6 -0
- package/demos/jsapi-integration/index.html +89 -0
- package/demos/jsapi-integration/package-lock.json +184 -0
- package/demos/jsapi-integration/package.json +19 -0
- package/demos/node-cli-item-management/README.md +10 -0
- package/demos/node-cli-item-management/index.js +238 -0
- package/demos/node-cli-item-management/package-lock.json +152 -0
- package/demos/node-cli-item-management/package.json +27 -0
- package/demos/node-cli-item-management/screenshot.png +0 -0
- package/demos/oauth2-browser/README.md +14 -0
- package/demos/oauth2-browser/authenticate.html +30 -0
- package/demos/oauth2-browser/config.js.template +6 -0
- package/demos/oauth2-browser/index.html +211 -0
- package/demos/oauth2-browser/logo.svg +4 -0
- package/demos/oauth2-browser/package-lock.json +224 -0
- package/demos/oauth2-browser/package.json +18 -0
- package/demos/oauth2-browser/style.css +36 -0
- package/demos/oauth2-browser-retry/README.md +25 -0
- package/demos/oauth2-browser-retry/authenticate.html +22 -0
- package/demos/oauth2-browser-retry/index.html +116 -0
- package/demos/oauth2-browser-retry/logo.svg +4 -0
- package/demos/stream-response-to-file/README.md +7 -0
- package/demos/stream-response-to-file/index.js +36 -0
- package/demos/stream-response-to-file/output/.gitkeep +0 -0
- package/demos/stream-response-to-file/package-lock.json +60 -0
- package/demos/stream-response-to-file/package.json +33 -0
- package/demos/tree-shaking-rollup/.babelrc +3 -0
- package/demos/tree-shaking-rollup/README.md +9 -0
- package/demos/tree-shaking-rollup/index.html +11 -0
- package/demos/tree-shaking-rollup/package-lock.json +2225 -0
- package/demos/tree-shaking-rollup/package.json +25 -0
- package/demos/tree-shaking-rollup/rollup.config.js +17 -0
- package/demos/tree-shaking-rollup/src/index.js +8 -0
- package/demos/tree-shaking-webpack/README.md +8 -0
- package/demos/tree-shaking-webpack/index.html +11 -0
- package/demos/tree-shaking-webpack/package-lock.json +4614 -0
- package/demos/tree-shaking-webpack/package.json +24 -0
- package/demos/tree-shaking-webpack/src/index.js +10 -0
- package/demos/tree-shaking-webpack/webpack.config.js +27 -0
- package/demos/vue/.env.example +11 -0
- package/demos/vue/.eslintrc.js +17 -0
- package/demos/vue/.postcssrc.js +5 -0
- package/demos/vue/README.md +17 -0
- package/demos/vue/babel.config.js +3 -0
- package/demos/vue/package-lock.json +11342 -0
- package/demos/vue/package.json +33 -0
- package/demos/vue/public/favicon.ico +0 -0
- package/demos/vue/public/index.html +24 -0
- package/demos/vue/src/assets/logo.svg +29 -0
- package/demos/vue/src/components/App.vue +305 -0
- package/demos/vue/src/components/Authenticate.vue +65 -0
- package/demos/vue/src/components/Loader.vue +230 -0
- package/demos/vue/src/main.js +92 -0
- package/demos/webmap-checker-sapper/.env.example +5 -0
- package/demos/webmap-checker-sapper/README.md +123 -0
- package/demos/webmap-checker-sapper/appveyor.yml +18 -0
- package/demos/webmap-checker-sapper/cypress/fixtures/example.json +5 -0
- package/demos/webmap-checker-sapper/cypress/integration/spec.js +19 -0
- package/demos/webmap-checker-sapper/cypress/plugins/index.js +17 -0
- package/demos/webmap-checker-sapper/cypress/support/commands.js +25 -0
- package/demos/webmap-checker-sapper/cypress/support/index.js +20 -0
- package/demos/webmap-checker-sapper/cypress.json +4 -0
- package/demos/webmap-checker-sapper/package-lock.json +3870 -0
- package/demos/webmap-checker-sapper/package.json +50 -0
- package/demos/webmap-checker-sapper/rollup.config.js +87 -0
- package/demos/webmap-checker-sapper/src/client.js +20 -0
- package/demos/webmap-checker-sapper/src/components/LayerStatus.html +108 -0
- package/demos/webmap-checker-sapper/src/components/Nav.html +21 -0
- package/demos/webmap-checker-sapper/src/components/WebMap.html +62 -0
- package/demos/webmap-checker-sapper/src/routes/_error.html +41 -0
- package/demos/webmap-checker-sapper/src/routes/_layout.html +21 -0
- package/demos/webmap-checker-sapper/src/routes/auth/authorize.js +18 -0
- package/demos/webmap-checker-sapper/src/routes/auth/exchange-token.js +20 -0
- package/demos/webmap-checker-sapper/src/routes/auth/post-sign-in.js +24 -0
- package/demos/webmap-checker-sapper/src/routes/auth/sign-out.js +10 -0
- package/demos/webmap-checker-sapper/src/routes/index.html +20 -0
- package/demos/webmap-checker-sapper/src/routes/webmaps/[webmapId].html +83 -0
- package/demos/webmap-checker-sapper/src/routes/webmaps/index.html +59 -0
- package/demos/webmap-checker-sapper/src/server.js +101 -0
- package/demos/webmap-checker-sapper/src/service-worker.js +82 -0
- package/demos/webmap-checker-sapper/src/template.html +33 -0
- package/demos/webmap-checker-sapper/src/userInfoMiddleware.js +21 -0
- package/demos/webmap-checker-sapper/src/utils.js +33 -0
- package/demos/webmap-checker-sapper/static/favicon.png +0 -0
- package/demos/webmap-checker-sapper/static/global.css +36 -0
- package/demos/webmap-checker-sapper/static/manifest.json +20 -0
- package/demos/webmap-checker-sapper/static/svelte-logo-192.png +0 -0
- package/demos/webmap-checker-sapper/static/svelte-logo-512.png +0 -0
- package/docs/FAQ.md +48 -0
- package/docs/HISTORY.md +62 -0
- package/docs/acetate.config.js +262 -0
- package/docs/build-typedoc.js +434 -0
- package/docs/generate-srihashes.js +53 -0
- package/docs/src/_layout.html +86 -0
- package/docs/src/api/_declaration.html +600 -0
- package/docs/src/api/_layout.html +204 -0
- package/docs/src/api/_package.html +38 -0
- package/docs/src/api/index.html +16 -0
- package/docs/src/guides/_layout.html +24 -0
- package/docs/src/guides/amd-requirejs-dojo.md +40 -0
- package/docs/src/guides/browser-authentication.md +41 -0
- package/docs/src/guides/bundlers.md +52 -0
- package/docs/src/guides/cli-authentication.md +9 -0
- package/docs/src/guides/client-server-authentication.md +9 -0
- package/docs/src/guides/embedded-apps.md +93 -0
- package/docs/src/guides/from-a-cdn.md +38 -0
- package/docs/src/guides/index.md +59 -0
- package/docs/src/guides/node.md +87 -0
- package/docs/src/guides/package-overview.md +111 -0
- package/docs/src/guides/server-authentication.md +9 -0
- package/docs/src/guides/whats-new-v2-0.md +305 -0
- package/docs/src/img/icons.png +0 -0
- package/docs/src/img/icons@2x.png +0 -0
- package/docs/src/index.html +12 -0
- package/docs/src/js/api-search.js +112 -0
- package/docs/src/js/nav-toggle.js +41 -0
- package/docs/src/sass/_highlight.scss +96 -0
- package/docs/src/sass/_icons.scss +157 -0
- package/docs/src/sass/style.scss +242 -0
- package/docs/src/srihashes.json +12 -0
- package/jasmine.json +7 -0
- package/karma.conf.js +106 -0
- package/lerna.json +8 -0
- package/notes/README.md +68 -0
- package/package.json +87 -0
- package/packages/arcgis-rest-auth/README.md +71 -0
- package/packages/arcgis-rest-auth/package-lock.json +11 -0
- package/packages/arcgis-rest-auth/package.json +69 -0
- package/packages/arcgis-rest-auth/src/ApplicationSession.ts +122 -0
- package/packages/arcgis-rest-auth/src/UserSession.ts +1206 -0
- package/packages/arcgis-rest-auth/src/app-tokens.ts +91 -0
- package/packages/arcgis-rest-auth/src/authenticated-request-options.ts +24 -0
- package/packages/arcgis-rest-auth/src/federation-utils.ts +85 -0
- package/packages/arcgis-rest-auth/src/fetch-token.ts +50 -0
- package/packages/arcgis-rest-auth/src/generate-token.ts +35 -0
- package/packages/arcgis-rest-auth/src/index.ts +9 -0
- package/packages/arcgis-rest-auth/src/validate-app-access.ts +68 -0
- package/packages/arcgis-rest-auth/test/ApplicationSession.test.ts +124 -0
- package/packages/arcgis-rest-auth/test/UserSession.test.ts +1807 -0
- package/packages/arcgis-rest-auth/test/app-tokens.test.ts +91 -0
- package/packages/arcgis-rest-auth/test/federation-utils.test.ts +323 -0
- package/packages/arcgis-rest-auth/test/fetchToken.test.ts +112 -0
- package/packages/arcgis-rest-auth/test/generateToken.test.ts +102 -0
- package/packages/arcgis-rest-auth/test/utils.ts +14 -0
- package/packages/arcgis-rest-auth/test/validate-app-access.test.ts +46 -0
- package/packages/arcgis-rest-auth/tsconfig.json +6 -0
- package/packages/arcgis-rest-feature-layer/README.md +77 -0
- package/packages/arcgis-rest-feature-layer/package-lock.json +11 -0
- package/packages/arcgis-rest-feature-layer/package.json +64 -0
- package/packages/arcgis-rest-feature-layer/src/add.ts +56 -0
- package/packages/arcgis-rest-feature-layer/src/addAttachment.ts +53 -0
- package/packages/arcgis-rest-feature-layer/src/applyEdits.ts +90 -0
- package/packages/arcgis-rest-feature-layer/src/decodeValues.ts +124 -0
- package/packages/arcgis-rest-feature-layer/src/delete.ts +61 -0
- package/packages/arcgis-rest-feature-layer/src/deleteAttachments.ts +52 -0
- package/packages/arcgis-rest-feature-layer/src/getAttachments.ts +55 -0
- package/packages/arcgis-rest-feature-layer/src/getLayer.ts +24 -0
- package/packages/arcgis-rest-feature-layer/src/getService.ts +26 -0
- package/packages/arcgis-rest-feature-layer/src/helpers.ts +79 -0
- package/packages/arcgis-rest-feature-layer/src/index.ts +31 -0
- package/packages/arcgis-rest-feature-layer/src/query.ts +204 -0
- package/packages/arcgis-rest-feature-layer/src/queryRelated.ts +89 -0
- package/packages/arcgis-rest-feature-layer/src/update.ts +56 -0
- package/packages/arcgis-rest-feature-layer/src/updateAttachment.ts +59 -0
- package/packages/arcgis-rest-feature-layer/test/attachments.test.ts +200 -0
- package/packages/arcgis-rest-feature-layer/test/crud.test.ts +195 -0
- package/packages/arcgis-rest-feature-layer/test/decodeValues.test.ts +67 -0
- package/packages/arcgis-rest-feature-layer/test/getLayer.test.ts +31 -0
- package/packages/arcgis-rest-feature-layer/test/getService.test.ts +31 -0
- package/packages/arcgis-rest-feature-layer/test/mocks/cvdQueryResponse.ts +225 -0
- package/packages/arcgis-rest-feature-layer/test/mocks/feature.ts +302 -0
- package/packages/arcgis-rest-feature-layer/test/mocks/fields.ts +779 -0
- package/packages/arcgis-rest-feature-layer/test/mocks/foo.txt +1 -0
- package/packages/arcgis-rest-feature-layer/test/mocks/service.ts +398 -0
- package/packages/arcgis-rest-feature-layer/test/query.test.ts +167 -0
- package/packages/arcgis-rest-feature-layer/tsconfig.json +6 -0
- package/packages/arcgis-rest-geocoding/README.md +86 -0
- package/packages/arcgis-rest-geocoding/package-lock.json +11 -0
- package/packages/arcgis-rest-geocoding/package.json +64 -0
- package/packages/arcgis-rest-geocoding/src/bulk.ts +104 -0
- package/packages/arcgis-rest-geocoding/src/geocode.ts +133 -0
- package/packages/arcgis-rest-geocoding/src/helpers.ts +54 -0
- package/packages/arcgis-rest-geocoding/src/index.ts +15 -0
- package/packages/arcgis-rest-geocoding/src/reverse.ts +84 -0
- package/packages/arcgis-rest-geocoding/src/suggest.ts +45 -0
- package/packages/arcgis-rest-geocoding/test/bulk.test.ts +194 -0
- package/packages/arcgis-rest-geocoding/test/geocode.test.ts +249 -0
- package/packages/arcgis-rest-geocoding/test/helpers.test.ts +85 -0
- package/packages/arcgis-rest-geocoding/test/mocks/responses.ts +637 -0
- package/packages/arcgis-rest-geocoding/test/reverse.test.ts +126 -0
- package/packages/arcgis-rest-geocoding/test/suggest.test.ts +53 -0
- package/packages/arcgis-rest-geocoding/tsconfig.json +6 -0
- package/packages/arcgis-rest-portal/README.md +73 -0
- package/packages/arcgis-rest-portal/package-lock.json +11 -0
- package/packages/arcgis-rest-portal/package.json +64 -0
- package/packages/arcgis-rest-portal/src/groups/add-users.ts +140 -0
- package/packages/arcgis-rest-portal/src/groups/create.ts +43 -0
- package/packages/arcgis-rest-portal/src/groups/get.ts +184 -0
- package/packages/arcgis-rest-portal/src/groups/helpers.ts +14 -0
- package/packages/arcgis-rest-portal/src/groups/invite-users.ts +127 -0
- package/packages/arcgis-rest-portal/src/groups/join.ts +57 -0
- package/packages/arcgis-rest-portal/src/groups/notification.ts +77 -0
- package/packages/arcgis-rest-portal/src/groups/protect.ts +56 -0
- package/packages/arcgis-rest-portal/src/groups/remove-users.ts +76 -0
- package/packages/arcgis-rest-portal/src/groups/remove.ts +32 -0
- package/packages/arcgis-rest-portal/src/groups/search.ts +47 -0
- package/packages/arcgis-rest-portal/src/groups/update-user-membership.ts +63 -0
- package/packages/arcgis-rest-portal/src/groups/update.ts +39 -0
- package/packages/arcgis-rest-portal/src/index.ts +66 -0
- package/packages/arcgis-rest-portal/src/items/add.ts +138 -0
- package/packages/arcgis-rest-portal/src/items/content.ts +67 -0
- package/packages/arcgis-rest-portal/src/items/create.ts +150 -0
- package/packages/arcgis-rest-portal/src/items/export.ts +80 -0
- package/packages/arcgis-rest-portal/src/items/get.ts +437 -0
- package/packages/arcgis-rest-portal/src/items/helpers.ts +275 -0
- package/packages/arcgis-rest-portal/src/items/protect.ts +41 -0
- package/packages/arcgis-rest-portal/src/items/reassign.ts +61 -0
- package/packages/arcgis-rest-portal/src/items/remove.ts +135 -0
- package/packages/arcgis-rest-portal/src/items/search.ts +25 -0
- package/packages/arcgis-rest-portal/src/items/update.ts +184 -0
- package/packages/arcgis-rest-portal/src/items/upload.ts +125 -0
- package/packages/arcgis-rest-portal/src/orgs/notification.ts +131 -0
- package/packages/arcgis-rest-portal/src/sharing/access.ts +84 -0
- package/packages/arcgis-rest-portal/src/sharing/helpers.ts +81 -0
- package/packages/arcgis-rest-portal/src/sharing/is-item-shared-with-group.ts +42 -0
- package/packages/arcgis-rest-portal/src/sharing/share-item-with-group.ts +319 -0
- package/packages/arcgis-rest-portal/src/sharing/unshare-item-with-group.ts +105 -0
- package/packages/arcgis-rest-portal/src/users/get-user-tags.ts +52 -0
- package/packages/arcgis-rest-portal/src/users/get-user-url.ts +18 -0
- package/packages/arcgis-rest-portal/src/users/get-user.ts +58 -0
- package/packages/arcgis-rest-portal/src/users/invitation.ts +156 -0
- package/packages/arcgis-rest-portal/src/users/notification.ts +68 -0
- package/packages/arcgis-rest-portal/src/users/search-users.ts +37 -0
- package/packages/arcgis-rest-portal/src/users/update.ts +66 -0
- package/packages/arcgis-rest-portal/src/util/SearchQueryBuilder.ts +374 -0
- package/packages/arcgis-rest-portal/src/util/array.ts +16 -0
- package/packages/arcgis-rest-portal/src/util/generic-search.ts +99 -0
- package/packages/arcgis-rest-portal/src/util/get-portal-settings.ts +45 -0
- package/packages/arcgis-rest-portal/src/util/get-portal-url.ts +27 -0
- package/packages/arcgis-rest-portal/src/util/get-portal.ts +52 -0
- package/packages/arcgis-rest-portal/src/util/get-subscription-info.ts +43 -0
- package/packages/arcgis-rest-portal/src/util/scrub-control-chars.ts +12 -0
- package/packages/arcgis-rest-portal/src/util/search.ts +42 -0
- package/packages/arcgis-rest-portal/test/groups/add-users.test.ts +239 -0
- package/packages/arcgis-rest-portal/test/groups/crud.test.ts +180 -0
- package/packages/arcgis-rest-portal/test/groups/get.test.ts +176 -0
- package/packages/arcgis-rest-portal/test/groups/invite-users.test.ts +149 -0
- package/packages/arcgis-rest-portal/test/groups/join.test.ts +72 -0
- package/packages/arcgis-rest-portal/test/groups/notification.test.ts +112 -0
- package/packages/arcgis-rest-portal/test/groups/protect.test.ts +72 -0
- package/packages/arcgis-rest-portal/test/groups/remove-users.test.ts +140 -0
- package/packages/arcgis-rest-portal/test/groups/search.test.ts +151 -0
- package/packages/arcgis-rest-portal/test/groups/update-user-membership.test.ts +62 -0
- package/packages/arcgis-rest-portal/test/items/add.test.ts +323 -0
- package/packages/arcgis-rest-portal/test/items/content.test.ts +156 -0
- package/packages/arcgis-rest-portal/test/items/create.test.ts +399 -0
- package/packages/arcgis-rest-portal/test/items/export.test.ts +122 -0
- package/packages/arcgis-rest-portal/test/items/get.test.ts +583 -0
- package/packages/arcgis-rest-portal/test/items/helpers.test.ts +60 -0
- package/packages/arcgis-rest-portal/test/items/protect.test.ts +122 -0
- package/packages/arcgis-rest-portal/test/items/reassign.test.ts +131 -0
- package/packages/arcgis-rest-portal/test/items/remove.test.ts +238 -0
- package/packages/arcgis-rest-portal/test/items/search.test.ts +272 -0
- package/packages/arcgis-rest-portal/test/items/update.test.ts +554 -0
- package/packages/arcgis-rest-portal/test/items/upload.test.ts +282 -0
- package/packages/arcgis-rest-portal/test/mocks/groups/responses.ts +208 -0
- package/packages/arcgis-rest-portal/test/mocks/items/foo.zip +0 -0
- package/packages/arcgis-rest-portal/test/mocks/items/item.ts +526 -0
- package/packages/arcgis-rest-portal/test/mocks/items/resources.ts +38 -0
- package/packages/arcgis-rest-portal/test/mocks/items/search.ts +121 -0
- package/packages/arcgis-rest-portal/test/mocks/portal/response.ts +126 -0
- package/packages/arcgis-rest-portal/test/mocks/portal/settings-response.ts +56 -0
- package/packages/arcgis-rest-portal/test/mocks/sharing/sharing.ts +18 -0
- package/packages/arcgis-rest-portal/test/mocks/users/invitation.ts +70 -0
- package/packages/arcgis-rest-portal/test/mocks/users/notification.ts +34 -0
- package/packages/arcgis-rest-portal/test/mocks/users/user-search.ts +388 -0
- package/packages/arcgis-rest-portal/test/mocks/users/user-tags.ts +5 -0
- package/packages/arcgis-rest-portal/test/mocks/users/user.ts +174 -0
- package/packages/arcgis-rest-portal/test/orgs/notification.test.ts +142 -0
- package/packages/arcgis-rest-portal/test/sharing/access.test.ts +162 -0
- package/packages/arcgis-rest-portal/test/sharing/helpers.test.ts +55 -0
- package/packages/arcgis-rest-portal/test/sharing/share-item-with-group.test.ts +1325 -0
- package/packages/arcgis-rest-portal/test/sharing/unshare-item-with-group.test.ts +288 -0
- package/packages/arcgis-rest-portal/test/users/get-user-tags.test.ts +71 -0
- package/packages/arcgis-rest-portal/test/users/get-user-url.test.ts +40 -0
- package/packages/arcgis-rest-portal/test/users/get-user.test.ts +90 -0
- package/packages/arcgis-rest-portal/test/users/invitation.test.ts +127 -0
- package/packages/arcgis-rest-portal/test/users/notification.test.ts +77 -0
- package/packages/arcgis-rest-portal/test/users/search.test.ts +42 -0
- package/packages/arcgis-rest-portal/test/users/update.test.ts +151 -0
- package/packages/arcgis-rest-portal/test/util/SearchQueryBuilder.test.ts +340 -0
- package/packages/arcgis-rest-portal/test/util/array.test.ts +30 -0
- package/packages/arcgis-rest-portal/test/util/get-portal-settings.test.ts +68 -0
- package/packages/arcgis-rest-portal/test/util/get-portal-url.test.ts +37 -0
- package/packages/arcgis-rest-portal/test/util/portal.test.ts +148 -0
- package/packages/arcgis-rest-portal/test/util/scrub-control-chars.test.ts +22 -0
- package/packages/arcgis-rest-portal/tsconfig.json +6 -0
- package/packages/arcgis-rest-request/README.md +72 -0
- package/packages/arcgis-rest-request/package-lock.json +11 -0
- package/packages/arcgis-rest-request/package.json +60 -0
- package/packages/arcgis-rest-request/src/index.ts +25 -0
- package/packages/arcgis-rest-request/src/request.ts +413 -0
- package/packages/arcgis-rest-request/src/utils/ArcGISRequestError.ts +76 -0
- package/packages/arcgis-rest-request/src/utils/ErrorTypes.ts +29 -0
- package/packages/arcgis-rest-request/src/utils/GrantTypes.ts +5 -0
- package/packages/arcgis-rest-request/src/utils/HTTPMethods.ts +6 -0
- package/packages/arcgis-rest-request/src/utils/IAuthenticationManager.ts +21 -0
- package/packages/arcgis-rest-request/src/utils/IFetchTokenParams.ts +11 -0
- package/packages/arcgis-rest-request/src/utils/IGenerateTokenParams.ts +9 -0
- package/packages/arcgis-rest-request/src/utils/IParamBuilder.ts +3 -0
- package/packages/arcgis-rest-request/src/utils/IParams.ts +6 -0
- package/packages/arcgis-rest-request/src/utils/IParamsBuilder.ts +5 -0
- package/packages/arcgis-rest-request/src/utils/IRequestOptions.ts +49 -0
- package/packages/arcgis-rest-request/src/utils/ITokenRequestOptions.ts +9 -0
- package/packages/arcgis-rest-request/src/utils/ResponseFormats.ts +10 -0
- package/packages/arcgis-rest-request/src/utils/append-custom-params.ts +49 -0
- package/packages/arcgis-rest-request/src/utils/clean-url.ts +20 -0
- package/packages/arcgis-rest-request/src/utils/decode-query-string.ts +27 -0
- package/packages/arcgis-rest-request/src/utils/encode-form-data.ts +38 -0
- package/packages/arcgis-rest-request/src/utils/encode-query-string.ts +35 -0
- package/packages/arcgis-rest-request/src/utils/process-params.ts +108 -0
- package/packages/arcgis-rest-request/src/utils/retryAuthError.ts +10 -0
- package/packages/arcgis-rest-request/src/utils/warn.ts +11 -0
- package/packages/arcgis-rest-request/src/utils/with-options.ts +48 -0
- package/packages/arcgis-rest-request/test/mocks/errors.ts +76 -0
- package/packages/arcgis-rest-request/test/mocks/geojson-feature-collection.ts +13 -0
- package/packages/arcgis-rest-request/test/mocks/param-builder.ts +7 -0
- package/packages/arcgis-rest-request/test/mocks/sharing-rest-info.ts +41 -0
- package/packages/arcgis-rest-request/test/mocks/webmap.ts +41 -0
- package/packages/arcgis-rest-request/test/request.test.ts +571 -0
- package/packages/arcgis-rest-request/test/utils/ArcGISAuthError.test.ts +191 -0
- package/packages/arcgis-rest-request/test/utils/ArcGISRequestError.test.ts +51 -0
- package/packages/arcgis-rest-request/test/utils/check-for-errors.test.ts +111 -0
- package/packages/arcgis-rest-request/test/utils/clean-url.test.ts +50 -0
- package/packages/arcgis-rest-request/test/utils/encode-form-data.test.ts +133 -0
- package/packages/arcgis-rest-request/test/utils/encode-query-string.test.ts +18 -0
- package/packages/arcgis-rest-request/test/utils/process-params.test.ts +205 -0
- package/packages/arcgis-rest-request/test/utils/with-options.test.ts +133 -0
- package/packages/arcgis-rest-request/tsconfig.json +4 -0
- package/packages/arcgis-rest-routing/README.md +75 -0
- package/packages/arcgis-rest-routing/package-lock.json +11 -0
- package/packages/arcgis-rest-routing/package.json +63 -0
- package/packages/arcgis-rest-routing/src/helpers.ts +16 -0
- package/packages/arcgis-rest-routing/src/index.ts +11 -0
- package/packages/arcgis-rest-routing/src/solveRoute.ts +124 -0
- package/packages/arcgis-rest-routing/test/mocks/responses.ts +825 -0
- package/packages/arcgis-rest-routing/test/solveRoute.test.ts +509 -0
- package/packages/arcgis-rest-routing/tsconfig.json +6 -0
- package/packages/arcgis-rest-service-admin/README.md +73 -0
- package/packages/arcgis-rest-service-admin/package-lock.json +11 -0
- package/packages/arcgis-rest-service-admin/package.json +65 -0
- package/packages/arcgis-rest-service-admin/src/addTo.ts +70 -0
- package/packages/arcgis-rest-service-admin/src/create.ts +189 -0
- package/packages/arcgis-rest-service-admin/src/index.ts +11 -0
- package/packages/arcgis-rest-service-admin/src/update.ts +50 -0
- package/packages/arcgis-rest-service-admin/test/addTo.test.ts +350 -0
- package/packages/arcgis-rest-service-admin/test/create.test.ts +294 -0
- package/packages/arcgis-rest-service-admin/test/mocks/layerDefinition.ts +79 -0
- package/packages/arcgis-rest-service-admin/test/mocks/service.ts +81 -0
- package/packages/arcgis-rest-service-admin/test/update.test.ts +115 -0
- package/packages/arcgis-rest-service-admin/tsconfig.json +6 -0
- package/packages/arcgis-rest-types/README.md +66 -0
- package/packages/arcgis-rest-types/package.json +54 -0
- package/packages/arcgis-rest-types/src/feature.ts +39 -0
- package/packages/arcgis-rest-types/src/geometry.ts +272 -0
- package/packages/arcgis-rest-types/src/group.ts +72 -0
- package/packages/arcgis-rest-types/src/index.ts +9 -0
- package/packages/arcgis-rest-types/src/item.ts +81 -0
- package/packages/arcgis-rest-types/src/service.ts +114 -0
- package/packages/arcgis-rest-types/src/statisticDefinition.ts +33 -0
- package/packages/arcgis-rest-types/src/symbol.ts +170 -0
- package/packages/arcgis-rest-types/src/user.ts +49 -0
- package/packages/arcgis-rest-types/src/webmap.ts +1367 -0
- package/packages/arcgis-rest-types/tsconfig.json +10 -0
- package/support/changelog.js +393 -0
- package/support/deploy-doc-site.js +16 -0
- package/support/dev.sh +6 -0
- package/support/publish.sh +47 -0
- package/support/test-helpers.js +9 -0
- package/tsconfig.json +63 -0
- package/tslint.json +16 -0
- package/umd-base-profile.js +81 -0
- package/umd-production-profile.js +13 -0
@@ -0,0 +1,1325 @@
|
|
1
|
+
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
|
2
|
+
* Apache-2.0 */
|
3
|
+
|
4
|
+
import * as fetchMock from "fetch-mock";
|
5
|
+
import { shareItemWithGroup, ensureMembership } from "../../src/sharing/share-item-with-group";
|
6
|
+
import { MOCK_USER_SESSION } from "../mocks/sharing/sharing";
|
7
|
+
import { TOMORROW } from "@esri/arcgis-rest-auth/test/utils";
|
8
|
+
import { ArcGISAuthError } from "@esri/arcgis-rest-request";
|
9
|
+
|
10
|
+
import {
|
11
|
+
GroupNonMemberUserResponse,
|
12
|
+
GroupMemberUserResponse,
|
13
|
+
GroupAdminUserResponse,
|
14
|
+
OrgAdminUserResponse,
|
15
|
+
AnonUserResponse
|
16
|
+
} from "../mocks/users/user";
|
17
|
+
|
18
|
+
import { SearchResponse } from "../mocks/items/search";
|
19
|
+
import { ISharingResponse } from "../../src/sharing/helpers";
|
20
|
+
|
21
|
+
const SharingResponse = {
|
22
|
+
notSharedWith: [] as any,
|
23
|
+
itemId: "n3v"
|
24
|
+
};
|
25
|
+
|
26
|
+
const FailedSharingResponse = {
|
27
|
+
notSharedWith: ["t6b"],
|
28
|
+
itemId: "n3v"
|
29
|
+
};
|
30
|
+
|
31
|
+
const CachedSharingResponse = {
|
32
|
+
notSharedWith: [] as any,
|
33
|
+
itemId: "a5b",
|
34
|
+
shortcut: true
|
35
|
+
};
|
36
|
+
|
37
|
+
const NoResultsSearchResponse = {
|
38
|
+
query: "",
|
39
|
+
total: 0,
|
40
|
+
start: 0,
|
41
|
+
num: 0,
|
42
|
+
nextStart: 0,
|
43
|
+
results: [] as any
|
44
|
+
};
|
45
|
+
|
46
|
+
export const GroupOwnerResponse = {
|
47
|
+
id: "tb6",
|
48
|
+
title: "fake group",
|
49
|
+
userMembership: {
|
50
|
+
memberType: "owner"
|
51
|
+
}
|
52
|
+
};
|
53
|
+
|
54
|
+
export const GroupMemberResponse = {
|
55
|
+
id: "tb6",
|
56
|
+
title: "fake group",
|
57
|
+
userMembership: {
|
58
|
+
memberType: "member"
|
59
|
+
}
|
60
|
+
};
|
61
|
+
|
62
|
+
export const GroupNonMemberResponse = {
|
63
|
+
id: "tb6",
|
64
|
+
title: "fake group",
|
65
|
+
userMembership: {
|
66
|
+
memberType: "none"
|
67
|
+
}
|
68
|
+
};
|
69
|
+
|
70
|
+
export const GroupAdminResponse = {
|
71
|
+
id: "tb6",
|
72
|
+
title: "fake group",
|
73
|
+
userMembership: {
|
74
|
+
memberType: "admin"
|
75
|
+
}
|
76
|
+
};
|
77
|
+
|
78
|
+
export const GroupNoAccessResponse = {
|
79
|
+
error: {
|
80
|
+
code: 400,
|
81
|
+
messageCode: "COM_0003",
|
82
|
+
message: "Group does not exist or is inaccessible.",
|
83
|
+
details: [] as any[]
|
84
|
+
}
|
85
|
+
};
|
86
|
+
|
87
|
+
describe("shareItemWithGroup() ::", () => {
|
88
|
+
// make sure session doesnt cache metadata
|
89
|
+
beforeEach(done => {
|
90
|
+
fetchMock.post("https://myorg.maps.arcgis.com/sharing/rest/generateToken", {
|
91
|
+
token: "fake-token",
|
92
|
+
expires: TOMORROW.getTime(),
|
93
|
+
username: "jsmith"
|
94
|
+
});
|
95
|
+
|
96
|
+
// make sure session doesnt cache metadata
|
97
|
+
MOCK_USER_SESSION.refreshSession()
|
98
|
+
.then(() => done())
|
99
|
+
.catch();
|
100
|
+
});
|
101
|
+
|
102
|
+
afterEach(fetchMock.restore);
|
103
|
+
describe("share item as owner::", () => {
|
104
|
+
it("should share an item with a group by owner", done => {
|
105
|
+
// this is called when we try to determine if the item is already in the group
|
106
|
+
fetchMock.once(
|
107
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
108
|
+
SearchResponse
|
109
|
+
);
|
110
|
+
|
111
|
+
// the actual sharing request
|
112
|
+
fetchMock.once(
|
113
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/users/jsmith/items/n3v/share",
|
114
|
+
SharingResponse
|
115
|
+
);
|
116
|
+
|
117
|
+
shareItemWithGroup({
|
118
|
+
authentication: MOCK_USER_SESSION,
|
119
|
+
id: "n3v",
|
120
|
+
groupId: "t6b"
|
121
|
+
})
|
122
|
+
.then(response => {
|
123
|
+
expect(fetchMock.done()).toBeTruthy(
|
124
|
+
"All fetchMocks should have been called"
|
125
|
+
);
|
126
|
+
const [url, options]: [string, RequestInit] = fetchMock.lastCall(
|
127
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/users/jsmith/items/n3v/share"
|
128
|
+
);
|
129
|
+
expect(url).toBe(
|
130
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/users/jsmith/items/n3v/share"
|
131
|
+
);
|
132
|
+
expect(options.method).toBe("POST");
|
133
|
+
expect(response).toEqual(SharingResponse);
|
134
|
+
expect(options.body).toContain("f=json");
|
135
|
+
expect(options.body).toContain("groups=t6b");
|
136
|
+
done();
|
137
|
+
})
|
138
|
+
.catch(e => {
|
139
|
+
expect(fetchMock.done()).toBeTruthy(
|
140
|
+
"All fetchMocks should have been called"
|
141
|
+
);
|
142
|
+
fail(e);
|
143
|
+
});
|
144
|
+
});
|
145
|
+
|
146
|
+
it("should share an item with a group by org administrator", done => {
|
147
|
+
fetchMock.once(
|
148
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
149
|
+
OrgAdminUserResponse
|
150
|
+
);
|
151
|
+
|
152
|
+
fetchMock.once(
|
153
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/casey?f=json&token=fake-token",
|
154
|
+
{
|
155
|
+
username: "casey",
|
156
|
+
orgId: "qWAReEOCnD7eTxOe",
|
157
|
+
groups: [] as any[]
|
158
|
+
}
|
159
|
+
);
|
160
|
+
|
161
|
+
fetchMock.once(
|
162
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
163
|
+
NoResultsSearchResponse
|
164
|
+
);
|
165
|
+
|
166
|
+
// called when we determine if the user is a member of the group
|
167
|
+
fetchMock.get(
|
168
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
169
|
+
GroupOwnerResponse
|
170
|
+
);
|
171
|
+
|
172
|
+
fetchMock.once(
|
173
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share",
|
174
|
+
SharingResponse
|
175
|
+
);
|
176
|
+
shareItemWithGroup({
|
177
|
+
authentication: MOCK_USER_SESSION,
|
178
|
+
id: "n3v",
|
179
|
+
groupId: "t6b",
|
180
|
+
owner: "casey"
|
181
|
+
})
|
182
|
+
.then(response => {
|
183
|
+
expect(fetchMock.done()).toBeTruthy(
|
184
|
+
"All fetchMocks should have been called"
|
185
|
+
);
|
186
|
+
const [url, options]: [string, RequestInit] = fetchMock.lastCall(
|
187
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share"
|
188
|
+
);
|
189
|
+
expect(url).toBe(
|
190
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share"
|
191
|
+
);
|
192
|
+
expect(options.method).toBe("POST");
|
193
|
+
expect(response).toEqual(SharingResponse);
|
194
|
+
expect(options.body).toContain("f=json");
|
195
|
+
expect(options.body).toContain("groups=t6b");
|
196
|
+
done();
|
197
|
+
})
|
198
|
+
.catch(e => {
|
199
|
+
fail(e);
|
200
|
+
});
|
201
|
+
});
|
202
|
+
|
203
|
+
it("should share an item with a group by group owner/admin", done => {
|
204
|
+
fetchMock.once(
|
205
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
206
|
+
GroupAdminUserResponse
|
207
|
+
);
|
208
|
+
|
209
|
+
fetchMock.once(
|
210
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/otherguy?f=json&token=fake-token",
|
211
|
+
{
|
212
|
+
username: "otherguy",
|
213
|
+
orgId: "qWAReEOCnD7eTxOe",
|
214
|
+
groups: [] as any[]
|
215
|
+
}
|
216
|
+
);
|
217
|
+
|
218
|
+
fetchMock.once(
|
219
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
220
|
+
SearchResponse
|
221
|
+
);
|
222
|
+
|
223
|
+
// called when we determine if the user is a member of the group
|
224
|
+
fetchMock.get(
|
225
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
226
|
+
GroupOwnerResponse
|
227
|
+
);
|
228
|
+
|
229
|
+
fetchMock.once(
|
230
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share",
|
231
|
+
SharingResponse
|
232
|
+
);
|
233
|
+
|
234
|
+
shareItemWithGroup({
|
235
|
+
authentication: MOCK_USER_SESSION,
|
236
|
+
id: "n3v",
|
237
|
+
groupId: "t6b",
|
238
|
+
owner: "otherguy"
|
239
|
+
})
|
240
|
+
.then(response => {
|
241
|
+
expect(fetchMock.done()).toBeTruthy(
|
242
|
+
"All fetchMocks should have been called"
|
243
|
+
);
|
244
|
+
const [url, options]: [string, RequestInit] = fetchMock.lastCall(
|
245
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share"
|
246
|
+
);
|
247
|
+
expect(url).toBe(
|
248
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share"
|
249
|
+
);
|
250
|
+
expect(options.method).toBe("POST");
|
251
|
+
expect(response).toEqual(SharingResponse);
|
252
|
+
expect(options.body).toContain("f=json");
|
253
|
+
expect(options.body).toContain("groups=t6b");
|
254
|
+
done();
|
255
|
+
})
|
256
|
+
.catch(e => {
|
257
|
+
expect(fetchMock.done()).toBeTruthy(
|
258
|
+
"All fetchMocks should have been called"
|
259
|
+
);
|
260
|
+
fail(e);
|
261
|
+
});
|
262
|
+
});
|
263
|
+
|
264
|
+
it("should mock the response if an item was previously shared with a group", done => {
|
265
|
+
fetchMock.once(
|
266
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
267
|
+
GroupAdminUserResponse
|
268
|
+
);
|
269
|
+
|
270
|
+
fetchMock.once(
|
271
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
272
|
+
SearchResponse
|
273
|
+
);
|
274
|
+
|
275
|
+
shareItemWithGroup({
|
276
|
+
authentication: MOCK_USER_SESSION,
|
277
|
+
id: "a5b",
|
278
|
+
groupId: "t6b"
|
279
|
+
})
|
280
|
+
.then(response => {
|
281
|
+
// no web request to share at all
|
282
|
+
expect(response).toEqual(CachedSharingResponse);
|
283
|
+
done();
|
284
|
+
})
|
285
|
+
.catch(e => {
|
286
|
+
expect(fetchMock.done()).toBeTruthy(
|
287
|
+
"All fetchMocks should have been called"
|
288
|
+
);
|
289
|
+
fail(e);
|
290
|
+
});
|
291
|
+
});
|
292
|
+
|
293
|
+
it("should allow group owner/admin/member to share item they do not own", done => {
|
294
|
+
fetchMock.once(
|
295
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
296
|
+
GroupMemberUserResponse
|
297
|
+
);
|
298
|
+
|
299
|
+
fetchMock.once(
|
300
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/casey?f=json&token=fake-token",
|
301
|
+
{
|
302
|
+
username: "casey",
|
303
|
+
orgId: "qWAReEOCnD7eTxOe",
|
304
|
+
groups: [] as any[]
|
305
|
+
}
|
306
|
+
);
|
307
|
+
|
308
|
+
fetchMock.once(
|
309
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
310
|
+
SearchResponse
|
311
|
+
);
|
312
|
+
|
313
|
+
// called when we determine if the user is a member of the group
|
314
|
+
fetchMock.get(
|
315
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
316
|
+
GroupMemberResponse
|
317
|
+
);
|
318
|
+
|
319
|
+
fetchMock.once(
|
320
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share",
|
321
|
+
SharingResponse
|
322
|
+
);
|
323
|
+
|
324
|
+
shareItemWithGroup({
|
325
|
+
authentication: MOCK_USER_SESSION,
|
326
|
+
id: "n3v",
|
327
|
+
groupId: "t6b",
|
328
|
+
owner: "casey"
|
329
|
+
})
|
330
|
+
.then(response => {
|
331
|
+
expect(fetchMock.done()).toBeTruthy(
|
332
|
+
"All fetchMocks should have been called"
|
333
|
+
);
|
334
|
+
const [url, options]: [string, RequestInit] = fetchMock.lastCall(
|
335
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share"
|
336
|
+
);
|
337
|
+
expect(url).toBe(
|
338
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share"
|
339
|
+
);
|
340
|
+
expect(options.method).toBe("POST");
|
341
|
+
expect(response).toEqual(SharingResponse);
|
342
|
+
expect(options.body).toContain("f=json");
|
343
|
+
expect(options.body).toContain("groups=t6b");
|
344
|
+
done();
|
345
|
+
})
|
346
|
+
.catch(e => {
|
347
|
+
fail(e);
|
348
|
+
});
|
349
|
+
});
|
350
|
+
|
351
|
+
it("should throw if non-owner tries to share to shared editing group", done => {
|
352
|
+
fetchMock.once(
|
353
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
354
|
+
GroupMemberUserResponse
|
355
|
+
);
|
356
|
+
|
357
|
+
fetchMock.once(
|
358
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/casey?f=json&token=fake-token",
|
359
|
+
{
|
360
|
+
username: "casey",
|
361
|
+
orgId: "qWAReEOCnD7eTxOe",
|
362
|
+
groups: [] as any[]
|
363
|
+
}
|
364
|
+
);
|
365
|
+
|
366
|
+
fetchMock.once(
|
367
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
368
|
+
SearchResponse
|
369
|
+
);
|
370
|
+
|
371
|
+
// called when we determine if the user is a member of the group
|
372
|
+
fetchMock.get(
|
373
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
374
|
+
GroupMemberResponse
|
375
|
+
);
|
376
|
+
|
377
|
+
shareItemWithGroup({
|
378
|
+
authentication: MOCK_USER_SESSION,
|
379
|
+
id: "n3v",
|
380
|
+
groupId: "t6b",
|
381
|
+
owner: "casey",
|
382
|
+
confirmItemControl: true
|
383
|
+
}).catch(e => {
|
384
|
+
expect(fetchMock.done()).toBeTruthy(
|
385
|
+
"All fetchMocks should have been called"
|
386
|
+
);
|
387
|
+
expect(e.message).toContain(
|
388
|
+
"This item can not be shared to shared editing group t6b by jsmith as they not the item owner or org admin."
|
389
|
+
);
|
390
|
+
done();
|
391
|
+
});
|
392
|
+
});
|
393
|
+
|
394
|
+
it("should throw if the response from the server is fishy", done => {
|
395
|
+
fetchMock.once(
|
396
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
397
|
+
SearchResponse
|
398
|
+
);
|
399
|
+
|
400
|
+
fetchMock.once(
|
401
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/users/jsmith/items/n3v/share",
|
402
|
+
FailedSharingResponse
|
403
|
+
);
|
404
|
+
|
405
|
+
shareItemWithGroup({
|
406
|
+
authentication: MOCK_USER_SESSION,
|
407
|
+
id: "n3v",
|
408
|
+
groupId: "t6b"
|
409
|
+
}).catch(e => {
|
410
|
+
expect(fetchMock.done()).toBeTruthy(
|
411
|
+
"All fetchMocks should have been called"
|
412
|
+
);
|
413
|
+
expect(e.message).toBe("Item n3v could not be shared to group t6b.");
|
414
|
+
done();
|
415
|
+
});
|
416
|
+
});
|
417
|
+
});
|
418
|
+
|
419
|
+
describe("share item as org admin on behalf of other user ::", () => {
|
420
|
+
it("should add user to group then share item", done => {
|
421
|
+
fetchMock
|
422
|
+
.once(
|
423
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
424
|
+
OrgAdminUserResponse
|
425
|
+
)
|
426
|
+
.once(
|
427
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
428
|
+
NoResultsSearchResponse
|
429
|
+
)
|
430
|
+
.get(
|
431
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
432
|
+
GroupOwnerResponse
|
433
|
+
)
|
434
|
+
.once(
|
435
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/casey?f=json&token=fake-token",
|
436
|
+
{
|
437
|
+
username: "casey",
|
438
|
+
orgId: "qWAReEOCnD7eTxOe",
|
439
|
+
groups: [] as any[]
|
440
|
+
}
|
441
|
+
)
|
442
|
+
.post(
|
443
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b/addUsers",
|
444
|
+
{ notAdded: [] }
|
445
|
+
)
|
446
|
+
.post(
|
447
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share",
|
448
|
+
{ notSharedWith: [], itemId: "n3v" }
|
449
|
+
);
|
450
|
+
|
451
|
+
shareItemWithGroup({
|
452
|
+
authentication: MOCK_USER_SESSION,
|
453
|
+
id: "n3v",
|
454
|
+
groupId: "t6b",
|
455
|
+
owner: "casey",
|
456
|
+
confirmItemControl: true
|
457
|
+
})
|
458
|
+
.then(result => {
|
459
|
+
expect(fetchMock.done()).toBeTruthy(
|
460
|
+
"All fetchMocks should have been called"
|
461
|
+
);
|
462
|
+
// verify we added casey to t6b
|
463
|
+
const addUsersOptions: RequestInit = fetchMock.lastOptions(
|
464
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b/addUsers"
|
465
|
+
);
|
466
|
+
expect(addUsersOptions.body).toContain("admins=casey");
|
467
|
+
// verify we shared the item
|
468
|
+
const shareOptions: RequestInit = fetchMock.lastOptions(
|
469
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share"
|
470
|
+
);
|
471
|
+
expect(shareOptions.body).toContain("groups=t6b");
|
472
|
+
expect(shareOptions.body).toContain("confirmItemControl=true");
|
473
|
+
|
474
|
+
done();
|
475
|
+
})
|
476
|
+
.catch(e => {
|
477
|
+
fail();
|
478
|
+
});
|
479
|
+
});
|
480
|
+
it("should add user to group the returned user lacks groups array", done => {
|
481
|
+
// tbh, not 100% sure this can even happen, but... 100% coverage
|
482
|
+
fetchMock
|
483
|
+
.once(
|
484
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
485
|
+
OrgAdminUserResponse
|
486
|
+
)
|
487
|
+
.once(
|
488
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
489
|
+
NoResultsSearchResponse
|
490
|
+
)
|
491
|
+
.get(
|
492
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
493
|
+
GroupOwnerResponse
|
494
|
+
)
|
495
|
+
.once(
|
496
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/casey?f=json&token=fake-token",
|
497
|
+
{
|
498
|
+
username: "casey",
|
499
|
+
orgId: "qWAReEOCnD7eTxOe"
|
500
|
+
}
|
501
|
+
)
|
502
|
+
.post(
|
503
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b/addUsers",
|
504
|
+
{ notAdded: [] }
|
505
|
+
)
|
506
|
+
.post(
|
507
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share",
|
508
|
+
{ notSharedWith: [], itemId: "n3v" }
|
509
|
+
);
|
510
|
+
|
511
|
+
shareItemWithGroup({
|
512
|
+
authentication: MOCK_USER_SESSION,
|
513
|
+
id: "n3v",
|
514
|
+
groupId: "t6b",
|
515
|
+
owner: "casey",
|
516
|
+
confirmItemControl: true
|
517
|
+
})
|
518
|
+
.then(result => {
|
519
|
+
expect(fetchMock.done()).toBeTruthy(
|
520
|
+
"All fetchMocks should have been called"
|
521
|
+
);
|
522
|
+
// verify we added casey to t6b
|
523
|
+
const addUsersOptions: RequestInit = fetchMock.lastOptions(
|
524
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b/addUsers"
|
525
|
+
);
|
526
|
+
expect(addUsersOptions.body).toContain("admins=casey");
|
527
|
+
// verify we shared the item
|
528
|
+
const shareOptions: RequestInit = fetchMock.lastOptions(
|
529
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share"
|
530
|
+
);
|
531
|
+
expect(shareOptions.body).toContain("groups=t6b");
|
532
|
+
expect(shareOptions.body).toContain("confirmItemControl=true");
|
533
|
+
|
534
|
+
done();
|
535
|
+
})
|
536
|
+
.catch(e => {
|
537
|
+
fail();
|
538
|
+
});
|
539
|
+
});
|
540
|
+
it("should upgrade user to admin then share item", done => {
|
541
|
+
fetchMock
|
542
|
+
.once(
|
543
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
544
|
+
OrgAdminUserResponse
|
545
|
+
)
|
546
|
+
.once(
|
547
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
548
|
+
NoResultsSearchResponse
|
549
|
+
)
|
550
|
+
.get(
|
551
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
552
|
+
GroupOwnerResponse
|
553
|
+
)
|
554
|
+
.once(
|
555
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/casey?f=json&token=fake-token",
|
556
|
+
{
|
557
|
+
username: "casey",
|
558
|
+
orgId: "qWAReEOCnD7eTxOe",
|
559
|
+
groups: [
|
560
|
+
{
|
561
|
+
id: "t6b",
|
562
|
+
userMembership: {
|
563
|
+
memberType: "member"
|
564
|
+
}
|
565
|
+
}
|
566
|
+
] as any[]
|
567
|
+
}
|
568
|
+
)
|
569
|
+
.post(
|
570
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b/updateUsers",
|
571
|
+
{ results: [{ username: "casey", success: true }] }
|
572
|
+
)
|
573
|
+
.post(
|
574
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share",
|
575
|
+
{ notSharedWith: [], itemId: "n3v" }
|
576
|
+
);
|
577
|
+
|
578
|
+
shareItemWithGroup({
|
579
|
+
authentication: MOCK_USER_SESSION,
|
580
|
+
id: "n3v",
|
581
|
+
groupId: "t6b",
|
582
|
+
owner: "casey",
|
583
|
+
confirmItemControl: true
|
584
|
+
})
|
585
|
+
.then(result => {
|
586
|
+
expect(fetchMock.done()).toBeTruthy(
|
587
|
+
"All fetchMocks should have been called"
|
588
|
+
);
|
589
|
+
// verify we added casey to t6b
|
590
|
+
const addUsersOptions: RequestInit = fetchMock.lastOptions(
|
591
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b/updateUsers"
|
592
|
+
);
|
593
|
+
expect(addUsersOptions.body).toContain("admins=casey");
|
594
|
+
// verify we shared the item
|
595
|
+
const shareOptions: RequestInit = fetchMock.lastOptions(
|
596
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share"
|
597
|
+
);
|
598
|
+
expect(shareOptions.body).toContain("groups=t6b");
|
599
|
+
expect(shareOptions.body).toContain("confirmItemControl=true");
|
600
|
+
|
601
|
+
done();
|
602
|
+
})
|
603
|
+
.catch(e => {
|
604
|
+
fail();
|
605
|
+
});
|
606
|
+
});
|
607
|
+
it("should share item if user is already admin in group", done => {
|
608
|
+
fetchMock
|
609
|
+
.once(
|
610
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
611
|
+
OrgAdminUserResponse
|
612
|
+
)
|
613
|
+
.once(
|
614
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
615
|
+
NoResultsSearchResponse
|
616
|
+
)
|
617
|
+
.get(
|
618
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
619
|
+
GroupOwnerResponse
|
620
|
+
)
|
621
|
+
.once(
|
622
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/casey?f=json&token=fake-token",
|
623
|
+
{
|
624
|
+
username: "casey",
|
625
|
+
orgId: "qWAReEOCnD7eTxOe",
|
626
|
+
groups: [
|
627
|
+
{
|
628
|
+
id: "t6b",
|
629
|
+
userMembership: {
|
630
|
+
memberType: "admin"
|
631
|
+
}
|
632
|
+
}
|
633
|
+
] as any[]
|
634
|
+
}
|
635
|
+
)
|
636
|
+
.post(
|
637
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share",
|
638
|
+
{ notSharedWith: [], itemId: "n3v" }
|
639
|
+
);
|
640
|
+
|
641
|
+
shareItemWithGroup({
|
642
|
+
authentication: MOCK_USER_SESSION,
|
643
|
+
id: "n3v",
|
644
|
+
groupId: "t6b",
|
645
|
+
owner: "casey",
|
646
|
+
confirmItemControl: true
|
647
|
+
})
|
648
|
+
.then(result => {
|
649
|
+
expect(fetchMock.done()).toBeTruthy(
|
650
|
+
"All fetchMocks should have been called"
|
651
|
+
);
|
652
|
+
// verify we shared the item
|
653
|
+
const shareOptions: RequestInit = fetchMock.lastOptions(
|
654
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share"
|
655
|
+
);
|
656
|
+
expect(shareOptions.body).toContain("groups=t6b");
|
657
|
+
expect(shareOptions.body).toContain("confirmItemControl=true");
|
658
|
+
|
659
|
+
done();
|
660
|
+
})
|
661
|
+
.catch(e => {
|
662
|
+
fail();
|
663
|
+
});
|
664
|
+
});
|
665
|
+
it("should throw if we can not upgrade user membership", done => {
|
666
|
+
fetchMock
|
667
|
+
.once(
|
668
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
669
|
+
OrgAdminUserResponse
|
670
|
+
)
|
671
|
+
.once(
|
672
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
673
|
+
NoResultsSearchResponse
|
674
|
+
)
|
675
|
+
.get(
|
676
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
677
|
+
GroupOwnerResponse
|
678
|
+
)
|
679
|
+
.once(
|
680
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/casey?f=json&token=fake-token",
|
681
|
+
{
|
682
|
+
username: "casey",
|
683
|
+
orgId: "qWAReEOCnD7eTxOe",
|
684
|
+
groups: [
|
685
|
+
{
|
686
|
+
id: "t6b",
|
687
|
+
userMembership: {
|
688
|
+
memberType: "member"
|
689
|
+
}
|
690
|
+
}
|
691
|
+
] as any[]
|
692
|
+
}
|
693
|
+
)
|
694
|
+
.post(
|
695
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b/updateUsers",
|
696
|
+
{ results: [{ username: "casey", success: false }] }
|
697
|
+
);
|
698
|
+
|
699
|
+
return shareItemWithGroup({
|
700
|
+
authentication: MOCK_USER_SESSION,
|
701
|
+
id: "n3v",
|
702
|
+
groupId: "t6b",
|
703
|
+
owner: "casey",
|
704
|
+
confirmItemControl: true
|
705
|
+
})
|
706
|
+
.then(() => {
|
707
|
+
expect("").toBe("Should Throw, but it returned");
|
708
|
+
fail();
|
709
|
+
})
|
710
|
+
.catch(e => {
|
711
|
+
expect(fetchMock.done()).toBeTruthy(
|
712
|
+
"All fetchMocks should have been called"
|
713
|
+
);
|
714
|
+
const addUsersOptions: RequestInit = fetchMock.lastOptions(
|
715
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b/updateUsers"
|
716
|
+
);
|
717
|
+
expect(addUsersOptions.body).toContain("admins=casey");
|
718
|
+
expect(e.message).toBe(
|
719
|
+
"Error promoting user casey to admin in edit group t6b. Consequently item n3v was not shared to the group."
|
720
|
+
);
|
721
|
+
done();
|
722
|
+
});
|
723
|
+
});
|
724
|
+
it("should throw if we cannot add the user as a group admin", done => {
|
725
|
+
fetchMock
|
726
|
+
.once(
|
727
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
728
|
+
{
|
729
|
+
...OrgAdminUserResponse,
|
730
|
+
groups: []
|
731
|
+
}
|
732
|
+
)
|
733
|
+
.once(
|
734
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
735
|
+
NoResultsSearchResponse
|
736
|
+
)
|
737
|
+
.get(
|
738
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
739
|
+
GroupNonMemberUserResponse
|
740
|
+
)
|
741
|
+
.once(
|
742
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/casey?f=json&token=fake-token",
|
743
|
+
{
|
744
|
+
username: "casey",
|
745
|
+
orgId: "qWAReEOCnD7eTxOe",
|
746
|
+
groups: [
|
747
|
+
{
|
748
|
+
id: "t6b",
|
749
|
+
userMembership: {
|
750
|
+
memberType: "admin"
|
751
|
+
}
|
752
|
+
}
|
753
|
+
] as any[]
|
754
|
+
}
|
755
|
+
)
|
756
|
+
.post(
|
757
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b/addUsers",
|
758
|
+
{ errors: [new ArcGISAuthError('my error', 717)] }
|
759
|
+
);
|
760
|
+
|
761
|
+
return shareItemWithGroup({
|
762
|
+
authentication: MOCK_USER_SESSION,
|
763
|
+
id: "n3v",
|
764
|
+
groupId: "t6b",
|
765
|
+
owner: "casey",
|
766
|
+
confirmItemControl: true
|
767
|
+
})
|
768
|
+
.then(() => {
|
769
|
+
expect("").toBe("Should Throw, but it returned");
|
770
|
+
fail();
|
771
|
+
})
|
772
|
+
.catch(e => {
|
773
|
+
expect(fetchMock.done()).toBeTruthy(
|
774
|
+
"All fetchMocks should have been called"
|
775
|
+
);
|
776
|
+
expect(e.message).toBe(
|
777
|
+
"Error adding jsmith as member to edit group t6b. Consequently item n3v was not shared to the group."
|
778
|
+
);
|
779
|
+
done();
|
780
|
+
});
|
781
|
+
});
|
782
|
+
it("should throw when a non org admin, non group member attempts to share a view group", done => {
|
783
|
+
fetchMock
|
784
|
+
.once(
|
785
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
786
|
+
{ ...AnonUserResponse, orgId: "qWAReEOCnD7eTxOe" }
|
787
|
+
)
|
788
|
+
.once(
|
789
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
790
|
+
NoResultsSearchResponse
|
791
|
+
)
|
792
|
+
.get(
|
793
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
794
|
+
GroupNonMemberUserResponse
|
795
|
+
)
|
796
|
+
.once(
|
797
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/casey?f=json&token=fake-token",
|
798
|
+
{
|
799
|
+
username: "casey",
|
800
|
+
orgId: "qWAReEOCnD7eTxOe",
|
801
|
+
groups: [
|
802
|
+
{
|
803
|
+
id: "t6b",
|
804
|
+
userMembership: {
|
805
|
+
memberType: "member"
|
806
|
+
}
|
807
|
+
}
|
808
|
+
] as any[]
|
809
|
+
}
|
810
|
+
);
|
811
|
+
|
812
|
+
return shareItemWithGroup({
|
813
|
+
authentication: MOCK_USER_SESSION,
|
814
|
+
id: "n3v",
|
815
|
+
groupId: "t6b",
|
816
|
+
owner: "casey",
|
817
|
+
confirmItemControl: false
|
818
|
+
})
|
819
|
+
.then(() => {
|
820
|
+
expect("").toBe("Should Throw, but it returned");
|
821
|
+
fail();
|
822
|
+
})
|
823
|
+
.catch(e => {
|
824
|
+
expect(fetchMock.done()).toBeTruthy(
|
825
|
+
"All fetchMocks should have been called"
|
826
|
+
);
|
827
|
+
expect(e.message).toBe(
|
828
|
+
"This item can not be shared by jsmith as they are not a member of the specified group t6b."
|
829
|
+
);
|
830
|
+
done();
|
831
|
+
});
|
832
|
+
});
|
833
|
+
it("should throw if owner is in other org", done => {
|
834
|
+
fetchMock
|
835
|
+
.get(
|
836
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
837
|
+
OrgAdminUserResponse
|
838
|
+
)
|
839
|
+
.once(
|
840
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
841
|
+
NoResultsSearchResponse
|
842
|
+
)
|
843
|
+
.get(
|
844
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
845
|
+
GroupOwnerResponse
|
846
|
+
)
|
847
|
+
.get(
|
848
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/casey?f=json&token=fake-token",
|
849
|
+
{
|
850
|
+
username: "casey",
|
851
|
+
orgId: "some-other-org",
|
852
|
+
groups: [] as any[]
|
853
|
+
}
|
854
|
+
);
|
855
|
+
|
856
|
+
return shareItemWithGroup({
|
857
|
+
authentication: MOCK_USER_SESSION,
|
858
|
+
id: "n3v",
|
859
|
+
groupId: "t6b",
|
860
|
+
owner: "casey",
|
861
|
+
confirmItemControl: true
|
862
|
+
})
|
863
|
+
.then(() => {
|
864
|
+
expect("").toBe("Should Throw, but it returned");
|
865
|
+
fail();
|
866
|
+
})
|
867
|
+
.catch(e => {
|
868
|
+
expect(fetchMock.done()).toBeTruthy(
|
869
|
+
"All fetchMocks should have been called"
|
870
|
+
);
|
871
|
+
|
872
|
+
expect(e.message).toBe(
|
873
|
+
"User casey is not a member of the same org as jsmith. Consequently they can not be added added to group t6b nor can item n3v be shared to the group."
|
874
|
+
);
|
875
|
+
done();
|
876
|
+
});
|
877
|
+
});
|
878
|
+
it("should throw if owner has > 511 groups", done => {
|
879
|
+
const caseyUser = {
|
880
|
+
username: "casey",
|
881
|
+
orgId: "qWAReEOCnD7eTxOe",
|
882
|
+
groups: new Array(512)
|
883
|
+
};
|
884
|
+
caseyUser.groups.fill({ id: "not-real-group" });
|
885
|
+
fetchMock
|
886
|
+
.get(
|
887
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
888
|
+
OrgAdminUserResponse
|
889
|
+
)
|
890
|
+
.once(
|
891
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
892
|
+
NoResultsSearchResponse
|
893
|
+
)
|
894
|
+
.get(
|
895
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
896
|
+
GroupOwnerResponse
|
897
|
+
)
|
898
|
+
.get(
|
899
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/casey?f=json&token=fake-token",
|
900
|
+
caseyUser
|
901
|
+
);
|
902
|
+
|
903
|
+
return shareItemWithGroup({
|
904
|
+
authentication: MOCK_USER_SESSION,
|
905
|
+
id: "n3v",
|
906
|
+
groupId: "t6b",
|
907
|
+
owner: "casey",
|
908
|
+
confirmItemControl: true
|
909
|
+
})
|
910
|
+
.then(() => {
|
911
|
+
expect("").toBe("Should Throw, but it returned");
|
912
|
+
fail();
|
913
|
+
})
|
914
|
+
.catch(e => {
|
915
|
+
expect(fetchMock.done()).toBeTruthy(
|
916
|
+
"All fetchMocks should have been called"
|
917
|
+
);
|
918
|
+
|
919
|
+
expect(e.message).toBe(
|
920
|
+
"User casey already has 512 groups, and can not be added to group t6b. Consequently item n3v can not be shared to the group."
|
921
|
+
);
|
922
|
+
done();
|
923
|
+
});
|
924
|
+
});
|
925
|
+
|
926
|
+
it("should throw when updateUserMemberships fails", done => {
|
927
|
+
fetchMock
|
928
|
+
.once(
|
929
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
930
|
+
OrgAdminUserResponse
|
931
|
+
)
|
932
|
+
.once(
|
933
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
934
|
+
NoResultsSearchResponse
|
935
|
+
)
|
936
|
+
.get(
|
937
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
938
|
+
GroupOwnerResponse
|
939
|
+
)
|
940
|
+
.once(
|
941
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/casey?f=json&token=fake-token",
|
942
|
+
{
|
943
|
+
username: "casey",
|
944
|
+
orgId: "qWAReEOCnD7eTxOe",
|
945
|
+
groups: [
|
946
|
+
{
|
947
|
+
id: "t6b",
|
948
|
+
userMembership: {
|
949
|
+
memberType: "member"
|
950
|
+
}
|
951
|
+
}
|
952
|
+
] as any[]
|
953
|
+
}
|
954
|
+
)
|
955
|
+
.post(
|
956
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b/updateUsers",
|
957
|
+
{ throws: true }
|
958
|
+
);
|
959
|
+
|
960
|
+
return shareItemWithGroup({
|
961
|
+
authentication: MOCK_USER_SESSION,
|
962
|
+
id: "n3v",
|
963
|
+
groupId: "t6b",
|
964
|
+
owner: "casey",
|
965
|
+
confirmItemControl: true
|
966
|
+
})
|
967
|
+
.then(() => {
|
968
|
+
expect("").toBe("Should Throw, but it returned");
|
969
|
+
fail();
|
970
|
+
})
|
971
|
+
.catch(e => {
|
972
|
+
expect(fetchMock.done()).toBeTruthy(
|
973
|
+
"All fetchMocks should have been called"
|
974
|
+
);
|
975
|
+
const addUsersOptions: RequestInit = fetchMock.lastOptions(
|
976
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b/updateUsers"
|
977
|
+
);
|
978
|
+
expect(addUsersOptions.body).toContain("admins=casey");
|
979
|
+
expect(e.message).toBe(
|
980
|
+
"Error promoting user casey to admin in edit group t6b. Consequently item n3v was not shared to the group."
|
981
|
+
);
|
982
|
+
done();
|
983
|
+
});
|
984
|
+
});
|
985
|
+
|
986
|
+
it("should add the admin user as a member, share the item, then remove the admin from the group", done => {
|
987
|
+
fetchMock
|
988
|
+
.once(
|
989
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
990
|
+
{
|
991
|
+
...OrgAdminUserResponse,
|
992
|
+
groups: []
|
993
|
+
}
|
994
|
+
)
|
995
|
+
.once(
|
996
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
997
|
+
NoResultsSearchResponse
|
998
|
+
)
|
999
|
+
.get(
|
1000
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
1001
|
+
GroupNonMemberUserResponse
|
1002
|
+
)
|
1003
|
+
.once(
|
1004
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/casey?f=json&token=fake-token",
|
1005
|
+
{
|
1006
|
+
username: "casey",
|
1007
|
+
orgId: "qWAReEOCnD7eTxOe",
|
1008
|
+
groups: [
|
1009
|
+
{
|
1010
|
+
id: "t6b",
|
1011
|
+
userMembership: {
|
1012
|
+
memberType: "admin"
|
1013
|
+
}
|
1014
|
+
}
|
1015
|
+
] as any[]
|
1016
|
+
}
|
1017
|
+
)
|
1018
|
+
.post(
|
1019
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b/addUsers",
|
1020
|
+
{ notAdded: [] }
|
1021
|
+
)
|
1022
|
+
.post(
|
1023
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share",
|
1024
|
+
{ notSharedWith: [], itemId: "nv3" }
|
1025
|
+
)
|
1026
|
+
.post(
|
1027
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b/removeUsers",
|
1028
|
+
{ notRemoved: [] }
|
1029
|
+
);
|
1030
|
+
|
1031
|
+
return shareItemWithGroup({
|
1032
|
+
authentication: MOCK_USER_SESSION,
|
1033
|
+
id: "n3v",
|
1034
|
+
groupId: "t6b",
|
1035
|
+
owner: "casey",
|
1036
|
+
confirmItemControl: true
|
1037
|
+
})
|
1038
|
+
.then(result => {
|
1039
|
+
expect(fetchMock.done()).toBeTruthy(
|
1040
|
+
"All fetchMocks should have been called"
|
1041
|
+
);
|
1042
|
+
const shareOptions: RequestInit = fetchMock.lastOptions(
|
1043
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share"
|
1044
|
+
);
|
1045
|
+
expect(shareOptions.body).toContain("groups=t6b");
|
1046
|
+
expect(shareOptions.body).toContain("confirmItemControl=true");
|
1047
|
+
|
1048
|
+
done();
|
1049
|
+
})
|
1050
|
+
.catch(e => {
|
1051
|
+
fail();
|
1052
|
+
});
|
1053
|
+
});
|
1054
|
+
it("should add the admin user as a member, share the item, then suppress any removeUser errors", done => {
|
1055
|
+
fetchMock
|
1056
|
+
.once(
|
1057
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
1058
|
+
{
|
1059
|
+
...OrgAdminUserResponse,
|
1060
|
+
groups: []
|
1061
|
+
}
|
1062
|
+
)
|
1063
|
+
.once(
|
1064
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
1065
|
+
NoResultsSearchResponse
|
1066
|
+
)
|
1067
|
+
.get(
|
1068
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
1069
|
+
GroupNonMemberUserResponse
|
1070
|
+
)
|
1071
|
+
.once(
|
1072
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/casey?f=json&token=fake-token",
|
1073
|
+
{
|
1074
|
+
username: "casey",
|
1075
|
+
orgId: "qWAReEOCnD7eTxOe",
|
1076
|
+
groups: [
|
1077
|
+
{
|
1078
|
+
id: "t6b",
|
1079
|
+
userMembership: {
|
1080
|
+
memberType: "admin"
|
1081
|
+
}
|
1082
|
+
}
|
1083
|
+
] as any[]
|
1084
|
+
}
|
1085
|
+
)
|
1086
|
+
.post(
|
1087
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b/addUsers",
|
1088
|
+
{ notAdded: [] }
|
1089
|
+
)
|
1090
|
+
.post(
|
1091
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share",
|
1092
|
+
{ notSharedWith: [], itemId: "nv3" }
|
1093
|
+
)
|
1094
|
+
.post(
|
1095
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b/removeUsers",
|
1096
|
+
{ throws: true }
|
1097
|
+
);
|
1098
|
+
|
1099
|
+
return shareItemWithGroup({
|
1100
|
+
authentication: MOCK_USER_SESSION,
|
1101
|
+
id: "n3v",
|
1102
|
+
groupId: "t6b",
|
1103
|
+
owner: "casey",
|
1104
|
+
confirmItemControl: true
|
1105
|
+
})
|
1106
|
+
.then(result => {
|
1107
|
+
expect(fetchMock.done()).toBeTruthy(
|
1108
|
+
"All fetchMocks should have been called"
|
1109
|
+
);
|
1110
|
+
const shareOptions: RequestInit = fetchMock.lastOptions(
|
1111
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share"
|
1112
|
+
);
|
1113
|
+
expect(shareOptions.body).toContain("groups=t6b");
|
1114
|
+
expect(shareOptions.body).toContain("confirmItemControl=true");
|
1115
|
+
|
1116
|
+
done();
|
1117
|
+
})
|
1118
|
+
.catch(e => {
|
1119
|
+
fail();
|
1120
|
+
});
|
1121
|
+
});
|
1122
|
+
it("should upgrade user to group admin, add admin as member, then share item, then remove admin user", done => {
|
1123
|
+
fetchMock
|
1124
|
+
.once(
|
1125
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
1126
|
+
{
|
1127
|
+
...OrgAdminUserResponse,
|
1128
|
+
groups: [
|
1129
|
+
{
|
1130
|
+
...OrgAdminUserResponse.groups[0],
|
1131
|
+
userMembership: {
|
1132
|
+
...OrgAdminUserResponse.groups[0].userMembership,
|
1133
|
+
memberType: "member"
|
1134
|
+
}
|
1135
|
+
}
|
1136
|
+
]
|
1137
|
+
}
|
1138
|
+
)
|
1139
|
+
.once(
|
1140
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
1141
|
+
NoResultsSearchResponse
|
1142
|
+
)
|
1143
|
+
.get(
|
1144
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
1145
|
+
GroupNonMemberResponse
|
1146
|
+
)
|
1147
|
+
.once(
|
1148
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/casey?f=json&token=fake-token",
|
1149
|
+
{
|
1150
|
+
username: "casey",
|
1151
|
+
orgId: "qWAReEOCnD7eTxOe",
|
1152
|
+
groups: [
|
1153
|
+
{
|
1154
|
+
id: "t6b",
|
1155
|
+
userMembership: {
|
1156
|
+
memberType: "member"
|
1157
|
+
}
|
1158
|
+
}
|
1159
|
+
] as any[]
|
1160
|
+
}
|
1161
|
+
)
|
1162
|
+
.once(
|
1163
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b/updateUsers",
|
1164
|
+
{ results: [{ username: "casey", success: true }] }
|
1165
|
+
)
|
1166
|
+
.post(
|
1167
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share",
|
1168
|
+
{ notSharedWith: [], itemId: "n3v" }
|
1169
|
+
);
|
1170
|
+
|
1171
|
+
shareItemWithGroup({
|
1172
|
+
authentication: MOCK_USER_SESSION,
|
1173
|
+
id: "n3v",
|
1174
|
+
groupId: "t6b",
|
1175
|
+
owner: "casey",
|
1176
|
+
confirmItemControl: true
|
1177
|
+
})
|
1178
|
+
.then(result => {
|
1179
|
+
expect(fetchMock.done()).toBeTruthy(
|
1180
|
+
"All fetchMocks should have been called"
|
1181
|
+
);
|
1182
|
+
// verify we added casey to t6b
|
1183
|
+
const addUsersOptions: RequestInit = fetchMock.lastOptions(
|
1184
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b/updateUsers"
|
1185
|
+
);
|
1186
|
+
expect(addUsersOptions.body).toContain("admins=casey");
|
1187
|
+
// verify we shared the item
|
1188
|
+
const shareOptions: RequestInit = fetchMock.lastOptions(
|
1189
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share"
|
1190
|
+
);
|
1191
|
+
expect(shareOptions.body).toContain("groups=t6b");
|
1192
|
+
expect(shareOptions.body).toContain("confirmItemControl=true");
|
1193
|
+
|
1194
|
+
done();
|
1195
|
+
})
|
1196
|
+
.catch(e => {
|
1197
|
+
fail();
|
1198
|
+
});
|
1199
|
+
});
|
1200
|
+
});
|
1201
|
+
describe("ensureMembership", function () {
|
1202
|
+
it("should revert the user promotion and suppress resolved error", done => {
|
1203
|
+
fetchMock
|
1204
|
+
.once(
|
1205
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b/updateUsers",
|
1206
|
+
{ results: [{ username: "jsmith", success: true }] }
|
1207
|
+
)
|
1208
|
+
.once(
|
1209
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b/updateUsers",
|
1210
|
+
{ results: [{ username: "jsmith", success: false }] }
|
1211
|
+
);
|
1212
|
+
const { revert } = ensureMembership(
|
1213
|
+
GroupAdminUserResponse,
|
1214
|
+
GroupMemberUserResponse,
|
1215
|
+
true,
|
1216
|
+
'some error message',
|
1217
|
+
{
|
1218
|
+
authentication: MOCK_USER_SESSION,
|
1219
|
+
id: "n3v",
|
1220
|
+
groupId: "t6b",
|
1221
|
+
owner: "casey",
|
1222
|
+
confirmItemControl: true
|
1223
|
+
}
|
1224
|
+
);
|
1225
|
+
revert({ notSharedWith: [] } as ISharingResponse)
|
1226
|
+
.then(() => {
|
1227
|
+
expect(fetchMock.done()).toBeTruthy(
|
1228
|
+
"All fetchMocks should have been called"
|
1229
|
+
);
|
1230
|
+
done();
|
1231
|
+
})
|
1232
|
+
.catch(e => {
|
1233
|
+
fail();
|
1234
|
+
});
|
1235
|
+
});
|
1236
|
+
it("should revert the user promotion and suppress rejected error", done => {
|
1237
|
+
fetchMock
|
1238
|
+
.once(
|
1239
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b/updateUsers",
|
1240
|
+
{ results: [{ username: "jsmith", success: true }] }
|
1241
|
+
)
|
1242
|
+
.once(
|
1243
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b/updateUsers",
|
1244
|
+
{ throws: true }
|
1245
|
+
);
|
1246
|
+
const { revert } = ensureMembership(
|
1247
|
+
GroupAdminUserResponse,
|
1248
|
+
GroupMemberUserResponse,
|
1249
|
+
true,
|
1250
|
+
'some error message',
|
1251
|
+
{
|
1252
|
+
authentication: MOCK_USER_SESSION,
|
1253
|
+
id: "n3v",
|
1254
|
+
groupId: "t6b",
|
1255
|
+
owner: "casey",
|
1256
|
+
confirmItemControl: true
|
1257
|
+
}
|
1258
|
+
);
|
1259
|
+
revert({ notSharedWith: [] } as ISharingResponse)
|
1260
|
+
.then(() => {
|
1261
|
+
expect(fetchMock.done()).toBeTruthy(
|
1262
|
+
"All fetchMocks should have been called"
|
1263
|
+
);
|
1264
|
+
done();
|
1265
|
+
})
|
1266
|
+
.catch(e => {
|
1267
|
+
fail();
|
1268
|
+
});
|
1269
|
+
});
|
1270
|
+
});
|
1271
|
+
describe("share item to admin user's favorites group ::", () => {
|
1272
|
+
it("should share item", done => {
|
1273
|
+
fetchMock
|
1274
|
+
.once(
|
1275
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
1276
|
+
{
|
1277
|
+
...OrgAdminUserResponse,
|
1278
|
+
favGroupId: "t6b"
|
1279
|
+
}
|
1280
|
+
)
|
1281
|
+
.once(
|
1282
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
1283
|
+
NoResultsSearchResponse
|
1284
|
+
)
|
1285
|
+
.get(
|
1286
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
1287
|
+
GroupOwnerResponse
|
1288
|
+
)
|
1289
|
+
.once(
|
1290
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/casey?f=json&token=fake-token",
|
1291
|
+
{
|
1292
|
+
username: "casey",
|
1293
|
+
orgId: "qWAReEOCnD7eTxOe",
|
1294
|
+
groups: [] as any[]
|
1295
|
+
}
|
1296
|
+
)
|
1297
|
+
.post(
|
1298
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share",
|
1299
|
+
{ notSharedWith: [], itemId: "n3v" }
|
1300
|
+
);
|
1301
|
+
|
1302
|
+
shareItemWithGroup({
|
1303
|
+
authentication: MOCK_USER_SESSION,
|
1304
|
+
id: "n3v",
|
1305
|
+
groupId: "t6b",
|
1306
|
+
owner: "casey"
|
1307
|
+
})
|
1308
|
+
.then(result => {
|
1309
|
+
expect(fetchMock.done()).toBeTruthy(
|
1310
|
+
"All fetchMocks should have been called"
|
1311
|
+
);
|
1312
|
+
// verify we shared the item
|
1313
|
+
const shareOptions: RequestInit = fetchMock.lastOptions(
|
1314
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share"
|
1315
|
+
);
|
1316
|
+
expect(shareOptions.body).toContain("groups=t6b");
|
1317
|
+
|
1318
|
+
done();
|
1319
|
+
})
|
1320
|
+
.catch(e => {
|
1321
|
+
fail();
|
1322
|
+
});
|
1323
|
+
});
|
1324
|
+
});
|
1325
|
+
});
|