Change state of applicability

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2026-01-02 15:04:11 +01:00
parent c60e19a7a8
commit 4ed3f5a067
105 changed files with 18351 additions and 284 deletions

View File

@@ -66,6 +66,7 @@ func TestControl_Create(t *testing.T) {
"name": "Information Security Policies",
"description": "Policies for information security",
"status": "INCLUDED",
"bestPractice": true,
},
}, &result)
require.NoError(t, err)
@@ -112,6 +113,7 @@ func TestControl_Create(t *testing.T) {
"description": "Cryptography controls",
"status": "EXCLUDED",
"exclusionJustification": "Not applicable - no cryptographic data processing",
"bestPractice": false,
},
}, &result)
require.NoError(t, err)
@@ -356,6 +358,7 @@ func TestControl_RequiredFields(t *testing.T) {
"description": "Test",
"sectionTitle": "Section 1",
"status": "INCLUDED",
"bestPractice": true,
},
},
wantError: true,
@@ -368,6 +371,7 @@ func TestControl_RequiredFields(t *testing.T) {
"description": "Test",
"sectionTitle": "Section 1",
"status": "INCLUDED",
"bestPractice": true,
},
},
wantError: true,
@@ -376,10 +380,11 @@ func TestControl_RequiredFields(t *testing.T) {
name: "Missing sectionTitle should fail",
variables: map[string]any{
"input": map[string]any{
"frameworkId": frameworkID,
"name": "Test Control",
"description": "Test",
"status": "INCLUDED",
"frameworkId": frameworkID,
"name": "Test Control",
"description": "Test",
"status": "INCLUDED",
"bestPractice": true,
},
},
wantError: true,
@@ -392,6 +397,7 @@ func TestControl_RequiredFields(t *testing.T) {
"name": "Test Control",
"description": "Test",
"sectionTitle": "Section 1",
"bestPractice": true,
},
},
wantError: true,
@@ -404,6 +410,20 @@ func TestControl_RequiredFields(t *testing.T) {
"name": "Test Control",
"sectionTitle": "Section 1",
"status": "INCLUDED",
"bestPractice": true,
},
},
wantError: true,
},
{
name: "Missing bestPractice should fail",
variables: map[string]any{
"input": map[string]any{
"frameworkId": frameworkID,
"name": "Test Control",
"description": "Test",
"sectionTitle": "Section 1",
"status": "INCLUDED",
},
},
wantError: true,
@@ -417,6 +437,7 @@ func TestControl_RequiredFields(t *testing.T) {
"description": "Test",
"sectionTitle": "Section 1",
"status": "INVALID_STATUS",
"bestPractice": true,
},
},
wantError: true,
@@ -504,6 +525,7 @@ func TestControl_OmittableDescription(t *testing.T) {
"description": "Initial description",
"sectionTitle": "Section 1",
"status": "INCLUDED",
"bestPractice": true,
},
}, &createResult)
require.NoError(t, err)
@@ -668,6 +690,7 @@ func TestControl_SubResolvers(t *testing.T) {
"description": "Test description",
"sectionTitle": "Section 1",
"status": "INCLUDED",
"bestPractice": true,
},
}, &controlResult)
require.NoError(t, err)
@@ -881,6 +904,7 @@ func TestControl_ExclusionJustification(t *testing.T) {
"sectionTitle": "Section 1",
"status": "EXCLUDED",
"exclusionJustification": "Not applicable to our business",
"bestPractice": false,
},
}, &result)
require.NoError(t, err)
@@ -919,6 +943,7 @@ func TestControl_ExclusionJustification(t *testing.T) {
"description": "Test",
"sectionTitle": "Section 2",
"status": "INCLUDED",
"bestPractice": true,
},
}, &createResult)
require.NoError(t, err)

View File

@@ -83,6 +83,7 @@ func TestControlMeasureMapping_CreateDelete(t *testing.T) {
"description": "Test control for mapping",
"sectionTitle": "Section 1",
"status": "INCLUDED",
"bestPractice": true,
},
}, &createControlResult)
require.NoError(t, err)
@@ -362,6 +363,7 @@ func TestControlDocumentMapping_CreateDelete(t *testing.T) {
"description": "Test control",
"sectionTitle": "Section 1",
"status": "INCLUDED",
"bestPractice": true,
},
}, &createControlResult)
require.NoError(t, err)
@@ -503,6 +505,7 @@ func TestControlAuditMapping_CreateDelete(t *testing.T) {
"description": "Test control",
"sectionTitle": "Section 1",
"status": "INCLUDED",
"bestPractice": true,
},
}, &createControlResult)
require.NoError(t, err)
@@ -640,6 +643,7 @@ func TestControlSnapshotMapping_CreateDelete(t *testing.T) {
"description": "Test control",
"sectionTitle": "Section 1",
"status": "INCLUDED",
"bestPractice": true,
},
}, &createControlResult)
require.NoError(t, err)
@@ -897,6 +901,7 @@ func TestRiskObligationMapping_CreateDelete(t *testing.T) {
"requirement": "Obligation for Risk Mapping",
"ownerId": peopleID,
"status": "NON_COMPLIANT",
"type": "LEGAL",
},
}, &createObligationResult)
require.NoError(t, err)

View File

@@ -69,6 +69,7 @@ func TestObligation_Create(t *testing.T) {
"regulator": "ICO",
"ownerId": peopleID,
"status": "NON_COMPLIANT",
"type": "LEGAL",
},
}, &result)
require.NoError(t, err)
@@ -115,6 +116,7 @@ func TestObligation_Update(t *testing.T) {
"area": "Original Area",
"ownerId": peopleID,
"status": "NON_COMPLIANT",
"type": "LEGAL",
},
}, &createResult)
require.NoError(t, err)
@@ -191,6 +193,7 @@ func TestObligation_Delete(t *testing.T) {
"area": "Obligation to Delete",
"ownerId": peopleID,
"status": "NON_COMPLIANT",
"type": "LEGAL",
},
}, &createResult)
require.NoError(t, err)
@@ -256,6 +259,7 @@ func TestObligation_List(t *testing.T) {
"area": area,
"ownerId": peopleID,
"status": "NON_COMPLIANT",
"type": "LEGAL",
},
}, &result)
require.NoError(t, err)
@@ -342,6 +346,7 @@ func TestObligation_StatusValues(t *testing.T) {
"area": "Status Test " + status,
"ownerId": peopleID,
"status": status,
"type": "LEGAL",
},
}, &result)
require.NoError(t, err)

View File

@@ -413,7 +413,7 @@ func TestRBAC(t *testing.T) {
client: owner,
query: createControlMutation,
variables: func() map[string]any {
return map[string]any{"input": map[string]any{"frameworkId": frameworkID, "name": factory.SafeName("Control"), "description": "Test", "sectionTitle": factory.SafeName("Section Owner"), "status": "INCLUDED"}}
return map[string]any{"input": map[string]any{"frameworkId": frameworkID, "name": factory.SafeName("Control"), "description": "Test", "sectionTitle": factory.SafeName("Section Owner"), "status": "INCLUDED", "bestPractice": true}}
},
shouldAllow: true,
},
@@ -423,7 +423,7 @@ func TestRBAC(t *testing.T) {
client: admin,
query: createControlMutation,
variables: func() map[string]any {
return map[string]any{"input": map[string]any{"frameworkId": frameworkID, "name": factory.SafeName("Control"), "description": "Test", "sectionTitle": factory.SafeName("Section Admin"), "status": "INCLUDED"}}
return map[string]any{"input": map[string]any{"frameworkId": frameworkID, "name": factory.SafeName("Control"), "description": "Test", "sectionTitle": factory.SafeName("Section Admin"), "status": "INCLUDED", "bestPractice": true}}
},
shouldAllow: true,
},
@@ -433,7 +433,7 @@ func TestRBAC(t *testing.T) {
client: viewer,
query: createControlMutation,
variables: func() map[string]any {
return map[string]any{"input": map[string]any{"frameworkId": frameworkID, "name": factory.SafeName("Control"), "description": "Test", "sectionTitle": factory.SafeName("Section Viewer"), "status": "INCLUDED"}}
return map[string]any{"input": map[string]any{"frameworkId": frameworkID, "name": factory.SafeName("Control"), "description": "Test", "sectionTitle": factory.SafeName("Section Viewer"), "status": "INCLUDED", "bestPractice": true}}
},
shouldAllow: false,
},

View File

@@ -218,6 +218,7 @@ func CreateControl(c *testutil.Client, frameworkID string, attrs ...Attrs) strin
"description": a.getString("description", "Test control description"),
"sectionTitle": a.getString("sectionTitle", fmt.Sprintf("Section %s", gofakeit.LetterN(3))),
"status": a.getString("status", "INCLUDED"),
"bestPractice": a.getBool("bestPractice", true),
}
var result struct {
@@ -389,9 +390,9 @@ func CreatePeople(c *testutil.Client, attrs ...Attrs) string {
`
input := map[string]any{
"organizationId": c.GetOrganizationID().String(),
"organizationId": c.GetOrganizationID().String(),
"fullName": a.getString("fullName", SafeName("Person")),
"primaryEmailAddress": a.getString("primaryEmailAddress", SafeEmail()),
"primaryEmailAddress": a.getString("primaryEmailAddress", SafeEmail()),
"additionalEmailAddresses": a.getSlice("additionalEmailAddresses", []string{}),
"kind": a.getString("kind", "EMPLOYEE"),
}
@@ -498,6 +499,11 @@ func (b *ControlBuilder) WithStatus(status string) *ControlBuilder {
return b
}
func (b *ControlBuilder) WithBestPractice(bestPractice bool) *ControlBuilder {
b.attrs["bestPractice"] = bestPractice
return b
}
func (b *ControlBuilder) Create() string {
return CreateControl(b.client, b.frameworkID, b.attrs)
}