Subscriptions.robot 6.64 KB
Newer Older
1
2
*** Settings ***
Library           JSONSchemaLibrary    schemas/
3
Resource          environment/variables.txt    # Generic Parameters
4
5
Resource          environment/subscriptions.txt
Library           OperatingSystem
6
Library           JSONLibrary
7
Library           REST    ${NFVO_SCHEMA}://${NFVO_HOST}:${NFVO_PORT}
8
9
10
11

*** Test Cases ***
GET Subscription
    Log    Trying to get the list of subscriptions
12
13
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
14
    GET    ${apiRoot}/${apiName}/${apiVersion}/subscriptions
15
    Integer    response status    200
16
    Log    Received a 200 OK as expected
17
18
19
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    ${CONTENT_TYPE_JSON}
    ${result}=    Output    response body
Elian Kraja's avatar
Elian Kraja committed
20
    Validate Json    PkgmSubscriptions.schema.json    ${result}
21
22
23
24
    Log    Validated PkgmSubscription schema

GET Subscription - Filter
    Log    Trying to get the list of subscriptions using filters
25
26
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
27
    GET    ${apiRoot}/${apiName}/${apiVersion}/subscriptions?${filter_ok}
28
    Integer    response status    200
29
    Log    Received a 200 OK as expected
30
31
32
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    ${CONTENT_TYPE_JSON}
    ${result}=    Output    response body
Elian Kraja's avatar
Elian Kraja committed
33
    Validate Json    PkgmSubscriptions.schema.json    ${result}
34
35
36
37
    Log    Validated PkgmSubscription schema

GET Subscription - Negative Filter
    Log    Trying to get the list of subscriptions using filters with wrong attribute name
38
39
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
40
    GET    ${apiRoot}/${apiName}/${apiVersion}/subscriptions?${filter_ko}
41
    Integer    response status    400
42
    Log    Received a 400 Bad Request as expected
43
44
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    ${CONTENT_TYPE_JSON}
45
    Log    Trying to validate ProblemDetails
46
    ${problemDetails}=    Output    response body
Elian Kraja's avatar
Elian Kraja committed
47
    Validate Json    ProblemDetails.schema.json    ${problemDetails}
48
49
50
51
    Log    Validation OK

GET Subscription - Negative (Not Found)
    Log    Trying to perform a request on a Uri which doesn't exist
52
53
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
54
    GET    ${apiRoot}/${apiName}/${apiVersion}/subscription
55
    Integer    response status    404
56
    Log    Received 404 Not Found as expected
57
58
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    ${CONTENT_TYPE_JSON}
59
    Log    Trying to validate ProblemDetails
60
    ${problemDetails}=    Output    response body
Elian Kraja's avatar
Elian Kraja committed
61
    Validate Json    ProblemDetails.schema.json    ${problemDetails}
62
63
64
65
    Log    Validation OK

POST Subscription
    Log    Trying to create a new subscription
66
67
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
Elian Kraja's avatar
Elian Kraja committed
68
    ${body}=    Get File    jsons/subscriptions.json
69
70
71
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
    POST    ${apiRoot}/${apiName}/${apiVersion}/subscriptions    ${body}
    Integer    response status    201
72
    Log    Received 201 Created as expected
73
74
    ${headers}=    Output    response headers
    Should Contain    ${headers}    Location
75
    Log    Response has header Location
76
    ${result}=    Output    response body
Elian Kraja's avatar
Elian Kraja committed
77
    Validate Json    PkgmSubscription.schema.json    ${result}
78
79
80
81
    Log    Validation of PkgmSubscription OK

POST Subscription - DUPLICATION
    Log    Trying to create a subscription with an already created content
82
83
84
    Pass Execution If    ${NFVO_DUPLICATION} == 0    NFVO is not permitting duplication. Skipping the test
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
Elian Kraja's avatar
Elian Kraja committed
85
    ${body}=    Get File    jsons/subscriptions.json
86
87
88
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
    POST    ${apiRoot}/${apiName}/${apiVersion}/subscriptions    ${body}
    Integer    response status    201
89
    Log    Received 201 Created as expected
90
91
    ${headers}=    Output    response headers
    Should Contain    ${headers}    Location
92
    Log    Response has header Location
93
    ${result}=    Output    response body
Elian Kraja's avatar
Elian Kraja committed
94
    Validate Json    PkgmSubscription.schema.json    ${result}
95
96
97
98
    Log    Validation of PkgmSubscription OK

POST Subscription - NO DUPLICATION
    Log    Trying to create a subscription with an already created content
99
100
101
    Pass Execution If    ${NFVO_DUPLICATION} == 1    NFVO is permitting duplication. Skipping the test
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
Elian Kraja's avatar
Elian Kraja committed
102
    ${body}=    Get File    jsons/subscriptions.json
103
104
105
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
    POST    ${apiRoot}/${apiName}/${apiVersion}/subscriptions    ${body}
    Integer    response status    303
106
    Log    Received 303 See Other as expected
107
108
    ${headers}=    Output    response headers
    Should Contain    ${headers}    Location
109
110
111
112
    Log    Response header contains Location

PUT Subscription - (Method not implemented)
    Log    Trying to perform a PUT. This method should not be implemented
113
114
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
115
    PUT    ${apiRoot}/${apiName}/${apiVersion}/subscriptions
116
    Integer    response status    405
117
118
119
120
    Log    Received 405 Method not implemented as expected

PATCH Subscription - (Method not implemented)
    Log    Trying to perform a PATCH. This method should not be implemented
121
122
123
124
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
    PATCH    ${apiRoot}/${apiName}/${apiVersion}/subscriptions
    Integer    response status    405
125
126
127
128
    Log    Received 405 Method not implemented as expected

DELETE Subscription - (Method not implemented)
    Log    Trying to perform a DELETE. This method should not be implemented
129
130
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
131
    DELETE    ${apiRoot}/${apiName}/${apiVersion}/subscriptions
132
    Integer    response status    405
133
    Log    Received 405 Method not implemented as expected