main was 16 days and 259 commits behind the line the product is actually built on, at contract 0.30.0 against 0.35.0, with no per-PC credential code at all. It was neither current nor curated - just stale. This brings it forward and, at the same time, makes it mean something: main is what a receiving site installs, and nothing else. WHAT IT CARRIES. Twelve plugins - backups, computers, endpoints, guides, knowledgebase, machines, network, notifications, printers, slides, tools, warranty - plus applications, which is manifest-less core and always ships. The only manifest dependency inside that set is endpoints on computers, and both are in it, so the closure is self-contained. WHAT IT DOES NOT. employees, geenforce, measuringtools, printedparts and usb stay on the site line. So do the Windows installer tree, the VM rehearsal helpers, the agent tooling config, one site's data loader, the internal audit and findings records, and the planner spreadsheet. 1,135 tracked files against 1,438. A REMOVAL THAT BREAKS THE APP IS NOT A REMOVAL, and two nearly shipped: deploy/site-profile-universal.json still named all seventeen plugins. It is the file docs/DEPLOY.md tells a site to provision from, so a fresh install would have failed at `flask plugin apply-profile` with PluginError - the first thing a receiving site does, broken by the branch meant to serve them. It now names the twelve that exist, and its comment says the two must agree. agent/ was never refreshed. Whoever populated this branch copied shopdb/, plugins/, frontend/ and tests/ from the site line and left the agent tree at its September state: 22 C# and PowerShell sources missing, including AgentCredentials, EnrollmentService, AgentHttpFactory and the fleet-alert client, plus one file the site line had deleted still present. The old tree is internally consistent, so it compiles, and nothing in CI builds it - every gate was green over a server that speaks enrollment and per-PC credentials to a bundled agent source that cannot. Resynced whole. DECISIONS THIS ENCODES, rather than defers: - The plugin-authoring lab builds printedparts, whose manifest depends on employees, so it could not stay. The lab remains on the site line and main ships no build-along tutorial. That is a real loss for an adopting developer and is recorded here rather than discovered later. - Recognition, Training and Recertification notifications are no longer seeded. Each splits one notification into a card per employee and renders a photo, which needs a plugin this branch does not bundle. Seeding them would offer an author a type that cannot resolve anybody. A site that installs employees gets them from that plugin's own seed. - Windows/IIS is documented as the legacy path throughout, and the README leads with Docker, because that is what a receiving site gets. The API description is regenerated for THIS branch - 347 paths and 483 operations, down from 415 and 573 - so the published contract describes what is here rather than what the site line serves. docs/CONFIG.md lost the two measuring-tool label keys the code no longer declares, which two lanes had decided opposite ways. Suite: 3124 passed, 6 skipped. Naming and style gates pass. The docs gates run rather than skip, and every index line count is derived from the file it names.
96 lines
4.5 KiB
JavaScript
96 lines
4.5 KiB
JavaScript
/**
|
|
* Run Scripts tab on PC Details.
|
|
*
|
|
* The thing worth pinning here is the SEPARATION. run_script and
|
|
* scheduledtask_run map to different grants in plugins/endpoints/commands.py
|
|
* (endpoints.runscript and endpoints.corptools), split out of a single
|
|
* endpoints.deploy bundle precisely so that being able to trigger a corporate
|
|
* tool does not also mean being able to run arbitrary PowerShell as SYSTEM.
|
|
*
|
|
* That split lives in the backend. The UI can quietly undo it by hanging the
|
|
* script picker off the Corporate Tools tab, whose only gate is
|
|
* endpoints.corptools - and the failure would be invisible in review, because
|
|
* the page would look correct and the server would simply 403 the push. These
|
|
* tests fail if someone merges the two.
|
|
*
|
|
* Asserted against the file text, matching systemScriptsSettings.spec.js.
|
|
*/
|
|
import { describe, it, expect } from 'vitest'
|
|
import { readFileSync } from 'fs'
|
|
import { join, dirname } from 'path'
|
|
import { fileURLToPath } from 'url'
|
|
|
|
const here = dirname(fileURLToPath(import.meta.url))
|
|
const source = readFileSync(join(here, 'PCDetail.vue'), 'utf8')
|
|
|
|
describe('PCDetail Run Scripts tab', () => {
|
|
it('gates the tab on endpoints.runscript, not the Corporate Tools grant', () => {
|
|
expect(source).toMatch(
|
|
/const canRunScript = computed\(\(\) => authStore\.hasPermission\('endpoints\.runscript'\)\)/)
|
|
})
|
|
|
|
it('pushes run_script from its own tab, not from the Corporate Tools block', () => {
|
|
// The corptools block must not gain a run_script call: that would put the
|
|
// action behind endpoints.corptools in the UI while the server still
|
|
// demands endpoints.runscript.
|
|
const corptools = source.slice(
|
|
source.indexOf("activegroup === 'corptools'"),
|
|
source.indexOf("activegroup === 'runscripts'"))
|
|
expect(corptools).not.toMatch(/run_script/)
|
|
expect(source).toMatch(/activegroup === 'runscripts'/)
|
|
})
|
|
|
|
it('enqueues run_script with a script-id target', () => {
|
|
expect(source).toMatch(/'run_script', `script:\$\{script\.scriptid\}`/)
|
|
})
|
|
|
|
it('requires a typed confirmation before running', () => {
|
|
// Every script on this tab is arbitrary code, so unlike Corporate Tools
|
|
// there is no safe branch that gets a plain OK button.
|
|
const handler = source.slice(source.indexOf('async function confirmRunScript'))
|
|
const body = handler.slice(0, handler.indexOf('\n}\n'))
|
|
expect(body).toMatch(/Type RUN to confirm/)
|
|
expect(body).toMatch(/typed !== 'RUN'/)
|
|
})
|
|
|
|
it('warns that a script runs as SYSTEM before it is sent', () => {
|
|
const tab = source.slice(source.indexOf("activegroup === 'runscripts'"))
|
|
expect(tab.slice(0, 2000)).toMatch(/runs as SYSTEM/)
|
|
})
|
|
|
|
it('shows the run context and working directory read-only', () => {
|
|
// Both are authoring decisions made in the library. Offering an override
|
|
// here would mean the script that ran is not the script that was reviewed,
|
|
// so they must be rendered as facts and never bound with v-model.
|
|
const tab = source.slice(source.indexOf("activegroup === 'runscripts'"))
|
|
const block = tab.slice(0, tab.indexOf('runscripts-actions'))
|
|
expect(block).toMatch(/selectedscript\.workingdirectory/)
|
|
expect(block).toMatch(/selectedscript\.runcontext/)
|
|
expect(block).not.toMatch(/v-model="[^"]*workingdirectory/)
|
|
expect(block).not.toMatch(/v-model="[^"]*runcontext/)
|
|
})
|
|
|
|
it('offers only scripts that have a body', () => {
|
|
// A bodyless script is rejected at enqueue by _resolve_run_script, so
|
|
// listing it would offer a button whose only outcome is an error.
|
|
expect(source).toMatch(/filter\(\(script\) => script\.hasbody\)/)
|
|
})
|
|
|
|
it('reports the push as queued rather than as finished', () => {
|
|
// The agent collects the command on its next check-in; claiming it ran
|
|
// would assert an outcome nothing has observed.
|
|
const handler = source.slice(source.indexOf('async function confirmRunScript'))
|
|
expect(handler.slice(0, handler.indexOf('\n}\n'))).toMatch(/queued for/)
|
|
})
|
|
|
|
it('styles the Run Scripts tab from defined theme tokens only', () => {
|
|
// --text-primary/--text-secondary/--bg-secondary are not defined by this
|
|
// app's theme. var() then falls through to the fallback, or to inherit,
|
|
// which reads fine in light mode and misrenders for dark-mode users - the
|
|
// failure only shows up on the theme most of the shop floor runs.
|
|
const runscripts = source.slice(source.indexOf('.corptools-intro'))
|
|
expect(runscripts).not.toMatch(/--text-primary|--text-secondary|--bg-secondary|--surface/)
|
|
expect(runscripts).not.toMatch(/var\(--[a-z-]+,\s*#/)
|
|
})
|
|
})
|