Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image scanning lambda: unit test coverage #412

Open
ginglis13 opened this issue Sep 20, 2023 · 0 comments
Open

image scanning lambda: unit test coverage #412

ginglis13 opened this issue Sep 20, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@ginglis13
Copy link
Contributor

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.

@ginglis13 ginglis13 added the enhancement New feature or request label Sep 20, 2023
@ginglis13 ginglis13 self-assigned this Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant