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__
.DS_Store
log.html
output.xml
pip-selfcheck.json
report.html
variables.py
@@ -1,15 +1,14 @@
*** Settings ***
Library XML
Resource MDQ.robot
Variables variables.py

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

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

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

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

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

*** Test Cases ***
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

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

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

3.1.2 One Entity Descriptor Returned
${resp}= Get uri=entities/${ENTITY_ID_ENCODED}
${root}= Parse XML ${resp.text}
${resp}= Get Entity baseUrl=${BASE_URL} identifier=${ENTITY_ID_ENCODED}
${root}= Parse XML ${resp.text}
Should Be Equal ${root.tag} EntityDescriptor msg=MUST use EntityDescriptor document 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

3.1.3 More Than One Entity Descriptor Returned
[Tags] aggregate
${resp}= Get uri=entities
${root}= Parse XML ${resp.text}
${resp}= Get All Entities baseUrl=${BASE_URL}
${root}= Parse XML ${resp.text}
Should Be Equal ${root.tag} EntitiesDescriptor msg=MUST use EntitiesDescriptor document element
${count}= Get Element Count ${root} .//EntitiesDescriptor
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)
# 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
Should Contain ${Curl.stdout} 505 HTTP Version Not Supported msg=MUST NOT support HTTP versions prior to 1.1
${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 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
Should Contain ${Curl.stdout} 200 OK msg=MUST support HTTP version 1.1
${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

2.2.2 HTTP Version (Optional)
[Tags] optional
${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
[Tags] optional
${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

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

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

4.1 Conditional Retrieval
[Tags] optional
Get uri=entities/${ENTITY_ID_ENCODED}
${resp}= Get uri=/entities/${ENTITY_ID_ENCODED}
Get Entity baseUrl=${BASE_URL} identifier=${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

# 4.2 Content Caching

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

# Any known existing entityID
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.