Rename vendors to third parties
Renames the user-facing 'vendor' concept to 'third party' across the entire codebase. The shared common_third_parties reference table is unchanged. Migration. Renames the vendor_category enum, the vendors and vendor_<entity> tables (contacts, services, compliance_reports, business_associate_agreements, data_privacy_agreements, risk_assessments) and their vendor_id columns, the asset_vendors / data_vendors / processing_activity_vendors junction tables, generated_documents.vendors_document_id, the webhook_event_type 'vendor:<verb>' values, and the snapshots_type 'VENDORS' value. Backend. Renames coredata models and SQL queries, probo services, GraphQL / MCP API surface, console / trust / webhook resolvers and types, the CLI (prb vendor* -> prb third-party*; pkg/cmd/vendormgmt -> pkg/cmd/thirdpartymgmt), the document generator, vetting agent prompts, and the common-third-parties-import command. Frontend, packages, n8n, e2e. Renames apps/console pages, components, hooks, routes, dialogs, and tabs; the shared @probo/vendors package (now @probo/third-parties); the @probo/ui Vendors atoms (now ThirdParties, VendorLogo -> ThirdPartyLogo); the n8n community node actions/vendor folder (now actions/thirdParty); and the e2e Go test suite (console and MCP). Filesystem and URL paths use kebab-case (third-parties), GraphQL fields and TypeScript identifiers use camelCase (thirdParty / thirdParties), Go types use PascalCase (ThirdParty), and human-facing text uses 'third party' with a space. Co-authored-by: Bryan Frimin <bryan@getprobo.com> Signed-off-by: Bryan Frimin <bryan@getprobo.com> Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -27,8 +27,8 @@ func TestAuditLog_List(t *testing.T) {
|
||||
t.Parallel()
|
||||
owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
|
||||
// Create a vendor to generate an audit log entry.
|
||||
factory.NewVendor(owner).WithName(factory.SafeName("AuditVendor")).Create()
|
||||
// Create a thirdParty to generate an audit log entry.
|
||||
factory.NewThirdParty(owner).WithName(factory.SafeName("AuditThirdParty")).Create()
|
||||
|
||||
const query = `
|
||||
query($orgId: ID!) {
|
||||
@@ -78,20 +78,20 @@ func TestAuditLog_List(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.GreaterOrEqual(t, result.Node.AuditLogEntries.TotalCount, 1)
|
||||
|
||||
// Find the vendor create entry.
|
||||
// Find the thirdParty create entry.
|
||||
found := false
|
||||
for _, edge := range result.Node.AuditLogEntries.Edges {
|
||||
if edge.Node.Action == "core:vendor:create" {
|
||||
if edge.Node.Action == "core:thirdParty:create" {
|
||||
found = true
|
||||
assert.Equal(t, "USER", edge.Node.ActorType)
|
||||
assert.Equal(t, "Vendor", edge.Node.ResourceType)
|
||||
assert.Equal(t, "ThirdParty", edge.Node.ResourceType)
|
||||
assert.NotEmpty(t, edge.Node.ActorID)
|
||||
assert.NotEmpty(t, edge.Node.ResourceID)
|
||||
assert.NotEmpty(t, edge.Node.CreatedAt)
|
||||
break
|
||||
}
|
||||
}
|
||||
assert.True(t, found, "expected to find core:vendor:create audit log entry")
|
||||
assert.True(t, found, "expected to find core:thirdParty:create audit log entry")
|
||||
}
|
||||
|
||||
func TestAuditLog_Filter(t *testing.T) {
|
||||
@@ -99,7 +99,7 @@ func TestAuditLog_Filter(t *testing.T) {
|
||||
owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
|
||||
// Create different resources to generate different audit log entries.
|
||||
factory.NewVendor(owner).WithName(factory.SafeName("FilterVendor")).Create()
|
||||
factory.NewThirdParty(owner).WithName(factory.SafeName("FilterThirdParty")).Create()
|
||||
|
||||
const query = `
|
||||
query($orgId: ID!, $filter: AuditLogEntryFilter) {
|
||||
@@ -139,12 +139,12 @@ func TestAuditLog_Filter(t *testing.T) {
|
||||
|
||||
err := owner.Execute(query, map[string]any{
|
||||
"orgId": owner.GetOrganizationID().String(),
|
||||
"filter": map[string]any{"action": "core:vendor:create"},
|
||||
"filter": map[string]any{"action": "core:thirdParty:create"},
|
||||
}, &result)
|
||||
require.NoError(t, err)
|
||||
assert.GreaterOrEqual(t, result.Node.AuditLogEntries.TotalCount, 1)
|
||||
for _, edge := range result.Node.AuditLogEntries.Edges {
|
||||
assert.Equal(t, "core:vendor:create", edge.Node.Action)
|
||||
assert.Equal(t, "core:thirdParty:create", edge.Node.Action)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -167,12 +167,12 @@ func TestAuditLog_Filter(t *testing.T) {
|
||||
|
||||
err := owner.Execute(query, map[string]any{
|
||||
"orgId": owner.GetOrganizationID().String(),
|
||||
"filter": map[string]any{"resourceType": "Vendor"},
|
||||
"filter": map[string]any{"resourceType": "ThirdParty"},
|
||||
}, &result)
|
||||
require.NoError(t, err)
|
||||
assert.GreaterOrEqual(t, result.Node.AuditLogEntries.TotalCount, 1)
|
||||
for _, edge := range result.Node.AuditLogEntries.Edges {
|
||||
assert.Equal(t, "Vendor", edge.Node.ResourceType)
|
||||
assert.Equal(t, "ThirdParty", edge.Node.ResourceType)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -182,7 +182,7 @@ func TestAuditLog_RBAC(t *testing.T) {
|
||||
owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
|
||||
// Generate an audit log entry.
|
||||
factory.NewVendor(owner).WithName(factory.SafeName("RBACVendor")).Create()
|
||||
factory.NewThirdParty(owner).WithName(factory.SafeName("RBACThirdParty")).Create()
|
||||
|
||||
const query = `
|
||||
query($orgId: ID!) {
|
||||
@@ -253,8 +253,8 @@ func TestAuditLog_TenantIsolation(t *testing.T) {
|
||||
org1Owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
org2Owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
|
||||
// Create a vendor in org1 to generate audit log entries.
|
||||
factory.NewVendor(org1Owner).WithName(factory.SafeName("IsoVendor")).Create()
|
||||
// Create a thirdParty in org1 to generate audit log entries.
|
||||
factory.NewThirdParty(org1Owner).WithName(factory.SafeName("IsoThirdParty")).Create()
|
||||
|
||||
const query = `
|
||||
query($orgId: ID!) {
|
||||
@@ -275,7 +275,7 @@ func TestAuditLog_TenantIsolation(t *testing.T) {
|
||||
}
|
||||
`
|
||||
|
||||
// org2 should not see org1's audit log entries about vendors.
|
||||
// org2 should not see org1's audit log entries about thirdParties.
|
||||
var result struct {
|
||||
Node struct {
|
||||
AuditLogEntries struct {
|
||||
@@ -298,9 +298,9 @@ func TestAuditLog_TenantIsolation(t *testing.T) {
|
||||
|
||||
for _, edge := range result.Node.AuditLogEntries.Edges {
|
||||
// org2 may have its own audit log entries (from user/org creation),
|
||||
// but should never see org1's vendor entries.
|
||||
if edge.Node.ResourceType == "Vendor" {
|
||||
t.Fatalf("org2 should not see org1's vendor audit log entries, but found: %s", edge.Node.Action)
|
||||
// but should never see org1's thirdParty entries.
|
||||
if edge.Node.ResourceType == "ThirdParty" {
|
||||
t.Fatalf("org2 should not see org1's thirdParty audit log entries, but found: %s", edge.Node.Action)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,32 +174,32 @@ const (
|
||||
}
|
||||
}`
|
||||
|
||||
createVendorMutation = `
|
||||
mutation CreateVendor($input: CreateVendorInput!) {
|
||||
createVendor(input: $input) {
|
||||
vendorEdge { node { id } }
|
||||
createThirdPartyMutation = `
|
||||
mutation CreateThirdParty($input: CreateThirdPartyInput!) {
|
||||
createThirdParty(input: $input) {
|
||||
thirdPartyEdge { node { id } }
|
||||
}
|
||||
}`
|
||||
|
||||
updateVendorMutation = `
|
||||
mutation UpdateVendor($input: UpdateVendorInput!) {
|
||||
updateVendor(input: $input) {
|
||||
vendor { id }
|
||||
updateThirdPartyMutation = `
|
||||
mutation UpdateThirdParty($input: UpdateThirdPartyInput!) {
|
||||
updateThirdParty(input: $input) {
|
||||
thirdParty { id }
|
||||
}
|
||||
}`
|
||||
|
||||
deleteVendorMutation = `
|
||||
mutation DeleteVendor($input: DeleteVendorInput!) {
|
||||
deleteVendor(input: $input) {
|
||||
deletedVendorId
|
||||
deleteThirdPartyMutation = `
|
||||
mutation DeleteThirdParty($input: DeleteThirdPartyInput!) {
|
||||
deleteThirdParty(input: $input) {
|
||||
deletedThirdPartyId
|
||||
}
|
||||
}`
|
||||
|
||||
listVendorsQuery = `
|
||||
query GetVendors($id: ID!) {
|
||||
listThirdPartiesQuery = `
|
||||
query GetThirdParties($id: ID!) {
|
||||
node(id: $id) {
|
||||
... on Organization {
|
||||
vendors(first: 10) { totalCount }
|
||||
thirdParties(first: 10) { totalCount }
|
||||
}
|
||||
}
|
||||
}`
|
||||
@@ -304,7 +304,7 @@ func TestRBAC(t *testing.T) {
|
||||
measureID := factory.NewMeasure(owner).WithName("RBAC Test Measure").Create()
|
||||
taskID := factory.NewTask(owner, measureID).WithName("RBAC Test Task").Create()
|
||||
riskID := factory.NewRisk(owner).WithName("RBAC Test Risk").Create()
|
||||
vendorID := factory.NewVendor(owner).WithName("RBAC Test Vendor").Create()
|
||||
thirdPartyID := factory.NewThirdParty(owner).WithName("RBAC Test ThirdParty").Create()
|
||||
accessSourceID := factory.NewAccessSource(owner, owner.GetOrganizationID().String()).WithName("RBAC Test Source").Create()
|
||||
accessReviewCampaignID := factory.NewAccessReviewCampaign(owner, owner.GetOrganizationID().String()).WithName("RBAC Test Campaign").Create()
|
||||
|
||||
@@ -936,123 +936,123 @@ func TestRBAC(t *testing.T) {
|
||||
shouldAllow: true,
|
||||
},
|
||||
{
|
||||
name: "owner can create vendor",
|
||||
name: "owner can create thirdParty",
|
||||
role: "owner",
|
||||
client: owner,
|
||||
query: createVendorMutation,
|
||||
query: createThirdPartyMutation,
|
||||
variables: func() map[string]any {
|
||||
return map[string]any{"input": map[string]any{"organizationId": owner.GetOrganizationID().String(), "name": factory.SafeName("Vendor")}}
|
||||
return map[string]any{"input": map[string]any{"organizationId": owner.GetOrganizationID().String(), "name": factory.SafeName("ThirdParty")}}
|
||||
},
|
||||
shouldAllow: true,
|
||||
},
|
||||
{
|
||||
name: "admin can create vendor",
|
||||
name: "admin can create thirdParty",
|
||||
role: "admin",
|
||||
client: admin,
|
||||
query: createVendorMutation,
|
||||
query: createThirdPartyMutation,
|
||||
variables: func() map[string]any {
|
||||
return map[string]any{"input": map[string]any{"organizationId": owner.GetOrganizationID().String(), "name": factory.SafeName("Vendor")}}
|
||||
return map[string]any{"input": map[string]any{"organizationId": owner.GetOrganizationID().String(), "name": factory.SafeName("ThirdParty")}}
|
||||
},
|
||||
shouldAllow: true,
|
||||
},
|
||||
{
|
||||
name: "viewer cannot create vendor",
|
||||
name: "viewer cannot create thirdParty",
|
||||
role: "viewer",
|
||||
client: viewer,
|
||||
query: createVendorMutation,
|
||||
query: createThirdPartyMutation,
|
||||
variables: func() map[string]any {
|
||||
return map[string]any{"input": map[string]any{"organizationId": owner.GetOrganizationID().String(), "name": factory.SafeName("Vendor")}}
|
||||
return map[string]any{"input": map[string]any{"organizationId": owner.GetOrganizationID().String(), "name": factory.SafeName("ThirdParty")}}
|
||||
},
|
||||
shouldAllow: false,
|
||||
},
|
||||
{
|
||||
name: "owner can update vendor",
|
||||
name: "owner can update thirdParty",
|
||||
role: "owner",
|
||||
client: owner,
|
||||
query: updateVendorMutation,
|
||||
query: updateThirdPartyMutation,
|
||||
variables: func() map[string]any {
|
||||
return map[string]any{"input": map[string]any{"id": vendorID, "name": factory.SafeName("Updated Vendor")}}
|
||||
return map[string]any{"input": map[string]any{"id": thirdPartyID, "name": factory.SafeName("Updated ThirdParty")}}
|
||||
},
|
||||
shouldAllow: true,
|
||||
},
|
||||
{
|
||||
name: "admin can update vendor",
|
||||
name: "admin can update thirdParty",
|
||||
role: "admin",
|
||||
client: admin,
|
||||
query: updateVendorMutation,
|
||||
query: updateThirdPartyMutation,
|
||||
variables: func() map[string]any {
|
||||
return map[string]any{"input": map[string]any{"id": vendorID, "name": factory.SafeName("Updated Vendor")}}
|
||||
return map[string]any{"input": map[string]any{"id": thirdPartyID, "name": factory.SafeName("Updated ThirdParty")}}
|
||||
},
|
||||
shouldAllow: true,
|
||||
},
|
||||
{
|
||||
name: "viewer cannot update vendor",
|
||||
name: "viewer cannot update thirdParty",
|
||||
role: "viewer",
|
||||
client: viewer,
|
||||
query: updateVendorMutation,
|
||||
query: updateThirdPartyMutation,
|
||||
variables: func() map[string]any {
|
||||
return map[string]any{"input": map[string]any{"id": vendorID, "name": factory.SafeName("Updated Vendor")}}
|
||||
return map[string]any{"input": map[string]any{"id": thirdPartyID, "name": factory.SafeName("Updated ThirdParty")}}
|
||||
},
|
||||
shouldAllow: false,
|
||||
},
|
||||
{
|
||||
name: "owner can delete vendor",
|
||||
name: "owner can delete thirdParty",
|
||||
role: "owner",
|
||||
client: owner,
|
||||
query: deleteVendorMutation,
|
||||
query: deleteThirdPartyMutation,
|
||||
variables: func() map[string]any {
|
||||
id := factory.NewVendor(owner).WithName(factory.SafeName("ToDelete")).Create()
|
||||
return map[string]any{"input": map[string]any{"vendorId": id}}
|
||||
id := factory.NewThirdParty(owner).WithName(factory.SafeName("ToDelete")).Create()
|
||||
return map[string]any{"input": map[string]any{"thirdPartyId": id}}
|
||||
},
|
||||
shouldAllow: true,
|
||||
},
|
||||
{
|
||||
name: "admin can delete vendor",
|
||||
name: "admin can delete thirdParty",
|
||||
role: "admin",
|
||||
client: admin,
|
||||
query: deleteVendorMutation,
|
||||
query: deleteThirdPartyMutation,
|
||||
variables: func() map[string]any {
|
||||
id := factory.NewVendor(owner).WithName(factory.SafeName("ToDelete")).Create()
|
||||
return map[string]any{"input": map[string]any{"vendorId": id}}
|
||||
id := factory.NewThirdParty(owner).WithName(factory.SafeName("ToDelete")).Create()
|
||||
return map[string]any{"input": map[string]any{"thirdPartyId": id}}
|
||||
},
|
||||
shouldAllow: true,
|
||||
},
|
||||
{
|
||||
name: "viewer cannot delete vendor",
|
||||
name: "viewer cannot delete thirdParty",
|
||||
role: "viewer",
|
||||
client: viewer,
|
||||
query: deleteVendorMutation,
|
||||
query: deleteThirdPartyMutation,
|
||||
variables: func() map[string]any {
|
||||
id := factory.NewVendor(owner).WithName(factory.SafeName("ToDelete")).Create()
|
||||
return map[string]any{"input": map[string]any{"vendorId": id}}
|
||||
id := factory.NewThirdParty(owner).WithName(factory.SafeName("ToDelete")).Create()
|
||||
return map[string]any{"input": map[string]any{"thirdPartyId": id}}
|
||||
},
|
||||
shouldAllow: false,
|
||||
},
|
||||
{
|
||||
name: "owner can list vendors",
|
||||
name: "owner can list third parties",
|
||||
role: "owner",
|
||||
client: owner,
|
||||
query: listVendorsQuery,
|
||||
query: listThirdPartiesQuery,
|
||||
variables: func() map[string]any {
|
||||
return map[string]any{"id": owner.GetOrganizationID().String()}
|
||||
},
|
||||
shouldAllow: true,
|
||||
},
|
||||
{
|
||||
name: "admin can list vendors",
|
||||
name: "admin can list third parties",
|
||||
role: "admin",
|
||||
client: admin,
|
||||
query: listVendorsQuery,
|
||||
query: listThirdPartiesQuery,
|
||||
variables: func() map[string]any {
|
||||
return map[string]any{"id": owner.GetOrganizationID().String()}
|
||||
},
|
||||
shouldAllow: true,
|
||||
},
|
||||
{
|
||||
name: "viewer can list vendors",
|
||||
name: "viewer can list third parties",
|
||||
role: "viewer",
|
||||
client: viewer,
|
||||
query: listVendorsQuery,
|
||||
query: listThirdPartiesQuery,
|
||||
variables: func() map[string]any {
|
||||
return map[string]any{"id": owner.GetOrganizationID().String()}
|
||||
},
|
||||
|
||||
@@ -23,15 +23,15 @@ import (
|
||||
"go.probo.inc/probo/e2e/internal/testutil"
|
||||
)
|
||||
|
||||
func TestVendorComplianceReport_Upload(t *testing.T) {
|
||||
func TestThirdPartyComplianceReport_Upload(t *testing.T) {
|
||||
t.Parallel()
|
||||
owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
vendorID := factory.NewVendor(owner).WithName("Compliance Report Upload Vendor").Create()
|
||||
thirdPartyID := factory.NewThirdParty(owner).WithName("Compliance Report Upload ThirdParty").Create()
|
||||
|
||||
const query = `
|
||||
mutation UploadVendorComplianceReport($input: UploadVendorComplianceReportInput!) {
|
||||
uploadVendorComplianceReport(input: $input) {
|
||||
vendorComplianceReportEdge {
|
||||
mutation UploadThirdPartyComplianceReport($input: UploadThirdPartyComplianceReportInput!) {
|
||||
uploadThirdPartyComplianceReport(input: $input) {
|
||||
thirdPartyComplianceReportEdge {
|
||||
node {
|
||||
id
|
||||
reportName
|
||||
@@ -46,27 +46,27 @@ func TestVendorComplianceReport_Upload(t *testing.T) {
|
||||
pdfContent := []byte("%PDF-1.4\n1 0 obj\n<< /Type /Catalog >>\nendobj\ntrailer\n<< /Root 1 0 R >>\n%%EOF")
|
||||
|
||||
var result struct {
|
||||
UploadVendorComplianceReport struct {
|
||||
VendorComplianceReportEdge struct {
|
||||
UploadThirdPartyComplianceReport struct {
|
||||
ThirdPartyComplianceReportEdge struct {
|
||||
Node struct {
|
||||
ID string `json:"id"`
|
||||
ReportName string `json:"reportName"`
|
||||
ReportDate string `json:"reportDate"`
|
||||
ValidUntil *string `json:"validUntil"`
|
||||
} `json:"node"`
|
||||
} `json:"vendorComplianceReportEdge"`
|
||||
} `json:"uploadVendorComplianceReport"`
|
||||
} `json:"thirdPartyComplianceReportEdge"`
|
||||
} `json:"uploadThirdPartyComplianceReport"`
|
||||
}
|
||||
|
||||
err := owner.ExecuteWithFile(
|
||||
query,
|
||||
map[string]any{
|
||||
"input": map[string]any{
|
||||
"vendorId": vendorID,
|
||||
"reportName": "SOC 2 Type II",
|
||||
"reportDate": "2024-01-01T00:00:00Z",
|
||||
"validUntil": "2025-01-01T00:00:00Z",
|
||||
"file": nil,
|
||||
"thirdPartyId": thirdPartyID,
|
||||
"reportName": "SOC 2 Type II",
|
||||
"reportDate": "2024-01-01T00:00:00Z",
|
||||
"validUntil": "2025-01-01T00:00:00Z",
|
||||
"file": nil,
|
||||
},
|
||||
}, "input.file", testutil.UploadFile{
|
||||
Filename: "soc2-report.pdf",
|
||||
@@ -77,23 +77,23 @@ func TestVendorComplianceReport_Upload(t *testing.T) {
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
node := result.UploadVendorComplianceReport.VendorComplianceReportEdge.Node
|
||||
node := result.UploadThirdPartyComplianceReport.ThirdPartyComplianceReportEdge.Node
|
||||
assert.NotEmpty(t, node.ID)
|
||||
assert.Equal(t, "SOC 2 Type II", node.ReportName)
|
||||
assert.NotEmpty(t, node.ReportDate)
|
||||
assert.NotNil(t, node.ValidUntil)
|
||||
}
|
||||
func TestVendorComplianceReport_List(t *testing.T) {
|
||||
func TestThirdPartyComplianceReport_List(t *testing.T) {
|
||||
t.Parallel()
|
||||
owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
vendorID := factory.NewVendor(owner).WithName("Compliance Report List Vendor").Create()
|
||||
thirdPartyID := factory.NewThirdParty(owner).WithName("Compliance Report List ThirdParty").Create()
|
||||
|
||||
pdfContent := []byte("%PDF-1.4\n1 0 obj\n<< /Type /Catalog >>\nendobj\ntrailer\n<< /Root 1 0 R >>\n%%EOF")
|
||||
|
||||
uploadQuery := `
|
||||
mutation UploadVendorComplianceReport($input: UploadVendorComplianceReportInput!) {
|
||||
uploadVendorComplianceReport(input: $input) {
|
||||
vendorComplianceReportEdge {
|
||||
mutation UploadThirdPartyComplianceReport($input: UploadThirdPartyComplianceReportInput!) {
|
||||
uploadThirdPartyComplianceReport(input: $input) {
|
||||
thirdPartyComplianceReportEdge {
|
||||
node { id }
|
||||
}
|
||||
}
|
||||
@@ -101,23 +101,23 @@ func TestVendorComplianceReport_List(t *testing.T) {
|
||||
`
|
||||
|
||||
var uploadResult struct {
|
||||
UploadVendorComplianceReport struct {
|
||||
VendorComplianceReportEdge struct {
|
||||
UploadThirdPartyComplianceReport struct {
|
||||
ThirdPartyComplianceReportEdge struct {
|
||||
Node struct {
|
||||
ID string `json:"id"`
|
||||
} `json:"node"`
|
||||
} `json:"vendorComplianceReportEdge"`
|
||||
} `json:"uploadVendorComplianceReport"`
|
||||
} `json:"thirdPartyComplianceReportEdge"`
|
||||
} `json:"uploadThirdPartyComplianceReport"`
|
||||
}
|
||||
|
||||
err := owner.ExecuteWithFile(
|
||||
uploadQuery,
|
||||
map[string]any{
|
||||
"input": map[string]any{
|
||||
"vendorId": vendorID,
|
||||
"reportName": "ISO 27001",
|
||||
"reportDate": "2024-06-01T00:00:00Z",
|
||||
"file": nil,
|
||||
"thirdPartyId": thirdPartyID,
|
||||
"reportName": "ISO 27001",
|
||||
"reportDate": "2024-06-01T00:00:00Z",
|
||||
"file": nil,
|
||||
},
|
||||
}, "input.file", testutil.UploadFile{
|
||||
Filename: "iso27001.pdf",
|
||||
@@ -128,13 +128,13 @@ func TestVendorComplianceReport_List(t *testing.T) {
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
reportID := uploadResult.UploadVendorComplianceReport.VendorComplianceReportEdge.Node.ID
|
||||
reportID := uploadResult.UploadThirdPartyComplianceReport.ThirdPartyComplianceReportEdge.Node.ID
|
||||
require.NotEmpty(t, reportID)
|
||||
|
||||
const listQuery = `
|
||||
query($id: ID!) {
|
||||
node(id: $id) {
|
||||
... on Vendor {
|
||||
... on ThirdParty {
|
||||
id
|
||||
complianceReports(first: 10) {
|
||||
edges {
|
||||
@@ -165,7 +165,7 @@ func TestVendorComplianceReport_List(t *testing.T) {
|
||||
} `json:"node"`
|
||||
}
|
||||
|
||||
err = owner.Execute(listQuery, map[string]any{"id": vendorID}, &listResult)
|
||||
err = owner.Execute(listQuery, map[string]any{"id": thirdPartyID}, &listResult)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, listResult.Node.ComplianceReports.Edges, 1)
|
||||
@@ -173,17 +173,17 @@ func TestVendorComplianceReport_List(t *testing.T) {
|
||||
assert.Equal(t, "ISO 27001", listResult.Node.ComplianceReports.Edges[0].Node.ReportName)
|
||||
}
|
||||
|
||||
func TestVendorComplianceReport_Delete(t *testing.T) {
|
||||
func TestThirdPartyComplianceReport_Delete(t *testing.T) {
|
||||
t.Parallel()
|
||||
owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
vendorID := factory.NewVendor(owner).WithName("Compliance Report Delete Vendor").Create()
|
||||
thirdPartyID := factory.NewThirdParty(owner).WithName("Compliance Report Delete ThirdParty").Create()
|
||||
|
||||
pdfContent := []byte("%PDF-1.4\n1 0 obj\n<< /Type /Catalog >>\nendobj\ntrailer\n<< /Root 1 0 R >>\n%%EOF")
|
||||
|
||||
uploadQuery := `
|
||||
mutation UploadVendorComplianceReport($input: UploadVendorComplianceReportInput!) {
|
||||
uploadVendorComplianceReport(input: $input) {
|
||||
vendorComplianceReportEdge {
|
||||
mutation UploadThirdPartyComplianceReport($input: UploadThirdPartyComplianceReportInput!) {
|
||||
uploadThirdPartyComplianceReport(input: $input) {
|
||||
thirdPartyComplianceReportEdge {
|
||||
node { id }
|
||||
}
|
||||
}
|
||||
@@ -191,21 +191,21 @@ func TestVendorComplianceReport_Delete(t *testing.T) {
|
||||
`
|
||||
|
||||
var uploadResult struct {
|
||||
UploadVendorComplianceReport struct {
|
||||
VendorComplianceReportEdge struct {
|
||||
UploadThirdPartyComplianceReport struct {
|
||||
ThirdPartyComplianceReportEdge struct {
|
||||
Node struct {
|
||||
ID string `json:"id"`
|
||||
} `json:"node"`
|
||||
} `json:"vendorComplianceReportEdge"`
|
||||
} `json:"uploadVendorComplianceReport"`
|
||||
} `json:"thirdPartyComplianceReportEdge"`
|
||||
} `json:"uploadThirdPartyComplianceReport"`
|
||||
}
|
||||
|
||||
err := owner.ExecuteWithFile(uploadQuery, map[string]any{
|
||||
"input": map[string]any{
|
||||
"vendorId": vendorID,
|
||||
"reportName": "PCI DSS",
|
||||
"reportDate": "2024-03-01T00:00:00Z",
|
||||
"file": nil,
|
||||
"thirdPartyId": thirdPartyID,
|
||||
"reportName": "PCI DSS",
|
||||
"reportDate": "2024-03-01T00:00:00Z",
|
||||
"file": nil,
|
||||
},
|
||||
}, "input.file", testutil.UploadFile{
|
||||
Filename: "pci-dss.pdf",
|
||||
@@ -214,21 +214,21 @@ func TestVendorComplianceReport_Delete(t *testing.T) {
|
||||
}, &uploadResult)
|
||||
require.NoError(t, err)
|
||||
|
||||
reportID := uploadResult.UploadVendorComplianceReport.VendorComplianceReportEdge.Node.ID
|
||||
reportID := uploadResult.UploadThirdPartyComplianceReport.ThirdPartyComplianceReportEdge.Node.ID
|
||||
require.NotEmpty(t, reportID)
|
||||
|
||||
const deleteQuery = `
|
||||
mutation DeleteVendorComplianceReport($input: DeleteVendorComplianceReportInput!) {
|
||||
deleteVendorComplianceReport(input: $input) {
|
||||
deletedVendorComplianceReportId
|
||||
mutation DeleteThirdPartyComplianceReport($input: DeleteThirdPartyComplianceReportInput!) {
|
||||
deleteThirdPartyComplianceReport(input: $input) {
|
||||
deletedThirdPartyComplianceReportId
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
var deleteResult struct {
|
||||
DeleteVendorComplianceReport struct {
|
||||
DeletedVendorComplianceReportID string `json:"deletedVendorComplianceReportId"`
|
||||
} `json:"deleteVendorComplianceReport"`
|
||||
DeleteThirdPartyComplianceReport struct {
|
||||
DeletedThirdPartyComplianceReportID string `json:"deletedThirdPartyComplianceReportId"`
|
||||
} `json:"deleteThirdPartyComplianceReport"`
|
||||
}
|
||||
|
||||
err = owner.Execute(
|
||||
@@ -241,5 +241,5 @@ func TestVendorComplianceReport_Delete(t *testing.T) {
|
||||
&deleteResult,
|
||||
)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, reportID, deleteResult.DeleteVendorComplianceReport.DeletedVendorComplianceReportID)
|
||||
assert.Equal(t, reportID, deleteResult.DeleteThirdPartyComplianceReport.DeletedThirdPartyComplianceReportID)
|
||||
}
|
||||
@@ -25,17 +25,17 @@ import (
|
||||
"go.probo.inc/probo/e2e/internal/testutil"
|
||||
)
|
||||
|
||||
func TestVendorContact_Create(t *testing.T) {
|
||||
func TestThirdPartyContact_Create(t *testing.T) {
|
||||
t.Parallel()
|
||||
owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
|
||||
// Create a vendor first
|
||||
vendorID := factory.NewVendor(owner).WithName("Contact Test Vendor").Create()
|
||||
// Create a thirdParty first
|
||||
thirdPartyID := factory.NewThirdParty(owner).WithName("Contact Test ThirdParty").Create()
|
||||
|
||||
query := `
|
||||
mutation CreateVendorContact($input: CreateVendorContactInput!) {
|
||||
createVendorContact(input: $input) {
|
||||
vendorContactEdge {
|
||||
mutation CreateThirdPartyContact($input: CreateThirdPartyContactInput!) {
|
||||
createThirdPartyContact(input: $input) {
|
||||
thirdPartyContactEdge {
|
||||
node {
|
||||
id
|
||||
fullName
|
||||
@@ -49,8 +49,8 @@ func TestVendorContact_Create(t *testing.T) {
|
||||
`
|
||||
|
||||
var result struct {
|
||||
CreateVendorContact struct {
|
||||
VendorContactEdge struct {
|
||||
CreateThirdPartyContact struct {
|
||||
ThirdPartyContactEdge struct {
|
||||
Node struct {
|
||||
ID string `json:"id"`
|
||||
FullName string `json:"fullName"`
|
||||
@@ -58,39 +58,39 @@ func TestVendorContact_Create(t *testing.T) {
|
||||
Phone string `json:"phone"`
|
||||
Role string `json:"role"`
|
||||
} `json:"node"`
|
||||
} `json:"vendorContactEdge"`
|
||||
} `json:"createVendorContact"`
|
||||
} `json:"thirdPartyContactEdge"`
|
||||
} `json:"createThirdPartyContact"`
|
||||
}
|
||||
|
||||
err := owner.Execute(query, map[string]any{
|
||||
"input": map[string]any{
|
||||
"vendorId": vendorID,
|
||||
"fullName": "John Doe",
|
||||
"email": fmt.Sprintf("john.doe.%d@vendor.com", time.Now().UnixNano()),
|
||||
"phone": "+1-555-123-4567",
|
||||
"role": "Account Manager",
|
||||
"thirdPartyId": thirdPartyID,
|
||||
"fullName": "John Doe",
|
||||
"email": fmt.Sprintf("john.doe.%d@thirdParty.com", time.Now().UnixNano()),
|
||||
"phone": "+1-555-123-4567",
|
||||
"role": "Account Manager",
|
||||
},
|
||||
}, &result)
|
||||
require.NoError(t, err)
|
||||
|
||||
contact := result.CreateVendorContact.VendorContactEdge.Node
|
||||
contact := result.CreateThirdPartyContact.ThirdPartyContactEdge.Node
|
||||
assert.NotEmpty(t, contact.ID)
|
||||
assert.Equal(t, "John Doe", contact.FullName)
|
||||
assert.Equal(t, "+1-555-123-4567", contact.Phone)
|
||||
assert.Equal(t, "Account Manager", contact.Role)
|
||||
}
|
||||
|
||||
func TestVendorContact_Update(t *testing.T) {
|
||||
func TestThirdPartyContact_Update(t *testing.T) {
|
||||
t.Parallel()
|
||||
owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
|
||||
// Create a vendor and contact
|
||||
vendorID := factory.NewVendor(owner).WithName("Update Contact Vendor").Create()
|
||||
// Create a thirdParty and contact
|
||||
thirdPartyID := factory.NewThirdParty(owner).WithName("Update Contact ThirdParty").Create()
|
||||
|
||||
createQuery := `
|
||||
mutation CreateVendorContact($input: CreateVendorContactInput!) {
|
||||
createVendorContact(input: $input) {
|
||||
vendorContactEdge {
|
||||
mutation CreateThirdPartyContact($input: CreateThirdPartyContactInput!) {
|
||||
createThirdPartyContact(input: $input) {
|
||||
thirdPartyContactEdge {
|
||||
node {
|
||||
id
|
||||
}
|
||||
@@ -100,30 +100,30 @@ func TestVendorContact_Update(t *testing.T) {
|
||||
`
|
||||
|
||||
var createResult struct {
|
||||
CreateVendorContact struct {
|
||||
VendorContactEdge struct {
|
||||
CreateThirdPartyContact struct {
|
||||
ThirdPartyContactEdge struct {
|
||||
Node struct {
|
||||
ID string `json:"id"`
|
||||
} `json:"node"`
|
||||
} `json:"vendorContactEdge"`
|
||||
} `json:"createVendorContact"`
|
||||
} `json:"thirdPartyContactEdge"`
|
||||
} `json:"createThirdPartyContact"`
|
||||
}
|
||||
|
||||
err := owner.Execute(createQuery, map[string]any{
|
||||
"input": map[string]any{
|
||||
"vendorId": vendorID,
|
||||
"fullName": "Initial Name",
|
||||
"email": fmt.Sprintf("initial.%d@vendor.com", time.Now().UnixNano()),
|
||||
"thirdPartyId": thirdPartyID,
|
||||
"fullName": "Initial Name",
|
||||
"email": fmt.Sprintf("initial.%d@thirdParty.com", time.Now().UnixNano()),
|
||||
},
|
||||
}, &createResult)
|
||||
require.NoError(t, err)
|
||||
|
||||
contactID := createResult.CreateVendorContact.VendorContactEdge.Node.ID
|
||||
contactID := createResult.CreateThirdPartyContact.ThirdPartyContactEdge.Node.ID
|
||||
|
||||
query := `
|
||||
mutation UpdateVendorContact($input: UpdateVendorContactInput!) {
|
||||
updateVendorContact(input: $input) {
|
||||
vendorContact {
|
||||
mutation UpdateThirdPartyContact($input: UpdateThirdPartyContactInput!) {
|
||||
updateThirdPartyContact(input: $input) {
|
||||
thirdPartyContact {
|
||||
id
|
||||
fullName
|
||||
phone
|
||||
@@ -134,14 +134,14 @@ func TestVendorContact_Update(t *testing.T) {
|
||||
`
|
||||
|
||||
var result struct {
|
||||
UpdateVendorContact struct {
|
||||
VendorContact struct {
|
||||
UpdateThirdPartyContact struct {
|
||||
ThirdPartyContact struct {
|
||||
ID string `json:"id"`
|
||||
FullName string `json:"fullName"`
|
||||
Phone string `json:"phone"`
|
||||
Role string `json:"role"`
|
||||
} `json:"vendorContact"`
|
||||
} `json:"updateVendorContact"`
|
||||
} `json:"thirdPartyContact"`
|
||||
} `json:"updateThirdPartyContact"`
|
||||
}
|
||||
|
||||
err = owner.Execute(query, map[string]any{
|
||||
@@ -154,23 +154,23 @@ func TestVendorContact_Update(t *testing.T) {
|
||||
}, &result)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, contactID, result.UpdateVendorContact.VendorContact.ID)
|
||||
assert.Equal(t, "Updated Name", result.UpdateVendorContact.VendorContact.FullName)
|
||||
assert.Equal(t, "+1-555-999-8888", result.UpdateVendorContact.VendorContact.Phone)
|
||||
assert.Equal(t, "Senior Account Manager", result.UpdateVendorContact.VendorContact.Role)
|
||||
assert.Equal(t, contactID, result.UpdateThirdPartyContact.ThirdPartyContact.ID)
|
||||
assert.Equal(t, "Updated Name", result.UpdateThirdPartyContact.ThirdPartyContact.FullName)
|
||||
assert.Equal(t, "+1-555-999-8888", result.UpdateThirdPartyContact.ThirdPartyContact.Phone)
|
||||
assert.Equal(t, "Senior Account Manager", result.UpdateThirdPartyContact.ThirdPartyContact.Role)
|
||||
}
|
||||
|
||||
func TestVendorContact_Delete(t *testing.T) {
|
||||
func TestThirdPartyContact_Delete(t *testing.T) {
|
||||
t.Parallel()
|
||||
owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
|
||||
vendorID := factory.NewVendor(owner).WithName("Delete Contact Vendor").Create()
|
||||
thirdPartyID := factory.NewThirdParty(owner).WithName("Delete Contact ThirdParty").Create()
|
||||
|
||||
// Create a contact to delete
|
||||
createQuery := `
|
||||
mutation CreateVendorContact($input: CreateVendorContactInput!) {
|
||||
createVendorContact(input: $input) {
|
||||
vendorContactEdge {
|
||||
mutation CreateThirdPartyContact($input: CreateThirdPartyContactInput!) {
|
||||
createThirdPartyContact(input: $input) {
|
||||
thirdPartyContactEdge {
|
||||
node {
|
||||
id
|
||||
}
|
||||
@@ -180,61 +180,61 @@ func TestVendorContact_Delete(t *testing.T) {
|
||||
`
|
||||
|
||||
var createResult struct {
|
||||
CreateVendorContact struct {
|
||||
VendorContactEdge struct {
|
||||
CreateThirdPartyContact struct {
|
||||
ThirdPartyContactEdge struct {
|
||||
Node struct {
|
||||
ID string `json:"id"`
|
||||
} `json:"node"`
|
||||
} `json:"vendorContactEdge"`
|
||||
} `json:"createVendorContact"`
|
||||
} `json:"thirdPartyContactEdge"`
|
||||
} `json:"createThirdPartyContact"`
|
||||
}
|
||||
|
||||
err := owner.Execute(createQuery, map[string]any{
|
||||
"input": map[string]any{
|
||||
"vendorId": vendorID,
|
||||
"fullName": fmt.Sprintf("Contact to Delete %d", time.Now().UnixNano()),
|
||||
"email": fmt.Sprintf("delete.%d@vendor.com", time.Now().UnixNano()),
|
||||
"thirdPartyId": thirdPartyID,
|
||||
"fullName": fmt.Sprintf("Contact to Delete %d", time.Now().UnixNano()),
|
||||
"email": fmt.Sprintf("delete.%d@thirdParty.com", time.Now().UnixNano()),
|
||||
},
|
||||
}, &createResult)
|
||||
require.NoError(t, err)
|
||||
|
||||
contactID := createResult.CreateVendorContact.VendorContactEdge.Node.ID
|
||||
contactID := createResult.CreateThirdPartyContact.ThirdPartyContactEdge.Node.ID
|
||||
|
||||
deleteQuery := `
|
||||
mutation DeleteVendorContact($input: DeleteVendorContactInput!) {
|
||||
deleteVendorContact(input: $input) {
|
||||
deletedVendorContactId
|
||||
mutation DeleteThirdPartyContact($input: DeleteThirdPartyContactInput!) {
|
||||
deleteThirdPartyContact(input: $input) {
|
||||
deletedThirdPartyContactId
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
var result struct {
|
||||
DeleteVendorContact struct {
|
||||
DeletedVendorContactID string `json:"deletedVendorContactId"`
|
||||
} `json:"deleteVendorContact"`
|
||||
DeleteThirdPartyContact struct {
|
||||
DeletedThirdPartyContactID string `json:"deletedThirdPartyContactId"`
|
||||
} `json:"deleteThirdPartyContact"`
|
||||
}
|
||||
|
||||
err = owner.Execute(deleteQuery, map[string]any{
|
||||
"input": map[string]any{
|
||||
"vendorContactId": contactID,
|
||||
"thirdPartyContactId": contactID,
|
||||
},
|
||||
}, &result)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, contactID, result.DeleteVendorContact.DeletedVendorContactID)
|
||||
assert.Equal(t, contactID, result.DeleteThirdPartyContact.DeletedThirdPartyContactID)
|
||||
}
|
||||
|
||||
func TestVendorContact_List(t *testing.T) {
|
||||
func TestThirdPartyContact_List(t *testing.T) {
|
||||
t.Parallel()
|
||||
owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
|
||||
vendorID := factory.NewVendor(owner).WithName("List Contacts Vendor").Create()
|
||||
thirdPartyID := factory.NewThirdParty(owner).WithName("List Contacts ThirdParty").Create()
|
||||
|
||||
// Create multiple contacts
|
||||
for i := range 3 {
|
||||
query := `
|
||||
mutation CreateVendorContact($input: CreateVendorContactInput!) {
|
||||
createVendorContact(input: $input) {
|
||||
vendorContactEdge {
|
||||
mutation CreateThirdPartyContact($input: CreateThirdPartyContactInput!) {
|
||||
createThirdPartyContact(input: $input) {
|
||||
thirdPartyContactEdge {
|
||||
node {
|
||||
id
|
||||
}
|
||||
@@ -245,18 +245,18 @@ func TestVendorContact_List(t *testing.T) {
|
||||
|
||||
_, err := owner.Do(query, map[string]any{
|
||||
"input": map[string]any{
|
||||
"vendorId": vendorID,
|
||||
"fullName": fmt.Sprintf("Contact %d", i),
|
||||
"email": fmt.Sprintf("contact.%d.%d@vendor.com", i, time.Now().UnixNano()),
|
||||
"thirdPartyId": thirdPartyID,
|
||||
"fullName": fmt.Sprintf("Contact %d", i),
|
||||
"email": fmt.Sprintf("contact.%d.%d@thirdParty.com", i, time.Now().UnixNano()),
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
query := `
|
||||
query GetVendorContacts($id: ID!) {
|
||||
query GetThirdPartyContacts($id: ID!) {
|
||||
node(id: $id) {
|
||||
... on Vendor {
|
||||
... on ThirdParty {
|
||||
contacts(first: 10) {
|
||||
edges {
|
||||
node {
|
||||
@@ -286,7 +286,7 @@ func TestVendorContact_List(t *testing.T) {
|
||||
}
|
||||
|
||||
err := owner.Execute(query, map[string]any{
|
||||
"id": vendorID,
|
||||
"id": thirdPartyID,
|
||||
}, &result)
|
||||
require.NoError(t, err)
|
||||
assert.GreaterOrEqual(t, len(result.Node.Contacts.Edges), 3)
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
"go.probo.inc/probo/e2e/internal/testutil"
|
||||
)
|
||||
|
||||
func TestVendor_PublishVendorList(t *testing.T) {
|
||||
func TestThirdParty_PublishThirdPartyList(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
t.Run(
|
||||
@@ -32,11 +32,11 @@ func TestVendor_PublishVendorList(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
factory.CreateVendor(owner, factory.Attrs{"name": "Test Vendor"})
|
||||
factory.CreateThirdParty(owner, factory.Attrs{"name": "Test ThirdParty"})
|
||||
|
||||
const query = `
|
||||
mutation($input: PublishVendorListInput!) {
|
||||
publishVendorList(input: $input) {
|
||||
mutation($input: PublishThirdPartyListInput!) {
|
||||
publishThirdPartyList(input: $input) {
|
||||
documentEdge {
|
||||
node {
|
||||
id
|
||||
@@ -60,7 +60,7 @@ func TestVendor_PublishVendorList(t *testing.T) {
|
||||
`
|
||||
|
||||
var result struct {
|
||||
PublishVendorList struct {
|
||||
PublishThirdPartyList struct {
|
||||
DocumentEdge struct {
|
||||
Node struct {
|
||||
ID string `json:"id"`
|
||||
@@ -79,7 +79,7 @@ func TestVendor_PublishVendorList(t *testing.T) {
|
||||
Content string `json:"content"`
|
||||
} `json:"node"`
|
||||
} `json:"documentVersionEdge"`
|
||||
} `json:"publishVendorList"`
|
||||
} `json:"publishThirdPartyList"`
|
||||
}
|
||||
|
||||
err := owner.Execute(
|
||||
@@ -94,12 +94,12 @@ func TestVendor_PublishVendorList(t *testing.T) {
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
doc := result.PublishVendorList.DocumentEdge.Node
|
||||
doc := result.PublishThirdPartyList.DocumentEdge.Node
|
||||
assert.NotEmpty(t, doc.ID)
|
||||
assert.Equal(t, "GENERATED", doc.WriteMode)
|
||||
assert.Equal(t, "ACTIVE", doc.Status)
|
||||
|
||||
ver := result.PublishVendorList.DocumentVersionEdge.Node
|
||||
ver := result.PublishThirdPartyList.DocumentVersionEdge.Node
|
||||
assert.NotEmpty(t, ver.ID)
|
||||
assert.Equal(t, "REGISTER", ver.DocumentType)
|
||||
assert.Equal(t, "PUBLISHED", ver.Status)
|
||||
@@ -117,8 +117,8 @@ func TestVendor_PublishVendorList(t *testing.T) {
|
||||
owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
|
||||
const query = `
|
||||
mutation($input: PublishVendorListInput!) {
|
||||
publishVendorList(input: $input) {
|
||||
mutation($input: PublishThirdPartyListInput!) {
|
||||
publishThirdPartyList(input: $input) {
|
||||
documentEdge {
|
||||
node { id writeMode }
|
||||
}
|
||||
@@ -130,7 +130,7 @@ func TestVendor_PublishVendorList(t *testing.T) {
|
||||
`
|
||||
|
||||
var result struct {
|
||||
PublishVendorList struct {
|
||||
PublishThirdPartyList struct {
|
||||
DocumentEdge struct {
|
||||
Node struct {
|
||||
ID string `json:"id"`
|
||||
@@ -144,7 +144,7 @@ func TestVendor_PublishVendorList(t *testing.T) {
|
||||
Major int `json:"major"`
|
||||
} `json:"node"`
|
||||
} `json:"documentVersionEdge"`
|
||||
} `json:"publishVendorList"`
|
||||
} `json:"publishThirdPartyList"`
|
||||
}
|
||||
|
||||
err := owner.Execute(
|
||||
@@ -160,11 +160,11 @@ func TestVendor_PublishVendorList(t *testing.T) {
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
doc := result.PublishVendorList.DocumentEdge.Node
|
||||
doc := result.PublishThirdPartyList.DocumentEdge.Node
|
||||
assert.NotEmpty(t, doc.ID)
|
||||
assert.Equal(t, "GENERATED", doc.WriteMode)
|
||||
|
||||
ver := result.PublishVendorList.DocumentVersionEdge.Node
|
||||
ver := result.PublishThirdPartyList.DocumentVersionEdge.Node
|
||||
assert.NotEmpty(t, ver.ID)
|
||||
assert.Equal(t, "PENDING_APPROVAL", ver.Status)
|
||||
},
|
||||
@@ -176,11 +176,11 @@ func TestVendor_PublishVendorList(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
factory.CreateVendor(owner, factory.Attrs{"name": "Reuse Vendor"})
|
||||
factory.CreateThirdParty(owner, factory.Attrs{"name": "Reuse ThirdParty"})
|
||||
|
||||
const query = `
|
||||
mutation($input: PublishVendorListInput!) {
|
||||
publishVendorList(input: $input) {
|
||||
mutation($input: PublishThirdPartyListInput!) {
|
||||
publishThirdPartyList(input: $input) {
|
||||
documentEdge { node { id } }
|
||||
documentVersionEdge { node { id major } }
|
||||
}
|
||||
@@ -188,7 +188,7 @@ func TestVendor_PublishVendorList(t *testing.T) {
|
||||
`
|
||||
|
||||
var r1, r2 struct {
|
||||
PublishVendorList struct {
|
||||
PublishThirdPartyList struct {
|
||||
DocumentEdge struct {
|
||||
Node struct {
|
||||
ID string `json:"id"`
|
||||
@@ -200,7 +200,7 @@ func TestVendor_PublishVendorList(t *testing.T) {
|
||||
Major int `json:"major"`
|
||||
} `json:"node"`
|
||||
} `json:"documentVersionEdge"`
|
||||
} `json:"publishVendorList"`
|
||||
} `json:"publishThirdPartyList"`
|
||||
}
|
||||
|
||||
input := map[string]any{
|
||||
@@ -217,26 +217,26 @@ func TestVendor_PublishVendorList(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t,
|
||||
r1.PublishVendorList.DocumentEdge.Node.ID,
|
||||
r2.PublishVendorList.DocumentEdge.Node.ID,
|
||||
r1.PublishThirdPartyList.DocumentEdge.Node.ID,
|
||||
r2.PublishThirdPartyList.DocumentEdge.Node.ID,
|
||||
"should reuse same document",
|
||||
)
|
||||
assert.Equal(t, 1, r1.PublishVendorList.DocumentVersionEdge.Node.Major)
|
||||
assert.Equal(t, 2, r2.PublishVendorList.DocumentVersionEdge.Node.Major)
|
||||
assert.Equal(t, 1, r1.PublishThirdPartyList.DocumentVersionEdge.Node.Major)
|
||||
assert.Equal(t, 2, r2.PublishThirdPartyList.DocumentVersionEdge.Node.Major)
|
||||
},
|
||||
)
|
||||
|
||||
t.Run(
|
||||
"organization vendorsDocument links to published document",
|
||||
"organization thirdPartiesDocument links to published document",
|
||||
func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
factory.CreateVendor(owner, factory.Attrs{"name": "Linked Vendor"})
|
||||
factory.CreateThirdParty(owner, factory.Attrs{"name": "Linked ThirdParty"})
|
||||
|
||||
const publishQuery = `
|
||||
mutation($input: PublishVendorListInput!) {
|
||||
publishVendorList(input: $input) {
|
||||
mutation($input: PublishThirdPartyListInput!) {
|
||||
publishThirdPartyList(input: $input) {
|
||||
documentEdge { node { id } }
|
||||
documentVersionEdge { node { id } }
|
||||
}
|
||||
@@ -244,7 +244,7 @@ func TestVendor_PublishVendorList(t *testing.T) {
|
||||
`
|
||||
|
||||
var publishResult struct {
|
||||
PublishVendorList struct {
|
||||
PublishThirdPartyList struct {
|
||||
DocumentEdge struct {
|
||||
Node struct {
|
||||
ID string `json:"id"`
|
||||
@@ -255,7 +255,7 @@ func TestVendor_PublishVendorList(t *testing.T) {
|
||||
ID string `json:"id"`
|
||||
} `json:"node"`
|
||||
} `json:"documentVersionEdge"`
|
||||
} `json:"publishVendorList"`
|
||||
} `json:"publishThirdPartyList"`
|
||||
}
|
||||
|
||||
err := owner.Execute(
|
||||
@@ -270,14 +270,14 @@ func TestVendor_PublishVendorList(t *testing.T) {
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
docID := publishResult.PublishVendorList.DocumentEdge.Node.ID
|
||||
docID := publishResult.PublishThirdPartyList.DocumentEdge.Node.ID
|
||||
|
||||
const orgQuery = `
|
||||
query($id: ID!) {
|
||||
node(id: $id) {
|
||||
... on Organization {
|
||||
id
|
||||
vendorsDocument { id }
|
||||
thirdPartiesDocument { id }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -285,10 +285,10 @@ func TestVendor_PublishVendorList(t *testing.T) {
|
||||
|
||||
var orgResult struct {
|
||||
Node struct {
|
||||
ID string `json:"id"`
|
||||
VendorsDocument *struct {
|
||||
ID string `json:"id"`
|
||||
ThirdPartiesDocument *struct {
|
||||
ID string `json:"id"`
|
||||
} `json:"vendorsDocument"`
|
||||
} `json:"thirdPartiesDocument"`
|
||||
} `json:"node"`
|
||||
}
|
||||
|
||||
@@ -298,23 +298,23 @@ func TestVendor_PublishVendorList(t *testing.T) {
|
||||
&orgResult,
|
||||
)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, orgResult.Node.VendorsDocument)
|
||||
assert.Equal(t, docID, orgResult.Node.VendorsDocument.ID)
|
||||
require.NotNil(t, orgResult.Node.ThirdPartiesDocument)
|
||||
assert.Equal(t, docID, orgResult.Node.ThirdPartiesDocument.ID)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func TestVendor_PublishVendorList_RBAC(t *testing.T) {
|
||||
func TestThirdParty_PublishThirdPartyList_RBAC(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
viewer := testutil.NewClientInOrg(t, testutil.RoleViewer, owner)
|
||||
|
||||
factory.CreateVendor(owner, factory.Attrs{"name": "RBAC Vendor"})
|
||||
factory.CreateThirdParty(owner, factory.Attrs{"name": "RBAC ThirdParty"})
|
||||
|
||||
const query = `
|
||||
mutation($input: PublishVendorListInput!) {
|
||||
publishVendorList(input: $input) {
|
||||
mutation($input: PublishThirdPartyListInput!) {
|
||||
publishThirdPartyList(input: $input) {
|
||||
documentEdge { node { id } }
|
||||
documentVersionEdge { node { id } }
|
||||
}
|
||||
@@ -322,7 +322,7 @@ func TestVendor_PublishVendorList_RBAC(t *testing.T) {
|
||||
`
|
||||
|
||||
t.Run(
|
||||
"viewer cannot publish vendor list",
|
||||
"viewer cannot publish thirdParty list",
|
||||
func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -22,15 +22,15 @@ import (
|
||||
"go.probo.inc/probo/e2e/internal/testutil"
|
||||
)
|
||||
|
||||
func TestVendorService_Create(t *testing.T) {
|
||||
func TestThirdPartyService_Create(t *testing.T) {
|
||||
t.Parallel()
|
||||
owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
|
||||
// Create a vendor first
|
||||
createVendorMutation := `
|
||||
mutation CreateVendor($input: CreateVendorInput!) {
|
||||
createVendor(input: $input) {
|
||||
vendorEdge {
|
||||
// Create a thirdParty first
|
||||
createThirdPartyMutation := `
|
||||
mutation CreateThirdParty($input: CreateThirdPartyInput!) {
|
||||
createThirdParty(input: $input) {
|
||||
thirdPartyEdge {
|
||||
node {
|
||||
id
|
||||
}
|
||||
@@ -39,129 +39,129 @@ func TestVendorService_Create(t *testing.T) {
|
||||
}
|
||||
`
|
||||
|
||||
var createVendorResult struct {
|
||||
CreateVendor struct {
|
||||
VendorEdge struct {
|
||||
var createThirdPartyResult struct {
|
||||
CreateThirdParty struct {
|
||||
ThirdPartyEdge struct {
|
||||
Node struct {
|
||||
ID string `json:"id"`
|
||||
} `json:"node"`
|
||||
} `json:"vendorEdge"`
|
||||
} `json:"createVendor"`
|
||||
} `json:"thirdPartyEdge"`
|
||||
} `json:"createThirdParty"`
|
||||
}
|
||||
|
||||
err := owner.Execute(createVendorMutation, map[string]any{
|
||||
err := owner.Execute(createThirdPartyMutation, map[string]any{
|
||||
"input": map[string]any{
|
||||
"organizationId": owner.GetOrganizationID().String(),
|
||||
"name": "AWS",
|
||||
"category": "CLOUD_PROVIDER",
|
||||
},
|
||||
}, &createVendorResult)
|
||||
}, &createThirdPartyResult)
|
||||
require.NoError(t, err)
|
||||
|
||||
vendorID := createVendorResult.CreateVendor.VendorEdge.Node.ID
|
||||
thirdPartyID := createThirdPartyResult.CreateThirdParty.ThirdPartyEdge.Node.ID
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
role testutil.TestRole
|
||||
variables func() map[string]any
|
||||
check func(t *testing.T, err error, m *struct {
|
||||
CreateVendorService struct {
|
||||
VendorServiceEdge struct {
|
||||
CreateThirdPartyService struct {
|
||||
ThirdPartyServiceEdge struct {
|
||||
Node struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description *string `json:"description"`
|
||||
} `json:"node"`
|
||||
} `json:"vendorServiceEdge"`
|
||||
} `json:"createVendorService"`
|
||||
} `json:"thirdPartyServiceEdge"`
|
||||
} `json:"createThirdPartyService"`
|
||||
})
|
||||
}{
|
||||
{
|
||||
name: "Owner can create vendor service",
|
||||
name: "Owner can create thirdParty service",
|
||||
role: testutil.RoleOwner,
|
||||
variables: func() map[string]any {
|
||||
return map[string]any{
|
||||
"input": map[string]any{
|
||||
"vendorId": vendorID,
|
||||
"name": "Amazon S3",
|
||||
"description": "Simple Storage Service",
|
||||
"thirdPartyId": thirdPartyID,
|
||||
"name": "Amazon S3",
|
||||
"description": "Simple Storage Service",
|
||||
},
|
||||
}
|
||||
},
|
||||
check: func(t *testing.T, err error, m *struct {
|
||||
CreateVendorService struct {
|
||||
VendorServiceEdge struct {
|
||||
CreateThirdPartyService struct {
|
||||
ThirdPartyServiceEdge struct {
|
||||
Node struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description *string `json:"description"`
|
||||
} `json:"node"`
|
||||
} `json:"vendorServiceEdge"`
|
||||
} `json:"createVendorService"`
|
||||
} `json:"thirdPartyServiceEdge"`
|
||||
} `json:"createThirdPartyService"`
|
||||
}) {
|
||||
require.NoError(t, err)
|
||||
assert.NotEmpty(t, m.CreateVendorService.VendorServiceEdge.Node.ID)
|
||||
assert.Equal(t, "Amazon S3", m.CreateVendorService.VendorServiceEdge.Node.Name)
|
||||
assert.Equal(t, "Simple Storage Service", *m.CreateVendorService.VendorServiceEdge.Node.Description)
|
||||
assert.NotEmpty(t, m.CreateThirdPartyService.ThirdPartyServiceEdge.Node.ID)
|
||||
assert.Equal(t, "Amazon S3", m.CreateThirdPartyService.ThirdPartyServiceEdge.Node.Name)
|
||||
assert.Equal(t, "Simple Storage Service", *m.CreateThirdPartyService.ThirdPartyServiceEdge.Node.Description)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Admin can create vendor service",
|
||||
name: "Admin can create thirdParty service",
|
||||
role: testutil.RoleAdmin,
|
||||
variables: func() map[string]any {
|
||||
return map[string]any{
|
||||
"input": map[string]any{
|
||||
"vendorId": vendorID,
|
||||
"name": "Amazon EC2",
|
||||
"description": "Elastic Compute Cloud",
|
||||
"thirdPartyId": thirdPartyID,
|
||||
"name": "Amazon EC2",
|
||||
"description": "Elastic Compute Cloud",
|
||||
},
|
||||
}
|
||||
},
|
||||
check: func(t *testing.T, err error, m *struct {
|
||||
CreateVendorService struct {
|
||||
VendorServiceEdge struct {
|
||||
CreateThirdPartyService struct {
|
||||
ThirdPartyServiceEdge struct {
|
||||
Node struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description *string `json:"description"`
|
||||
} `json:"node"`
|
||||
} `json:"vendorServiceEdge"`
|
||||
} `json:"createVendorService"`
|
||||
} `json:"thirdPartyServiceEdge"`
|
||||
} `json:"createThirdPartyService"`
|
||||
}) {
|
||||
require.NoError(t, err)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Viewer cannot create vendor service",
|
||||
name: "Viewer cannot create thirdParty service",
|
||||
role: testutil.RoleViewer,
|
||||
variables: func() map[string]any {
|
||||
return map[string]any{
|
||||
"input": map[string]any{
|
||||
"vendorId": vendorID,
|
||||
"name": "Should Fail",
|
||||
"thirdPartyId": thirdPartyID,
|
||||
"name": "Should Fail",
|
||||
},
|
||||
}
|
||||
},
|
||||
check: func(t *testing.T, err error, m *struct {
|
||||
CreateVendorService struct {
|
||||
VendorServiceEdge struct {
|
||||
CreateThirdPartyService struct {
|
||||
ThirdPartyServiceEdge struct {
|
||||
Node struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description *string `json:"description"`
|
||||
} `json:"node"`
|
||||
} `json:"vendorServiceEdge"`
|
||||
} `json:"createVendorService"`
|
||||
} `json:"thirdPartyServiceEdge"`
|
||||
} `json:"createThirdPartyService"`
|
||||
}) {
|
||||
require.Error(t, err, "Viewer should not be able to create vendor service")
|
||||
require.Error(t, err, "Viewer should not be able to create thirdParty service")
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
createVendorServiceMutation := `
|
||||
mutation CreateVendorService($input: CreateVendorServiceInput!) {
|
||||
createVendorService(input: $input) {
|
||||
vendorServiceEdge {
|
||||
createThirdPartyServiceMutation := `
|
||||
mutation CreateThirdPartyService($input: CreateThirdPartyServiceInput!) {
|
||||
createThirdPartyService(input: $input) {
|
||||
thirdPartyServiceEdge {
|
||||
node {
|
||||
id
|
||||
name
|
||||
@@ -182,32 +182,32 @@ func TestVendorService_Create(t *testing.T) {
|
||||
}
|
||||
|
||||
var m struct {
|
||||
CreateVendorService struct {
|
||||
VendorServiceEdge struct {
|
||||
CreateThirdPartyService struct {
|
||||
ThirdPartyServiceEdge struct {
|
||||
Node struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description *string `json:"description"`
|
||||
} `json:"node"`
|
||||
} `json:"vendorServiceEdge"`
|
||||
} `json:"createVendorService"`
|
||||
} `json:"thirdPartyServiceEdge"`
|
||||
} `json:"createThirdPartyService"`
|
||||
}
|
||||
|
||||
err := client.Execute(createVendorServiceMutation, tt.variables(), &m)
|
||||
err := client.Execute(createThirdPartyServiceMutation, tt.variables(), &m)
|
||||
tt.check(t, err, &m)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestVendorService_Update(t *testing.T) {
|
||||
func TestThirdPartyService_Update(t *testing.T) {
|
||||
t.Parallel()
|
||||
owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
|
||||
// Create a vendor first
|
||||
createVendorMutation := `
|
||||
mutation CreateVendor($input: CreateVendorInput!) {
|
||||
createVendor(input: $input) {
|
||||
vendorEdge {
|
||||
// Create a thirdParty first
|
||||
createThirdPartyMutation := `
|
||||
mutation CreateThirdParty($input: CreateThirdPartyInput!) {
|
||||
createThirdParty(input: $input) {
|
||||
thirdPartyEdge {
|
||||
node {
|
||||
id
|
||||
}
|
||||
@@ -216,32 +216,32 @@ func TestVendorService_Update(t *testing.T) {
|
||||
}
|
||||
`
|
||||
|
||||
var createVendorResult struct {
|
||||
CreateVendor struct {
|
||||
VendorEdge struct {
|
||||
var createThirdPartyResult struct {
|
||||
CreateThirdParty struct {
|
||||
ThirdPartyEdge struct {
|
||||
Node struct {
|
||||
ID string `json:"id"`
|
||||
} `json:"node"`
|
||||
} `json:"vendorEdge"`
|
||||
} `json:"createVendor"`
|
||||
} `json:"thirdPartyEdge"`
|
||||
} `json:"createThirdParty"`
|
||||
}
|
||||
|
||||
err := owner.Execute(createVendorMutation, map[string]any{
|
||||
err := owner.Execute(createThirdPartyMutation, map[string]any{
|
||||
"input": map[string]any{
|
||||
"organizationId": owner.GetOrganizationID().String(),
|
||||
"name": "Google Cloud",
|
||||
"category": "CLOUD_PROVIDER",
|
||||
},
|
||||
}, &createVendorResult)
|
||||
}, &createThirdPartyResult)
|
||||
require.NoError(t, err)
|
||||
|
||||
vendorID := createVendorResult.CreateVendor.VendorEdge.Node.ID
|
||||
thirdPartyID := createThirdPartyResult.CreateThirdParty.ThirdPartyEdge.Node.ID
|
||||
|
||||
// Create a vendor service
|
||||
// Create a thirdParty service
|
||||
createServiceMutation := `
|
||||
mutation CreateVendorService($input: CreateVendorServiceInput!) {
|
||||
createVendorService(input: $input) {
|
||||
vendorServiceEdge {
|
||||
mutation CreateThirdPartyService($input: CreateThirdPartyServiceInput!) {
|
||||
createThirdPartyService(input: $input) {
|
||||
thirdPartyServiceEdge {
|
||||
node {
|
||||
id
|
||||
}
|
||||
@@ -251,42 +251,42 @@ func TestVendorService_Update(t *testing.T) {
|
||||
`
|
||||
|
||||
var createServiceResult struct {
|
||||
CreateVendorService struct {
|
||||
VendorServiceEdge struct {
|
||||
CreateThirdPartyService struct {
|
||||
ThirdPartyServiceEdge struct {
|
||||
Node struct {
|
||||
ID string `json:"id"`
|
||||
} `json:"node"`
|
||||
} `json:"vendorServiceEdge"`
|
||||
} `json:"createVendorService"`
|
||||
} `json:"thirdPartyServiceEdge"`
|
||||
} `json:"createThirdPartyService"`
|
||||
}
|
||||
|
||||
err = owner.Execute(createServiceMutation, map[string]any{
|
||||
"input": map[string]any{
|
||||
"vendorId": vendorID,
|
||||
"name": "Cloud Storage",
|
||||
"description": "Initial description",
|
||||
"thirdPartyId": thirdPartyID,
|
||||
"name": "Cloud Storage",
|
||||
"description": "Initial description",
|
||||
},
|
||||
}, &createServiceResult)
|
||||
require.NoError(t, err)
|
||||
|
||||
serviceID := createServiceResult.CreateVendorService.VendorServiceEdge.Node.ID
|
||||
serviceID := createServiceResult.CreateThirdPartyService.ThirdPartyServiceEdge.Node.ID
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
role testutil.TestRole
|
||||
variables func() map[string]any
|
||||
check func(t *testing.T, err error, m *struct {
|
||||
UpdateVendorService struct {
|
||||
VendorService struct {
|
||||
UpdateThirdPartyService struct {
|
||||
ThirdPartyService struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description *string `json:"description"`
|
||||
} `json:"vendorService"`
|
||||
} `json:"updateVendorService"`
|
||||
} `json:"thirdPartyService"`
|
||||
} `json:"updateThirdPartyService"`
|
||||
})
|
||||
}{
|
||||
{
|
||||
name: "Owner can update vendor service",
|
||||
name: "Owner can update thirdParty service",
|
||||
role: testutil.RoleOwner,
|
||||
variables: func() map[string]any {
|
||||
return map[string]any{
|
||||
@@ -298,22 +298,22 @@ func TestVendorService_Update(t *testing.T) {
|
||||
}
|
||||
},
|
||||
check: func(t *testing.T, err error, m *struct {
|
||||
UpdateVendorService struct {
|
||||
VendorService struct {
|
||||
UpdateThirdPartyService struct {
|
||||
ThirdPartyService struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description *string `json:"description"`
|
||||
} `json:"vendorService"`
|
||||
} `json:"updateVendorService"`
|
||||
} `json:"thirdPartyService"`
|
||||
} `json:"updateThirdPartyService"`
|
||||
}) {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, serviceID, m.UpdateVendorService.VendorService.ID)
|
||||
assert.Equal(t, "Updated Cloud Storage", m.UpdateVendorService.VendorService.Name)
|
||||
assert.Equal(t, "Updated description", *m.UpdateVendorService.VendorService.Description)
|
||||
assert.Equal(t, serviceID, m.UpdateThirdPartyService.ThirdPartyService.ID)
|
||||
assert.Equal(t, "Updated Cloud Storage", m.UpdateThirdPartyService.ThirdPartyService.Name)
|
||||
assert.Equal(t, "Updated description", *m.UpdateThirdPartyService.ThirdPartyService.Description)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Admin can update vendor service",
|
||||
name: "Admin can update thirdParty service",
|
||||
role: testutil.RoleAdmin,
|
||||
variables: func() map[string]any {
|
||||
return map[string]any{
|
||||
@@ -324,19 +324,19 @@ func TestVendorService_Update(t *testing.T) {
|
||||
}
|
||||
},
|
||||
check: func(t *testing.T, err error, m *struct {
|
||||
UpdateVendorService struct {
|
||||
VendorService struct {
|
||||
UpdateThirdPartyService struct {
|
||||
ThirdPartyService struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description *string `json:"description"`
|
||||
} `json:"vendorService"`
|
||||
} `json:"updateVendorService"`
|
||||
} `json:"thirdPartyService"`
|
||||
} `json:"updateThirdPartyService"`
|
||||
}) {
|
||||
require.NoError(t, err)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Viewer cannot update vendor service",
|
||||
name: "Viewer cannot update thirdParty service",
|
||||
role: testutil.RoleViewer,
|
||||
variables: func() map[string]any {
|
||||
return map[string]any{
|
||||
@@ -347,23 +347,23 @@ func TestVendorService_Update(t *testing.T) {
|
||||
}
|
||||
},
|
||||
check: func(t *testing.T, err error, m *struct {
|
||||
UpdateVendorService struct {
|
||||
VendorService struct {
|
||||
UpdateThirdPartyService struct {
|
||||
ThirdPartyService struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description *string `json:"description"`
|
||||
} `json:"vendorService"`
|
||||
} `json:"updateVendorService"`
|
||||
} `json:"thirdPartyService"`
|
||||
} `json:"updateThirdPartyService"`
|
||||
}) {
|
||||
require.Error(t, err, "Viewer should not be able to update vendor service")
|
||||
require.Error(t, err, "Viewer should not be able to update thirdParty service")
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
updateVendorServiceMutation := `
|
||||
mutation UpdateVendorService($input: UpdateVendorServiceInput!) {
|
||||
updateVendorService(input: $input) {
|
||||
vendorService {
|
||||
updateThirdPartyServiceMutation := `
|
||||
mutation UpdateThirdPartyService($input: UpdateThirdPartyServiceInput!) {
|
||||
updateThirdPartyService(input: $input) {
|
||||
thirdPartyService {
|
||||
id
|
||||
name
|
||||
description
|
||||
@@ -382,30 +382,30 @@ func TestVendorService_Update(t *testing.T) {
|
||||
}
|
||||
|
||||
var m struct {
|
||||
UpdateVendorService struct {
|
||||
VendorService struct {
|
||||
UpdateThirdPartyService struct {
|
||||
ThirdPartyService struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description *string `json:"description"`
|
||||
} `json:"vendorService"`
|
||||
} `json:"updateVendorService"`
|
||||
} `json:"thirdPartyService"`
|
||||
} `json:"updateThirdPartyService"`
|
||||
}
|
||||
|
||||
err := client.Execute(updateVendorServiceMutation, tt.variables(), &m)
|
||||
err := client.Execute(updateThirdPartyServiceMutation, tt.variables(), &m)
|
||||
tt.check(t, err, &m)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestVendorService_Delete(t *testing.T) {
|
||||
func TestThirdPartyService_Delete(t *testing.T) {
|
||||
t.Parallel()
|
||||
owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
|
||||
// Create a vendor first
|
||||
createVendorMutation := `
|
||||
mutation CreateVendor($input: CreateVendorInput!) {
|
||||
createVendor(input: $input) {
|
||||
vendorEdge {
|
||||
// Create a thirdParty first
|
||||
createThirdPartyMutation := `
|
||||
mutation CreateThirdParty($input: CreateThirdPartyInput!) {
|
||||
createThirdParty(input: $input) {
|
||||
thirdPartyEdge {
|
||||
node {
|
||||
id
|
||||
}
|
||||
@@ -414,32 +414,32 @@ func TestVendorService_Delete(t *testing.T) {
|
||||
}
|
||||
`
|
||||
|
||||
var createVendorResult struct {
|
||||
CreateVendor struct {
|
||||
VendorEdge struct {
|
||||
var createThirdPartyResult struct {
|
||||
CreateThirdParty struct {
|
||||
ThirdPartyEdge struct {
|
||||
Node struct {
|
||||
ID string `json:"id"`
|
||||
} `json:"node"`
|
||||
} `json:"vendorEdge"`
|
||||
} `json:"createVendor"`
|
||||
} `json:"thirdPartyEdge"`
|
||||
} `json:"createThirdParty"`
|
||||
}
|
||||
|
||||
err := owner.Execute(createVendorMutation, map[string]any{
|
||||
err := owner.Execute(createThirdPartyMutation, map[string]any{
|
||||
"input": map[string]any{
|
||||
"organizationId": owner.GetOrganizationID().String(),
|
||||
"name": "Azure",
|
||||
"category": "CLOUD_PROVIDER",
|
||||
},
|
||||
}, &createVendorResult)
|
||||
}, &createThirdPartyResult)
|
||||
require.NoError(t, err)
|
||||
|
||||
vendorID := createVendorResult.CreateVendor.VendorEdge.Node.ID
|
||||
thirdPartyID := createThirdPartyResult.CreateThirdParty.ThirdPartyEdge.Node.ID
|
||||
|
||||
createService := func() string {
|
||||
createServiceMutation := `
|
||||
mutation CreateVendorService($input: CreateVendorServiceInput!) {
|
||||
createVendorService(input: $input) {
|
||||
vendorServiceEdge {
|
||||
mutation CreateThirdPartyService($input: CreateThirdPartyServiceInput!) {
|
||||
createThirdPartyService(input: $input) {
|
||||
thirdPartyServiceEdge {
|
||||
node {
|
||||
id
|
||||
}
|
||||
@@ -449,24 +449,24 @@ func TestVendorService_Delete(t *testing.T) {
|
||||
`
|
||||
|
||||
var m struct {
|
||||
CreateVendorService struct {
|
||||
VendorServiceEdge struct {
|
||||
CreateThirdPartyService struct {
|
||||
ThirdPartyServiceEdge struct {
|
||||
Node struct {
|
||||
ID string `json:"id"`
|
||||
} `json:"node"`
|
||||
} `json:"vendorServiceEdge"`
|
||||
} `json:"createVendorService"`
|
||||
} `json:"thirdPartyServiceEdge"`
|
||||
} `json:"createThirdPartyService"`
|
||||
}
|
||||
|
||||
err := owner.Execute(createServiceMutation, map[string]any{
|
||||
"input": map[string]any{
|
||||
"vendorId": vendorID,
|
||||
"name": "Service to delete",
|
||||
"thirdPartyId": thirdPartyID,
|
||||
"name": "Service to delete",
|
||||
},
|
||||
}, &m)
|
||||
require.NoError(t, err)
|
||||
|
||||
return m.CreateVendorService.VendorServiceEdge.Node.ID
|
||||
return m.CreateThirdPartyService.ThirdPartyServiceEdge.Node.ID
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
@@ -474,73 +474,73 @@ func TestVendorService_Delete(t *testing.T) {
|
||||
role testutil.TestRole
|
||||
variables func(serviceID string) map[string]any
|
||||
check func(t *testing.T, err error, serviceID string, m *struct {
|
||||
DeleteVendorService struct {
|
||||
DeletedVendorServiceID string `json:"deletedVendorServiceId"`
|
||||
} `json:"deleteVendorService"`
|
||||
DeleteThirdPartyService struct {
|
||||
DeletedThirdPartyServiceID string `json:"deletedThirdPartyServiceId"`
|
||||
} `json:"deleteThirdPartyService"`
|
||||
})
|
||||
}{
|
||||
{
|
||||
name: "Viewer cannot delete vendor service",
|
||||
name: "Viewer cannot delete thirdParty service",
|
||||
role: testutil.RoleViewer,
|
||||
variables: func(serviceID string) map[string]any {
|
||||
return map[string]any{
|
||||
"input": map[string]any{
|
||||
"vendorServiceId": serviceID,
|
||||
"thirdPartyServiceId": serviceID,
|
||||
},
|
||||
}
|
||||
},
|
||||
check: func(t *testing.T, err error, serviceID string, m *struct {
|
||||
DeleteVendorService struct {
|
||||
DeletedVendorServiceID string `json:"deletedVendorServiceId"`
|
||||
} `json:"deleteVendorService"`
|
||||
DeleteThirdPartyService struct {
|
||||
DeletedThirdPartyServiceID string `json:"deletedThirdPartyServiceId"`
|
||||
} `json:"deleteThirdPartyService"`
|
||||
}) {
|
||||
require.Error(t, err, "Viewer should not be able to delete vendor service")
|
||||
require.Error(t, err, "Viewer should not be able to delete thirdParty service")
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Admin can delete vendor service",
|
||||
name: "Admin can delete thirdParty service",
|
||||
role: testutil.RoleAdmin,
|
||||
variables: func(serviceID string) map[string]any {
|
||||
return map[string]any{
|
||||
"input": map[string]any{
|
||||
"vendorServiceId": serviceID,
|
||||
"thirdPartyServiceId": serviceID,
|
||||
},
|
||||
}
|
||||
},
|
||||
check: func(t *testing.T, err error, serviceID string, m *struct {
|
||||
DeleteVendorService struct {
|
||||
DeletedVendorServiceID string `json:"deletedVendorServiceId"`
|
||||
} `json:"deleteVendorService"`
|
||||
DeleteThirdPartyService struct {
|
||||
DeletedThirdPartyServiceID string `json:"deletedThirdPartyServiceId"`
|
||||
} `json:"deleteThirdPartyService"`
|
||||
}) {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, serviceID, m.DeleteVendorService.DeletedVendorServiceID)
|
||||
assert.Equal(t, serviceID, m.DeleteThirdPartyService.DeletedThirdPartyServiceID)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Owner can delete vendor service",
|
||||
name: "Owner can delete thirdParty service",
|
||||
role: testutil.RoleOwner,
|
||||
variables: func(serviceID string) map[string]any {
|
||||
return map[string]any{
|
||||
"input": map[string]any{
|
||||
"vendorServiceId": serviceID,
|
||||
"thirdPartyServiceId": serviceID,
|
||||
},
|
||||
}
|
||||
},
|
||||
check: func(t *testing.T, err error, serviceID string, m *struct {
|
||||
DeleteVendorService struct {
|
||||
DeletedVendorServiceID string `json:"deletedVendorServiceId"`
|
||||
} `json:"deleteVendorService"`
|
||||
DeleteThirdPartyService struct {
|
||||
DeletedThirdPartyServiceID string `json:"deletedThirdPartyServiceId"`
|
||||
} `json:"deleteThirdPartyService"`
|
||||
}) {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, serviceID, m.DeleteVendorService.DeletedVendorServiceID)
|
||||
assert.Equal(t, serviceID, m.DeleteThirdPartyService.DeletedThirdPartyServiceID)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
deleteVendorServiceMutation := `
|
||||
mutation DeleteVendorService($input: DeleteVendorServiceInput!) {
|
||||
deleteVendorService(input: $input) {
|
||||
deletedVendorServiceId
|
||||
deleteThirdPartyServiceMutation := `
|
||||
mutation DeleteThirdPartyService($input: DeleteThirdPartyServiceInput!) {
|
||||
deleteThirdPartyService(input: $input) {
|
||||
deletedThirdPartyServiceId
|
||||
}
|
||||
}
|
||||
`
|
||||
@@ -557,26 +557,26 @@ func TestVendorService_Delete(t *testing.T) {
|
||||
}
|
||||
|
||||
var m struct {
|
||||
DeleteVendorService struct {
|
||||
DeletedVendorServiceID string `json:"deletedVendorServiceId"`
|
||||
} `json:"deleteVendorService"`
|
||||
DeleteThirdPartyService struct {
|
||||
DeletedThirdPartyServiceID string `json:"deletedThirdPartyServiceId"`
|
||||
} `json:"deleteThirdPartyService"`
|
||||
}
|
||||
|
||||
err := client.Execute(deleteVendorServiceMutation, tt.variables(serviceID), &m)
|
||||
err := client.Execute(deleteThirdPartyServiceMutation, tt.variables(serviceID), &m)
|
||||
tt.check(t, err, serviceID, &m)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestVendorService_List(t *testing.T) {
|
||||
func TestThirdPartyService_List(t *testing.T) {
|
||||
t.Parallel()
|
||||
owner := testutil.NewClient(t, testutil.RoleOwner)
|
||||
|
||||
// Create a vendor first
|
||||
createVendorMutation := `
|
||||
mutation CreateVendor($input: CreateVendorInput!) {
|
||||
createVendor(input: $input) {
|
||||
vendorEdge {
|
||||
// Create a thirdParty first
|
||||
createThirdPartyMutation := `
|
||||
mutation CreateThirdParty($input: CreateThirdPartyInput!) {
|
||||
createThirdParty(input: $input) {
|
||||
thirdPartyEdge {
|
||||
node {
|
||||
id
|
||||
}
|
||||
@@ -585,32 +585,32 @@ func TestVendorService_List(t *testing.T) {
|
||||
}
|
||||
`
|
||||
|
||||
var createVendorResult struct {
|
||||
CreateVendor struct {
|
||||
VendorEdge struct {
|
||||
var createThirdPartyResult struct {
|
||||
CreateThirdParty struct {
|
||||
ThirdPartyEdge struct {
|
||||
Node struct {
|
||||
ID string `json:"id"`
|
||||
} `json:"node"`
|
||||
} `json:"vendorEdge"`
|
||||
} `json:"createVendor"`
|
||||
} `json:"thirdPartyEdge"`
|
||||
} `json:"createThirdParty"`
|
||||
}
|
||||
|
||||
err := owner.Execute(createVendorMutation, map[string]any{
|
||||
err := owner.Execute(createThirdPartyMutation, map[string]any{
|
||||
"input": map[string]any{
|
||||
"organizationId": owner.GetOrganizationID().String(),
|
||||
"name": "Vendor for Services",
|
||||
"name": "ThirdParty for Services",
|
||||
"category": "CLOUD_PROVIDER",
|
||||
},
|
||||
}, &createVendorResult)
|
||||
}, &createThirdPartyResult)
|
||||
require.NoError(t, err)
|
||||
|
||||
vendorID := createVendorResult.CreateVendor.VendorEdge.Node.ID
|
||||
thirdPartyID := createThirdPartyResult.CreateThirdParty.ThirdPartyEdge.Node.ID
|
||||
|
||||
// Create multiple services
|
||||
createServiceMutation := `
|
||||
mutation CreateVendorService($input: CreateVendorServiceInput!) {
|
||||
createVendorService(input: $input) {
|
||||
vendorServiceEdge {
|
||||
mutation CreateThirdPartyService($input: CreateThirdPartyServiceInput!) {
|
||||
createThirdPartyService(input: $input) {
|
||||
thirdPartyServiceEdge {
|
||||
node {
|
||||
id
|
||||
}
|
||||
@@ -622,19 +622,19 @@ func TestVendorService_List(t *testing.T) {
|
||||
services := []string{"Service A", "Service B", "Service C"}
|
||||
for _, name := range services {
|
||||
var m struct {
|
||||
CreateVendorService struct {
|
||||
VendorServiceEdge struct {
|
||||
CreateThirdPartyService struct {
|
||||
ThirdPartyServiceEdge struct {
|
||||
Node struct {
|
||||
ID string `json:"id"`
|
||||
} `json:"node"`
|
||||
} `json:"vendorServiceEdge"`
|
||||
} `json:"createVendorService"`
|
||||
} `json:"thirdPartyServiceEdge"`
|
||||
} `json:"createThirdPartyService"`
|
||||
}
|
||||
|
||||
err := owner.Execute(createServiceMutation, map[string]any{
|
||||
"input": map[string]any{
|
||||
"vendorId": vendorID,
|
||||
"name": name,
|
||||
"thirdPartyId": thirdPartyID,
|
||||
"name": name,
|
||||
},
|
||||
}, &m)
|
||||
require.NoError(t, err)
|
||||
@@ -659,11 +659,11 @@ func TestVendorService_List(t *testing.T) {
|
||||
})
|
||||
}{
|
||||
{
|
||||
name: "Owner can list vendor services",
|
||||
name: "Owner can list thirdParty services",
|
||||
role: testutil.RoleOwner,
|
||||
variables: func() map[string]any {
|
||||
return map[string]any{
|
||||
"id": vendorID,
|
||||
"id": thirdPartyID,
|
||||
}
|
||||
},
|
||||
check: func(t *testing.T, err error, q *struct {
|
||||
@@ -684,11 +684,11 @@ func TestVendorService_List(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Viewer can list vendor services",
|
||||
name: "Viewer can list thirdParty services",
|
||||
role: testutil.RoleViewer,
|
||||
variables: func() map[string]any {
|
||||
return map[string]any{
|
||||
"id": vendorID,
|
||||
"id": thirdPartyID,
|
||||
}
|
||||
},
|
||||
check: func(t *testing.T, err error, q *struct {
|
||||
@@ -709,10 +709,10 @@ func TestVendorService_List(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
listVendorServicesQuery := `
|
||||
query ListVendorServices($id: ID!) {
|
||||
listThirdPartyServicesQuery := `
|
||||
query ListThirdPartyServices($id: ID!) {
|
||||
node(id: $id) {
|
||||
... on Vendor {
|
||||
... on ThirdParty {
|
||||
id
|
||||
services(first: 10) {
|
||||
edges {
|
||||
@@ -750,7 +750,7 @@ func TestVendorService_List(t *testing.T) {
|
||||
} `json:"node"`
|
||||
}
|
||||
|
||||
err := client.Execute(listVendorServicesQuery, tt.variables(), &q)
|
||||
err := client.Execute(listThirdPartyServicesQuery, tt.variables(), &q)
|
||||
tt.check(t, err, &q)
|
||||
})
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user