Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions tests/e2e/framework/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func (f *Framework) addFrameworks() error {
}

// MCO objects
if f.Platform != "rosa" {
if f.Platform != "rosa" && f.Platform != "HyperShift" {
mcoObjs := [2]dynclient.ObjectList{
&mcfgv1.MachineConfigPoolList{},
&mcfgv1.MachineConfigList{},
Expand Down Expand Up @@ -600,7 +600,7 @@ func (f *Framework) GetReadyProfileBundle(name, namespace string) (*compv1alpha1
}

func (f *Framework) updateScanSettingsForDebug() error {
if f.Platform == "rosa" {
if f.Platform == "rosa" || f.Platform == "HyperShift" {
fmt.Printf("bypassing ScanSettings test setup because it's not supported on %s\n", f.Platform)
return nil
}
Expand All @@ -622,7 +622,7 @@ func (f *Framework) updateScanSettingsForDebug() error {
}

func (f *Framework) ensureE2EScanSettings() error {
if f.Platform == "rosa" {
if f.Platform == "rosa" || f.Platform == "HyperShift" {
fmt.Printf("bypassing ScanSettings test setup because it's not supported on %s\n", f.Platform)
return nil
}
Expand Down Expand Up @@ -652,7 +652,7 @@ func (f *Framework) ensureE2EScanSettings() error {
}

func (f *Framework) deleteScanSettings(name string) error {
if f.Platform == "rosa" {
if f.Platform == "rosa" || f.Platform == "HyperShift" {
fmt.Printf("bypassing ScanSettings test setup because it's not supported on %s\n", f.Platform)
return nil
}
Expand All @@ -670,7 +670,7 @@ func (f *Framework) deleteScanSettings(name string) error {
}

func (f *Framework) createMachineConfigPool(n string) error {
if f.Platform == "rosa" {
if f.Platform == "rosa" || f.Platform == "HyperShift" {
fmt.Printf("bypassing MachineConfigPool test setup because it's not supported on %s\n", f.Platform)
return nil
}
Expand Down Expand Up @@ -792,7 +792,7 @@ func (f *Framework) createMachineConfigPool(n string) error {
}

func (f *Framework) createInvalidMachineConfigPool(n string) error {
if f.Platform == "rosa" {
if f.Platform == "rosa" || f.Platform == "HyperShift" {
fmt.Printf("bypassing MachineConfigPool test setup because it's not supported on %s\n", f.Platform)
return nil
}
Expand Down Expand Up @@ -823,7 +823,7 @@ func (f *Framework) createInvalidMachineConfigPool(n string) error {
}

func (f *Framework) cleanUpMachineConfigPool(n string) error {
if f.Platform == "rosa" {
if f.Platform == "rosa" || f.Platform == "HyperShift" {
fmt.Printf("bypassing MachineConfigPool cleanup because it's not supported on %s\n", f.Platform)
return nil
}
Expand All @@ -841,7 +841,7 @@ func (f *Framework) cleanUpMachineConfigPool(n string) error {
}

func (f *Framework) restoreNodeLabelsForPool(n string) error {
if f.Platform == "rosa" {
if f.Platform == "rosa" || f.Platform == "HyperShift" {
fmt.Printf("bypassing node label restoration because MachineConfigPools are not supported on %s\n", f.Platform)
return nil
}
Expand Down
94 changes: 94 additions & 0 deletions tests/e2e/serial/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2164,6 +2164,100 @@ func TestScanTailoredProfileExtendsDeprecated(t *testing.T) {
}
}

// TestHypershiftTailoredProfileScan tests scanning HyperShift hosted cluster
// with tailored profiles for ocp4-cis and ocp4-pci-dss compliance profiles
func TestHypershiftTailoredProfileScan(t *testing.T) {
f := framework.Global

// Skip test if not running on a HyperShift cluster
if f.Platform != "HyperShift" {
t.Skip("Test requires HyperShift platform")
}

// Create tailored profile for ocp4-cis
var err error
cisTPName := "test-hypershift-cis-tp"
cisTP := &compv1alpha1.TailoredProfile{
ObjectMeta: metav1.ObjectMeta{
Name: cisTPName,
Namespace: f.OperatorNamespace,
},
Spec: compv1alpha1.TailoredProfileSpec{
Extends: "ocp4-cis",
Title: "HyperShift CIS Tailored Profile",
Description: "Tailored profile for ocp4-cis on HyperShift cluster",
},
}
err = f.Client.Create(context.TODO(), cisTP, nil)
if err != nil {
t.Fatalf("failed to create CIS TailoredProfile: %s", err)
}
defer f.Client.Delete(context.TODO(), cisTP)

// Create tailored profile for ocp4-pci-dss
pciTPName := "test-hypershift-pci-tp"
pciTP := &compv1alpha1.TailoredProfile{
ObjectMeta: metav1.ObjectMeta{
Name: pciTPName,
Namespace: f.OperatorNamespace,
},
Spec: compv1alpha1.TailoredProfileSpec{
Extends: "ocp4-pci-dss",
Title: "HyperShift PCI-DSS Tailored Profile",
Description: "Tailored profile for ocp4-pci-dss on HyperShift cluster",
},
}
err = f.Client.Create(context.TODO(), pciTP, nil)
if err != nil {
t.Fatalf("failed to create PCI-DSS TailoredProfile: %s", err)
}
defer f.Client.Delete(context.TODO(), pciTP)

// Create ScanSettingBinding with both tailored profiles
suiteName := framework.GetObjNameFromTest(t)
ssb := &compv1alpha1.ScanSettingBinding{
ObjectMeta: metav1.ObjectMeta{
Name: suiteName,
Namespace: f.OperatorNamespace,
},
Profiles: []compv1alpha1.NamedObjectReference{
{
APIGroup: "compliance.openshift.io/v1alpha1",
Kind: "TailoredProfile",
Name: cisTPName,
},
{
APIGroup: "compliance.openshift.io/v1alpha1",
Kind: "TailoredProfile",
Name: pciTPName,
},
},
SettingsRef: &compv1alpha1.NamedObjectReference{
APIGroup: "compliance.openshift.io/v1alpha1",
Kind: "ScanSetting",
Name: "default",
},
}
err = f.Client.Create(context.TODO(), ssb, nil)
if err != nil {
t.Fatalf("failed to create ScanSettingBinding: %s", err)
}
defer f.Client.Delete(context.TODO(), ssb)

// Wait for CIS scan to complete
// When using SSB with TailoredProfile, the scan has same name as the TP
if err = f.WaitForScanStatus(f.OperatorNamespace, cisTPName, compv1alpha1.PhaseDone); err != nil {
t.Fatalf("CIS scan failed to complete: %s", err)
}

// Wait for PCI-DSS scan to complete
if err = f.WaitForScanStatus(f.OperatorNamespace, pciTPName, compv1alpha1.PhaseDone); err != nil {
t.Fatalf("PCI-DSS scan failed to complete: %s", err)
}

t.Logf("Both HyperShift tailored profile scans completed successfully")
}

//testExecution{
// Name: "TestNodeSchedulingErrorFailsTheScan",
// IsParallel: false,
Expand Down
Loading