From 353848a251bf9c16f3bfdf750e5aad487edd241a Mon Sep 17 00:00:00 2001 From: Michal Krzyz Date: Wed, 23 Oct 2024 15:01:36 +0200 Subject: [PATCH] Final --- internal/api/graphql/graph/baseResolver/common.go | 2 +- internal/api/graphql/graph/model/models.go | 1 + .../graph/queryCollection/issue/listIssues.graphql | 3 +-- internal/e2e/common/issue.go | 2 +- internal/e2e/common/user.go | 1 + internal/e2e/metadata_test.go | 14 ++++++-------- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/internal/api/graphql/graph/baseResolver/common.go b/internal/api/graphql/graph/baseResolver/common.go index dddee8c9..ffb93495 100644 --- a/internal/api/graphql/graph/baseResolver/common.go +++ b/internal/api/graphql/graph/baseResolver/common.go @@ -98,6 +98,6 @@ func GetListOptions(requestedFields []string) *entity.ListOptions { return &entity.ListOptions{ ShowTotalCount: lo.Contains(requestedFields, "totalCount"), ShowPageInfo: lo.Contains(requestedFields, "pageInfo"), - IncludeAggregations: lo.Contains(requestedFields, "edges.node.metadata"), + IncludeAggregations: lo.Contains(requestedFields, "edges.node.issueMetadata"), } } diff --git a/internal/api/graphql/graph/model/models.go b/internal/api/graphql/graph/model/models.go index 617bbc6c..54691b59 100644 --- a/internal/api/graphql/graph/model/models.go +++ b/internal/api/graphql/graph/model/models.go @@ -177,6 +177,7 @@ func NewIssueWithAggregations(issue *entity.IssueResult) Issue { ID: fmt.Sprintf("%d", issue.Issue.Id), PrimaryName: &issue.Issue.PrimaryName, Type: &issueType, + Description: &issue.Issue.Description, LastModified: &lastModified, IssueMetadata: &issueMetadata, Metadata: getModelMetadata(issue.Issue.Metadata), diff --git a/internal/api/graphql/graph/queryCollection/issue/listIssues.graphql b/internal/api/graphql/graph/queryCollection/issue/listIssues.graphql index 734dd459..9ace4ac1 100644 --- a/internal/api/graphql/graph/queryCollection/issue/listIssues.graphql +++ b/internal/api/graphql/graph/queryCollection/issue/listIssues.graphql @@ -11,10 +11,9 @@ query ($filter: IssueFilter, $first: Int, $after: String) { edges { node { id - type primaryName + type description - lastModified metadata { created_at created_by diff --git a/internal/e2e/common/issue.go b/internal/e2e/common/issue.go index d5f7ff9f..8fc26276 100644 --- a/internal/e2e/common/issue.go +++ b/internal/e2e/common/issue.go @@ -31,7 +31,7 @@ func QueryCreateIssue(port string, issue Issue) *model.Issue { str := string(b) req := graphql.NewRequest(str) - req.Var("input", map[string]interface{}{ + req.Var("input", map[string]string{ "primaryName": issue.PrimaryName, "description": issue.Description, "type": issue.Type, diff --git a/internal/e2e/common/user.go b/internal/e2e/common/user.go index c5b8db6d..9c697476 100644 --- a/internal/e2e/common/user.go +++ b/internal/e2e/common/user.go @@ -20,6 +20,7 @@ import ( const NumberOfSystemUsers = 1 const SystemUserId = 1 +const EmptyUserId = -1 var SystemUserName = "systemuser" var SystemUserUniqueUserId = "S0000000" diff --git a/internal/e2e/metadata_test.go b/internal/e2e/metadata_test.go index ebd4ec4f..bb0d82a9 100644 --- a/internal/e2e/metadata_test.go +++ b/internal/e2e/metadata_test.go @@ -26,8 +26,8 @@ const ( ) var ( - testCreatedIssueType = entity.IssueTypeVulnerability.String() - testUpdatedIssueType = entity.IssueTypePolicyViolation.String() + testCreatedIssueType = entity.IssueTypeVulnerability.String() + testUpdatedIssueType = entity.IssueTypePolicyViolation.String() ) func createTestIssue(port string) string { @@ -35,7 +35,6 @@ func createTestIssue(port string) string { Expect(*issue.PrimaryName).To(Equal(testIssuePrimaryName)) Expect(*issue.Description).To(Equal(testCreatedIssueDescription)) Expect(issue.Type.String()).To(Equal(testCreatedIssueType)) - fmt.Println("AAAAAAAAAAAAAAAAAA ", *issue) return issue.ID } func updateTestIssue(port string, iid string) { @@ -48,7 +47,6 @@ func updateTestIssue(port string, iid string) { func getTestIssue(port string) model.Issue { issues := e2e_common.QueryGetIssue(port, testIssuePrimaryName) Expect(issues.TotalCount).To(Equal(1)) - fmt.Println("AAAAAAAAAAAAAAAAAA ", *issues.Edges[0].Node) return *issues.Edges[0].Node } @@ -81,13 +79,13 @@ var _ = Describe("Creating and updating entity via API", Label("e2e", "Entities" Expect(issue.Type.String()).To(Equal(testCreatedIssueType)) Expect(issue.Metadata).To(Not(BeNil())) - Expect(*issue.Metadata.CreatedBy).To(Equal(e2e_common.SystemUserId)) + Expect(*issue.Metadata.CreatedBy).To(Equal(fmt.Sprintf("%d", e2e_common.SystemUserId))) createdAt, err := time.Parse(dbDateLayout, *issue.Metadata.CreatedAt) Expect(err).Should(BeNil()) Expect(createdAt).Should(BeTemporally("~", time.Now().UTC(), 3*time.Second)) - Expect(*issue.Metadata.UpdatedBy).To(BeEmpty()) + Expect(*issue.Metadata.UpdatedBy).To(Equal(fmt.Sprintf("%d", e2e_common.EmptyUserId))) updatedAt, err := time.Parse(dbDateLayout, *issue.Metadata.UpdatedAt) Expect(err).Should(BeNil()) @@ -107,13 +105,13 @@ var _ = Describe("Creating and updating entity via API", Label("e2e", "Entities" Expect(issue.Type.String()).To(Equal(testUpdatedIssueType)) Expect(issue.Metadata).To(Not(BeNil())) - Expect(*issue.Metadata.CreatedBy).To(Equal(e2e_common.SystemUserId)) + Expect(*issue.Metadata.CreatedBy).To(Equal(fmt.Sprintf("%d", e2e_common.SystemUserId))) createdAt, err := time.Parse(dbDateLayout, *issue.Metadata.CreatedAt) Expect(err).Should(BeNil()) Expect(createdAt).Should(BeTemporally("~", time.Now().UTC(), 3*time.Second)) - Expect(*issue.Metadata.UpdatedBy).To(Equal(e2e_common.SystemUserId)) + Expect(*issue.Metadata.UpdatedBy).To(Equal(fmt.Sprintf("%d", e2e_common.SystemUserId))) updatedAt, err := time.Parse(dbDateLayout, *issue.Metadata.UpdatedAt) Expect(err).Should(BeNil())