Skip to content

Commit

Permalink
Added Object encryption details validation test
Browse files Browse the repository at this point in the history
Signed-off-by: Parag Kamble <[email protected]>
  • Loading branch information
paraggit committed Dec 13, 2024
1 parent 1c9a71b commit 3e2e9c8
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 24 deletions.
1 change: 0 additions & 1 deletion ocs_ci/ocs/ui/page_objects/block_and_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ def get_block_file_encryption_summary(self):
"In-transit encryption": "intransit_encryption",
"Block storage": "block_storage",
}
# status_code = {"#3e8635": True, "#c9190b": False}

# Get elements for text and root
encryption_content_location = self.validation_loc["encryption_summary"][
Expand Down
4 changes: 4 additions & 0 deletions ocs_ci/ocs/ui/page_objects/storage_system_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def nav_details_object(self):
else:
self.do_click(self.validation_loc["object"], enable_screenshot=True)

from ocs_ci.ocs.ui.page_objects.object_details_tab import ObjectDetails

return ObjectDetails()

def nav_block_and_file(self):
"""
Accessible only at StorageSystems / StorageSystem details / Overview
Expand Down
18 changes: 15 additions & 3 deletions ocs_ci/ocs/ui/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1788,7 +1788,7 @@
"encryption_summary": {
"file_and_block": {
"enabled": (
"//button[@class='pf-v5-c-button pf-m-link pf-m-inline']",
"//button[@class='pf-v5-c-button pf-m-link pf-m-inline' and text()='Enabled']",
By.XPATH,
),
"close": (
Expand All @@ -1799,9 +1799,21 @@
"//div[@class='pf-v5-c-popover__body']",
By.XPATH,
),
"encryption_status_data": (".pf-v5-c-popover__content h6", By.CSS_SELECTOR),
},
"object": ("button.pf-v5-c-button.pf-m-link.pf-m-inline", By.CSS_SELECTOR),
"object": {
"enabled": (
"//button[@class='pf-v5-c-button pf-m-link pf-m-inline' and text()='Enabled']",
By.XPATH,
),
"close": (
"//button[@class='pf-v5-c-button pf-m-plain' and @aria-label='Close']",
By.XPATH,
),
"encryption_content_data": (
"//div[@class='pf-v5-c-popover__content']",
By.XPATH,
),
},
}
}

Expand Down
103 changes: 83 additions & 20 deletions tests/functional/encryption/test_encryption_configuration_dashboard.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,61 @@
# import pytest
import pytest
import logging

log = logging.getLogger(__name__)
from ocs_ci.ocs.ui.page_objects.page_navigator import PageNavigator
from ocs_ci.ocs.resources.storage_cluster import get_storagecluster_obj
from ocs_ci.framework.pytest_customization.marks import green_squad, tier1
from ocs_ci.ocs.ocp import OCP
from ocs_ci.framework import config


@green_squad
@tier1
class TestEncryptionConfigurationDashboard:
def test_encryption_configuration_dashboard(self, setup_ui_class):
"""
Test the encryption configuration dashboard for correctness.
"""
@pytest.fixture(autouse=True)
def encryption_status(self):
"""_summary_"""
# Retrieve encryption details
sc_obj = get_storagecluster_obj()
enc_details = sc_obj.data["spec"].get("encryption", {})
intransit_encryption_status = (
self.enc_details = sc_obj.data["spec"].get("encryption", {})
self.intransit_encryption_status = (
sc_obj.data["spec"]
.get("network", {})
.get("connections", {})
.get("encryption", {})
.get("enabled", False)
)
log.info(f"Encryption details: {enc_details}")
log.info(f"Encryption details: {self.enc_details}")

noobaa_obj = OCP(
kind="noobaa",
namespace=config.ENV_DATA["cluster_namespace"],
resource_name="noobaa",
)

self.noobaa_kms = (
noobaa_obj.data["spec"]
.get("security", {})
.get("kms", {})
.get("connectionDetails", {})
.get("KMS_PROVIDER", None) # Provide a default value of None if not found
)

# Helper function to validate encryption details
def validate_encryption(
self, context, actual_status, expected_status, error_message
):
assert actual_status == expected_status, error_message
log.info(f"{context} status is as expected: {actual_status}")

def test_file_block_encryption_configuration_dashboard(self, setup_ui_class):
"""Test the encryption configuration dashboard of File And Block details for correctness.
Steps:
1. Navigate to file and block details page
2. Open encryption details.
3. verify encryption data with the nooba and storagecluster spec.
"""

# Navigate to the block and file page
block_and_file_page = (
Expand All @@ -38,21 +69,16 @@ def test_encryption_configuration_dashboard(self, setup_ui_class):
# Retrieve encryption summary from the dashboard
encryption_summary = block_and_file_page.get_block_file_encryption_summary()

# Helper function to validate encryption details
def validate_encryption(context, actual_status, expected_status, error_message):
assert actual_status == expected_status, error_message
log.info(f"{context} status is as expected: {actual_status}")

# Validate cluster-wide encryption
cluster_wide_details = enc_details.get("clusterWide", {})
cluster_wide_details = self.enc_details.get("clusterWide", {})
if isinstance(cluster_wide_details, dict):
validate_encryption(
self.validate_encryption(
"ClusterWide Encryption",
encryption_summary["cluster_wide_encryption"]["status"],
cluster_wide_details.get("status", False),
"ClusterWide Encryption is not showing correctly in the dashboard.",
)
validate_encryption(
self.validate_encryption(
"ClusterWide KMS",
encryption_summary["cluster_wide_encryption"]["kms"],
cluster_wide_details.get("kms", {}).get("enable", False),
Expand All @@ -64,9 +90,9 @@ def validate_encryption(context, actual_status, expected_status, error_message):
)

# Validate storage class encryption
storage_class_details = enc_details.get("storageClass", {})
storage_class_details = self.enc_details.get("storageClass", {})
if isinstance(storage_class_details, dict):
validate_encryption(
self.validate_encryption(
"StorageClass Encryption",
encryption_summary["storageclass_encryption"]["status"],
storage_class_details.get("status", False),
Expand All @@ -76,9 +102,46 @@ def validate_encryption(context, actual_status, expected_status, error_message):
log.warning("StorageClass details are not a dictionary, skipping checks.")

# Validate in-transit encryption
validate_encryption(
self.validate_encryption(
"InTransit Encryption",
encryption_summary["intransit_encryption"]["status"],
self.intransit_encryption_status,
"InTransit Encryption status is incorrect in the dashboard.",
)

def test_object_storage_encryption_configuration_dashboard(self, setup_ui_class):
"""Test the encryption configuration dashboard of Object details for correctness.
Steps:
1. Navigate to object details page
2. Open encryption details.
3. verify encryption data with the nooba and storagecluster spec.
"""
# Navigate to the Object Storage page
object_details_page = (
PageNavigator()
.nav_odf_default_page()
.nav_storage_systems_tab()
.nav_storagecluster_storagesystem_details()
.nav_details_object()
)

encryption_summary = object_details_page.get_encryption_summary()
log.info(f"Encryption Summary from page : {encryption_summary}")

# Validate Object Encryption Summary
assert encryption_summary["object_storage"][
"status"
], "Object encryption summary is wrong"
assert (
encryption_summary["object_storage"]["kms"].upper()
== self.noobaa_kms.upper()
), "KMS details is not correct"

# Validate in-transit encryption
self.validate_encryption(
"InTransit Encryption",
encryption_summary["intransit_encryption"]["status"],
intransit_encryption_status,
self.intransit_encryption_status,
"InTransit Encryption status is incorrect in the dashboard.",
)

0 comments on commit 3e2e9c8

Please sign in to comment.