Skip to content
Permalink
Browse files

Refactor tests

  • Loading branch information
dshafer committed Oct 27, 2018
1 parent cc57aeb commit d3d5dce81408152e00d3c062db25c639f0fe6a72
Showing with 57 additions and 58 deletions.
  1. +2 −0 .gitignore
  2. +5 −6 InCommon.robot
  3. +16 −17 MDQ.robot
  4. +7 −7 md-query-saml.robot
  5. +24 −25 md-query.robot
  6. +3 −3 variables.py → variables.py.example
@@ -1,6 +1,8 @@
*.pyc
__pycache__ __pycache__
.DS_Store .DS_Store
log.html log.html
output.xml output.xml
pip-selfcheck.json pip-selfcheck.json
report.html report.html
variables.py
@@ -1,15 +1,14 @@
*** Settings *** *** Settings ***
Library XML
Resource MDQ.robot Resource MDQ.robot
Variables variables.py Variables variables.py


*** Test Cases *** *** Test Cases ***
URL-Style Entity ID URL-Style Entity ID
[Documentation] GET an entity with a URL-style entityID [Documentation] GET an entity with a URL-style entityID
${resp}= Get uri=/entities/${INC_ENTITY_ID_URL_ENCODED} ${resp}= Get Entity baseUrl=${BASE_URL} identifier=${INC_ENTITY_ID_URL_ENCODED}
Should Be Equal As Strings ${resp.status_code} 200 Should Be Equal As Strings ${resp.status_code} 200


URN-Style Entity ID URN-Style Entity ID
[Documentation] GET an entity with a URN-style entityID [Documentation] GET an entity with a URN-style entityID
${resp}= Get uri=/entities/${INC_ENTITY_ID_URN} ${resp}= Get Entity baseUrl=${BASE_URL} identifier=${INC_ENTITY_ID_URN}
Should Be Equal As Strings ${resp.status_code} 200 Should Be Equal As Strings ${resp.status_code} 200
@@ -2,22 +2,21 @@
Library RequestsLibrary Library RequestsLibrary


*** Keywords *** *** Keywords ***
Get Get All Entities
[Arguments] ${uri} [Arguments] ${baseUrl}
Create Session alias=md url=http://md.sandbox.ti.internet2.edu Create Session alias=md url=${baseUrl}
${resp}= Get Request alias=md uri=${uri} ${resp}= Get Request alias=md uri=entities
[Return] ${resp} [Return] ${resp}


Get With Gzip Get Entity
[Arguments] ${uri} [Arguments] ${baseUrl} ${identifier}
Create Session alias=md url=http://md.sandbox.ti.internet2.edu Create Session alias=md url=${baseUrl} debug=1
&{headers}= Create Dictionary Accept-Encoding=gzip ${resp}= Get Request alias=md uri=/entities/${identifier}
${resp}= Get Request alias=md uri=${uri} headers=&{headers} [Return] ${resp}
[Return] ${resp}


Head Get Entity With Gzip
[Arguments] ${uri} [Arguments] ${baseUrl} ${identifier}
Log ${uri} Create Session alias=md url=${baseUrl}
Create Session alias=md url=http://md.sandbox.ti.internet2.edu &{headers}= Create Dictionary Accept-Encoding=gzip
${resp}= Head Request alias=md uri=${uri} ${resp}= Get Request alias=md uri=entities/${identifier} headers=&{headers}
[Return] ${resp} [Return] ${resp}
@@ -9,28 +9,28 @@ Variables variables.py


*** Test Cases *** *** Test Cases ***
2.2.1 Unique Identifier 2.2.1 Unique Identifier
${resp}= Get uri=entities/${ENTITY_ID_ENCODED} ${resp}= Get Entity baseUrl=${BASE_URL} identifier=${ENTITY_ID_ENCODED}
Should Be Equal As Strings ${resp.status_code} 200 msg=MUST respond to a unique identifier Should Be Equal As Strings ${resp.status_code} 200 msg=MUST respond to a unique identifier


2.2.2 Transformed Identifier 2.2.2 Transformed Identifier
${resp}= Get uri=entities/{sha1}${ENTITY_ID_SHA1} ${resp}= Get Entity baseUrl=${BASE_URL} identifier={sha1}${ENTITY_ID_SHA1}
Should Be Equal As Strings ${resp.status_code} 200 msg=MUST respond to SHA-1 transformed identifier Should Be Equal As Strings ${resp.status_code} 200 msg=MUST respond to SHA-1 transformed identifier


3.1.1 No Entity Descriptors Returned 3.1.1 No Entity Descriptors Returned
${resp}= Get uri=entities/foo ${resp}= Get Entity baseUrl=${BASE_URL} identifier=foo
Should Be Equal As Strings ${resp.status_code} 404 msg=MUST return HTTP status code 404 Should Be Equal As Strings ${resp.status_code} 404 msg=MUST return HTTP status code 404


3.1.2 One Entity Descriptor Returned 3.1.2 One Entity Descriptor Returned
${resp}= Get uri=entities/${ENTITY_ID_ENCODED} ${resp}= Get Entity baseUrl=${BASE_URL} identifier=${ENTITY_ID_ENCODED}
${root}= Parse XML ${resp.text} ${root}= Parse XML ${resp.text}
Should Be Equal ${root.tag} EntityDescriptor msg=MUST use EntityDescriptor document element Should Be Equal ${root.tag} EntityDescriptor msg=MUST use EntityDescriptor document element
Should Not Contain ${resp.text} EntitiesDescriptor msg=MUST NOT use EntitiesDescriptor element 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 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 3.1.3 More Than One Entity Descriptor Returned
[Tags] aggregate [Tags] aggregate
${resp}= Get uri=entities ${resp}= Get All Entities baseUrl=${BASE_URL}
${root}= Parse XML ${resp.text} ${root}= Parse XML ${resp.text}
Should Be Equal ${root.tag} EntitiesDescriptor msg=MUST use EntitiesDescriptor document element Should Be Equal ${root.tag} EntitiesDescriptor msg=MUST use EntitiesDescriptor document element
${count}= Get Element Count ${root} .//EntitiesDescriptor ${count}= Get Element Count ${root} .//EntitiesDescriptor
Should Be Equal As Integers ${count} 0 msg=MUST NOT contain nested EntitiesDescriptor elements Should Be Equal As Integers ${count} 0 msg=MUST NOT contain nested EntitiesDescriptor elements
@@ -10,50 +10,49 @@ Variables variables.py
2.2.1 HTTP Version (Required) 2.2.1 HTTP Version (Required)
# Using curl because the Requests library doesn't let us specify HTTP version # Using curl because the Requests library doesn't let us specify HTTP version


${Curl} Run Process /usr/bin/curl --http1.0 -i ${BASE_URL}entities/${ENTITY_ID_ENCODED} |head -n 1 shell=true ${Curl} Run Process /usr/bin/curl --http1.0 -i ${BASE_URL}/entities/${ENTITY_ID_ENCODED} |head -n 1 shell=true
Should Contain ${Curl.stdout} 505 HTTP Version Not Supported msg=MUST NOT support HTTP versions prior to 1.1 Should Contain ${Curl.stdout} 505 msg=MUST NOT support HTTP versions prior to 1.1


${Curl} Run Process /usr/bin/curl --http1.1 -i ${BASE_URL}entities/${ENTITY_ID_ENCODED} |head -n 1 shell=true ${Curl} Run Process /usr/bin/curl --http1.1 -i ${BASE_URL}/entities/${ENTITY_ID_ENCODED} |head -n 1 shell=true
Should Contain ${Curl.stdout} 200 OK msg=MUST support HTTP version 1.1 Should Contain ${Curl.stdout} 200 OK msg=MUST support HTTP version 1.1


2.2.2 HTTP Version (Optional) 2.2.2 HTTP Version (Optional)
[Tags] optional [Tags] optional
${Curl} Run Process /usr/bin/curl --http2 -i ${BASE_URL}/entities/${ENTITY_ID_ENCODED} |head -n 1 shell=true
${Curl} Run Process /usr/bin/curl --http2 -i ${BASE_URL}entities/${ENTITY_ID_ENCODED} |head -n 1 shell=true Should Contain ${Curl.stdout} 200 OK msg=MAY support HTTP versions later than 1.1
Should Contain ${Curl.stdout} 200 OK msg=MAY support HTTP versions later than 1.1


2.5 Response Headers (Required) 2.5 Response Headers (Required)
# Content-Encoding # Content-Encoding
${resp}= Get With Gzip uri=entities/${ENTITY_ID_ENCODED} ${resp}= Get Entity With Gzip baseUrl=${BASE_URL} identifier=${ENTITY_ID_ENCODED}
Dictionary Should Contain Key ${resp.headers} content-encoding msg=MUST return Content-Encoding header if compressed Dictionary Should Contain Key ${resp.headers} content-encoding msg=MUST return Content-Encoding header if compressed
# Content-Type # Content-Type
${resp}= Get uri=entities/${ENTITY_ID_ENCODED} ${resp}= Get Entity baseUrl=${BASE_URL} identifier=${ENTITY_ID_ENCODED}
Dictionary Should Contain Key ${resp.headers} content-type msg=MUST return Content-Type header Dictionary Should Contain Key ${resp.headers} content-type msg=MUST return Content-Type header
# ETag # ETag
${resp}= Get uri=entities/${ENTITY_ID_ENCODED} ${resp}= Get Entity baseUrl=${BASE_URL} identifier=${ENTITY_ID_ENCODED}
Dictionary Should Contain Key ${resp.headers} etag msg=MUST return ETag header Dictionary Should Contain Key ${resp.headers} etag msg=MUST return ETag header


2.5 Response Headers (Optional) 2.5 Response Headers (Optional)
[Tags] optional [Tags] optional
#Cache-Control #Cache-Control
${resp}= Get uri=entities/${ENTITY_ID_ENCODED} ${resp}= Get Entity baseUrl=${BASE_URL} identifier=${ENTITY_ID_ENCODED}
Dictionary Should Contain Key ${resp.headers} cache-control msg=SHOULD return Cache-Control header Dictionary Should Contain Key ${resp.headers} cache-control msg=SHOULD return Cache-Control header
# Content-Length # Content-Length
${resp}= Get uri=entities/${ENTITY_ID_ENCODED} ${resp}= Get Entity baseUrl=${BASE_URL} identifier=${ENTITY_ID_ENCODED}
Dictionary Should Contain Key ${resp.headers} content-length msg=SHOULD return Content-Length header Dictionary Should Contain Key ${resp.headers} content-length msg=SHOULD return Content-Length header
# Last-Modified # Last-Modified
${resp}= Get uri=entities/${ENTITY_ID_ENCODED} ${resp}= Get Entity baseUrl=${BASE_URL} identifier=${ENTITY_ID_ENCODED}
Dictionary Should Contain Key ${resp.headers} last-modified msg=SHOULD return Last-Modified header Dictionary Should Contain Key ${resp.headers} last-modified msg=SHOULD return Last-Modified header


4.1 Conditional Retrieval 4.1 Conditional Retrieval
[Tags] optional [Tags] optional
Get uri=entities/${ENTITY_ID_ENCODED} Get Entity baseUrl=${BASE_URL} identifier=${ENTITY_ID_ENCODED}
${resp}= Get uri=/entities/${ENTITY_ID_ENCODED} ${resp}= Get Entity baseUrl=${BASE_URL} identifier=${ENTITY_ID_ENCODED}
Should Be Equal As Strings ${resp.status_code} 304 msg=SHOULD return HTTP status code 304 Should Be Equal As Strings ${resp.status_code} 304 msg=SHOULD return HTTP status code 304


# 4.2 Content Caching # 4.2 Content Caching


4.3 Content Compression 4.3 Content Compression
${resp}= Get With Gzip uri=entities/${ENTITY_ID_ENCODED} ${resp}= Get Entity With Gzip baseUrl=${BASE_URL} identifier=${ENTITY_ID_ENCODED}
Should Be Equal As Strings ${resp.status_code} 200 msg=MUST support gzip compression Should Be Equal As Strings ${resp.status_code} 200 msg=MUST support gzip compression
Dictionary Should Contain Item ${resp.headers} content-encoding gzip msg=MUST support gzip compression Dictionary Should Contain Item ${resp.headers} content-encoding gzip msg=MUST support gzip compression
@@ -1,6 +1,6 @@
# Base Metadata Query server URL # Base Metadata Query server URL (without trailing "/")
# Example: https://example.org/md/ # Example: https://example.org/md
BASE_URL = "http://md.sandbox.ti.internet2.edu/" BASE_URL = "http://md.sandbox.ti.internet2.edu"


# Any known existing entityID # Any known existing entityID
ENTITY_ID = "urn:mace:incommon:internet2.edu" ENTITY_ID = "urn:mace:incommon:internet2.edu"

0 comments on commit d3d5dce

Please sign in to comment.
You can’t perform that action at this time.