Update e2e tests for compliance portal
Rename trust center coverage to compliance portal so console, MCP, and trust suites assert against the new API surface. Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
@@ -28,15 +28,15 @@ import (
|
||||
"go.probo.inc/probo/e2e/internal/testutil"
|
||||
)
|
||||
|
||||
// trustCenterID looks up the caller's own organization's trust center id.
|
||||
func trustCenterID(t *testing.T, c *testutil.Client) string {
|
||||
// compliancePortalID looks up the caller's own organization's compliance portal id.
|
||||
func compliancePortalID(t *testing.T, c *testutil.Client) string {
|
||||
t.Helper()
|
||||
|
||||
var result struct {
|
||||
Node struct {
|
||||
TrustCenter struct {
|
||||
CompliancePortal struct {
|
||||
ID string `json:"id"`
|
||||
} `json:"trustCenter"`
|
||||
} `json:"compliancePortal"`
|
||||
} `json:"node"`
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ func trustCenterID(t *testing.T, c *testutil.Client) string {
|
||||
query($organizationId: ID!) {
|
||||
node(id: $organizationId) {
|
||||
... on Organization {
|
||||
trustCenter { id }
|
||||
compliancePortal { id }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,16 +52,16 @@ func trustCenterID(t *testing.T, c *testutil.Client) string {
|
||||
"organizationId": c.GetOrganizationID().String(),
|
||||
}, &result)
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, result.Node.TrustCenter.ID)
|
||||
require.NotEmpty(t, result.Node.CompliancePortal.ID)
|
||||
|
||||
return result.Node.TrustCenter.ID
|
||||
return result.Node.CompliancePortal.ID
|
||||
}
|
||||
|
||||
func TestComplianceFramework_Create(t *testing.T) {
|
||||
t.Parallel()
|
||||
owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
|
||||
trustCenterID := trustCenterID(t, owner)
|
||||
compliancePortalID := compliancePortalID(t, owner)
|
||||
frameworkID := factory.CreateFramework(owner)
|
||||
|
||||
var result struct {
|
||||
@@ -82,8 +82,8 @@ func TestComplianceFramework_Create(t *testing.T) {
|
||||
}
|
||||
`, map[string]any{
|
||||
"input": map[string]any{
|
||||
"trustCenterId": trustCenterID,
|
||||
"frameworkId": frameworkID,
|
||||
"compliancePortalId": compliancePortalID,
|
||||
"frameworkId": frameworkID,
|
||||
},
|
||||
}, &result)
|
||||
require.NoError(t, err)
|
||||
@@ -102,7 +102,7 @@ func TestComplianceFramework_TenantIsolation(t *testing.T) {
|
||||
org1Owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
org2Owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
|
||||
org1TrustCenterID := trustCenterID(t, org1Owner)
|
||||
org1CompliancePortalID := compliancePortalID(t, org1Owner)
|
||||
org2FrameworkID := factory.CreateFramework(org2Owner)
|
||||
|
||||
_, err := org1Owner.Do(`
|
||||
@@ -113,8 +113,8 @@ func TestComplianceFramework_TenantIsolation(t *testing.T) {
|
||||
}
|
||||
`, map[string]any{
|
||||
"input": map[string]any{
|
||||
"trustCenterId": org1TrustCenterID,
|
||||
"frameworkId": org2FrameworkID,
|
||||
"compliancePortalId": org1CompliancePortalID,
|
||||
"frameworkId": org2FrameworkID,
|
||||
},
|
||||
})
|
||||
require.Error(t, err, "must not accept a frameworkId belonging to another organization")
|
||||
|
||||
@@ -29,17 +29,17 @@ import (
|
||||
"go.probo.inc/probo/e2e/internal/testutil"
|
||||
)
|
||||
|
||||
func TestTrustCenter_UploadNDA(t *testing.T) {
|
||||
func TestCompliancePortal_UploadNDA(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
organizationID := owner.GetOrganizationID().String()
|
||||
|
||||
const trustCenterQuery = `
|
||||
const compliancePortalQuery = `
|
||||
query($organizationId: ID!) {
|
||||
node(id: $organizationId) {
|
||||
... on Organization {
|
||||
trustCenter {
|
||||
compliancePortal {
|
||||
id
|
||||
}
|
||||
}
|
||||
@@ -47,26 +47,26 @@ func TestTrustCenter_UploadNDA(t *testing.T) {
|
||||
}
|
||||
`
|
||||
|
||||
var trustCenterLookup struct {
|
||||
var compliancePortalLookup struct {
|
||||
Node struct {
|
||||
TrustCenter struct {
|
||||
CompliancePortal struct {
|
||||
ID string `json:"id"`
|
||||
} `json:"trustCenter"`
|
||||
} `json:"compliancePortal"`
|
||||
} `json:"node"`
|
||||
}
|
||||
|
||||
err := owner.Execute(trustCenterQuery, map[string]any{
|
||||
err := owner.Execute(compliancePortalQuery, map[string]any{
|
||||
"organizationId": organizationID,
|
||||
}, &trustCenterLookup)
|
||||
}, &compliancePortalLookup)
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, trustCenterLookup.Node.TrustCenter.ID)
|
||||
require.NotEmpty(t, compliancePortalLookup.Node.CompliancePortal.ID)
|
||||
|
||||
trustCenterID := trustCenterLookup.Node.TrustCenter.ID
|
||||
compliancePortalID := compliancePortalLookup.Node.CompliancePortal.ID
|
||||
|
||||
const uploadMutation = `
|
||||
mutation UploadTrustCenterNDA($input: UploadTrustCenterNDAInput!) {
|
||||
uploadTrustCenterNDA(input: $input) {
|
||||
trustCenter {
|
||||
mutation UploadCompliancePortalNDA($input: UploadCompliancePortalNDAInput!) {
|
||||
uploadCompliancePortalNDA(input: $input) {
|
||||
compliancePortal {
|
||||
id
|
||||
nda {
|
||||
id
|
||||
@@ -81,23 +81,23 @@ func TestTrustCenter_UploadNDA(t *testing.T) {
|
||||
pdfContent := []byte("%PDF-1.4\n1 0 obj\n<< /Type /Catalog >>\nendobj\ntrailer\n<< /Root 1 0 R >>\n%%EOF")
|
||||
|
||||
var uploadResult struct {
|
||||
UploadTrustCenterNDA struct {
|
||||
TrustCenter struct {
|
||||
UploadCompliancePortalNDA struct {
|
||||
CompliancePortal struct {
|
||||
ID string `json:"id"`
|
||||
Nda *struct {
|
||||
ID string `json:"id"`
|
||||
FileName string `json:"fileName"`
|
||||
DownloadURL string `json:"downloadUrl"`
|
||||
} `json:"nda"`
|
||||
} `json:"trustCenter"`
|
||||
} `json:"uploadTrustCenterNDA"`
|
||||
} `json:"compliancePortal"`
|
||||
} `json:"uploadCompliancePortalNDA"`
|
||||
}
|
||||
|
||||
err = owner.ExecuteWithFile(uploadMutation, map[string]any{
|
||||
"input": map[string]any{
|
||||
"trustCenterId": trustCenterID,
|
||||
"fileName": "nda.pdf",
|
||||
"file": nil,
|
||||
"compliancePortalId": compliancePortalID,
|
||||
"fileName": "nda.pdf",
|
||||
"file": nil,
|
||||
},
|
||||
}, "input.file", testutil.UploadFile{
|
||||
Filename: "nda.pdf",
|
||||
@@ -106,14 +106,14 @@ func TestTrustCenter_UploadNDA(t *testing.T) {
|
||||
}, &uploadResult)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, trustCenterID, uploadResult.UploadTrustCenterNDA.TrustCenter.ID)
|
||||
require.NotNil(t, uploadResult.UploadTrustCenterNDA.TrustCenter.Nda)
|
||||
assert.Equal(t, "nda.pdf", uploadResult.UploadTrustCenterNDA.TrustCenter.Nda.FileName)
|
||||
assert.NotEmpty(t, uploadResult.UploadTrustCenterNDA.TrustCenter.Nda.DownloadURL)
|
||||
assert.Equal(t, compliancePortalID, uploadResult.UploadCompliancePortalNDA.CompliancePortal.ID)
|
||||
require.NotNil(t, uploadResult.UploadCompliancePortalNDA.CompliancePortal.Nda)
|
||||
assert.Equal(t, "nda.pdf", uploadResult.UploadCompliancePortalNDA.CompliancePortal.Nda.FileName)
|
||||
assert.NotEmpty(t, uploadResult.UploadCompliancePortalNDA.CompliancePortal.Nda.DownloadURL)
|
||||
assert.True(
|
||||
t,
|
||||
strings.Contains(uploadResult.UploadTrustCenterNDA.TrustCenter.Nda.DownloadURL, "/api/files/v1/"),
|
||||
strings.Contains(uploadResult.UploadCompliancePortalNDA.CompliancePortal.Nda.DownloadURL, "/api/files/v1/"),
|
||||
"downloadUrl must route through the files API, got %q",
|
||||
uploadResult.UploadTrustCenterNDA.TrustCenter.Nda.DownloadURL,
|
||||
uploadResult.UploadCompliancePortalNDA.CompliancePortal.Nda.DownloadURL,
|
||||
)
|
||||
}
|
||||
@@ -22,17 +22,17 @@ import (
|
||||
"go.probo.inc/probo/e2e/internal/testutil"
|
||||
)
|
||||
|
||||
func TestTrustCenter_UpdateProfile(t *testing.T) {
|
||||
func TestCompliancePortal_UpdateProfile(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
organizationID := owner.GetOrganizationID().String()
|
||||
|
||||
const trustCenterQuery = `
|
||||
const compliancePortalQuery = `
|
||||
query($organizationId: ID!) {
|
||||
node(id: $organizationId) {
|
||||
... on Organization {
|
||||
trustCenter {
|
||||
compliancePortal {
|
||||
id
|
||||
}
|
||||
}
|
||||
@@ -40,26 +40,26 @@ func TestTrustCenter_UpdateProfile(t *testing.T) {
|
||||
}
|
||||
`
|
||||
|
||||
var trustCenterLookup struct {
|
||||
var compliancePortalLookup struct {
|
||||
Node struct {
|
||||
TrustCenter struct {
|
||||
CompliancePortal struct {
|
||||
ID string `json:"id"`
|
||||
} `json:"trustCenter"`
|
||||
} `json:"compliancePortal"`
|
||||
} `json:"node"`
|
||||
}
|
||||
|
||||
err := owner.Execute(trustCenterQuery, map[string]any{
|
||||
err := owner.Execute(compliancePortalQuery, map[string]any{
|
||||
"organizationId": organizationID,
|
||||
}, &trustCenterLookup)
|
||||
}, &compliancePortalLookup)
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, trustCenterLookup.Node.TrustCenter.ID)
|
||||
require.NotEmpty(t, compliancePortalLookup.Node.CompliancePortal.ID)
|
||||
|
||||
trustCenterID := trustCenterLookup.Node.TrustCenter.ID
|
||||
compliancePortalID := compliancePortalLookup.Node.CompliancePortal.ID
|
||||
|
||||
const updateMutation = `
|
||||
mutation UpdateTrustCenter($input: UpdateTrustCenterInput!) {
|
||||
updateTrustCenter(input: $input) {
|
||||
trustCenter {
|
||||
mutation UpdateCompliancePortal($input: UpdateCompliancePortalInput!) {
|
||||
updateCompliancePortal(input: $input) {
|
||||
compliancePortal {
|
||||
id
|
||||
title
|
||||
description
|
||||
@@ -72,21 +72,21 @@ func TestTrustCenter_UpdateProfile(t *testing.T) {
|
||||
`
|
||||
|
||||
var result struct {
|
||||
UpdateTrustCenter struct {
|
||||
TrustCenter struct {
|
||||
UpdateCompliancePortal struct {
|
||||
CompliancePortal struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Description *string `json:"description"`
|
||||
WebsiteURL *string `json:"websiteUrl"`
|
||||
Email *string `json:"email"`
|
||||
HeadquarterAddress *string `json:"headquarterAddress"`
|
||||
} `json:"trustCenter"`
|
||||
} `json:"updateTrustCenter"`
|
||||
} `json:"compliancePortal"`
|
||||
} `json:"updateCompliancePortal"`
|
||||
}
|
||||
|
||||
err = owner.Execute(updateMutation, map[string]any{
|
||||
"input": map[string]any{
|
||||
"trustCenterId": trustCenterID,
|
||||
"compliancePortalId": compliancePortalID,
|
||||
"title": "Acme Security",
|
||||
"description": "We keep your data safe.",
|
||||
"websiteUrl": "https://example.com",
|
||||
@@ -96,8 +96,8 @@ func TestTrustCenter_UpdateProfile(t *testing.T) {
|
||||
}, &result)
|
||||
require.NoError(t, err)
|
||||
|
||||
tc := result.UpdateTrustCenter.TrustCenter
|
||||
assert.Equal(t, trustCenterID, tc.ID)
|
||||
tc := result.UpdateCompliancePortal.CompliancePortal
|
||||
assert.Equal(t, compliancePortalID, tc.ID)
|
||||
assert.Equal(t, "Acme Security", tc.Title)
|
||||
require.NotNil(t, tc.Description)
|
||||
assert.Equal(t, "We keep your data safe.", *tc.Description)
|
||||
@@ -645,8 +645,8 @@ func TestDocument_Timestamps(t *testing.T) {
|
||||
|
||||
err = owner.Execute(updateQuery, map[string]any{
|
||||
"input": map[string]any{
|
||||
"id": documentID,
|
||||
"trustCenterVisibility": "PRIVATE",
|
||||
"id": documentID,
|
||||
"compliancePortalVisibility": "PRIVATE",
|
||||
},
|
||||
}, &updateResult)
|
||||
require.NoError(t, err)
|
||||
@@ -778,8 +778,8 @@ func TestDocument_RBAC(t *testing.T) {
|
||||
}
|
||||
`, map[string]any{
|
||||
"input": map[string]any{
|
||||
"id": documentID,
|
||||
"trustCenterVisibility": "PRIVATE",
|
||||
"id": documentID,
|
||||
"compliancePortalVisibility": "PRIVATE",
|
||||
},
|
||||
})
|
||||
require.NoError(t, err, "owner should be able to update document")
|
||||
@@ -799,8 +799,8 @@ func TestDocument_RBAC(t *testing.T) {
|
||||
}
|
||||
`, map[string]any{
|
||||
"input": map[string]any{
|
||||
"id": documentID,
|
||||
"trustCenterVisibility": "PRIVATE",
|
||||
"id": documentID,
|
||||
"compliancePortalVisibility": "PRIVATE",
|
||||
},
|
||||
})
|
||||
require.NoError(t, err, "admin should be able to update document")
|
||||
@@ -820,8 +820,8 @@ func TestDocument_RBAC(t *testing.T) {
|
||||
}
|
||||
`, map[string]any{
|
||||
"input": map[string]any{
|
||||
"id": documentID,
|
||||
"trustCenterVisibility": "PRIVATE",
|
||||
"id": documentID,
|
||||
"compliancePortalVisibility": "PRIVATE",
|
||||
},
|
||||
})
|
||||
testutil.RequireForbiddenError(t, err, "viewer should not be able to update document")
|
||||
@@ -1240,8 +1240,8 @@ func TestDocument_TenantIsolation(t *testing.T) {
|
||||
|
||||
_, err := org2Owner.Do(query, map[string]any{
|
||||
"input": map[string]any{
|
||||
"id": documentID,
|
||||
"trustCenterVisibility": "PRIVATE",
|
||||
"id": documentID,
|
||||
"compliancePortalVisibility": "PRIVATE",
|
||||
},
|
||||
})
|
||||
require.Error(t, err, "Should not be able to update document from another org")
|
||||
|
||||
@@ -71,40 +71,40 @@ func TestSecurity_WriteGap_PublishRiskListApproverIDs(t *testing.T) {
|
||||
require.Error(t, err, "must not accept an approverId belonging to another organization")
|
||||
}
|
||||
|
||||
// TestSecurity_WriteGap_TrustCenterAccessDocuments covers a write-gap found
|
||||
// while auditing GHSA-c74x-79w6-63jh's blast radius: TrustCenterAccessService.Update
|
||||
// TestSecurity_WriteGap_CompliancePortalAccessDocuments covers a write-gap found
|
||||
// while auditing GHSA-c74x-79w6-63jh's blast radius: CompliancePortalAccessService.Update
|
||||
// persisted caller-supplied document/report-file/trust-center-file ids into
|
||||
// trust_center_document_accesses (via coredata's MergeDocumentAccesses/
|
||||
// MergeReportFileAccesses/MergeTrustCenterFileAccesses) without validating
|
||||
// they belong to the trust center's own organization -- the DB-level FK check
|
||||
// MergeReportFileAccesses/MergeCompliancePortalFileAccesses) without validating
|
||||
// they belong to the compliance portal's own organization -- the DB-level FK check
|
||||
// alone doesn't catch this because those primary keys are globally unique,
|
||||
// not per-tenant.
|
||||
//
|
||||
// TrustCenterAccess rows are normally created through the trust/v1 public
|
||||
// CompliancePortalAccess rows are normally created through the trust/v1 public
|
||||
// portal's visitor request flow (requestAllAccesses), which needs a
|
||||
// separate authenticated visitor identity and NDA acceptance. To keep this
|
||||
// test focused on the fix under test (the Update mutation's FK validation)
|
||||
// rather than that unrelated flow, the access row's prerequisite state is
|
||||
// seeded directly via SQL against the same Postgres database the e2e probod
|
||||
// instance runs against, then the real updateTrustCenterAccess mutation is
|
||||
// instance runs against, then the real updateCompliancePortalAccess mutation is
|
||||
// exercised through the live GraphQL API.
|
||||
func TestSecurity_WriteGap_TrustCenterAccessDocuments(t *testing.T) {
|
||||
func TestSecurity_WriteGap_CompliancePortalAccessDocuments(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
org1Owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
org2Owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
|
||||
org1TrustCenterID := trustCenterID(t, org1Owner)
|
||||
org1DocumentID := factory.NewDocument(org1Owner).WithTitle("Org1 Document for trust center access").Create()
|
||||
org1CompliancePortalID := compliancePortalID(t, org1Owner)
|
||||
org1DocumentID := factory.NewDocument(org1Owner).WithTitle("Org1 Document for compliance portal access").Create()
|
||||
org2DocumentID := factory.NewDocument(org2Owner).WithTitle("Org2 Secret Document").Create()
|
||||
|
||||
accessID := seedTrustCenterAccess(t, org1Owner, org1TrustCenterID)
|
||||
accessID := seedCompliancePortalAccess(t, org1Owner, org1CompliancePortalID)
|
||||
|
||||
t.Run("cannot grant access to a document from another organization", func(t *testing.T) {
|
||||
_, err := org1Owner.Do(`
|
||||
mutation($input: UpdateTrustCenterAccessInput!) {
|
||||
updateTrustCenterAccess(input: $input) {
|
||||
trustCenterAccess { id }
|
||||
mutation($input: UpdateCompliancePortalAccessInput!) {
|
||||
updateCompliancePortalAccess(input: $input) {
|
||||
compliancePortalAccess { id }
|
||||
}
|
||||
}
|
||||
`, map[string]any{
|
||||
@@ -118,9 +118,9 @@ func TestSecurity_WriteGap_TrustCenterAccessDocuments(t *testing.T) {
|
||||
|
||||
t.Run("can grant access to a document from the same organization", func(t *testing.T) {
|
||||
_, err := org1Owner.Do(`
|
||||
mutation($input: UpdateTrustCenterAccessInput!) {
|
||||
updateTrustCenterAccess(input: $input) {
|
||||
trustCenterAccess { id }
|
||||
mutation($input: UpdateCompliancePortalAccessInput!) {
|
||||
updateCompliancePortalAccess(input: $input) {
|
||||
compliancePortalAccess { id }
|
||||
}
|
||||
}
|
||||
`, map[string]any{
|
||||
@@ -133,20 +133,20 @@ func TestSecurity_WriteGap_TrustCenterAccessDocuments(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
// seedTrustCenterAccess inserts a minimal trust_center_accesses row directly
|
||||
// seedCompliancePortalAccess inserts a minimal trust_center_accesses row directly
|
||||
// via SQL, bypassing the trust/v1 visitor request flow (which requires a
|
||||
// separate authenticated visitor identity and NDA acceptance) so that
|
||||
// updateTrustCenterAccess -- the mutation under test -- can be exercised in
|
||||
// updateCompliancePortalAccess -- the mutation under test -- can be exercised in
|
||||
// isolation. owner's own identity id is reused to satisfy the row's
|
||||
// identity_id foreign key; which identity it is doesn't matter for this test.
|
||||
func seedTrustCenterAccess(t *testing.T, owner *testutil.Client, trustCenterID string) string {
|
||||
func seedCompliancePortalAccess(t *testing.T, owner *testutil.Client, compliancePortalID string) string {
|
||||
t.Helper()
|
||||
|
||||
tcID, err := gid.ParseGID(trustCenterID)
|
||||
tcID, err := gid.ParseGID(compliancePortalID)
|
||||
require.NoError(t, err)
|
||||
|
||||
tenantID := owner.GetOrganizationID().TenantID()
|
||||
accessID := gid.New(tenantID, coredata.TrustCenterAccessEntityType)
|
||||
accessID := gid.New(tenantID, coredata.CompliancePortalAccessEntityType)
|
||||
now := time.Now().UTC()
|
||||
|
||||
client := test.PGClient(t)
|
||||
|
||||
Reference in New Issue
Block a user