Skip to content

Commit

Permalink
Delete tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-maertens committed Jul 19, 2024
1 parent 6ccb7ba commit 0ede190
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 1,006 deletions.
334 changes: 1 addition & 333 deletions tests/test_dienst_catalogus_creation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from io import StringIO

from django.core.management import CommandError, call_command
from django.test import TestCase

import pytest
Expand All @@ -13,7 +10,6 @@
generate_dienst_catalogus_metadata,
)

from .conftest import EHERKENNING_TEST_CERTIFICATE_FILE, EHERKENNING_TEST_KEY_FILE
from .mixins import EherkenningMetadataMixin

NAMESPACES = {
Expand Down Expand Up @@ -274,7 +270,7 @@ def test_catalogus_with_requested_attributes_without_purpose_statement(
@pytest.mark.django_db
def test_makelaar_oin_is_configurable(eherkenning_config_defaults, temp_private_root):
config = EherkenningConfiguration.get_solo()
config.organisation_name = "Example"
config.organization_name = "Example"
config.service_name = "Example"
config.oin = "00000000000000000000"
config.makelaar_id = "00000000000000000123"
Expand Down Expand Up @@ -679,331 +675,3 @@ def test_no_eidas_service(self):
namespaces=NAMESPACES,
)
self.assertEqual(0, len(classifier_node))


@pytest.mark.django_db
def test_generate_metadata_all_options_specified(temp_private_root):
stdout = StringIO()

call_command(
"generate_eherkenning_dienstcatalogus",
"--no-save-config",
stdout=stdout,
key_file=str(EHERKENNING_TEST_KEY_FILE),
cert_file=str(EHERKENNING_TEST_CERTIFICATE_FILE),
signature_algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256",
digest_algorithm="http://www.w3.org/2001/04/xmlenc#sha256",
entity_id="http://test-entity.id",
base_url="http://test-entity.id",
organization_name="Test Organisation",
eh_attribute_consuming_service_index="9050",
eidas_attribute_consuming_service_index="9051",
oin="00000001112223330000",
service_name="Test Service Name",
service_description="Test Service Description",
makelaar_id="00000003332221110000",
privacy_policy="http://test-privacy.nl",
test=True,
)

output = stdout.getvalue()
service_catalogue_node = etree.XML(output.encode("utf-8"))

signature_algorithm_node = service_catalogue_node.find(
".//ds:SignatureMethod",
namespaces=NAMESPACES,
)
assert (
signature_algorithm_node.attrib["Algorithm"]
== "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
)

digest_algorithm_node = service_catalogue_node.find(
".//ds:DigestMethod",
namespaces=NAMESPACES,
)
assert (
digest_algorithm_node.attrib["Algorithm"]
== "http://www.w3.org/2001/04/xmlenc#sha256"
)

# Service Provider
service_provider_id_node = service_catalogue_node.find(
".//esc:ServiceProviderID",
namespaces=NAMESPACES,
)
assert service_provider_id_node.text == "00000001112223330000"

oganisation_display_node = service_catalogue_node.find(
".//esc:OrganizationDisplayName",
namespaces=NAMESPACES,
)
assert oganisation_display_node.text == "Test Organisation"

# Services
service_definition_nodes = service_catalogue_node.findall(
".//esc:ServiceDefinition",
namespaces=NAMESPACES,
)
assert len(service_definition_nodes) == 2

eherkenning_definition_node, eidas_definition_node = service_definition_nodes

# eHerkenning service definition
uuid_node = eherkenning_definition_node.find(
".//esc:ServiceUUID",
namespaces=NAMESPACES,
)
assert uuid_node is not None

service_name_node = eherkenning_definition_node.find(
".//esc:ServiceName",
namespaces=NAMESPACES,
)
assert service_name_node.text == "Test Service Name"

service_description_node = eherkenning_definition_node.find(
".//esc:ServiceDescription",
namespaces=NAMESPACES,
)
assert service_description_node.text == "Test Service Description"

loa_node = eherkenning_definition_node.find(
".//saml:AuthnContextClassRef",
namespaces=NAMESPACES,
)
assert loa_node.text == "urn:etoegang:core:assurance-class:loa3"

makelaar_id_node = eherkenning_definition_node.find(
".//esc:HerkenningsmakelaarId",
namespaces=NAMESPACES,
)
assert makelaar_id_node.text == "00000003332221110000"

entity_concerned_nodes = eherkenning_definition_node.findall(
".//esc:EntityConcernedTypesAllowed",
namespaces=NAMESPACES,
)
assert len(entity_concerned_nodes) == 3
assert entity_concerned_nodes[0].attrib["setNumber"] == "1"
assert entity_concerned_nodes[0].text == "urn:etoegang:1.9:EntityConcernedID:RSIN"
assert entity_concerned_nodes[1].attrib["setNumber"] == "1"
assert entity_concerned_nodes[1].text == "urn:etoegang:1.9:EntityConcernedID:KvKnr"
assert entity_concerned_nodes[2].attrib["setNumber"] == "2"
assert entity_concerned_nodes[2].text == "urn:etoegang:1.9:EntityConcernedID:KvKnr"

# eIDAS service definition
uuid_node = eidas_definition_node.find(
".//esc:ServiceUUID",
namespaces=NAMESPACES,
)
assert uuid_node is not None

service_name_node = eidas_definition_node.find(
".//esc:ServiceName",
namespaces=NAMESPACES,
)
assert service_name_node.text == "Test Service Name (eIDAS)"

service_description_node = eidas_definition_node.find(
".//esc:ServiceDescription",
namespaces=NAMESPACES,
)
assert service_description_node.text == "Test Service Description"

loa_node = eidas_definition_node.find(
".//saml:AuthnContextClassRef",
namespaces=NAMESPACES,
)
assert loa_node.text == "urn:etoegang:core:assurance-class:loa3"

makelaar_id_node = eidas_definition_node.find(
".//esc:HerkenningsmakelaarId",
namespaces=NAMESPACES,
)
assert makelaar_id_node.text == "00000003332221110000"

entity_concerned_nodes = eidas_definition_node.findall(
".//esc:EntityConcernedTypesAllowed",
namespaces=NAMESPACES,
)
assert len(entity_concerned_nodes) == 1
assert entity_concerned_nodes[0].text == "urn:etoegang:1.9:EntityConcernedID:Pseudo"

# Service instances
service_instance_nodes = service_catalogue_node.findall(
".//esc:ServiceInstance",
namespaces=NAMESPACES,
)
assert len(service_instance_nodes) == 2

eherkenning_instance_node, eidas_instance_node = service_instance_nodes

# Service instance eHerkenning
service_id_node = eherkenning_instance_node.find(
".//esc:ServiceID",
namespaces=NAMESPACES,
)
assert service_id_node.text == "urn:etoegang:DV:00000001112223330000:services:9050"

service_url_node = eherkenning_instance_node.find(
".//esc:ServiceURL",
namespaces=NAMESPACES,
)
assert service_url_node.text == "http://test-entity.id"

privacy_url_node = eherkenning_instance_node.find(
".//esc:PrivacyPolicyURL",
namespaces=NAMESPACES,
)
assert privacy_url_node.text == "http://test-privacy.nl"

makelaar_id_node = eherkenning_instance_node.find(
".//esc:HerkenningsmakelaarId",
namespaces=NAMESPACES,
)
assert makelaar_id_node.text == "00000003332221110000"

key_name_node = eherkenning_instance_node.find(
".//ds:KeyName",
namespaces=NAMESPACES,
)
assert key_name_node is not None
certificate_node = eherkenning_instance_node.find(
".//ds:X509Certificate",
namespaces=NAMESPACES,
)
assert certificate_node is not None

classifier_node = eherkenning_instance_node.findall(
".//esc:Classifier",
namespaces=NAMESPACES,
)
assert len(classifier_node) == 0

# Service instance eIDAS
service_id_node = eidas_instance_node.find(
".//esc:ServiceID",
namespaces=NAMESPACES,
)
assert service_id_node.text == "urn:etoegang:DV:00000001112223330000:services:9051"

service_url_node = eidas_instance_node.find(
".//esc:ServiceURL",
namespaces=NAMESPACES,
)
assert service_url_node.text == "http://test-entity.id"

privacy_url_node = eidas_instance_node.find(
".//esc:PrivacyPolicyURL",
namespaces=NAMESPACES,
)
assert privacy_url_node.text == "http://test-privacy.nl"

makelaar_id_node = eidas_instance_node.find(
".//esc:HerkenningsmakelaarId",
namespaces=NAMESPACES,
)
assert makelaar_id_node.text == "00000003332221110000"

key_name_node = eidas_instance_node.find(
".//ds:KeyName",
namespaces=NAMESPACES,
)
assert key_name_node is not None
certificate_node = eidas_instance_node.find(
".//ds:X509Certificate",
namespaces=NAMESPACES,
)
assert certificate_node is not None

classifier_node = eidas_instance_node.findall(
".//esc:Classifier",
namespaces=NAMESPACES,
)
assert len(classifier_node) == 1
assert classifier_node[0].text == "eIDAS-inbound"


@pytest.mark.django_db
def test_missing_required_properties():
with pytest.raises(CommandError):
call_command("generate_eherkenning_dienstcatalogus")


@pytest.mark.django_db
def test_no_eidas_service(temp_private_root):
stdout = StringIO()

call_command(
"generate_eherkenning_dienstcatalogus",
"--no-save-config",
stdout=stdout,
key_file=str(EHERKENNING_TEST_KEY_FILE),
cert_file=str(EHERKENNING_TEST_CERTIFICATE_FILE),
signature_algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256",
digest_algorithm="http://www.w3.org/2001/04/xmlenc#sha256",
entity_id="http://test-entity.id",
base_url="http://test-entity.id",
organization_name="Test Organisation",
eh_attribute_consuming_service_index="9050",
no_eidas=True,
oin="00000001112223330000",
service_name="Test Service Name",
service_description="Test Service Description",
makelaar_id="00000003332221110000",
privacy_policy="http://test-privacy.nl",
test=True,
)

output = stdout.getvalue()
service_catalogue_node = etree.XML(output.encode("utf-8"))

service_instance_nodes = service_catalogue_node.findall(
".//esc:ServiceInstance",
namespaces=NAMESPACES,
)
assert len(service_instance_nodes) == 1

eherkenning_instance_node = service_instance_nodes[0]
# Service instance eHerkenning
service_id_node = eherkenning_instance_node.find(
".//esc:ServiceID",
namespaces=NAMESPACES,
)
assert service_id_node.text == "urn:etoegang:DV:00000001112223330000:services:9050"

service_url_node = eherkenning_instance_node.find(
".//esc:ServiceURL",
namespaces=NAMESPACES,
)
assert service_url_node.text == "http://test-entity.id"

privacy_url_node = eherkenning_instance_node.find(
".//esc:PrivacyPolicyURL",
namespaces=NAMESPACES,
)
assert privacy_url_node.text == "http://test-privacy.nl"

makelaar_id_node = eherkenning_instance_node.find(
".//esc:HerkenningsmakelaarId",
namespaces=NAMESPACES,
)
assert makelaar_id_node.text == "00000003332221110000"

key_name_node = eherkenning_instance_node.find(
".//ds:KeyName",
namespaces=NAMESPACES,
)
assert key_name_node is not None
certificate_node = eherkenning_instance_node.find(
".//ds:X509Certificate",
namespaces=NAMESPACES,
)
assert certificate_node is not None

classifier_node = eherkenning_instance_node.findall(
".//esc:Classifier",
namespaces=NAMESPACES,
)
assert len(classifier_node) == 0
Loading

0 comments on commit 0ede190

Please sign in to comment.