Skip to content

Commit 85f1e0b

Browse files
fixes
Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>
1 parent ccf6f10 commit 85f1e0b

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

internal/graphapi/controlreport_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,17 @@ func TestQueryControlReports(t *testing.T) {
9999
orgUser := suite.seedOrgOwner(t)
100100

101101
orgOwnedCount := int64(11)
102-
systemOwnedCount := int64(3)
103102
controlIDs := []string{}
104103

105104
for range orgOwnedCount {
106105
control := (&ControlBuilder{client: suite.client}).MustNew(localTestOrg.owner.UserCtx, t)
107106
controlIDs = append(controlIDs, control.ID)
108107
}
109108

110-
// system-owned controls must not appear in controlReports results
111-
for range systemOwnedCount {
112-
(&ControlBuilder{client: suite.client, SystemOwned: lo.ToPtr(true)}).MustNew(localTestOrg.owner.UserCtx, t)
109+
// system-owned controls must not appear in controlReports results (resolver filters SystemOwned: false);
110+
// the hook sets system_owned = true automatically when it sees a system admin caller
111+
for range int64(3) {
112+
(&ControlBuilder{client: suite.client}).MustNew(sharedSystemAdminUser.UserCtx, t)
113113
}
114114

115115
// enrich the first three org-owned controls with associated data so enrichment paths are exercised
@@ -234,9 +234,10 @@ func TestQueryControlReportsByCategory(t *testing.T) {
234234
control3 := (&ControlBuilder{client: suite.client, Category: cat2}).MustNew(localTestOrg.owner.UserCtx, t)
235235
(&ControlBuilder{client: suite.client}).MustNew(localTestOrg.owner.UserCtx, t)
236236

237-
// system-owned controls must not appear in results regardless of category
238-
(&ControlBuilder{client: suite.client, Category: cat1, SystemOwned: lo.ToPtr(true)}).MustNew(localTestOrg.owner.UserCtx, t)
239-
(&ControlBuilder{client: suite.client, Category: cat2, SystemOwned: lo.ToPtr(true)}).MustNew(localTestOrg.owner.UserCtx, t)
237+
// system-owned controls must not appear in results regardless of category;
238+
// the hook sets system_owned = true automatically when it sees a system admin caller
239+
(&ControlBuilder{client: suite.client, Category: cat1}).MustNew(sharedSystemAdminUser.UserCtx, t)
240+
(&ControlBuilder{client: suite.client, Category: cat2}).MustNew(sharedSystemAdminUser.UserCtx, t)
240241

241242
// enrich control1 with associated data so enrichment paths are exercised;
242243
// control3 is used as the tertiary to confirm a second unique related control

internal/graphapi/controlreporthelpers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ func convertControlToControlReportEdge(controls *generated.ControlConnection) *m
462462

463463
return &model.ControlReportConnection{
464464
Edges: edges,
465+
PageInfo: &controls.PageInfo,
465466
TotalCount: controls.TotalCount,
466467
}
467468
}

internal/graphapi/models_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@ type ControlBuilder struct {
298298
AllFields bool
299299
Category string
300300
Subcategory string
301-
SystemOwned *bool
302301
}
303302

304303
type SubcontrolBuilder struct {
@@ -1363,7 +1362,7 @@ func (c *ControlBuilder) MustNew(ctx context.Context, t *testing.T) *ent.Control
13631362
}
13641363

13651364
mutation := c.client.db.Control.Create().
1366-
SetRefCode(c.RefCode).SetTitle(c.Title).SetNillableSystemOwned(c.SystemOwned)
1365+
SetRefCode(c.RefCode).SetTitle(c.Title)
13671366

13681367
if c.ProgramID != "" {
13691368
mutation.AddProgramIDs(c.ProgramID)

0 commit comments

Comments
 (0)