|
5 | 5 |
|
6 | 6 | from pydantic import TypeAdapter |
7 | 7 |
|
8 | | -from open_mpic_core.common_domain.check_parameters import CaaCheckParameters, DcvWebsiteChangeValidationDetails, DcvAcmeDns01ValidationDetails, DcvDnsChangeValidationDetails |
| 8 | +from open_mpic_core.common_domain.check_parameters import CaaCheckParameters, DcvWebsiteChangeValidationDetails, DcvAcmeDns01ValidationDetails, DcvAcmeHttp01ValidationDetails, DcvDnsChangeValidationDetails |
9 | 9 | from open_mpic_core.common_domain.check_parameters import DcvCheckParameters |
10 | 10 | from open_mpic_core.common_domain.enum.certificate_type import CertificateType |
11 | 11 | from open_mpic_core.common_domain.enum.check_type import CheckType |
@@ -191,6 +191,69 @@ def api_should_return_200_is_valid_false_given_invalid_dns_01_validation(self, a |
191 | 191 |
|
192 | 192 | assert mpic_response.is_valid is False |
193 | 193 |
|
| 194 | + |
| 195 | + @pytest.mark.parametrize('domain_or_ip_target, purpose_of_test, token, key_authorization', [ |
| 196 | + ('integration-testing.open-mpic.org', 'Standard http-01 test', "evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ-PCt92wr-oA", "evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ-PCt92wr-oA.NzbLsXh8uDCcd-6MNwXF4W_7noWXFZAfHkxZsRGC9Xs"), |
| 197 | + ('integration-testing.open-mpic.org', 'Redirect 302 http-01 test', "evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ-PCt92wr-oB", "evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ-PCt92wr-oA.NzbLsXh8uDCcd-6MNwXF4W_7noWXFZAfHkxZsRGC9Xs") |
| 198 | + ]) |
| 199 | + def api_should_return_200_given_valid_http_01_validation(self, api_client, domain_or_ip_target, purpose_of_test, token, key_authorization): |
| 200 | + print(f"Running test for {domain_or_ip_target} ({purpose_of_test})") |
| 201 | + request = MpicDcvRequest( |
| 202 | + domain_or_ip_target=domain_or_ip_target, |
| 203 | + orchestration_parameters=MpicRequestOrchestrationParameters(perspective_count=3, quorum_count=2), |
| 204 | + dcv_check_parameters=DcvCheckParameters( |
| 205 | + validation_details=DcvAcmeHttp01ValidationDetails(key_authorization=key_authorization, token=token) |
| 206 | + ) |
| 207 | + ) |
| 208 | + print("\nRequest:\n", json.dumps(request.model_dump(), indent=4)) # pretty print request body |
| 209 | + response = api_client.post(MPIC_REQUEST_PATH, json.dumps(request.model_dump())) |
| 210 | + assert response.status_code == 200 |
| 211 | + mpic_response = self.mpic_response_adapter.validate_json(response.text) |
| 212 | + |
| 213 | + assert mpic_response.is_valid is True |
| 214 | + |
| 215 | + |
| 216 | + @pytest.mark.parametrize('domain_or_ip_target, purpose_of_test, token, key_authorization', [ |
| 217 | + ('integration-testing.open-mpic.org', 'Failed http-01 test', "evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ-PCt92wr-oA", "evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ-PCt92wr-oA.NzbLsXh8uDCcd-6MNwXF4W_7noWXFZAfHkxZsRGC9Xa"), |
| 218 | + ('integration-testing.open-mpic.org', 'Failed 302 http-01 test', "evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ-PCt92wr-oB", "evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ-PCt92wr-oA.NzbLsXh8uDCcd-6MNwXF4W_7noWXFZAfHkxZsRGC9Xa") |
| 219 | + ]) |
| 220 | + def api_should_return_200_given_invalid_http_01_validation(self, api_client, domain_or_ip_target, purpose_of_test, token, key_authorization): |
| 221 | + print(f"Running test for {domain_or_ip_target} ({purpose_of_test})") |
| 222 | + request = MpicDcvRequest( |
| 223 | + domain_or_ip_target=domain_or_ip_target, |
| 224 | + orchestration_parameters=MpicRequestOrchestrationParameters(perspective_count=3, quorum_count=2), |
| 225 | + dcv_check_parameters=DcvCheckParameters( |
| 226 | + validation_details=DcvAcmeHttp01ValidationDetails(key_authorization=key_authorization, token=token) |
| 227 | + ) |
| 228 | + ) |
| 229 | + print("\nRequest:\n", json.dumps(request.model_dump(), indent=4)) # pretty print request body |
| 230 | + response = api_client.post(MPIC_REQUEST_PATH, json.dumps(request.model_dump())) |
| 231 | + assert response.status_code == 200 |
| 232 | + mpic_response = self.mpic_response_adapter.validate_json(response.text) |
| 233 | + |
| 234 | + assert mpic_response.is_valid is False |
| 235 | + |
| 236 | + @pytest.mark.parametrize('domain_or_ip_target, purpose_of_test, http_token_path, challenge_value', [ |
| 237 | + ('integration-testing.open-mpic.org', 'Valid website change v2 challenge', 'validation-doc.txt', 'test-validation'), |
| 238 | + ('integration-testing.open-mpic.org', 'Valid 302 website change v2 challenge', 'validation-doc-redirect.txt', "test-validation-redirect") |
| 239 | + ]) |
| 240 | + def api_should_return_200_given_valid_website_change_validation(self, api_client, domain_or_ip_target, purpose_of_test, http_token_path, challenge_value): |
| 241 | + print(f"Running test for {domain_or_ip_target} ({purpose_of_test})") |
| 242 | + request = MpicDcvRequest( |
| 243 | + domain_or_ip_target=domain_or_ip_target, |
| 244 | + orchestration_parameters=MpicRequestOrchestrationParameters(perspective_count=3, quorum_count=2), |
| 245 | + dcv_check_parameters=DcvCheckParameters( |
| 246 | + validation_details=DcvWebsiteChangeValidationDetails(http_token_path=http_token_path, |
| 247 | + challenge_value=challenge_value) |
| 248 | + ) |
| 249 | + ) |
| 250 | + print("\nRequest:\n", json.dumps(request.model_dump(), indent=4)) # pretty print request body |
| 251 | + response = api_client.post(MPIC_REQUEST_PATH, json.dumps(request.model_dump())) |
| 252 | + assert response.status_code == 200 |
| 253 | + mpic_response = self.mpic_response_adapter.validate_json(response.text) |
| 254 | + |
| 255 | + assert mpic_response.is_valid is True |
| 256 | + |
194 | 257 | @pytest.mark.parametrize('domain_or_ip_target, dns_record_type, challenge_value, purpose_of_test', [ |
195 | 258 | ('dns-change-txt.integration-testing.open-mpic.org', DnsRecordType.TXT, "1234567890abcdefg.", 'standard TXT dns change'), |
196 | 259 | ('dns-change-cname.integration-testing.open-mpic.org', DnsRecordType.CNAME, "1234567890abcdefg.", 'standard CNAME dns change'), |
|
0 commit comments