Newer
Older
*** Settings ***
Library JSONSchemaLibrary schemas/
Library BuiltIn
Library REST ${AMS_SCHEMA}://${AMS_HOST}:${AMS_PORT} ssl_verify=false
Library OperatingSystem
*** Variables ***
${response}
*** Keywords ***
Check HTTP Response Status Code Is
[Arguments] ${expected_status}
${status}= Convert To Integer ${expected_status}
Should Be Equal ${response['status']} ${status}
Log Status code validated
Check HTTP Response Body Json Schema Is
[Arguments] ${input}
Should Contain ${response['headers']['Content-Type']} application/json
${schema} = Catenate SEPARATOR= ${input} .schema.json
Validate Json ${schema} ${response['body']}
Log Json Schema Validation OK
Should Be Present In Json List
[Arguments] ${expr} ${json_field} ${json_value}
Log Check if ${json_field} is present in ${expr} with the value ${jsonvalue}
:FOR ${item} IN @{expr}
\ Exit For Loop If "${item['${json_field}']}" == "${json_value}"
Log Item found ${item}
[return] ${item}

Elian Kraja
committed

Elian Kraja
committed
[Arguments] ${source} ${parameter} ${value}
Should Be Present In Json List ${source} ${parameter} ${value}
Check ProblemDetails
[Arguments] ${expected_status}
${status}= Convert To Integer ${expected_status}
Should Be Equal ${response['body']['problemDetails']['status']} ${status}
Log ProblemDetails Status code validated
Check HTTP Response Header Contains
[Arguments] ${HEADER_TOCHECK}
Should Contain ${response['headers']} ${HEADER_TOCHECK}
Log Header is present
Check HTTP Response Body is Empty
Should Be Empty ${response['body']}
Log Body is empty
Check HTTP Response Contain Header with value
[Arguments] ${HEADER_TOCHECK} ${VALUE}
Check HTTP Response Header Contains ${HEADER_TOCHECK}
Should Be Equal As Strings ${value} ${response['headers']['Content-Type']}
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
vGET
[Arguments] ${uri}
Set Headers {"Accept":"application/json"}
Set Headers {"Content-Type":"application/json"}
Set Headers {"Authorization":"${TOKEN}"}
GET ${uri}
${output}= Output response
Set Suite Variable ${response} ${output}
vPOST
[Arguments] ${uri} ${content}
${file}= Catenate SEPARATOR= json/ ${content} .json
${body}= Get File ${file}
Set Headers {"Accept":"application/json"}
Set Headers {"Content-Type":"application/json"}
Set Headers {"Authorization":"${TOKEN}"}
POST ${uri} ${body}
${output}= Output response
Set Suite Variable ${response} ${output}
vPUT
[Arguments] ${uri} ${content}
${file}= Catenate SEPARATOR= json/ ${content} .json
${body}= Get File ${file}
# Retrieve the e-tag value to ensure a proper update.
vGET ${uri}
Set Headers {"If-Match":"${response['headers']['If-Match']}"}
Set Headers {"Accept":"application/json"}
Set Headers {"Content-Type":"application/json"}
Set Headers {"Authorization":"${TOKEN}"}
PUT ${uri} ${body}
${output}= Output response
Set Suite Variable ${response} ${output}
vPUT without e-tag
[Arguments] ${uri} ${content}
${file}= Catenate SEPARATOR= json/ ${content} .json
${body}= Get File ${file}
Set Headers {"Accept":"application/json"}
Set Headers {"Content-Type":"application/json"}
Set Headers {"Authorization":"${TOKEN}"}
PUT ${uri} ${body}
${output}= Output response
Set Suite Variable ${response} ${output}
vPUT invalid e-tag
[Arguments] ${uri} ${content}
${file}= Catenate SEPARATOR= json/ ${content} .json
${body}= Get File ${file}
Set Headers {"Accept":"application/json"}
Set Headers {"Content-Type":"application/json"}
Set Headers {"Authorization":"${TOKEN}"}
Set Headers {"If-Match":"__some_invalid_value__"}
PUT ${uri} ${body}
${output}= Output response
Set Suite Variable ${response} ${output}
vDELETE
[Arguments] ${uri}
# Retrieve the e-tag value to ensure a proper delete.
vGET ${uri}
Set Headers {"If-Match":"${response['headers']['If-Match']}"}
Set Headers {"Accept":"application/json"}
Set Headers {"Content-Type":"application/json"}
Set Headers {"Authorization":"${TOKEN}"}
DELETE ${uri}
${output}= Output response
Set Suite Variable ${response} ${output}
vDELETE without e-tag
[Arguments] ${uri}
Set Headers {"Accept":"application/json"}
Set Headers {"Content-Type":"application/json"}
Set Headers {"Authorization":"${TOKEN}"}
DELETE ${uri}
${output}= Output response
Set Suite Variable ${response} ${output}
vDELETE invalid e-tag
[Arguments] ${uri}
Set Headers {"Accept":"application/json"}
Set Headers {"Content-Type":"application/json"}
Set Headers {"Authorization":"${TOKEN}"}
Set Headers {"If-Match":"__some_invalid_value__"}
DELETE ${uri}
${output}= Output response
Set Suite Variable ${response} ${output}