Skip to content

Commit

Permalink
[Asset Inventory][AWS] Add integration test cases for implemented ass…
Browse files Browse the repository at this point in the history
…ets (#2487)
  • Loading branch information
kubasobon authored Sep 11, 2024
1 parent 91c6860 commit 01cf3fc
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/inventory/awsfetcher/fetcher_lambda.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,13 @@ func (s *lambdaFetcher) fetch(ctx context.Context, resourceName string, function
}

for _, item := range awsResources {
var id string = item.GetResourceArn()
if id == "" { // e.g. LambdaEventSourceMappings
id = item.GetResourceName()
}
assetChannel <- inventory.NewAssetEvent(
classification,
[]string{item.GetResourceArn()},
[]string{id},
item.GetResourceName(),
inventory.WithRawAsset(item),
inventory.WithCloud(inventory.AssetCloud{
Expand Down
120 changes: 120 additions & 0 deletions tests/product/tests/data/aws_asset_inventory/test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,124 @@
type_="role",
sub_type="iam-role",
),
"[Asset Inventory][AWS][ELBv1] assets found": AssetInventoryCase(
category="infrastructure",
sub_category="network",
type_="load-balancer",
sub_type="elastic-load-balancer",
),
"[Asset Inventory][AWS][ELBv2] assets found": AssetInventoryCase(
category="infrastructure",
sub_category="network",
type_="load-balancer",
sub_type="elastic-load-balancer-v2",
),
"[Asset Inventory][AWS][IAM Policy] assets found": AssetInventoryCase(
category="identity",
sub_category="digital-identity",
type_="policy",
sub_type="iam-policy",
),
"[Asset Inventory][AWS][IAM User] assets found": AssetInventoryCase(
category="identity",
sub_category="digital-identity",
type_="user",
sub_type="iam-user",
),
"[Asset Inventory][AWS][Lambda Event Source Mapping] assets found": AssetInventoryCase(
category="infrastructure",
sub_category="integration",
type_="event-source",
sub_type="lambda-event-source-mapping",
),
"[Asset Inventory][AWS][Lambda Function] assets found": AssetInventoryCase(
category="infrastructure",
sub_category="compute",
type_="serverless",
sub_type="lambda-function",
),
"[Asset Inventory][AWS][Lambda Layer] assets found": AssetInventoryCase(
category="infrastructure",
sub_category="compute",
type_="serverless",
sub_type="lambda-layer",
),
"[Asset Inventory][AWS][Internet Gateway] assets found": AssetInventoryCase(
category="infrastructure",
sub_category="network",
type_="gateway",
sub_type="internet-gateway",
),
"[Asset Inventory][AWS][NAT Gateway] assets found": AssetInventoryCase(
category="infrastructure",
sub_category="network",
type_="gateway",
sub_type="nat-gateway",
),
"[Asset Inventory][AWS][VPC ACL] assets found": AssetInventoryCase(
category="identity",
sub_category="authorization",
type_="acl",
sub_type="s3-access-control-list",
),
"[Asset Inventory][AWS][EC2 Network Interface] assets found": AssetInventoryCase(
category="infrastructure",
sub_category="network",
type_="interface",
sub_type="ec2-network-interface",
),
"[Asset Inventory][AWS][Security Group] assets found": AssetInventoryCase(
category="infrastructure",
sub_category="network",
type_="firewall",
sub_type="ec2-security-group",
),
"[Asset Inventory][AWS][EC2 Subnet] assets found": AssetInventoryCase(
category="infrastructure",
sub_category="network",
type_="subnet",
sub_type="ec2-subnet",
),
"[Asset Inventory][AWS][Transit Gateway] assets found": AssetInventoryCase(
category="infrastructure",
sub_category="network",
type_="virtual-network",
sub_type="transit-gateway",
),
"[Asset Inventory][AWS][Transit Gateway Attachment] assets found": AssetInventoryCase(
category="infrastructure",
sub_category="network",
type_="virtual-network",
sub_type="transit-gateway-attachment",
),
"[Asset Inventory][AWS][VPC Peering Connection] assets found": AssetInventoryCase(
category="infrastructure",
sub_category="network",
type_="peering",
sub_type="vpc-peering-connection",
),
"[Asset Inventory][AWS][VPC] assets found": AssetInventoryCase(
category="infrastructure",
sub_category="network",
type_="virtual-network",
sub_type="vpc",
),
"[Asset Inventory][AWS][RDS] assets found": AssetInventoryCase(
category="infrastructure",
sub_category="database",
type_="relational",
sub_type="rds-instance",
),
"[Asset Inventory][AWS][S3] assets found": AssetInventoryCase(
category="infrastructure",
sub_category="storage",
type_="object-storage",
sub_type="s3-bucket",
),
"[Asset Inventory][AWS][SNS Topic] assets found": AssetInventoryCase(
category="infrastructure",
sub_category="messaging",
type_="notification-service",
sub_type="sns-topic",
),
}

0 comments on commit 01cf3fc

Please sign in to comment.