mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-11-09 04:38:49 +00:00
Merge branch 'PRWLR-7300-create-ia-c-provider' into PRWLR-7318-add-ia-c-provider-tests
This commit is contained in:
139 files changed
+375
-186
No files matched your search
@@ -94,6 +94,93 @@ custom_compliance_metadata = {
|
||||
)
|
||||
],
|
||||
),
|
||||
"framework1_gcp": Compliance(
|
||||
Framework="Framework1",
|
||||
Provider="gcp",
|
||||
Version="1.0",
|
||||
Description="Framework 2 Description",
|
||||
Requirements=[
|
||||
Compliance_Requirement(
|
||||
Id="1.1.1",
|
||||
Description="description",
|
||||
Attributes=[
|
||||
CIS_Requirement_Attribute(
|
||||
Section="1. Identity",
|
||||
Profile=CIS_Requirement_Attribute_Profile("Level 1"),
|
||||
AssessmentStatus=CIS_Requirement_Attribute_AssessmentStatus(
|
||||
"Manual"
|
||||
),
|
||||
Description="Description",
|
||||
RationaleStatement="Rationale",
|
||||
ImpactStatement="Impact",
|
||||
RemediationProcedure="Remediation",
|
||||
AuditProcedure="Audit",
|
||||
AdditionalInformation="Additional",
|
||||
References="References",
|
||||
)
|
||||
],
|
||||
Checks=[],
|
||||
)
|
||||
],
|
||||
),
|
||||
"framework1_k8s": Compliance(
|
||||
Framework="Framework1",
|
||||
Provider="Kubernetes",
|
||||
Version="1.0",
|
||||
Description="Framework 2 Description",
|
||||
Requirements=[
|
||||
Compliance_Requirement(
|
||||
Id="1.1.1",
|
||||
Description="description",
|
||||
Attributes=[
|
||||
CIS_Requirement_Attribute(
|
||||
Section="1. Identity",
|
||||
Profile=CIS_Requirement_Attribute_Profile("Level 1"),
|
||||
AssessmentStatus=CIS_Requirement_Attribute_AssessmentStatus(
|
||||
"Manual"
|
||||
),
|
||||
Description="Description",
|
||||
RationaleStatement="Rationale",
|
||||
ImpactStatement="Impact",
|
||||
RemediationProcedure="Remediation",
|
||||
AuditProcedure="Audit",
|
||||
AdditionalInformation="Additional",
|
||||
References="References",
|
||||
)
|
||||
],
|
||||
Checks=[],
|
||||
)
|
||||
],
|
||||
),
|
||||
"framework1_m365": Compliance(
|
||||
Framework="Framework1",
|
||||
Provider="m365",
|
||||
Version="1.0",
|
||||
Description="Framework 2 Description",
|
||||
Requirements=[
|
||||
Compliance_Requirement(
|
||||
Id="1.1.1",
|
||||
Description="description",
|
||||
Attributes=[
|
||||
CIS_Requirement_Attribute(
|
||||
Section="1. Identity",
|
||||
Profile=CIS_Requirement_Attribute_Profile("E3 Level 1"),
|
||||
AssessmentStatus=CIS_Requirement_Attribute_AssessmentStatus(
|
||||
"Manual"
|
||||
),
|
||||
Description="Description",
|
||||
RationaleStatement="Rationale",
|
||||
ImpactStatement="Impact",
|
||||
RemediationProcedure="Remediation",
|
||||
AuditProcedure="Audit",
|
||||
AdditionalInformation="Additional",
|
||||
References="References",
|
||||
)
|
||||
],
|
||||
Checks=[],
|
||||
)
|
||||
],
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
@@ -209,9 +296,12 @@ class TestCompliance:
|
||||
|
||||
list_compliance = Compliance.list(bulk_compliance_frameworks)
|
||||
|
||||
assert len(list_compliance) == 2
|
||||
assert len(list_compliance) == 5
|
||||
assert list_compliance[0] == "framework1_aws"
|
||||
assert list_compliance[1] == "framework1_azure"
|
||||
assert list_compliance[2] == "framework1_gcp"
|
||||
assert list_compliance[3] == "framework1_k8s"
|
||||
assert list_compliance[4] == "framework1_m365"
|
||||
|
||||
def test_list_with_provider_aws(self):
|
||||
bulk_compliance_frameworks = custom_compliance_metadata
|
||||
@@ -229,6 +319,30 @@ class TestCompliance:
|
||||
assert len(list_compliance) == 1
|
||||
assert list_compliance[0] == "framework1_azure"
|
||||
|
||||
def test_list_with_provider_gcp(self):
|
||||
bulk_compliance_frameworks = custom_compliance_metadata
|
||||
|
||||
list_compliance = Compliance.list(bulk_compliance_frameworks, provider="gcp")
|
||||
|
||||
assert len(list_compliance) == 1
|
||||
assert list_compliance[0] == "framework1_gcp"
|
||||
|
||||
def test_list_with_provider_k8s(self):
|
||||
bulk_compliance_frameworks = custom_compliance_metadata
|
||||
|
||||
list_compliance = Compliance.list(bulk_compliance_frameworks, provider="k8s")
|
||||
|
||||
assert len(list_compliance) == 1
|
||||
assert list_compliance[0] == "framework1_k8s"
|
||||
|
||||
def test_list_with_provider_m365(self):
|
||||
bulk_compliance_frameworks = custom_compliance_metadata
|
||||
|
||||
list_compliance = Compliance.list(bulk_compliance_frameworks, provider="m365")
|
||||
|
||||
assert len(list_compliance) == 1
|
||||
assert list_compliance[0] == "framework1_m365"
|
||||
|
||||
def test_get_compliance_frameworks(self):
|
||||
bulk_compliance_frameworks = custom_compliance_metadata
|
||||
|
||||
@@ -252,6 +366,76 @@ class TestCompliance:
|
||||
assert compliance_framework.Description == "Framework 2 Description"
|
||||
assert len(compliance_framework.Requirements) == 1
|
||||
|
||||
compliance_framework = Compliance.get(
|
||||
bulk_compliance_frameworks, compliance_framework_name="framework1_gcp"
|
||||
)
|
||||
|
||||
assert compliance_framework.Framework == "Framework1"
|
||||
assert compliance_framework.Provider == "gcp"
|
||||
assert compliance_framework.Version == "1.0"
|
||||
assert compliance_framework.Description == "Framework 2 Description"
|
||||
assert len(compliance_framework.Requirements) == 1
|
||||
|
||||
compliance_framework = Compliance.get(
|
||||
bulk_compliance_frameworks, compliance_framework_name="framework1_k8s"
|
||||
)
|
||||
|
||||
assert compliance_framework.Framework == "Framework1"
|
||||
assert compliance_framework.Provider == "Kubernetes"
|
||||
assert compliance_framework.Version == "1.0"
|
||||
assert compliance_framework.Description == "Framework 2 Description"
|
||||
assert len(compliance_framework.Requirements) == 1
|
||||
|
||||
compliance_framework = Compliance.get(
|
||||
bulk_compliance_frameworks, compliance_framework_name="framework1_m365"
|
||||
)
|
||||
|
||||
assert compliance_framework.Framework == "Framework1"
|
||||
assert compliance_framework.Provider == "m365"
|
||||
assert compliance_framework.Version == "1.0"
|
||||
assert compliance_framework.Description == "Framework 2 Description"
|
||||
assert len(compliance_framework.Requirements) == 1
|
||||
assert compliance_framework.Requirements[0].Id == "1.1.1"
|
||||
assert compliance_framework.Requirements[0].Description == "description"
|
||||
assert len(compliance_framework.Requirements[0].Attributes) == 1
|
||||
assert (
|
||||
compliance_framework.Requirements[0].Attributes[0].Section == "1. Identity"
|
||||
)
|
||||
assert (
|
||||
compliance_framework.Requirements[0].Attributes[0].Profile == "E3 Level 1"
|
||||
)
|
||||
assert (
|
||||
compliance_framework.Requirements[0].Attributes[0].AssessmentStatus
|
||||
== "Manual"
|
||||
)
|
||||
assert (
|
||||
compliance_framework.Requirements[0].Attributes[0].Description
|
||||
== "Description"
|
||||
)
|
||||
assert (
|
||||
compliance_framework.Requirements[0].Attributes[0].RationaleStatement
|
||||
== "Rationale"
|
||||
)
|
||||
assert (
|
||||
compliance_framework.Requirements[0].Attributes[0].ImpactStatement
|
||||
== "Impact"
|
||||
)
|
||||
assert (
|
||||
compliance_framework.Requirements[0].Attributes[0].RemediationProcedure
|
||||
== "Remediation"
|
||||
)
|
||||
assert (
|
||||
compliance_framework.Requirements[0].Attributes[0].AuditProcedure == "Audit"
|
||||
)
|
||||
assert (
|
||||
compliance_framework.Requirements[0].Attributes[0].AdditionalInformation
|
||||
== "Additional"
|
||||
)
|
||||
assert (
|
||||
compliance_framework.Requirements[0].Attributes[0].References
|
||||
== "References"
|
||||
)
|
||||
|
||||
def test_get_non_existent_framework(self):
|
||||
bulk_compliance_frameworks = custom_compliance_metadata
|
||||
|
||||
|
||||
+3
-3
@@ -96,7 +96,7 @@ class Test_iam_service_account_unused:
|
||||
assert result[0].resource_id == iam_client.service_accounts[0].email
|
||||
assert result[0].project_id == GCP_PROJECT_ID
|
||||
assert result[0].location == GCP_US_CENTER1_LOCATION
|
||||
assert result[0].resource == iam_client.service_accounts[0].model_dump()
|
||||
assert result[0].resource == iam_client.service_accounts[0]
|
||||
|
||||
def test_iam_service_account_unused_mix(self):
|
||||
iam_client = mock.MagicMock()
|
||||
@@ -168,7 +168,7 @@ class Test_iam_service_account_unused:
|
||||
assert result[0].resource_id == iam_client.service_accounts[0].email
|
||||
assert result[0].project_id == GCP_PROJECT_ID
|
||||
assert result[0].location == GCP_US_CENTER1_LOCATION
|
||||
assert result[0].resource == iam_client.service_accounts[0].model_dump()
|
||||
assert result[0].resource == iam_client.service_accounts[0]
|
||||
|
||||
assert result[1].status == "FAIL"
|
||||
assert (
|
||||
@@ -178,4 +178,4 @@ class Test_iam_service_account_unused:
|
||||
assert result[1].resource_id == iam_client.service_accounts[1].email
|
||||
assert result[1].project_id == GCP_PROJECT_ID
|
||||
assert result[1].location == GCP_US_CENTER1_LOCATION
|
||||
assert result[1].resource == iam_client.service_accounts[1].model_dump()
|
||||
assert result[1].resource == iam_client.service_accounts[1]
|
||||
Reference in new issue
Block a user