Skip to content

image scanning lambda: unit test coverage #412

Description

@ginglis13

Right now there are no unit tests for the rootfs image scanning Lambda. While this is non-critical infrastructure and the function is fairly simple, unit test coverage for the function would surely be an enhancement to the overall testing profile of this package.

A solution could define a class like this with a boto3 resource to be easily mocked:

class SnsTopicClass:
    """
    AWS SNS Topic Resource Class
    """
    def __init__(self,  sns_topic_resource):
        self.resource = sns_topic_resource["resource"]
        self.topic_arn = sns_topic_resource["topic_arn"]
        self.topic = self.resource.Topic(self.topic_arn)

# [1] Globally scoped resources
# Initialize the resources once per Lambda execution environment by using global scope.
_LAMBDA_SNS_TOPIC_RESOURCE = { "resource" : resource('sns'), 
                              "topic_arn" : os.environ.get("SNS_ARN","NONE") }

Alternatively, given this project is mainly TypeScript, the lambda function could be rewritten in TS to get the built in benefit of all testing tooling already living with the project, i.e. not having to maintain a python virtual environment or similar for testing this both locally for devs and in the actual pipeline defined in this project.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions