@synopackageland/cli 0.6.1 → 0.7.0
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/CHANGELOG.md +613 -0
- package/README.md +81 -89
- package/dist/add.js +39 -16
- package/dist/build-spk/delegate-scope.d.ts +6 -0
- package/dist/build-spk/delegate-scope.js +34 -0
- package/dist/build-spk/dsm-arch.d.ts +7 -1
- package/dist/build-spk/dsm-arch.js +24 -28
- package/dist/build-spk/dsm-platforms.json +39 -0
- package/dist/build-spk/dsm-version.d.ts +11 -0
- package/dist/build-spk/dsm-version.js +17 -0
- package/dist/build-spk/gateway.d.ts +1 -1
- package/dist/build-spk/gateway.js +2 -2
- package/dist/build-spk/generator.js +30 -5
- package/dist/build-spk/notices.js +4 -1
- package/dist/build-spk/resource-worker.js +3 -0
- package/dist/build-spk/wizard-messages.d.ts +66 -0
- package/dist/build-spk/wizard-messages.js +75 -9
- package/dist/cli.js +15 -7
- package/dist/contract/schema-validate.js +8 -0
- package/dist/contract/validate.js +30 -0
- package/dist/deploy/deploy.d.ts +1 -1
- package/dist/deploy/deploy.js +8 -0
- package/dist/deploy/plan.js +1 -1
- package/dist/deploy/spk-version.js +1 -1
- package/dist/error-registry.js +43 -15
- package/dist/host/dsm-client.d.ts +8 -4
- package/dist/host/dsm-client.js +10 -4
- package/dist/host/types.d.ts +2 -1
- package/dist/info.js +18 -2
- package/dist/init.d.ts +3 -0
- package/dist/init.js +49 -18
- package/dist/package-metadata.d.ts +21 -0
- package/dist/package-metadata.js +101 -0
- package/dist/portal/alias.d.ts +25 -0
- package/dist/portal/alias.js +48 -0
- package/dist/portal/package.d.ts +33 -0
- package/dist/portal/package.js +116 -0
- package/dist/runtime/delegate-contract.d.ts +79 -0
- package/dist/runtime/delegate-contract.js +27 -0
- package/dist/runtime/executor-build.d.ts +1 -1
- package/dist/runtime/executor-build.js +5 -4
- package/dist/runtime/executor-inspect.d.ts +3 -0
- package/dist/runtime/executor-inspect.js +11 -5
- package/dist/runtime/executor-policy.d.ts +12 -0
- package/dist/runtime/executor-policy.js +43 -3
- package/dist/runtime/executor-scope-task.d.ts +4 -0
- package/dist/runtime/executor-scope-task.js +21 -0
- package/dist/runtime/executor-tasks.d.ts +2 -1
- package/dist/runtime/executor-tasks.js +4 -4
- package/dist/skill.js +1 -0
- package/dist/standalone/api-permissions.d.ts +10 -0
- package/dist/standalone/api-permissions.js +19 -2
- package/dist/standalone/background.d.ts +16 -0
- package/dist/standalone/background.js +69 -2
- package/dist/standalone/binary.d.ts +1 -1
- package/dist/standalone/binary.js +22 -8
- package/dist/standalone/build.d.ts +1 -1
- package/dist/standalone/build.js +38 -8
- package/dist/standalone/daemon.d.ts +1 -1
- package/dist/standalone/daemon.js +2 -1
- package/dist/standalone/dsm-window.d.ts +3 -1
- package/dist/standalone/dsm-window.js +72 -15
- package/dist/standalone/inspect-spk.d.ts +8 -0
- package/dist/standalone/inspect-spk.js +105 -26
- package/dist/standalone/lifecycle.js +86 -8
- package/dist/standalone/manifest.d.ts +13 -0
- package/dist/standalone/manifest.js +57 -8
- package/dist/standalone/native-authorization-window.d.ts +1 -1
- package/dist/standalone/native-authorization-window.js +2 -0
- package/dist/standalone/native-layout.d.ts +3 -0
- package/dist/standalone/native-layout.js +37 -5
- package/dist/standalone/portal-window.d.ts +21 -0
- package/dist/standalone/portal-window.js +155 -0
- package/dist/standalone/portal.d.ts +4 -0
- package/dist/standalone/portal.js +4 -0
- package/dist/standalone/resource.d.ts +5 -3
- package/dist/standalone/resource.js +6 -3
- package/dist/standalone/root-window.js +62 -15
- package/dist/standalone/spk.d.ts +1 -1
- package/dist/standalone/spk.js +25 -7
- package/dist/templates/_daemon/main_test.go +61 -8
- package/dist/templates/_executor/README.md +127 -16
- package/dist/templates/_executor/anchor.go +146 -0
- package/dist/templates/_executor/anchor_test.go +126 -0
- package/dist/templates/_executor/apppriv_review_test.go +1 -1
- package/dist/templates/_executor/cancel_contract_test.go +236 -0
- package/dist/templates/_executor/copy.go +64 -0
- package/dist/templates/_executor/copy_test.go +88 -0
- package/dist/templates/_executor/dsm.go +23 -10
- package/dist/templates/_executor/dsm_test.go +95 -1
- package/dist/templates/_executor/executor.go +260 -49
- package/dist/templates/_executor/executor_test.go +36 -6
- package/dist/templates/_executor/identity.go +27 -1
- package/dist/templates/_executor/identity_kernel_linux_test.go +60 -0
- package/dist/templates/_executor/identity_linux.go +82 -0
- package/dist/templates/_executor/identity_security_test.go +43 -0
- package/dist/templates/_executor/internal/lifecycle/lifecycle.go +5 -0
- package/dist/templates/_executor/internal/lifecycle/lifecycle_test.go +61 -3
- package/dist/templates/_executor/internal/taskscript/boot.sh +9 -9
- package/dist/templates/_executor/internal/taskscript/cmd/main.go +2 -2
- package/dist/templates/_executor/internal/taskscript/control.sh +15 -10
- package/dist/templates/_executor/internal/taskscript/tasks.go +5 -3
- package/dist/templates/_executor/lifecycle_test.go +11 -0
- package/dist/templates/_executor/link_linux.go +28 -0
- package/dist/templates/_executor/long_running_test.go +530 -0
- package/dist/templates/_executor/main.go +72 -20
- package/dist/templates/_executor/move_linux.go +490 -0
- package/dist/templates/_executor/move_linux_test.go +460 -0
- package/dist/templates/_executor/move_validation.go +46 -0
- package/dist/templates/_executor/move_validation_test.go +187 -0
- package/dist/templates/_executor/operations.go +926 -0
- package/dist/templates/_executor/platform_linux.go +24 -173
- package/dist/templates/_executor/platform_linux_test.go +9 -65
- package/dist/templates/_executor/platform_other.go +30 -4
- package/dist/templates/_executor/process.go +3 -0
- package/dist/templates/_executor/records.go +242 -0
- package/dist/templates/_executor/scope_cancel_contract_test.go +91 -0
- package/dist/templates/_executor/scope_client.go +37 -0
- package/dist/templates/_executor/scope_contract.go +12 -0
- package/dist/templates/_executor/selected_scope.go +146 -0
- package/dist/templates/_executor/selected_scope_test.go +186 -0
- package/dist/templates/_executor/status_disabled_test.go +33 -0
- package/dist/templates/_executor/store.go +4 -3
- package/dist/templates/_executor/supervise.go +109 -0
- package/dist/templates/_executor/supervise_test.go +130 -0
- package/dist/templates/_executor/task_race_review_test.go +1 -1
- package/dist/templates/_executor/tasks.go +7 -8
- package/dist/templates/_executor/tasks_review_test.go +1 -1
- package/dist/templates/_executor/tasks_test.go +4 -4
- package/dist/templates/_executor/watch.go +8 -0
- package/dist/templates/_executor/watch_test.go +23 -2
- package/dist/templates/_executor/write_review_linux_test.go +4 -12
- package/dist/templates/_shared/AGENTS.md +129 -0
- package/dist/templates/binary/dsm-package.yaml +24 -0
- package/dist/templates/binary/i18n/messages/de.json +4 -0
- package/dist/templates/binary/i18n/messages/en.json +4 -0
- package/dist/templates/binary/i18n/messages/es.json +4 -0
- package/dist/templates/binary/i18n/messages/fr.json +4 -0
- package/dist/templates/binary/i18n/messages/it.json +4 -0
- package/dist/templates/binary/i18n/messages/ja.json +4 -0
- package/dist/templates/binary/i18n/messages/ko.json +4 -0
- package/dist/templates/binary/i18n/messages/zh-CN.json +4 -0
- package/dist/templates/binary/i18n/messages/zh-TW.json +4 -0
- package/dist/templates/binary/ui/app.js +19 -4
- package/dist/templates/native-authorization/AuthorizationGate.vue +5 -3
- package/dist/templates/native-authorization/i18n/de.json +1 -0
- package/dist/templates/native-authorization/i18n/en.json +1 -0
- package/dist/templates/native-authorization/i18n/es.json +2 -1
- package/dist/templates/native-authorization/i18n/fr.json +1 -0
- package/dist/templates/native-authorization/i18n/it.json +11 -10
- package/dist/templates/native-authorization/i18n/ja.json +1 -0
- package/dist/templates/native-authorization/i18n/ko.json +10 -9
- package/dist/templates/native-authorization/i18n/zh-CN.json +6 -5
- package/dist/templates/native-authorization/i18n/zh-TW.json +6 -5
- package/dist/templates/native-go/README.md +43 -10
- package/dist/templates/native-go/backend/cmd/app/main.go +27 -7
- package/dist/templates/native-go/backend/internal/api/entry_test.go +47 -0
- package/dist/templates/native-go/backend/internal/api/permissions_test.go +3 -3
- package/dist/templates/native-go/backend/internal/api/registry.go +11 -0
- package/dist/templates/native-go/backend/internal/api/sdk-permissions.json +14 -1
- package/dist/templates/native-go/backend/internal/api/server.go +18 -5
- package/dist/templates/native-go/backend/internal/app/delegate_config.go +57 -0
- package/dist/templates/native-go/backend/internal/app/delegate_config_test.go +28 -0
- package/dist/templates/native-go/backend/internal/app/portal.go +30 -0
- package/dist/templates/native-go/backend/internal/app/portal_test.go +55 -0
- package/dist/templates/native-go/backend/internal/app/routes.go +8 -2
- package/dist/templates/native-go/backend/internal/background/runner.go +1 -1
- package/dist/templates/native-go/backend/internal/background/store.go +16 -14
- package/dist/templates/native-go/backend/internal/dsm/admin.go +8 -2
- package/dist/templates/native-go/backend/internal/dsm/admin_linux.go +43 -13
- package/dist/templates/native-go/backend/internal/dsm/admin_linux_test.go +56 -0
- package/dist/templates/native-go/backend/internal/dsm/admin_other.go +4 -1
- package/dist/templates/native-go/backend/internal/dsm/apppriv.go +30 -0
- package/dist/templates/native-go/backend/internal/dsm/bridge_file.go +75 -0
- package/dist/templates/native-go/backend/internal/dsm/bridge_file_test.go +57 -0
- package/dist/templates/native-go/backend/internal/dsm/entry.go +177 -0
- package/dist/templates/native-go/backend/internal/dsm/entry_test.go +315 -0
- package/dist/templates/native-go/backend/internal/dsm/native/admin-armv7.elf +0 -0
- package/dist/templates/native-go/backend/internal/dsm/native/apppriv-aarch64.elf +0 -0
- package/dist/templates/native-go/backend/internal/dsm/native/apppriv-armv7.elf +0 -0
- package/dist/templates/native-go/backend/internal/dsm/native/apppriv-x86_64.elf +0 -0
- package/dist/templates/native-go/backend/internal/dsm/native/apppriv_check.c +33 -0
- package/dist/templates/native-go/backend/internal/dsm/native/build.sh +13 -4
- package/dist/templates/native-go/backend/internal/dsm/native/provenance.json +9 -3
- package/dist/templates/native-go/backend/internal/filestation/check_permission.go +71 -0
- package/dist/templates/native-go/backend/internal/filestation/check_permission_test.go +77 -0
- package/dist/templates/native-go/backend/internal/filestation/sdk_policy_test.go +39 -0
- package/dist/templates/native-go/backend/internal/filestation/service.go +1 -1
- package/dist/templates/native-go/backend/internal/portal/portal.go +138 -0
- package/dist/templates/native-go/backend/internal/portal/portal_test.go +89 -0
- package/dist/templates/native-go/dsm-package.yaml +20 -1
- package/dist/templates/native-go/i18n/glossary.json +2 -1
- package/dist/templates/native-go/i18n/messages/de.json +1 -0
- package/dist/templates/native-go/i18n/messages/en.json +1 -0
- package/dist/templates/native-go/i18n/messages/es.json +1 -0
- package/dist/templates/native-go/i18n/messages/fr.json +1 -0
- package/dist/templates/native-go/i18n/messages/it.json +1 -0
- package/dist/templates/native-go/i18n/messages/ja.json +1 -0
- package/dist/templates/native-go/i18n/messages/ko.json +1 -0
- package/dist/templates/native-go/i18n/messages/zh-CN.json +1 -0
- package/dist/templates/native-go/i18n/messages/zh-TW.json +1 -0
- package/dist/templates/native-go/ui/app.css +10 -0
- package/dist/templates/native-go/ui/app.js +11 -1
- package/dist/templates/native-go-delegate/DELEGATE.md +126 -5
- package/dist/templates/native-go-delegate/backend/cmd/background-worker/main.go +7 -0
- package/dist/templates/native-go-delegate/backend/internal/app/delegate.go +11 -1
- package/dist/templates/native-go-delegate/backend/internal/app/delegate_routes_test.go +14 -0
- package/dist/templates/native-go-delegate/backend/internal/background/delegated_moves.go +270 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/admission_recovery_test.go +410 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/cancel_contract_test.go +95 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/client.go +8 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/destination.go +110 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/destination_state.go +117 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/destination_state_test.go +60 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/destination_test.go +116 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/example.go +81 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/example_test.go +91 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/executor_contract_test.go +511 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/files.go +1 -1
- package/dist/templates/native-go-delegate/backend/internal/delegate/long_running_routes.go +92 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/long_running_routes_test.go +99 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/move.go +348 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/move_test.go +351 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/operations_list.go +65 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/operations_list_test.go +114 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/retry_test.go +1 -1
- package/dist/templates/native-go-delegate/backend/internal/delegate/service.go +58 -17
- package/dist/templates/native-go-delegate/backend/internal/delegate/staging.go +121 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/status_disabled_test.go +51 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/testdata/executor_contract.txt +112 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/transient_contract_test.go +137 -0
- package/dist/templates/native-go-delegate/backend/internal/filestation/files.go +1 -31
- package/dist/templates/native-go-delegate/frontend/src/CapabilityPanels.vue +30 -3
- package/dist/templates/native-go-delegate/frontend/src/delegate/BackgroundSavePanel.vue +113 -0
- package/dist/templates/native-go-delegate/frontend/src/delegate/copy.ts +5 -6
- package/dist/templates/native-go-delegate/frontend/test/background-save.test.ts +121 -0
- package/dist/templates/native-go-delegate/frontend/test/scope-settings.test.ts +49 -0
- package/dist/templates/native-go-delegate/test.sh +1 -0
- package/dist/templates/native-go-jobs/frontend/src/background/i18n/de.json +2 -2
- package/dist/templates/native-go-jobs/frontend/src/background/i18n/en.json +2 -2
- package/dist/templates/native-go-jobs/frontend/src/background/i18n/es.json +12 -12
- package/dist/templates/native-go-jobs/frontend/src/background/i18n/fr.json +4 -4
- package/dist/templates/native-go-jobs/frontend/src/background/i18n/it.json +17 -17
- package/dist/templates/native-go-jobs/frontend/src/background/i18n/ja.json +7 -7
- package/dist/templates/native-go-jobs/frontend/src/background/i18n/ko.json +15 -15
- package/dist/templates/native-go-jobs/frontend/src/background/i18n/zh-CN.json +3 -3
- package/dist/templates/native-go-jobs/frontend/src/background/i18n/zh-TW.json +2 -2
- package/dist/templates/native-go-jobs/frontend/test/background.test.ts +25 -28
- package/dist/templates/native-go-vue/README.md +4 -0
- package/dist/templates/native-go-vue/frontend/package-lock.json +4 -4
- package/dist/templates/native-go-vue/frontend/package.json +1 -1
- package/dist/templates/native-go-vue/frontend/src/App.vue +18 -13
- package/dist/templates/native-go-vue/frontend/src/context.ts +31 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/ExecutorSettings.vue +52 -8
- package/dist/templates/native-go-vue/frontend/src/delegate/catalogs.ts +11 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/copy.test.ts +12 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/copy.ts +4 -4
- package/dist/templates/native-go-vue/frontend/src/delegate/executor-setup.ts +4 -2
- package/dist/templates/native-go-vue/frontend/src/delegate/facade.test.ts +100 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/facade.ts +85 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/de.json +46 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/en.json +12 -2
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/es.json +46 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/fr.json +46 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/it.json +46 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/ja.json +46 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/ko.json +46 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/save/de.json +42 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/save/en.json +42 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/save/es.json +42 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/save/fr.json +42 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/save/it.json +42 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/save/ja.json +42 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/save/ko.json +42 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/save/zh-CN.json +42 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/save/zh-TW.json +42 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/zh-CN.json +46 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/zh-TW.json +15 -5
- package/dist/templates/native-go-vue/frontend/src/delegate/long-running.ts +57 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/save-copy.test.ts +12 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/save-copy.ts +24 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/scoped-picker.test.ts +12 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/scoped-picker.ts +21 -0
- package/dist/templates/native-go-vue/frontend/src/files/files.test.ts +7 -0
- package/dist/templates/native-go-vue/frontend/src/i18n/de.json +20 -0
- package/dist/templates/native-go-vue/frontend/src/i18n/en.json +20 -0
- package/dist/templates/native-go-vue/frontend/src/i18n/es.json +20 -0
- package/dist/templates/native-go-vue/frontend/src/i18n/fr.json +20 -0
- package/dist/templates/native-go-vue/frontend/src/i18n/it.json +20 -0
- package/dist/templates/native-go-vue/frontend/src/i18n/ja.json +20 -0
- package/dist/templates/native-go-vue/frontend/src/i18n/ko.json +20 -0
- package/dist/templates/native-go-vue/frontend/src/i18n/zh-CN.json +20 -0
- package/dist/templates/native-go-vue/frontend/src/i18n/zh-TW.json +20 -0
- package/dist/templates/native-go-vue/frontend/src/i18n.ts +13 -0
- package/dist/templates/native-go-vue/frontend/src/identity/LoginPage.vue +16 -14
- package/dist/templates/native-go-vue/frontend/src/identity/i18n/de.json +27 -0
- package/dist/templates/native-go-vue/frontend/src/identity/i18n/en.json +27 -0
- package/dist/templates/native-go-vue/frontend/src/identity/i18n/es.json +27 -0
- package/dist/templates/native-go-vue/frontend/src/identity/i18n/fr.json +27 -0
- package/dist/templates/native-go-vue/frontend/src/identity/i18n/it.json +27 -0
- package/dist/templates/native-go-vue/frontend/src/identity/i18n/ja.json +27 -0
- package/dist/templates/native-go-vue/frontend/src/identity/i18n/ko.json +27 -0
- package/dist/templates/native-go-vue/frontend/src/identity/i18n/zh-CN.json +27 -0
- package/dist/templates/native-go-vue/frontend/src/identity/i18n/zh-TW.json +27 -0
- package/dist/templates/native-go-vue/frontend/src/identity/i18n.ts +14 -0
- package/dist/templates/native-go-vue/frontend/src/identity/session.test.ts +4 -0
- package/dist/templates/native-go-vue/frontend/src/identity/session.ts +9 -8
- package/dist/templates/native-go-vue/frontend/src/nas/NasPicker.vue +31 -12
- package/dist/templates/native-go-vue/frontend/src/nas/destination.test.ts +48 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/files/de.json +1 -1
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/files/en.json +1 -1
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/files/es.json +10 -10
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/files/fr.json +1 -1
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/files/it.json +12 -12
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/files/ja.json +15 -15
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/files/ko.json +12 -12
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/files/zh-CN.json +1 -1
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/files/zh-TW.json +1 -1
- package/dist/templates/native-go-vue/frontend/src/portal/PortalSettings.vue +39 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/fr.json +1 -1
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/ja.json +1 -1
- package/dist/templates/native-go-vue/frontend/test/apps.test.ts +14 -0
- package/dist/templates/native-go-vue/frontend/test/portal-settings.test.ts +71 -0
- package/dist/templates/native-go-vue/frontend/test/shell-i18n.test.ts +50 -0
- package/package.json +5 -1
- package/schema/package-metadata.schema.json +101 -0
- package/schema/synology-app.schema.json +112 -0
- package/skills/SKILL.md +106 -4
- package/skills/reference/create.md +101 -2
- package/skills/reference/deploy.md +2 -2
- package/skills/reference/files.md +113 -2
- package/skills/reference/identity.md +70 -1
- package/skills/reference/portal.md +17 -0
- package/skills/reference/ui-vue.md +12 -0
- package/templates/_daemon/main_test.go +61 -8
- package/templates/_executor/README.md +127 -16
- package/templates/_executor/anchor.go +146 -0
- package/templates/_executor/anchor_test.go +126 -0
- package/templates/_executor/apppriv_review_test.go +1 -1
- package/templates/_executor/cancel_contract_test.go +236 -0
- package/templates/_executor/copy.go +64 -0
- package/templates/_executor/copy_test.go +88 -0
- package/templates/_executor/dsm.go +23 -10
- package/templates/_executor/dsm_test.go +95 -1
- package/templates/_executor/executor.go +260 -49
- package/templates/_executor/executor_test.go +36 -6
- package/templates/_executor/identity.go +27 -1
- package/templates/_executor/identity_kernel_linux_test.go +60 -0
- package/templates/_executor/identity_linux.go +82 -0
- package/templates/_executor/identity_security_test.go +43 -0
- package/templates/_executor/internal/lifecycle/lifecycle.go +5 -0
- package/templates/_executor/internal/lifecycle/lifecycle_test.go +61 -3
- package/templates/_executor/internal/taskscript/boot.sh +9 -9
- package/templates/_executor/internal/taskscript/cmd/main.go +2 -2
- package/templates/_executor/internal/taskscript/control.sh +15 -10
- package/templates/_executor/internal/taskscript/tasks.go +5 -3
- package/templates/_executor/lifecycle_test.go +11 -0
- package/templates/_executor/link_linux.go +28 -0
- package/templates/_executor/long_running_test.go +530 -0
- package/templates/_executor/main.go +72 -20
- package/templates/_executor/move_linux.go +490 -0
- package/templates/_executor/move_linux_test.go +460 -0
- package/templates/_executor/move_validation.go +46 -0
- package/templates/_executor/move_validation_test.go +187 -0
- package/templates/_executor/operations.go +926 -0
- package/templates/_executor/platform_linux.go +24 -173
- package/templates/_executor/platform_linux_test.go +9 -65
- package/templates/_executor/platform_other.go +30 -4
- package/templates/_executor/process.go +3 -0
- package/templates/_executor/records.go +242 -0
- package/templates/_executor/scope_cancel_contract_test.go +91 -0
- package/templates/_executor/scope_client.go +37 -0
- package/templates/_executor/scope_contract.go +12 -0
- package/templates/_executor/selected_scope.go +146 -0
- package/templates/_executor/selected_scope_test.go +186 -0
- package/templates/_executor/status_disabled_test.go +33 -0
- package/templates/_executor/store.go +4 -3
- package/templates/_executor/supervise.go +109 -0
- package/templates/_executor/supervise_test.go +130 -0
- package/templates/_executor/task_race_review_test.go +1 -1
- package/templates/_executor/tasks.go +7 -8
- package/templates/_executor/tasks_review_test.go +1 -1
- package/templates/_executor/tasks_test.go +4 -4
- package/templates/_executor/watch.go +8 -0
- package/templates/_executor/watch_test.go +23 -2
- package/templates/_executor/write_review_linux_test.go +4 -12
- package/templates/_shared/AGENTS.md +129 -0
- package/templates/binary/dsm-package.yaml +24 -0
- package/templates/binary/i18n/messages/de.json +4 -0
- package/templates/binary/i18n/messages/en.json +4 -0
- package/templates/binary/i18n/messages/es.json +4 -0
- package/templates/binary/i18n/messages/fr.json +4 -0
- package/templates/binary/i18n/messages/it.json +4 -0
- package/templates/binary/i18n/messages/ja.json +4 -0
- package/templates/binary/i18n/messages/ko.json +4 -0
- package/templates/binary/i18n/messages/zh-CN.json +4 -0
- package/templates/binary/i18n/messages/zh-TW.json +4 -0
- package/templates/binary/ui/app.js +19 -4
- package/templates/native-authorization/AuthorizationGate.vue +5 -3
- package/templates/native-authorization/i18n/de.json +1 -0
- package/templates/native-authorization/i18n/en.json +1 -0
- package/templates/native-authorization/i18n/es.json +2 -1
- package/templates/native-authorization/i18n/fr.json +1 -0
- package/templates/native-authorization/i18n/it.json +11 -10
- package/templates/native-authorization/i18n/ja.json +1 -0
- package/templates/native-authorization/i18n/ko.json +10 -9
- package/templates/native-authorization/i18n/zh-CN.json +6 -5
- package/templates/native-authorization/i18n/zh-TW.json +6 -5
- package/templates/native-go/README.md +43 -10
- package/templates/native-go/backend/cmd/app/main.go +27 -7
- package/templates/native-go/backend/internal/api/entry_test.go +47 -0
- package/templates/native-go/backend/internal/api/permissions_test.go +3 -3
- package/templates/native-go/backend/internal/api/registry.go +11 -0
- package/templates/native-go/backend/internal/api/sdk-permissions.json +14 -1
- package/templates/native-go/backend/internal/api/server.go +18 -5
- package/templates/native-go/backend/internal/app/delegate_config.go +57 -0
- package/templates/native-go/backend/internal/app/delegate_config_test.go +28 -0
- package/templates/native-go/backend/internal/app/portal.go +30 -0
- package/templates/native-go/backend/internal/app/portal_test.go +55 -0
- package/templates/native-go/backend/internal/app/routes.go +8 -2
- package/templates/native-go/backend/internal/background/runner.go +1 -1
- package/templates/native-go/backend/internal/background/store.go +16 -14
- package/templates/native-go/backend/internal/dsm/admin.go +8 -2
- package/templates/native-go/backend/internal/dsm/admin_linux.go +43 -13
- package/templates/native-go/backend/internal/dsm/admin_linux_test.go +56 -0
- package/templates/native-go/backend/internal/dsm/admin_other.go +4 -1
- package/templates/native-go/backend/internal/dsm/apppriv.go +30 -0
- package/templates/native-go/backend/internal/dsm/bridge_file.go +75 -0
- package/templates/native-go/backend/internal/dsm/bridge_file_test.go +57 -0
- package/templates/native-go/backend/internal/dsm/entry.go +177 -0
- package/templates/native-go/backend/internal/dsm/entry_test.go +315 -0
- package/templates/native-go/backend/internal/dsm/native/admin-armv7.elf +0 -0
- package/templates/native-go/backend/internal/dsm/native/apppriv-aarch64.elf +0 -0
- package/templates/native-go/backend/internal/dsm/native/apppriv-armv7.elf +0 -0
- package/templates/native-go/backend/internal/dsm/native/apppriv-x86_64.elf +0 -0
- package/templates/native-go/backend/internal/dsm/native/apppriv_check.c +33 -0
- package/templates/native-go/backend/internal/dsm/native/build.sh +13 -4
- package/templates/native-go/backend/internal/dsm/native/provenance.json +9 -3
- package/templates/native-go/backend/internal/filestation/check_permission.go +71 -0
- package/templates/native-go/backend/internal/filestation/check_permission_test.go +77 -0
- package/templates/native-go/backend/internal/filestation/sdk_policy_test.go +39 -0
- package/templates/native-go/backend/internal/filestation/service.go +1 -1
- package/templates/native-go/backend/internal/portal/portal.go +138 -0
- package/templates/native-go/backend/internal/portal/portal_test.go +89 -0
- package/templates/native-go/dsm-package.yaml +20 -1
- package/templates/native-go/i18n/glossary.json +2 -1
- package/templates/native-go/i18n/messages/de.json +1 -0
- package/templates/native-go/i18n/messages/en.json +1 -0
- package/templates/native-go/i18n/messages/es.json +1 -0
- package/templates/native-go/i18n/messages/fr.json +1 -0
- package/templates/native-go/i18n/messages/it.json +1 -0
- package/templates/native-go/i18n/messages/ja.json +1 -0
- package/templates/native-go/i18n/messages/ko.json +1 -0
- package/templates/native-go/i18n/messages/zh-CN.json +1 -0
- package/templates/native-go/i18n/messages/zh-TW.json +1 -0
- package/templates/native-go/ui/app.css +10 -0
- package/templates/native-go/ui/app.js +11 -1
- package/templates/native-go-delegate/DELEGATE.md +126 -5
- package/templates/native-go-delegate/backend/cmd/background-worker/main.go +7 -0
- package/templates/native-go-delegate/backend/internal/app/delegate.go +11 -1
- package/templates/native-go-delegate/backend/internal/app/delegate_routes_test.go +14 -0
- package/templates/native-go-delegate/backend/internal/background/delegated_moves.go +270 -0
- package/templates/native-go-delegate/backend/internal/delegate/admission_recovery_test.go +410 -0
- package/templates/native-go-delegate/backend/internal/delegate/cancel_contract_test.go +95 -0
- package/templates/native-go-delegate/backend/internal/delegate/client.go +8 -0
- package/templates/native-go-delegate/backend/internal/delegate/destination.go +110 -0
- package/templates/native-go-delegate/backend/internal/delegate/destination_state.go +117 -0
- package/templates/native-go-delegate/backend/internal/delegate/destination_state_test.go +60 -0
- package/templates/native-go-delegate/backend/internal/delegate/destination_test.go +116 -0
- package/templates/native-go-delegate/backend/internal/delegate/example.go +81 -0
- package/templates/native-go-delegate/backend/internal/delegate/example_test.go +91 -0
- package/templates/native-go-delegate/backend/internal/delegate/executor_contract_test.go +511 -0
- package/templates/native-go-delegate/backend/internal/delegate/files.go +1 -1
- package/templates/native-go-delegate/backend/internal/delegate/long_running_routes.go +92 -0
- package/templates/native-go-delegate/backend/internal/delegate/long_running_routes_test.go +99 -0
- package/templates/native-go-delegate/backend/internal/delegate/move.go +348 -0
- package/templates/native-go-delegate/backend/internal/delegate/move_test.go +351 -0
- package/templates/native-go-delegate/backend/internal/delegate/operations_list.go +65 -0
- package/templates/native-go-delegate/backend/internal/delegate/operations_list_test.go +114 -0
- package/templates/native-go-delegate/backend/internal/delegate/retry_test.go +1 -1
- package/templates/native-go-delegate/backend/internal/delegate/service.go +58 -17
- package/templates/native-go-delegate/backend/internal/delegate/staging.go +121 -0
- package/templates/native-go-delegate/backend/internal/delegate/status_disabled_test.go +51 -0
- package/templates/native-go-delegate/backend/internal/delegate/testdata/executor_contract.txt +112 -0
- package/templates/native-go-delegate/backend/internal/delegate/transient_contract_test.go +137 -0
- package/templates/native-go-delegate/backend/internal/filestation/files.go +1 -31
- package/templates/native-go-delegate/frontend/src/CapabilityPanels.vue +30 -3
- package/templates/native-go-delegate/frontend/src/delegate/BackgroundSavePanel.vue +113 -0
- package/templates/native-go-delegate/frontend/src/delegate/copy.ts +5 -6
- package/templates/native-go-delegate/frontend/test/background-save.test.ts +121 -0
- package/templates/native-go-delegate/frontend/test/scope-settings.test.ts +49 -0
- package/templates/native-go-delegate/test.sh +1 -0
- package/templates/native-go-jobs/frontend/src/background/i18n/de.json +2 -2
- package/templates/native-go-jobs/frontend/src/background/i18n/en.json +2 -2
- package/templates/native-go-jobs/frontend/src/background/i18n/es.json +12 -12
- package/templates/native-go-jobs/frontend/src/background/i18n/fr.json +4 -4
- package/templates/native-go-jobs/frontend/src/background/i18n/it.json +17 -17
- package/templates/native-go-jobs/frontend/src/background/i18n/ja.json +7 -7
- package/templates/native-go-jobs/frontend/src/background/i18n/ko.json +15 -15
- package/templates/native-go-jobs/frontend/src/background/i18n/zh-CN.json +3 -3
- package/templates/native-go-jobs/frontend/src/background/i18n/zh-TW.json +2 -2
- package/templates/native-go-jobs/frontend/test/background.test.ts +25 -28
- package/templates/native-go-vue/README.md +4 -0
- package/templates/native-go-vue/frontend/package-lock.json +4 -4
- package/templates/native-go-vue/frontend/package.json +1 -1
- package/templates/native-go-vue/frontend/src/App.vue +18 -13
- package/templates/native-go-vue/frontend/src/context.ts +31 -0
- package/templates/native-go-vue/frontend/src/delegate/ExecutorSettings.vue +52 -8
- package/templates/native-go-vue/frontend/src/delegate/catalogs.ts +11 -0
- package/templates/native-go-vue/frontend/src/delegate/copy.test.ts +12 -0
- package/templates/native-go-vue/frontend/src/delegate/copy.ts +4 -4
- package/templates/native-go-vue/frontend/src/delegate/executor-setup.ts +4 -2
- package/templates/native-go-vue/frontend/src/delegate/facade.test.ts +100 -0
- package/templates/native-go-vue/frontend/src/delegate/facade.ts +85 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/de.json +46 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/en.json +12 -2
- package/templates/native-go-vue/frontend/src/delegate/i18n/es.json +46 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/fr.json +46 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/it.json +46 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/ja.json +46 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/ko.json +46 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/save/de.json +42 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/save/en.json +42 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/save/es.json +42 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/save/fr.json +42 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/save/it.json +42 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/save/ja.json +42 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/save/ko.json +42 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/save/zh-CN.json +42 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/save/zh-TW.json +42 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/zh-CN.json +46 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/zh-TW.json +15 -5
- package/templates/native-go-vue/frontend/src/delegate/long-running.ts +57 -0
- package/templates/native-go-vue/frontend/src/delegate/save-copy.test.ts +12 -0
- package/templates/native-go-vue/frontend/src/delegate/save-copy.ts +24 -0
- package/templates/native-go-vue/frontend/src/delegate/scoped-picker.test.ts +12 -0
- package/templates/native-go-vue/frontend/src/delegate/scoped-picker.ts +21 -0
- package/templates/native-go-vue/frontend/src/files/files.test.ts +7 -0
- package/templates/native-go-vue/frontend/src/i18n/de.json +20 -0
- package/templates/native-go-vue/frontend/src/i18n/en.json +20 -0
- package/templates/native-go-vue/frontend/src/i18n/es.json +20 -0
- package/templates/native-go-vue/frontend/src/i18n/fr.json +20 -0
- package/templates/native-go-vue/frontend/src/i18n/it.json +20 -0
- package/templates/native-go-vue/frontend/src/i18n/ja.json +20 -0
- package/templates/native-go-vue/frontend/src/i18n/ko.json +20 -0
- package/templates/native-go-vue/frontend/src/i18n/zh-CN.json +20 -0
- package/templates/native-go-vue/frontend/src/i18n/zh-TW.json +20 -0
- package/templates/native-go-vue/frontend/src/i18n.ts +13 -0
- package/templates/native-go-vue/frontend/src/identity/LoginPage.vue +16 -14
- package/templates/native-go-vue/frontend/src/identity/i18n/de.json +27 -0
- package/templates/native-go-vue/frontend/src/identity/i18n/en.json +27 -0
- package/templates/native-go-vue/frontend/src/identity/i18n/es.json +27 -0
- package/templates/native-go-vue/frontend/src/identity/i18n/fr.json +27 -0
- package/templates/native-go-vue/frontend/src/identity/i18n/it.json +27 -0
- package/templates/native-go-vue/frontend/src/identity/i18n/ja.json +27 -0
- package/templates/native-go-vue/frontend/src/identity/i18n/ko.json +27 -0
- package/templates/native-go-vue/frontend/src/identity/i18n/zh-CN.json +27 -0
- package/templates/native-go-vue/frontend/src/identity/i18n/zh-TW.json +27 -0
- package/templates/native-go-vue/frontend/src/identity/i18n.ts +14 -0
- package/templates/native-go-vue/frontend/src/identity/session.test.ts +4 -0
- package/templates/native-go-vue/frontend/src/identity/session.ts +9 -8
- package/templates/native-go-vue/frontend/src/nas/NasPicker.vue +31 -12
- package/templates/native-go-vue/frontend/src/nas/destination.test.ts +48 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/files/de.json +1 -1
- package/templates/native-go-vue/frontend/src/nas/i18n/files/en.json +1 -1
- package/templates/native-go-vue/frontend/src/nas/i18n/files/es.json +10 -10
- package/templates/native-go-vue/frontend/src/nas/i18n/files/fr.json +1 -1
- package/templates/native-go-vue/frontend/src/nas/i18n/files/it.json +12 -12
- package/templates/native-go-vue/frontend/src/nas/i18n/files/ja.json +15 -15
- package/templates/native-go-vue/frontend/src/nas/i18n/files/ko.json +12 -12
- package/templates/native-go-vue/frontend/src/nas/i18n/files/zh-CN.json +1 -1
- package/templates/native-go-vue/frontend/src/nas/i18n/files/zh-TW.json +1 -1
- package/templates/native-go-vue/frontend/src/portal/PortalSettings.vue +39 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/fr.json +1 -1
- package/templates/native-go-vue/frontend/src/shell/i18n/ja.json +1 -1
- package/templates/native-go-vue/frontend/test/apps.test.ts +14 -0
- package/templates/native-go-vue/frontend/test/portal-settings.test.ts +71 -0
- package/templates/native-go-vue/frontend/test/shell-i18n.test.ts +50 -0
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"encoding/json"
|
|
6
|
+
"errors"
|
|
7
|
+
"fmt"
|
|
8
|
+
"os"
|
|
9
|
+
"path/filepath"
|
|
10
|
+
"strings"
|
|
11
|
+
"testing"
|
|
12
|
+
"time"
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
func TestLongGrantExplicitOptInAndPersistence(t *testing.T) {
|
|
16
|
+
e, f, _ := setup(t)
|
|
17
|
+
p := map[string]any{"ops": []string{"files.moveFromStaging"}, "scope": "home", "path": "/home", "destination": "save", "lifetime": "until-revoked"}
|
|
18
|
+
if r := request(e, "delegate.create", p); r.OK {
|
|
19
|
+
t.Fatal("unopted policy created long grant")
|
|
20
|
+
}
|
|
21
|
+
e.Policy.Destinations = []string{"save"}
|
|
22
|
+
e.Policy.Lifetime = "until-revoked"
|
|
23
|
+
f.user.Admin = true
|
|
24
|
+
r := request(e, "delegate.create", p)
|
|
25
|
+
if !r.OK {
|
|
26
|
+
t.Fatal(r)
|
|
27
|
+
}
|
|
28
|
+
b, _ := json.Marshal(r.Result)
|
|
29
|
+
var d Delegation
|
|
30
|
+
json.Unmarshal(b, &d)
|
|
31
|
+
persisted, err := (&Store{Dir: e.Store.Dir}).Get(d.ID)
|
|
32
|
+
if err != nil || persisted.Lifetime != "until-revoked" || !persisted.Expires.IsZero() || persisted.Subject.UID != 1200 {
|
|
33
|
+
t.Fatal(persisted, err)
|
|
34
|
+
}
|
|
35
|
+
e.Now = func() time.Time { return time.Unix(9999999999, 0) }
|
|
36
|
+
if r := request(e, "delegate.revoke", map[string]any{"delegation_id": d.ID}); !r.OK {
|
|
37
|
+
t.Fatal(r)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
func TestAdminDisableCoversLegacyAndPersists(t *testing.T) {
|
|
41
|
+
e, f, w := setup(t)
|
|
42
|
+
id := create(t, e)
|
|
43
|
+
if r := request(e, "delegate.disable", map[string]any{}); r.Code != "ADMIN_REQUIRED" {
|
|
44
|
+
t.Fatal(r)
|
|
45
|
+
}
|
|
46
|
+
f.user.Admin = true
|
|
47
|
+
if r := request(e, "delegate.disable", map[string]any{}); !r.OK {
|
|
48
|
+
t.Fatal(r)
|
|
49
|
+
}
|
|
50
|
+
fresh := &Executor{Policy: e.Policy, DSM: e.DSM, Writer: w, Store: &Store{Dir: e.Store.Dir}, Now: e.Now}
|
|
51
|
+
if r := request(fresh, "delegate.create", map[string]any{"job_id": "new", "ops": []string{"files.write"}, "scope": "home", "path": "/home", "ttl_seconds": 60}); r.Code != "disabled" {
|
|
52
|
+
t.Fatal(r)
|
|
53
|
+
}
|
|
54
|
+
if r := request(fresh, "files.write", map[string]any{"delegation_id": id, "job_id": "job1", "staging": "source", "dest_dir": "/home", "name": "x"}); r.Code != "disabled" || w.calls != 0 {
|
|
55
|
+
t.Fatal(r)
|
|
56
|
+
}
|
|
57
|
+
if r := request(fresh, "delegate.enable", map[string]any{}); !r.OK {
|
|
58
|
+
t.Fatal(r)
|
|
59
|
+
}
|
|
60
|
+
if r := request(fresh, "files.write", map[string]any{"delegation_id": id, "job_id": "job1", "staging": "source", "dest_dir": "/home", "name": "x"}); r.Code != "DELEGATION_DENIED" {
|
|
61
|
+
t.Fatal("enable revived grant", r)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
func TestLongGrantNoSessionlessRevoke(t *testing.T) {
|
|
65
|
+
e, _, _ := setup(t)
|
|
66
|
+
e.Policy.Destinations = []string{"save"}
|
|
67
|
+
e.Policy.Lifetime = "until-revoked"
|
|
68
|
+
r := request(e, "delegate.create", map[string]any{"ops": []string{"files.moveFromStaging"}, "scope": "home", "path": "/home", "destination": "save", "lifetime": "until-revoked"})
|
|
69
|
+
if !r.OK {
|
|
70
|
+
t.Fatal(r)
|
|
71
|
+
}
|
|
72
|
+
b, _ := json.Marshal(r.Result)
|
|
73
|
+
var d Delegation
|
|
74
|
+
json.Unmarshal(b, &d)
|
|
75
|
+
r = e.Handle(context.Background(), Request{Version: 1, Op: "delegate.revoke", Params: json.RawMessage(`{"delegation_id":"` + d.ID + `","job_id":"job1"}`)})
|
|
76
|
+
if r.Code != "DELEGATION_DENIED" {
|
|
77
|
+
t.Fatal(r)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Two-phase fake blocks during bulk work but calls the REAL protected fence.
|
|
82
|
+
type barrierMoveWriter struct {
|
|
83
|
+
copying, release chan struct{}
|
|
84
|
+
published chan struct{}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
func (w *barrierMoveWriter) Write(context.Context, Subject, string, string, string, string) error {
|
|
88
|
+
return nil
|
|
89
|
+
}
|
|
90
|
+
func (w *barrierMoveWriter) Move(ctx context.Context, s Subject, op Operation, d Delegation, guard func(func() (MoveReceipt, error)) (MoveReceipt, error)) (MoveReceipt, error) {
|
|
91
|
+
close(w.copying)
|
|
92
|
+
select {
|
|
93
|
+
case <-ctx.Done():
|
|
94
|
+
return MoveReceipt{}, ctx.Err()
|
|
95
|
+
case <-w.release:
|
|
96
|
+
}
|
|
97
|
+
return guard(func() (MoveReceipt, error) { close(w.published); return MoveReceipt{Path: d.Path + "/" + op.Name}, nil })
|
|
98
|
+
}
|
|
99
|
+
func longGrant(t *testing.T, e *Executor) string {
|
|
100
|
+
t.Helper()
|
|
101
|
+
e.Policy.Destinations = []string{"save"}
|
|
102
|
+
e.Policy.Lifetime = "until-revoked"
|
|
103
|
+
r := request(e, "delegate.create", map[string]any{"ops": []string{"files.moveFromStaging"}, "scope": "home", "path": "/home", "destination": "save", "lifetime": "until-revoked"})
|
|
104
|
+
if !r.OK {
|
|
105
|
+
t.Fatal(r)
|
|
106
|
+
}
|
|
107
|
+
b, _ := json.Marshal(r.Result)
|
|
108
|
+
var d Delegation
|
|
109
|
+
json.Unmarshal(b, &d)
|
|
110
|
+
return d.ID
|
|
111
|
+
}
|
|
112
|
+
func offline(e *Executor, op string, p any) Response {
|
|
113
|
+
b, _ := json.Marshal(p)
|
|
114
|
+
return e.Handle(context.Background(), Request{Version: 1, Op: op, Params: b})
|
|
115
|
+
}
|
|
116
|
+
func moveParams(id, job string) map[string]any {
|
|
117
|
+
return map[string]any{"delegation_id": id, "job_id": job, "staging": "result", "name": "out.csv", "size": 123}
|
|
118
|
+
}
|
|
119
|
+
func waitState(t *testing.T, e *Executor, job, state string) Operation {
|
|
120
|
+
t.Helper()
|
|
121
|
+
deadline := time.Now().Add(2 * time.Second)
|
|
122
|
+
for time.Now().Before(deadline) {
|
|
123
|
+
e.commitMu.Lock()
|
|
124
|
+
op, err := e.Store.GetOperation(job)
|
|
125
|
+
e.commitMu.Unlock()
|
|
126
|
+
if err == nil && op.State == state {
|
|
127
|
+
return op
|
|
128
|
+
}
|
|
129
|
+
time.Sleep(time.Millisecond)
|
|
130
|
+
}
|
|
131
|
+
t.Fatal("missing state", state)
|
|
132
|
+
return Operation{}
|
|
133
|
+
}
|
|
134
|
+
func TestRevokeDisableCancelNeverPublishAfterAcknowledgement(t *testing.T) {
|
|
135
|
+
for _, action := range []string{"delegate.revoke", "delegate.disable", "files.cancelOperation"} {
|
|
136
|
+
t.Run(action, func(t *testing.T) {
|
|
137
|
+
e, f, _ := setup(t)
|
|
138
|
+
id := longGrant(t, e)
|
|
139
|
+
w := &barrierMoveWriter{make(chan struct{}), make(chan struct{}), make(chan struct{})}
|
|
140
|
+
e.Writer = w
|
|
141
|
+
if err := e.startOperations(context.Background()); err != nil {
|
|
142
|
+
t.Fatal(err)
|
|
143
|
+
}
|
|
144
|
+
defer e.stopOperations()
|
|
145
|
+
if r := offline(e, "files.moveFromStaging", moveParams(id, "job")); !r.OK {
|
|
146
|
+
t.Fatal(r)
|
|
147
|
+
}
|
|
148
|
+
select {
|
|
149
|
+
case <-w.copying:
|
|
150
|
+
case <-time.After(time.Second):
|
|
151
|
+
t.Fatal("copy did not start")
|
|
152
|
+
}
|
|
153
|
+
if action == "delegate.disable" {
|
|
154
|
+
f.user.Admin = true
|
|
155
|
+
}
|
|
156
|
+
r := request(e, action, map[string]any{"delegation_id": id, "job_id": "job"})
|
|
157
|
+
if action == "delegate.disable" {
|
|
158
|
+
r = request(e, action, map[string]any{})
|
|
159
|
+
}
|
|
160
|
+
if !r.OK {
|
|
161
|
+
t.Fatal(r)
|
|
162
|
+
}
|
|
163
|
+
close(w.release)
|
|
164
|
+
waitState(t, e, "job", "canceled")
|
|
165
|
+
select {
|
|
166
|
+
case <-w.published:
|
|
167
|
+
t.Fatal("published after revoke/disable/cancel")
|
|
168
|
+
default:
|
|
169
|
+
}
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
func TestCommittedIdempotencyReceiptAndOwnerIsolation(t *testing.T) {
|
|
174
|
+
e, f, _ := setup(t)
|
|
175
|
+
id := longGrant(t, e)
|
|
176
|
+
w := &barrierMoveWriter{make(chan struct{}), make(chan struct{}), make(chan struct{})}
|
|
177
|
+
e.Writer = w
|
|
178
|
+
if err := e.startOperations(context.Background()); err != nil {
|
|
179
|
+
t.Fatal(err)
|
|
180
|
+
}
|
|
181
|
+
defer e.stopOperations()
|
|
182
|
+
p := moveParams(id, "job")
|
|
183
|
+
if r := offline(e, "files.moveFromStaging", p); !r.OK {
|
|
184
|
+
t.Fatal(r)
|
|
185
|
+
}
|
|
186
|
+
<-w.copying
|
|
187
|
+
close(w.release)
|
|
188
|
+
waitState(t, e, "job", "committed")
|
|
189
|
+
r := offline(e, "files.operationStatus", map[string]any{"delegation_id": id, "job_id": "job"})
|
|
190
|
+
b, _ := json.Marshal(r.Result)
|
|
191
|
+
if !r.OK || !strings.Contains(string(b), `"receipt"`) {
|
|
192
|
+
t.Fatal(r)
|
|
193
|
+
}
|
|
194
|
+
if r = offline(e, "files.moveFromStaging", p); !r.OK {
|
|
195
|
+
t.Fatal(r)
|
|
196
|
+
}
|
|
197
|
+
p["name"] = "other"
|
|
198
|
+
if r = offline(e, "files.moveFromStaging", p); r.Code != "operation-conflict" {
|
|
199
|
+
t.Fatal(r)
|
|
200
|
+
}
|
|
201
|
+
f.user.Username = "bob"
|
|
202
|
+
if r = request(e, "files.operationStatus", map[string]any{"delegation_id": id, "job_id": "job"}); r.Code != "operation-not-found" {
|
|
203
|
+
t.Fatal(r)
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
func TestCrashRecoveryNeverReplaysCopyOrUncertain(t *testing.T) {
|
|
207
|
+
for _, intent := range []bool{false, true} {
|
|
208
|
+
t.Run(fmt.Sprint(intent), func(t *testing.T) {
|
|
209
|
+
e, _, _ := setup(t)
|
|
210
|
+
id := longGrant(t, e)
|
|
211
|
+
op := Operation{Version: 1, Package: e.Policy.Package, ID: id, Job: "job", State: "copying", PublishIntent: intent, Staging: "result", Name: "out.csv", Size: 123}
|
|
212
|
+
if e.Store.PutOperation(op) != nil {
|
|
213
|
+
t.Fatal("put")
|
|
214
|
+
}
|
|
215
|
+
w := &barrierMoveWriter{make(chan struct{}), make(chan struct{}), make(chan struct{})}
|
|
216
|
+
e.Writer = w
|
|
217
|
+
if err := e.startOperations(context.Background()); err != nil {
|
|
218
|
+
t.Fatal(err)
|
|
219
|
+
}
|
|
220
|
+
defer e.stopOperations()
|
|
221
|
+
want := "interrupted"
|
|
222
|
+
if intent {
|
|
223
|
+
want = "uncertain"
|
|
224
|
+
}
|
|
225
|
+
waitState(t, e, "job", want)
|
|
226
|
+
if r := offline(e, "files.moveFromStaging", moveParams(id, "job")); !r.OK {
|
|
227
|
+
t.Fatal("same job lost", r)
|
|
228
|
+
}
|
|
229
|
+
select {
|
|
230
|
+
case <-w.copying:
|
|
231
|
+
t.Fatal("crash operation replayed")
|
|
232
|
+
default:
|
|
233
|
+
}
|
|
234
|
+
})
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
func TestLongGrantRejectsInScopeSymlinkAndUnknownDestination(t *testing.T) {
|
|
239
|
+
e, f, _ := setup(t)
|
|
240
|
+
e.Policy.Destinations = []string{"save"}
|
|
241
|
+
e.Policy.Lifetime = "until-revoked"
|
|
242
|
+
os.Mkdir(filepath.Join(f.root, "real"), 0700)
|
|
243
|
+
os.Symlink(filepath.Join(f.root, "real"), filepath.Join(f.root, "alias"))
|
|
244
|
+
for _, p := range []map[string]any{
|
|
245
|
+
{"ops": []string{"files.moveFromStaging"}, "scope": "home", "path": "/home/alias", "destination": "save", "lifetime": "until-revoked"},
|
|
246
|
+
{"ops": []string{"files.moveFromStaging"}, "scope": "home", "path": "/home", "destination": "unknown", "lifetime": "until-revoked"},
|
|
247
|
+
} {
|
|
248
|
+
if r := request(e, "delegate.create", p); r.OK {
|
|
249
|
+
t.Fatal("invalid destination granted")
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
func TestLongGrantRevokeIsOwnerBoundEvenForAdmin(t *testing.T) {
|
|
254
|
+
e, f, _ := setup(t)
|
|
255
|
+
id := longGrant(t, e)
|
|
256
|
+
f.user.Username = "bob"
|
|
257
|
+
f.user.Admin = true
|
|
258
|
+
if r := request(e, "delegate.revoke", map[string]any{"delegation_id": id}); r.Code != "DELEGATION_DENIED" {
|
|
259
|
+
t.Fatal(r)
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
func TestInvalidatedGrantRequiresReselection(t *testing.T) {
|
|
263
|
+
e, f, _ := setup(t)
|
|
264
|
+
id := longGrant(t, e)
|
|
265
|
+
e.Writer = &barrierMoveWriter{make(chan struct{}), make(chan struct{}), make(chan struct{})}
|
|
266
|
+
if err := e.startOperations(context.Background()); err != nil {
|
|
267
|
+
t.Fatal(err)
|
|
268
|
+
}
|
|
269
|
+
defer e.stopOperations()
|
|
270
|
+
f.accountErr = errors.New("disabled")
|
|
271
|
+
if r := offline(e, "files.moveFromStaging", moveParams(id, "job")); r.Code != "INELIGIBLE" {
|
|
272
|
+
t.Fatal(r)
|
|
273
|
+
}
|
|
274
|
+
f.accountErr = nil
|
|
275
|
+
if r := offline(e, "files.moveFromStaging", moveParams(id, "job2")); r.Code != "DELEGATION_DENIED" {
|
|
276
|
+
t.Fatal("revived invalid grant", r)
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
type cleanupFailureWriter struct{}
|
|
281
|
+
|
|
282
|
+
func (cleanupFailureWriter) Write(context.Context, Subject, string, string, string, string) error {
|
|
283
|
+
return nil
|
|
284
|
+
}
|
|
285
|
+
func (cleanupFailureWriter) Move(_ context.Context, _ Subject, _ Operation, _ Delegation, guard func(func() (MoveReceipt, error)) (MoveReceipt, error)) (MoveReceipt, error) {
|
|
286
|
+
return guard(func() (MoveReceipt, error) { return MoveReceipt{CleanupPending: true}, nil })
|
|
287
|
+
}
|
|
288
|
+
func TestCommittedNeverDowngradesOnCleanupFailure(t *testing.T) {
|
|
289
|
+
e, _, _ := setup(t)
|
|
290
|
+
id := longGrant(t, e)
|
|
291
|
+
e.Writer = cleanupFailureWriter{}
|
|
292
|
+
if err := e.startOperations(context.Background()); err != nil {
|
|
293
|
+
t.Fatal(err)
|
|
294
|
+
}
|
|
295
|
+
defer e.stopOperations()
|
|
296
|
+
if r := offline(e, "files.moveFromStaging", moveParams(id, "job")); !r.OK {
|
|
297
|
+
t.Fatal(r)
|
|
298
|
+
}
|
|
299
|
+
op := waitState(t, e, "job", "committed")
|
|
300
|
+
if op.Code != "CLEANUP_PENDING" || op.Path != "/home/out.csv" {
|
|
301
|
+
t.Fatal(op)
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
func TestQueuedRestartsWithoutCredentialsAndUnknownRecordFailsClosed(t *testing.T) {
|
|
305
|
+
e, _, _ := setup(t)
|
|
306
|
+
id := longGrant(t, e)
|
|
307
|
+
d, _ := e.Store.Get(id)
|
|
308
|
+
op := Operation{Version: 1, Package: e.Policy.Package, ID: id, Job: "job", State: "queued", Subject: d.Subject, Staging: "result", Name: "out.csv", Size: 123}
|
|
309
|
+
if e.Store.PutOperation(op) != nil {
|
|
310
|
+
t.Fatal("put")
|
|
311
|
+
}
|
|
312
|
+
w := &barrierMoveWriter{make(chan struct{}), make(chan struct{}), make(chan struct{})}
|
|
313
|
+
e.Writer = w
|
|
314
|
+
if err := e.startOperations(context.Background()); err != nil {
|
|
315
|
+
t.Fatal(err)
|
|
316
|
+
}
|
|
317
|
+
select {
|
|
318
|
+
case <-w.copying:
|
|
319
|
+
case <-time.After(time.Second):
|
|
320
|
+
t.Fatal("queued not recovered")
|
|
321
|
+
}
|
|
322
|
+
close(w.release)
|
|
323
|
+
waitState(t, e, "job", "committed")
|
|
324
|
+
e.stopOperations()
|
|
325
|
+
path := filepath.Join(e.Store.Dir, "operation-"+recordKey(op.Job)+".record")
|
|
326
|
+
os.WriteFile(path, []byte(`{"v":99,"job_id":"job"}`), 0600)
|
|
327
|
+
if err := e.startOperations(context.Background()); err == nil {
|
|
328
|
+
e.stopOperations()
|
|
329
|
+
t.Fatal("unknown schema started")
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
func TestLegacyLeaseDrainsWithoutHoldingCommitLock(t *testing.T) {
|
|
333
|
+
e, _, _ := setup(t)
|
|
334
|
+
id := create(t, e)
|
|
335
|
+
d, _ := e.Store.Get(id)
|
|
336
|
+
done, code := e.beginLegacy(d)
|
|
337
|
+
if code != "" {
|
|
338
|
+
t.Fatal(code)
|
|
339
|
+
}
|
|
340
|
+
revoked := make(chan Response, 1)
|
|
341
|
+
go func() { revoked <- request(e, "delegate.revoke", map[string]any{"delegation_id": id}) }()
|
|
342
|
+
deadline := time.Now().Add(time.Second)
|
|
343
|
+
for time.Now().Before(deadline) {
|
|
344
|
+
fresh, _ := e.Store.Get(id)
|
|
345
|
+
if fresh.Revoked {
|
|
346
|
+
break
|
|
347
|
+
}
|
|
348
|
+
time.Sleep(time.Millisecond)
|
|
349
|
+
}
|
|
350
|
+
lock := make(chan struct{})
|
|
351
|
+
go func() { e.commitMu.Lock(); e.commitMu.Unlock(); close(lock) }()
|
|
352
|
+
select {
|
|
353
|
+
case <-lock:
|
|
354
|
+
case <-time.After(time.Second):
|
|
355
|
+
t.Fatal("drain held commit lock")
|
|
356
|
+
}
|
|
357
|
+
select {
|
|
358
|
+
case <-revoked:
|
|
359
|
+
t.Fatal("revoke acknowledged before legacy drain")
|
|
360
|
+
default:
|
|
361
|
+
}
|
|
362
|
+
done()
|
|
363
|
+
select {
|
|
364
|
+
case r := <-revoked:
|
|
365
|
+
if !r.OK {
|
|
366
|
+
t.Fatal(r)
|
|
367
|
+
}
|
|
368
|
+
case <-time.After(time.Second):
|
|
369
|
+
t.Fatal("revoke did not finish")
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
func TestRedundantEnablePreservesNewGrant(t *testing.T) {
|
|
374
|
+
e, f, _ := setup(t)
|
|
375
|
+
id := longGrant(t, e)
|
|
376
|
+
f.user.Admin = true
|
|
377
|
+
if r := request(e, "delegate.enable", map[string]any{}); !r.OK {
|
|
378
|
+
t.Fatal(r)
|
|
379
|
+
}
|
|
380
|
+
d, err := e.Store.Get(id)
|
|
381
|
+
if err != nil || d.Revoked {
|
|
382
|
+
t.Fatal("redundant enable revoked grant", d, err)
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
func TestAuditOwnerFilteringAndNoCredentials(t *testing.T) {
|
|
386
|
+
e, f, _ := setup(t)
|
|
387
|
+
_ = longGrant(t, e)
|
|
388
|
+
f.user.Username = "bob"
|
|
389
|
+
r := request(e, "delegate.audit", map[string]any{})
|
|
390
|
+
b, _ := json.Marshal(r.Result)
|
|
391
|
+
if !r.OK || strings.Contains(string(b), "alice") {
|
|
392
|
+
t.Fatal("audit owner leak", r)
|
|
393
|
+
}
|
|
394
|
+
f.user.Admin = true
|
|
395
|
+
r = request(e, "delegate.audit", map[string]any{})
|
|
396
|
+
b, _ = json.Marshal(r.Result)
|
|
397
|
+
if !r.OK || !strings.Contains(string(b), "alice") || strings.Contains(string(b), "session") || strings.Contains(string(b), "token") {
|
|
398
|
+
t.Fatal("admin audit", r)
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
func TestQueueAndByteLimitsFailClosed(t *testing.T) {
|
|
403
|
+
e, _, _ := setup(t)
|
|
404
|
+
id := longGrant(t, e)
|
|
405
|
+
w := &barrierMoveWriter{make(chan struct{}), make(chan struct{}), make(chan struct{})}
|
|
406
|
+
e.Writer = w
|
|
407
|
+
if err := e.startOperations(context.Background()); err != nil {
|
|
408
|
+
t.Fatal(err)
|
|
409
|
+
}
|
|
410
|
+
defer e.stopOperations()
|
|
411
|
+
if r := offline(e, "files.moveFromStaging", moveParams(id, "active")); !r.OK {
|
|
412
|
+
t.Fatal(r)
|
|
413
|
+
}
|
|
414
|
+
<-w.copying
|
|
415
|
+
for i := 0; i < maxQueued; i++ {
|
|
416
|
+
if r := offline(e, "files.moveFromStaging", moveParams(id, fmt.Sprintf("queued-%d", i))); !r.OK {
|
|
417
|
+
t.Fatal(i, r)
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
if r := offline(e, "files.moveFromStaging", moveParams(id, "overflow")); r.Code != "queue-full" {
|
|
421
|
+
t.Fatal(r)
|
|
422
|
+
}
|
|
423
|
+
p := moveParams(id, "oversize")
|
|
424
|
+
p["size"] = maxMoveBytes + 1
|
|
425
|
+
if r := offline(e, "files.moveFromStaging", p); r.Code != "invalid-size" {
|
|
426
|
+
t.Fatal(r)
|
|
427
|
+
}
|
|
428
|
+
p["size"] = -1
|
|
429
|
+
if r := offline(e, "files.moveFromStaging", p); r.Code != "invalid-size" {
|
|
430
|
+
t.Fatal(r)
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
type canceledDSM struct{ *fakeDSM }
|
|
435
|
+
|
|
436
|
+
func (d canceledDSM) Account(ctx context.Context, name string) (Subject, error) {
|
|
437
|
+
if err := ctx.Err(); err != nil {
|
|
438
|
+
return Subject{}, err
|
|
439
|
+
}
|
|
440
|
+
return d.fakeDSM.Account(ctx, name)
|
|
441
|
+
}
|
|
442
|
+
func TestLifecycleCancellationDoesNotRevokeHealthyGrant(t *testing.T) {
|
|
443
|
+
e, f, _ := setup(t)
|
|
444
|
+
id := longGrant(t, e)
|
|
445
|
+
e.DSM = canceledDSM{f}
|
|
446
|
+
e.Writer = cleanupFailureWriter{}
|
|
447
|
+
d, _ := e.Store.Get(id)
|
|
448
|
+
op := Operation{Version: 1, Package: e.Policy.Package, ID: id, Job: "job", Subject: d.Subject, State: "copying"}
|
|
449
|
+
if e.Store.PutOperation(op) != nil {
|
|
450
|
+
t.Fatal("put")
|
|
451
|
+
}
|
|
452
|
+
ctx, cancel := context.WithCancel(context.Background())
|
|
453
|
+
cancel()
|
|
454
|
+
e.performMove(ctx, &operationRuntime{ctx: ctx}, op)
|
|
455
|
+
d, err := e.Store.Get(id)
|
|
456
|
+
if err != nil || d.Revoked {
|
|
457
|
+
t.Fatal("stop canceled permanent authority", d, err)
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
func TestLegacyAndNewBulkCopyShareOneActiveSlot(t *testing.T) {
|
|
462
|
+
e, _, _ := setup(t)
|
|
463
|
+
id := longGrant(t, e)
|
|
464
|
+
legacy := create(t, e)
|
|
465
|
+
w := &barrierMoveWriter{make(chan struct{}), make(chan struct{}), make(chan struct{})}
|
|
466
|
+
e.Writer = w
|
|
467
|
+
if err := e.startOperations(context.Background()); err != nil {
|
|
468
|
+
t.Fatal(err)
|
|
469
|
+
}
|
|
470
|
+
defer e.stopOperations()
|
|
471
|
+
if r := offline(e, "files.moveFromStaging", moveParams(id, "active")); !r.OK {
|
|
472
|
+
t.Fatal(r)
|
|
473
|
+
}
|
|
474
|
+
<-w.copying
|
|
475
|
+
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Millisecond)
|
|
476
|
+
defer cancel()
|
|
477
|
+
params, _ := json.Marshal(map[string]any{"delegation_id": legacy, "job_id": "job1", "staging": "source", "dest_dir": "/home", "name": "other"})
|
|
478
|
+
r := e.Handle(ctx, Request{Version: 1, Op: "files.write", Params: params})
|
|
479
|
+
if r.OK || r.Code != "EXECUTOR_PAUSED" {
|
|
480
|
+
t.Fatal("legacy copy bypassed package active limit", r)
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
type publishedPartWriter struct {
|
|
485
|
+
*barrierMoveWriter
|
|
486
|
+
published bool
|
|
487
|
+
cleaned int
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
func (w *publishedPartWriter) PublishedPart(context.Context, Operation) bool { return w.published }
|
|
491
|
+
func (w *publishedPartWriter) CleanupRecorded(context.Context, Subject, partMetadata) error {
|
|
492
|
+
w.cleaned++
|
|
493
|
+
return nil
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
// A crash between publish intent and the committed record leaves "uncertain".
|
|
497
|
+
// Restart settles it from the recorded part inode instead of copying again.
|
|
498
|
+
func TestRestartSettlesUncertainFromRecordedPart(t *testing.T) {
|
|
499
|
+
for _, published := range []bool{true, false} {
|
|
500
|
+
t.Run(fmt.Sprint(published), func(t *testing.T) {
|
|
501
|
+
e, _, _ := setup(t)
|
|
502
|
+
id := longGrant(t, e)
|
|
503
|
+
part := &partMetadata{Temporary: ".synopkgland-job-0123456789abcdef0123456789abcdef.part", Directory: directoryIdentity{1, 2}, Part: directoryIdentity{1, 3}, Destination: "/volume1/home"}
|
|
504
|
+
op := Operation{Version: 1, Package: e.Policy.Package, ID: id, Job: "job", Subject: Subject{Username: "alice", UID: 1200}, State: "copying", PublishIntent: true, Staging: "result", Name: "out.csv", Size: 123, Part: part}
|
|
505
|
+
if e.Store.PutOperation(op) != nil {
|
|
506
|
+
t.Fatal("put")
|
|
507
|
+
}
|
|
508
|
+
w := &publishedPartWriter{barrierMoveWriter: &barrierMoveWriter{make(chan struct{}), make(chan struct{}), make(chan struct{})}, published: published}
|
|
509
|
+
e.Writer = w
|
|
510
|
+
if err := e.startOperations(context.Background()); err != nil {
|
|
511
|
+
t.Fatal(err)
|
|
512
|
+
}
|
|
513
|
+
defer e.stopOperations()
|
|
514
|
+
want := "uncertain"
|
|
515
|
+
if published {
|
|
516
|
+
want = "committed"
|
|
517
|
+
}
|
|
518
|
+
waitState(t, e, "job", want)
|
|
519
|
+
got, _ := e.Store.GetOperation("job")
|
|
520
|
+
if published && (got.Path != "/home/out.csv" || got.Code != "") {
|
|
521
|
+
t.Fatal(got)
|
|
522
|
+
}
|
|
523
|
+
select {
|
|
524
|
+
case <-w.copying:
|
|
525
|
+
t.Fatal("uncertain operation replayed")
|
|
526
|
+
default:
|
|
527
|
+
}
|
|
528
|
+
})
|
|
529
|
+
}
|
|
530
|
+
}
|