From 4c225f7d66c545cdda5338f6f86ab161ad5b6f1e Mon Sep 17 00:00:00 2001 From: Gianluca Zuccarelli Date: Tue, 23 Jul 2024 17:16:18 +0100 Subject: [PATCH] cloudapi: openscap tailoring tests Add an initial test for OpenSCAP tailoring customizations since we will be expanding the tailoring options to support json tailoring. --- internal/cloudapi/v2/compose_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/internal/cloudapi/v2/compose_test.go b/internal/cloudapi/v2/compose_test.go index adef329bb..bbb572d64 100644 --- a/internal/cloudapi/v2/compose_test.go +++ b/internal/cloudapi/v2/compose_test.go @@ -760,3 +760,29 @@ func TestGetImageRequests_BlueprintDistro(t *testing.T) { assert.Contains(t, got[0].repositories[0].Metalink, "38") assert.Equal(t, got[0].blueprint.Distro, "fedora-38") } + +func TestOpenSCAPTailoringOptions(t *testing.T) { + cr := ComposeRequest{ + Customizations: &Customizations{ + Openscap: &OpenSCAP{ + ProfileId: "test-123", + Tailoring: &OpenSCAPTailoring{ + Selected: common.ToPtr([]string{"one", "two", "three"}), + Unselected: common.ToPtr([]string{"four", "five", "six"}), + }, + }, + }, + } + + expectedOscap := &blueprint.OpenSCAPCustomization{ + ProfileID: "test-123", + Tailoring: &blueprint.OpenSCAPTailoringCustomizations{ + Selected: []string{"one", "two", "three"}, + Unselected: []string{"four", "five", "six"}, + }, + } + + bp, err := cr.GetBlueprintFromCustomizations() + assert.NoError(t, err) + assert.Equal(t, expectedOscap, bp.Customizations.OpenSCAP) +}