From 2d79658aefb1e5c314f763edc1a336f9b1b88173 Mon Sep 17 00:00:00 2001 From: David Shafer Date: Mon, 29 Oct 2018 10:30:21 -0500 Subject: [PATCH 1/2] Working on conditional requests --- MDQ.robot | 6 +++--- md-query.robot | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/MDQ.robot b/MDQ.robot index db7010d..6adc81d 100644 --- a/MDQ.robot +++ b/MDQ.robot @@ -9,14 +9,14 @@ Get All Entities [Return] ${resp} Get Entity - [Arguments] ${baseUrl} ${identifier} + [Arguments] ${baseUrl} ${identifier} ${headers}= Create Session alias=md url=${baseUrl} debug=1 - ${resp}= Get Request alias=md uri=/entities/${identifier} + ${resp}= Get Request alias=md uri=/entities/${identifier} headers=${headers} [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} + ${resp}= Get Request alias=md uri=entities/${identifier} headers=${headers} [Return] ${resp} diff --git a/md-query.robot b/md-query.robot index 879d398..ab6cac4 100644 --- a/md-query.robot +++ b/md-query.robot @@ -46,8 +46,10 @@ Variables variables.py 4.1 Conditional Retrieval [Tags] optional - Get Entity baseUrl=${BASE_URL} identifier=${ENTITY_ID_ENCODED} ${resp}= Get Entity baseUrl=${BASE_URL} identifier=${ENTITY_ID_ENCODED} + ${etag}= Get From Dictionary ${resp.headers} ETag + &{headers}= Create Dictionary If-None-Match=${etag} + ${resp}= Get Entity baseUrl=${BASE_URL} identifier=${ENTITY_ID_ENCODED} headers=${headers} Should Be Equal As Strings ${resp.status_code} 304 msg=SHOULD return HTTP status code 304 # 4.2 Content Caching From a7f91b1591a45bb384b51def0228d0fd46854096 Mon Sep 17 00:00:00 2001 From: David Shafer Date: Tue, 30 Oct 2018 09:12:59 -0500 Subject: [PATCH 2/2] Fix conditional retrieval --- MDQ.robot | 13 ++++++++++--- md-query.robot | 3 +-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/MDQ.robot b/MDQ.robot index 6adc81d..4115fc5 100644 --- a/MDQ.robot +++ b/MDQ.robot @@ -9,9 +9,9 @@ Get All Entities [Return] ${resp} Get Entity - [Arguments] ${baseUrl} ${identifier} ${headers}= - Create Session alias=md url=${baseUrl} debug=1 - ${resp}= Get Request alias=md uri=/entities/${identifier} headers=${headers} + [Arguments] ${baseUrl} ${identifier} + Create Session alias=md url=${baseUrl} + ${resp}= Get Request alias=md uri=/entities/${identifier} [Return] ${resp} Get Entity With Gzip @@ -20,3 +20,10 @@ Get Entity With Gzip &{headers}= Create Dictionary Accept-Encoding=gzip ${resp}= Get Request alias=md uri=entities/${identifier} headers=${headers} [Return] ${resp} + +Conditional Get Entity + [Arguments] ${baseUrl} ${identifier} ${etag} + &{headers}= Create Dictionary If-None-Match=${etag} + Create Session alias=md url=${baseUrl} + ${resp}= Get Request alias=md uri=/entities/${identifier} headers=${headers} + [Return] ${resp} diff --git a/md-query.robot b/md-query.robot index ab6cac4..8a2b21e 100644 --- a/md-query.robot +++ b/md-query.robot @@ -48,8 +48,7 @@ Variables variables.py [Tags] optional ${resp}= Get Entity baseUrl=${BASE_URL} identifier=${ENTITY_ID_ENCODED} ${etag}= Get From Dictionary ${resp.headers} ETag - &{headers}= Create Dictionary If-None-Match=${etag} - ${resp}= Get Entity baseUrl=${BASE_URL} identifier=${ENTITY_ID_ENCODED} headers=${headers} + ${resp}= Conditional Get Entity baseUrl=${BASE_URL} identifier=${ENTITY_ID_ENCODED} etag=${etag} Should Be Equal As Strings ${resp.status_code} 304 msg=SHOULD return HTTP status code 304 # 4.2 Content Caching