blob: 86554a13a4389b2b3edb650f0c16bf71280dcc13 [file] [log] [blame]
Daniel Silverthornd907b912017-08-18 13:24:32 -04001*** Settings ***
2Library OperatingSystem
3Library RequestsLibrary
4Library requests
5
6*** Variables ***
Daniel Silverthornb4a84462017-08-18 16:49:16 -04007${TARGETURL} https://${HOST_IP}:9509/services/search-data-service/v1/search/indexes/test-index3
Daniel Silverthornd907b912017-08-18 13:24:32 -04008${INDEXDATA} {"fields": [{"name": "Name", "data-type": "string"}, {"name": "Number", "data-type": "long"}]}
9${DOCUMENTDATA} {"Name": "A", "Number": 5}
10
11*** Test Cases ***
12Index Create Test
13 [Documentation] Create an index and verify success
14 ${resp}= PutWithCert ${TARGETURL} ${INDEXDATA}
15 Should Be Equal As Strings ${resp.status_code} 201
16
17Insert Document Test
18 [Documentation] Insert a document into the previously created index
19 ${resp}= PutWithCert ${TARGETURL}/documents/testdoc ${DOCUMENTDATA}
20 Should Be Equal As Strings ${resp.status_code} 201
21
22Get Document Test
23 [Documentation] Get the document that was just created
24 ${resp} GetWithCert ${TARGETURL}/documents/testdoc
25 ${content}= Evaluate $resp.json().get('content')
26 ${originaljson}= Evaluate json.loads('${DOCUMENTDATA}') json
27 Should Be Equal As Strings ${resp.status_code} 200
28 Should Be Equal ${content} ${originaljson}
29
30Delete Index Test
31 [Documentation] Delete the index
32 ${resp}= DeleteWithCert ${TARGETURL}
33 Should Be Equal As Strings ${resp.status_code} 200
34
35*** Keywords ***
36PutWithCert
37 [Arguments] ${url} ${data}
38 ${certinfo}= Evaluate ('${CURDIR}/publickey.crt', '${CURDIR}/private.key')
39 ${resp}= Evaluate requests.put('${url}', data='${data}', cert=${certinfo}, verify=False) requests
40 [return] ${resp}
41
42PostWithCert
43 [Arguments] ${url} ${data}
44 ${certinfo}= Evaluate ('${CURDIR}/publickey.crt', '${CURDIR}/private.key')
45 ${resp}= Evaluate requests.post('${url}', data='${data}', cert=${certinfo}, verify=False) requests
46 [return] ${resp}
47
48GetWithCert
49 [Arguments] ${url}
50 ${certinfo}= Evaluate ('${CURDIR}/publickey.crt', '${CURDIR}/private.key')
51 ${resp}= Evaluate requests.get('${url}', cert=${certinfo}, verify=False) requests
52 [return] ${resp}
53
54DeleteWithCert
55 [Arguments] ${url}
56 ${certinfo}= Evaluate ('${CURDIR}/publickey.crt', '${CURDIR}/private.key')
57 ${resp}= Evaluate requests.delete('${url}', cert=${certinfo}, verify=False) requests
58 [return] ${resp}
59