-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(oscal): single model write operations support (#502)
* fix(oscal): remove mutli-model write operations * fix(oscall): testing for GetOscalModel() * fix(oscal): remove assessment test file --------- Co-authored-by: Cole (Mike) Winberry <86802655+mike-winberry@users.noreply.github.com> Co-authored-by: Andy Mills <61879371+CloudBeard@users.noreply.github.com>
- Loading branch information
1 parent
0d69a45
commit 3646650
Showing
2 changed files
with
138 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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 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,72 @@ | ||
package oscal_test | ||
|
||
import ( | ||
oscalTypes_1_1_2 "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-2" | ||
"github.com/defenseunicorns/lula/src/pkg/common/oscal" | ||
"testing" | ||
) | ||
|
||
func TestGetOscalModel(t *testing.T) { | ||
t.Parallel() | ||
|
||
type TestCase struct { | ||
Model oscalTypes_1_1_2.OscalModels | ||
ModelType string | ||
} | ||
|
||
testCases := []TestCase{ | ||
{ | ||
Model: oscalTypes_1_1_2.OscalModels{ | ||
Catalog: &oscalTypes_1_1_2.Catalog{}, | ||
}, | ||
ModelType: "catalog", | ||
}, | ||
{ | ||
Model: oscalTypes_1_1_2.OscalModels{ | ||
Profile: &oscalTypes_1_1_2.Profile{}, | ||
}, | ||
ModelType: "profile", | ||
}, | ||
{ | ||
Model: oscalTypes_1_1_2.OscalModels{ | ||
ComponentDefinition: &oscalTypes_1_1_2.ComponentDefinition{}, | ||
}, | ||
ModelType: "component", | ||
}, | ||
{ | ||
Model: oscalTypes_1_1_2.OscalModels{ | ||
SystemSecurityPlan: &oscalTypes_1_1_2.SystemSecurityPlan{}, | ||
}, | ||
ModelType: "system-security-plan", | ||
}, | ||
{ | ||
Model: oscalTypes_1_1_2.OscalModels{ | ||
AssessmentPlan: &oscalTypes_1_1_2.AssessmentPlan{}, | ||
}, | ||
ModelType: "assessment-plan", | ||
}, | ||
{ | ||
Model: oscalTypes_1_1_2.OscalModels{ | ||
AssessmentResults: &oscalTypes_1_1_2.AssessmentResults{}, | ||
}, | ||
ModelType: "assessment-results", | ||
}, | ||
{ | ||
Model: oscalTypes_1_1_2.OscalModels{ | ||
PlanOfActionAndMilestones: &oscalTypes_1_1_2.PlanOfActionAndMilestones{}, | ||
}, | ||
ModelType: "poam", | ||
}, | ||
} | ||
for _, testCase := range testCases { | ||
actual, err := oscal.GetOscalModel(&testCase.Model) | ||
if err != nil { | ||
t.Fatalf("unexpected error for model %s", testCase.ModelType) | ||
} | ||
expected := testCase.ModelType | ||
if expected != actual { | ||
t.Fatalf("error GetOscalModel: expected: %s | got: %s", expected, actual) | ||
} | ||
} | ||
|
||
} |