@@ -108,3 +108,61 @@ def test_describe_clusters(self):
108108 snapshot_limit = 5 ,
109109 )
110110 }
111+
112+
113+ def mock_make_api_call_no_security_groups (self , operation_name , kwargs ):
114+ """Mock that simulates a cluster response WITHOUT the SecurityGroups field"""
115+ if operation_name == "DescribeClusters" :
116+ return {
117+ "Clusters" : [
118+ {
119+ "Name" : MEM_DB_CLUSTER_NAME ,
120+ "Description" : "Test cluster without SecurityGroups" ,
121+ "Status" : "available" ,
122+ "NumberOfShards" : 1 ,
123+ "AvailabilityMode" : "singleaz" ,
124+ "Engine" : "valkey" ,
125+ "EngineVersion" : MEM_DB_ENGINE_VERSION ,
126+ "EnginePatchVersion" : "5.0.6" ,
127+ # SecurityGroups field is MISSING
128+ "TLSEnabled" : True ,
129+ "ARN" : MEM_DB_CLUSTER_ARN ,
130+ "SnapshotRetentionLimit" : 5 ,
131+ "AutoMinorVersionUpgrade" : True ,
132+ },
133+ ]
134+ }
135+ return make_api_call (self , operation_name , kwargs )
136+
137+
138+ @patch (
139+ "prowler.providers.aws.aws_provider.AwsProvider.generate_regional_clients" ,
140+ new = mock_generate_regional_clients ,
141+ )
142+ @patch (
143+ "botocore.client.BaseClient._make_api_call" ,
144+ new = mock_make_api_call_no_security_groups ,
145+ )
146+ class Test_MemoryDB_Service_No_Security_Groups :
147+ """Test class for clusters without SecurityGroups field"""
148+
149+ def test_describe_clusters_no_security_groups (self ):
150+ """Test that clusters without SecurityGroups field are handled correctly"""
151+ aws_provider = set_mocked_aws_provider ()
152+ memorydb = MemoryDB (aws_provider )
153+ assert memorydb .clusters == {
154+ MEM_DB_CLUSTER_ARN : Cluster (
155+ name = MEM_DB_CLUSTER_NAME ,
156+ arn = MEM_DB_CLUSTER_ARN ,
157+ number_of_shards = 1 ,
158+ engine = "valkey" ,
159+ engine_version = MEM_DB_ENGINE_VERSION ,
160+ engine_patch_version = "5.0.6" ,
161+ multi_az = "singleaz" ,
162+ region = AWS_REGION_US_EAST_1 ,
163+ security_groups = [],
164+ tls_enabled = True ,
165+ auto_minor_version_upgrade = True ,
166+ snapshot_limit = 5 ,
167+ )
168+ }
0 commit comments