diff --git a/md-query-saml.robot b/md-query-saml.robot index 4ed9b95..3a9aedd 100644 --- a/md-query-saml.robot +++ b/md-query-saml.robot @@ -7,6 +7,13 @@ Library XML Resource MDQ.robot Variables variables.py +*** Keywords *** +Should Have SAML Metadata Content Type Header + [Arguments] ${resp} ${msg}=Response should include Content-Type header set to application/samlmetadata+xml + ${content_type_header}= Get From Dictionary ${resp.headers} Content-Type + # Check for application/samlmetadata+xml content type (with optional charset parameter) + Should Match Regexp ${content_type_header} ^application/samlmetadata\\+xml(;\\s*charset=.+)?$ msg=${msg} + *** Test Cases *** 2.2.1 Unique Identifier ${resp}= Get Entity baseUrl=${BASE_URL} identifier=${ENTITY_ID_ENCODED} @@ -21,16 +28,29 @@ Variables variables.py 3.1.2 One Entity Descriptor Returned ${resp}= Get Entity baseUrl=${BASE_URL} identifier=${ENTITY_ID_ENCODED} + + Should Have SAML Metadata Content Type Header ${resp} msg=MUST set Content-Type to application/samlmetadata+xml + ${root}= Parse XML ${resp.text} + + # The root of the XML document MUST be an EntityDescriptor element. Should Be Equal ${root.tag} EntityDescriptor msg=MUST use EntityDescriptor document element + + # The XML document MUST NOT contain any EntitiesDescriptor elements. Should Not Contain ${resp.text} EntitiesDescriptor msg=MUST NOT use EntitiesDescriptor element - Dictionary Should Contain Item ${resp.headers} content-type application/samlmetadata+xml msg=MUST return Content-Type=application/samlmetadata+xml header 3.1.3 More Than One Entity Descriptor Returned [Tags] aggregate + ${resp}= Get All Entities baseUrl=${BASE_URL} + + Should Have SAML Metadata Content Type Header ${resp} msg=MUST set Content-Type to application/samlmetadata+xml + ${root}= Parse XML ${resp.text} + + # The root of the XML document MUST be an EntitiesDescriptor element. Should Be Equal ${root.tag} EntitiesDescriptor msg=MUST use EntitiesDescriptor document element + + # The XML document MUST NOT contain any other EntitiesDescriptor elements. ${count}= Get Element Count ${root} .//EntitiesDescriptor Should Be Equal As Integers ${count} 0 msg=MUST NOT contain nested EntitiesDescriptor elements - Dictionary Should Contain Item ${resp.headers} content-type application/samlmetadata+xml msg=MUST return Content-Type=application/samlmetadata+xml header