-
Notifications
You must be signed in to change notification settings - Fork 3
lisa/feat/workflow-evidence-for-dashboards #411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gusfcarvalho
merged 18 commits into
main
from
lisa/feat/workflow-evidence-for-dashboards
Jun 1, 2026
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
d04b811
implement: workflow-evidence-for-dashboards
ccf-lisa[bot] 388e067
self-review: address pass 1 findings
ccf-lisa[bot] 057cc44
self-review: address pass 2 findings
ccf-lisa[bot] 6cee15c
self-review: address pass 3 findings
ccf-lisa[bot] 2e6dd40
fix: CI failures
ccf-lisa[bot] 6701082
fix: address review feedback
ccf-lisa[bot] 8e156a7
fix: address review feedback
ccf-lisa[bot] e5732eb
fix: address review feedback
ccf-lisa[bot] 4536d6e
fix: address review feedback
ccf-lisa[bot] af8b493
fix: address review feedback
ccf-lisa[bot] 37ef783
fix: address review feedback
ccf-lisa[bot] 2bfb76a
fix: address review feedback
ccf-lisa[bot] 125ed0d
fix: address review feedback
ccf-lisa[bot] 510ead2
fix: CI failures
ccf-lisa[bot] f271f36
fix: address review feedback
ccf-lisa[bot] 93cfe40
fix: address review feedback
ccf-lisa[bot] 52cac95
Merge branch 'main' into lisa/feat/workflow-evidence-for-dashboards
gusfcarvalho 38927e2
fix: address review feedback
ccf-lisa[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
internal/api/handler/oscal/profile_compliance_workflow_integration_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| //go:build integration | ||
|
|
||
| package oscal | ||
|
|
||
| import ( | ||
| "context" | ||
| "encoding/json" | ||
| "net/http" | ||
| "net/http/httptest" | ||
| "time" | ||
|
|
||
| "github.com/compliance-framework/api/internal/service/relational" | ||
| "github.com/compliance-framework/api/internal/service/relational/workflows" | ||
| workflowevidence "github.com/compliance-framework/api/internal/workflow" | ||
| "github.com/google/uuid" | ||
| "github.com/labstack/echo/v4" | ||
| "go.uber.org/zap" | ||
| ) | ||
|
|
||
| func (suite *ProfileIntegrationSuite) TestComplianceProgressIncludesWorkflowCompletionEvidence() { | ||
| suite.Require().NoError(suite.Migrator.Refresh()) | ||
| suite.Require().NoError(suite.DB.AutoMigrate( | ||
| &workflows.WorkflowDefinition{}, | ||
| &workflows.WorkflowInstance{}, | ||
| &workflows.RoleAssignment{}, | ||
| &workflows.WorkflowExecution{}, | ||
| &workflows.WorkflowStepDefinition{}, | ||
| &workflows.StepExecution{}, | ||
| &workflows.ControlRelationship{}, | ||
| )) | ||
|
|
||
| catalogID := uuid.New() | ||
| control := relational.Control{CatalogID: catalogID, ID: "ctrl-workflow", Title: "Workflow Control"} | ||
| suite.Require().NoError(suite.DB.Create(&control).Error) | ||
|
|
||
| profileID := uuid.New() | ||
| profile := relational.Profile{ | ||
| UUIDModel: relational.UUIDModel{ID: &profileID}, | ||
| Metadata: relational.Metadata{Title: "Workflow Profile"}, | ||
| } | ||
| suite.Require().NoError(suite.DB.Create(&profile).Error) | ||
| suite.Require().NoError(suite.DB.Model(&profile).Association("Controls").Append(&control)) | ||
|
|
||
| definition := workflows.WorkflowDefinition{ | ||
| Name: "Workflow Review", | ||
| Version: "1.0", | ||
| SuggestedCadence: string(workflows.CadenceWeekly), | ||
| } | ||
| suite.Require().NoError(suite.DB.Create(&definition).Error) | ||
|
|
||
| relationship := workflows.ControlRelationship{ | ||
| WorkflowDefinitionID: definition.ID, | ||
| ControlID: control.ID, | ||
| ControlSource: "Test Catalog", | ||
| CatalogID: catalogID.String(), | ||
| RelationshipType: "satisfies", | ||
| Strength: "primary", | ||
| IsActive: true, | ||
| } | ||
| suite.Require().NoError(suite.DB.Create(&relationship).Error) | ||
| suite.Require().NoError(workflows.NewFilterSyncService(suite.DB, zap.NewNop().Sugar()).SyncFilterForDefinition(*definition.ID)) | ||
|
|
||
| sspID := uuid.New() | ||
| instance := workflows.WorkflowInstance{ | ||
| WorkflowDefinitionID: definition.ID, | ||
| Name: "Workflow Instance", | ||
| Cadence: string(workflows.CadenceWeekly), | ||
| SystemSecurityPlanID: &sspID, | ||
| } | ||
| suite.Require().NoError(suite.DB.Create(&instance).Error) | ||
|
|
||
| startedAt := time.Now().Add(-time.Hour) | ||
| completedAt := time.Now() | ||
| execution := workflows.WorkflowExecution{ | ||
| WorkflowInstanceID: instance.ID, | ||
| Status: workflows.WorkflowStatusCompleted.String(), | ||
| TriggeredBy: "manual", | ||
| StartedAt: &startedAt, | ||
| CompletedAt: &completedAt, | ||
| } | ||
| suite.Require().NoError(suite.DB.Create(&execution).Error) | ||
| suite.Require().NoError(workflowevidence.NewEvidenceIntegration(suite.DB, zap.NewNop().Sugar()).AddExecutionCompletionEvidence(context.Background(), execution.ID)) | ||
|
|
||
| e := echo.New() | ||
| req := httptest.NewRequest(http.MethodGet, "/profiles/"+profileID.String()+"/compliance-progress", nil) | ||
| rec := httptest.NewRecorder() | ||
| ctx := e.NewContext(req, rec) | ||
| ctx.SetParamNames("id") | ||
| ctx.SetParamValues(profileID.String()) | ||
|
|
||
| suite.Require().NoError(NewProfileHandler(zap.NewNop().Sugar(), suite.DB).ComplianceProgress(ctx)) | ||
| suite.Require().Equal(http.StatusOK, rec.Code) | ||
|
|
||
| var response struct { | ||
| Data ProfileComplianceProgress `json:"data"` | ||
| } | ||
| suite.Require().NoError(json.Unmarshal(rec.Body.Bytes(), &response)) | ||
| suite.Require().Equal(1, response.Data.Summary.TotalControls) | ||
| suite.Require().Equal(1, response.Data.Summary.Satisfied) | ||
| suite.Require().Len(response.Data.Controls, 1) | ||
| suite.Require().Equal("satisfied", response.Data.Controls[0].ComputedStatus) | ||
|
|
||
| laterStartedAt := completedAt.Add(time.Hour) | ||
| nextExecution := workflows.WorkflowExecution{ | ||
| WorkflowInstanceID: instance.ID, | ||
| Status: workflows.WorkflowStatusPending.String(), | ||
| TriggeredBy: "manual", | ||
| StartedAt: &laterStartedAt, | ||
| } | ||
| suite.Require().NoError(suite.DB.Create(&nextExecution).Error) | ||
| suite.Require().NoError(workflowevidence.NewEvidenceIntegration(suite.DB, zap.NewNop().Sugar()).AddWorkflowExecutionEvidence(context.Background(), nextExecution.ID, "started")) | ||
|
|
||
| req = httptest.NewRequest(http.MethodGet, "/profiles/"+profileID.String()+"/compliance-progress", nil) | ||
| rec = httptest.NewRecorder() | ||
| ctx = e.NewContext(req, rec) | ||
| ctx.SetParamNames("id") | ||
| ctx.SetParamValues(profileID.String()) | ||
|
|
||
| suite.Require().NoError(NewProfileHandler(zap.NewNop().Sugar(), suite.DB).ComplianceProgress(ctx)) | ||
| suite.Require().Equal(http.StatusOK, rec.Code) | ||
|
|
||
| suite.Require().NoError(json.Unmarshal(rec.Body.Bytes(), &response)) | ||
| suite.Require().Equal(1, response.Data.Summary.TotalControls) | ||
| suite.Require().Equal(1, response.Data.Summary.Satisfied) | ||
| suite.Require().Len(response.Data.Controls, 1) | ||
| suite.Require().Equal("satisfied", response.Data.Controls[0].ComputedStatus) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.