Move CSIT to integration/csit repo
[integration/csit.git] / tests / aai / search-data-service / suite1 / test1.robot
1 *** Settings ***
2 Library       OperatingSystem
3 Library       RequestsLibrary
4 Library       requests
5
6 *** Variables ***
7 ${TARGETURL}  https://${HOST_IP}:9509/services/search-data-service/v1/search/indexes/test-index3
8 ${INDEXDATA}  {"fields": [{"name": "Name", "data-type": "string"}, {"name": "Number", "data-type": "long"}]}
9 ${DOCUMENTDATA}  {"Name": "A", "Number": 5}
10
11 *** Test Cases ***
12 Index 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
17 Insert 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
22 Get 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
30 Delete Index Test
31     [Documentation]             Delete the index
32     ${resp}=                    DeleteWithCert           ${TARGETURL}
33     Should Be Equal As Strings  ${resp.status_code}      200
34
35 *** Keywords ***
36 PutWithCert
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
42 PostWithCert
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
48 GetWithCert
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
54 DeleteWithCert
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