Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

Default Classification to a Pipeline instead of a Policy (#8026)

James Brunton8156c51d5fca
diff --git a/app/proprietary/src/main/java/stirling/software/proprietary/policy/seed/DefaultClassificationPolicySeeder.java b/app/proprietary/src/main/java/stirling/software/proprietary/policy/seed/DefaultClassificationPolicySeeder.java
index f22bbd162f..80db97acaf 100644
--- a/app/proprietary/src/main/java/stirling/software/proprietary/policy/seed/DefaultClassificationPolicySeeder.java
+++ b/app/proprietary/src/main/java/stirling/software/proprietary/policy/seed/DefaultClassificationPolicySeeder.java
@@ -23,7 +23,7 @@ import stirling.software.proprietary.security.repository.TeamRepository;
import stirling.software.proprietary.security.service.TeamService;
/**
- * Seeds an enabled Classification policy per team; idempotent, skips the internal team. Left
+ * Seeds an enabled Classification pipeline per team; idempotent, skips the internal team. Left
* unowned: nobody created it, and an owner here would have to name a real user.
*/
@Slf4j
@@ -95,7 +95,7 @@ public class DefaultClassificationPolicySeeder {
&& CATEGORY.equals(policy.output().options().get("categoryId"));
}
- /** The default Classification policy: classify each upload, versioning the file in place. */
+ /** The default Classification pipeline: classify each upload, versioning the file in place. */
static Policy defaultPolicy(Long teamId) {
Map<String, Object> options = new HashMap<>();
options.put("categoryId", CATEGORY);
@@ -110,7 +110,7 @@ public class DefaultClassificationPolicySeeder {
// every consumer of owner already handles its absence.
null,
true,
- true,
+ false,
"",
List.of(),
List.of(new PipelineStep(CLASSIFY_ENDPOINT, Map.of())),
diff --git a/app/proprietary/src/test/java/stirling/software/proprietary/policy/seed/DefaultClassificationPolicySeederTest.java b/app/proprietary/src/test/java/stirling/software/proprietary/policy/seed/DefaultClassificationPolicySeederTest.java
index 749d66ca60..ca63ff926c 100644
--- a/app/proprietary/src/test/java/stirling/software/proprietary/policy/seed/DefaultClassificationPolicySeederTest.java
+++ b/app/proprietary/src/test/java/stirling/software/proprietary/policy/seed/DefaultClassificationPolicySeederTest.java
@@ -52,7 +52,7 @@ class DefaultClassificationPolicySeederTest {
}
@Test
- void seedsAnEnabledClassificationPolicyWhenTheTeamHasNone() {
+ void seedsAnEnabledClassificationPipelineWhenTheTeamHasNone() {
when(policyStore.findByTeam(7L)).thenReturn(List.of());
seeder().onTeamCreated(new TeamCreatedEvent(7L, "Acme"));
@@ -61,8 +61,7 @@ class DefaultClassificationPolicySeederTest {
verify(policyStore).save(saved.capture());
Policy policy = saved.getValue();
assertThat(policy.enabled()).isTrue();
- // Org-mandated: the seeded classification policy is a Policy, not an opt-in Pipeline.
- assertThat(policy.required()).isTrue();
+ assertThat(policy.required()).isFalse();
assertThat(policy.teamId()).isEqualTo(7L);
assertThat(policy.output().type()).isEqualTo("inline");
assertThat(policy.output().options().get("categoryId")).isEqualTo("classification");
diff --git a/frontend/editor/src/portal/components/policies/PolicySetupWizard.test.tsx b/frontend/editor/src/portal/components/policies/PolicySetupWizard.test.tsx
index bd027d5ef5..29eb004521 100644
--- a/frontend/editor/src/portal/components/policies/PolicySetupWizard.test.tsx
+++ b/frontend/editor/src/portal/components/policies/PolicySetupWizard.test.tsx
@@ -365,30 +365,34 @@ describe("PolicySetupWizard", () => {
expect(await screen.findByRole("button", { name: ENABLE })).toBeDisabled();
});
- it("defaults a new template to a policy (blocking)", async () => {
- // A template's failure should block the file, so a new one defaults to required, independent of
- // who is creating it.
- const onSubmit = vi.fn().mockResolvedValue(undefined);
- const entry: CatalogueEntry = {
- category: security,
- config: securityConfig,
- policy: null,
- };
-
- render(
- <PolicySetupWizard
- entry={entry}
- onClose={vi.fn()}
- onSubmit={onSubmit}
- onCustomise={vi.fn()}
- />,
- );
- await submitWizard(ENABLE);
-
- await waitFor(() => expect(onSubmit).toHaveBeenCalled());
- const result = onSubmit.mock.calls[0][1] as PolicySetupResult;
- expect(result.required).toBe(true);
- });
+ it.each([
+ { categoryId: "security", required: true },
+ { categoryId: "classification", required: false },
+ ])(
+ "defaults $categoryId to required=$required",
+ async ({ categoryId, required }) => {
+ const onSubmit = vi.fn().mockResolvedValue(undefined);
+ const entry: CatalogueEntry = {
+ category: POLICY_CATEGORIES.find((c) => c.id === categoryId)!,
+ config: POLICY_CONFIG[categoryId],
+ policy: null,
+ };
+
+ render(
+ <PolicySetupWizard
+ entry={entry}
+ onClose={vi.fn()}
+ onSubmit={onSubmit}
+ onCustomise={vi.fn()}
+ />,
+ );
+ await submitWizard(ENABLE);
+
+ await waitFor(() => expect(onSubmit).toHaveBeenCalled());
+ const result = onSubmit.mock.calls[0][1] as PolicySetupResult;
+ expect(result.required).toBe(required);
+ },
+ );
it("seeds the compliance chain so the gate judges the delivered document", async () => {
const onSubmit = vi.fn().mockResolvedValue(undefined);
diff --git a/frontend/editor/src/proprietary/components/policies/PolicySetupWizard.tsx b/frontend/editor/src/proprietary/components/policies/PolicySetupWizard.tsx
index 0f706189c7..ad9f6bb0dc 100644
--- a/frontend/editor/src/proprietary/components/policies/PolicySetupWizard.tsx
+++ b/frontend/editor/src/proprietary/components/policies/PolicySetupWizard.tsx
@@ -360,9 +360,9 @@ function PolicySetupWizardBody({
);
const [maxRetries] = useState(policy?.state.maxRetries ?? 0);
const [retryDelayMinutes] = useState(policy?.state.retryDelayMinutes ?? 0);
- // A template is a policy by nature, where a failure blocks the file rather than waving it
- // through, so a new one defaults to required. Editing preserves what was saved.
- const [required, setRequired] = useState(policy?.state.required ?? true);
+ const [required, setRequired] = useState(
+ policy?.state.required ?? !isClassification,
+ );
const readOnly = !canManagePolicies;
const [submitting, setSubmitting] = useState(false);