Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dependencies = [
"dnspython==2.6.1",
"pydantic==2.8.2",
"aws-lambda-powertools[parser]==3.2.0",
"open-mpic-core==3.0.2",
"open-mpic-core==3.1.0",
]

[project.optional-dependencies]
Expand Down Expand Up @@ -123,8 +123,6 @@ markers = [
addopts = [
"--import-mode=prepend", # explicit default, as the tests rely on it for proper import resolution
]
spec_header_format = "Spec for {test_case} ({path}):"
spec_test_format = "{result} {docstring_summary}" # defaults to {name} if docstring is not present in test

[tool.coverage.run]
source = [
Expand Down
2 changes: 1 addition & 1 deletion src/aws_lambda_mpic/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3.1"
__version__ = "0.3.2"
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def load_aws_region_config() -> dict[str, RemotePerspective]:
Reads in the available perspectives from a configuration yaml and returns them as a dict (map).
:return: dict of available perspectives with region code as key
"""
with resources.open_text('resources', 'aws_region_config.yaml') as file:
with resources.files('resources').joinpath('aws_region_config.yaml').open('r') as file:
aws_region_config_yaml = yaml.safe_load(file)
aws_region_type_adapter = TypeAdapter(list[RemotePerspective])
aws_regions_list = aws_region_type_adapter.validate_python(aws_region_config_yaml['aws_available_regions'])
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/aws_lambda_mpic/test_caa_checker_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@

import aws_lambda_mpic.mpic_caa_checker_lambda.mpic_caa_checker_lambda_function as mpic_caa_checker_lambda_function
from open_mpic_core.common_domain.check_response import CaaCheckResponse, CaaCheckResponseDetails
from unit.test_util.valid_check_creator import ValidCheckCreator
from open_mpic_core_test.test_util.valid_check_creator import ValidCheckCreator


class TestCaaCheckerLambda:
@staticmethod
@pytest.fixture(scope='class')
def set_env_variables():
envvars = {
'rir_region': 'arin',
'AWS_REGION': 'us-east-1',
'default_caa_domains': 'ca1.com|ca2.org|ca3.net'
}
Expand Down
4 changes: 1 addition & 3 deletions tests/unit/aws_lambda_mpic/test_dcv_checker_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@

import aws_lambda_mpic.mpic_dcv_checker_lambda.mpic_dcv_checker_lambda_function as mpic_dcv_checker_lambda_function
from open_mpic_core.common_domain.validation_error import MpicValidationError
from unit.test_util.valid_check_creator import ValidCheckCreator
from open_mpic_core.common_domain.check_response_details import DcvHttpCheckResponseDetails
from open_mpic_core.common_domain.enum.dcv_validation_method import DcvValidationMethod
from open_mpic_core.common_domain.check_response import DcvCheckResponse
from open_mpic_core_test.test_util.valid_check_creator import ValidCheckCreator


class TestDcvCheckerLambda:
@staticmethod
@pytest.fixture(scope='class')
def set_env_variables():
envvars = {
'rir_region': 'arin',
'AWS_REGION': 'us-east-1',
'default_caa_domains': 'ca1.com|ca2.org|ca3.net'
}
with pytest.MonkeyPatch.context() as class_scoped_monkeypatch:
for k, v in envvars.items():
Expand Down
17 changes: 9 additions & 8 deletions tests/unit/aws_lambda_mpic/test_mpic_coordinator_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import aws_lambda_mpic.mpic_coordinator_lambda.mpic_coordinator_lambda_function as mpic_coordinator_lambda_function
from aws_lambda_mpic.mpic_coordinator_lambda.mpic_coordinator_lambda_function import PerspectiveEndpoints, PerspectiveEndpointInfo

from unit.test_util.valid_check_creator import ValidCheckCreator
from unit.test_util.valid_mpic_request_creator import ValidMpicRequestCreator
from open_mpic_core_test.test_util.valid_mpic_request_creator import ValidMpicRequestCreator
from open_mpic_core_test.test_util.valid_check_creator import ValidCheckCreator


# noinspection PyMethodMayBeStatic
Expand Down Expand Up @@ -63,7 +63,7 @@ def call_remote_perspective__should_make_aws_lambda_call_with_provided_arguments
CheckType.DCV,
dcv_check_request)
assert check_response.check_passed is True
# hijacking the value of 'perspective' to verify that the right arguments got passed to the call
# hijacking the value of 'perspective_code' to verify that the right arguments got passed to the call
assert check_response.perspective_code == dcv_check_request.domain_or_ip_target

def lambda_handler__should_return_400_error_and_details_given_invalid_request_body(self):
Expand Down Expand Up @@ -148,7 +148,7 @@ def constructor__should_initialize_mpic_coordinator_and_set_target_perspectives(
# noinspection PyUnusedLocal
def create_successful_boto3_api_call_response_for_dcv_check(self, lambda_method, lambda_configuration):
check_request = DcvCheckRequest.model_validate_json(lambda_configuration['Payload'])
# hijacking the value of 'perspective' to verify that the right arguments got passed to the call
# hijacking the value of 'perspective_code' to verify that the right arguments got passed to the call
expected_response_body = DcvCheckResponse(perspective_code=check_request.domain_or_ip_target,
check_passed=True, details=DcvDnsCheckResponseDetails(validation_method=DcvValidationMethod.ACME_DNS_01))
expected_response = {'statusCode': 200, 'body': expected_response_body.model_dump_json()}
Expand Down Expand Up @@ -198,10 +198,11 @@ def create_api_gateway_request():

@staticmethod
def get_perspectives_by_code_dict_from_file() -> dict[str, RemotePerspective]:
perspectives_yaml = yaml.safe_load(resources.open_text('resources', 'aws_region_config.yaml'))
perspective_type_adapter = TypeAdapter(list[RemotePerspective])
perspectives = perspective_type_adapter.validate_python(perspectives_yaml['aws_available_regions'])
return {perspective.code: perspective for perspective in perspectives}
with resources.files('resources').joinpath('aws_region_config.yaml').open('r') as file:
perspectives_yaml = yaml.safe_load(file)
perspective_type_adapter = TypeAdapter(list[RemotePerspective])
perspectives = perspective_type_adapter.validate_python(perspectives_yaml['aws_available_regions'])
return {perspective.code: perspective for perspective in perspectives}


if __name__ == '__main__':
Expand Down
64 changes: 0 additions & 64 deletions tests/unit/test_util/mock_dns_object_creator.py

This file was deleted.

33 changes: 0 additions & 33 deletions tests/unit/test_util/valid_check_creator.py

This file was deleted.

51 changes: 0 additions & 51 deletions tests/unit/test_util/valid_mpic_request_creator.py

This file was deleted.

Loading