Remove regression tag from disabled daily tests
[osm/tests.git] / robot-systest / deprecated / lib / cli / rbac_lib.robot
1 ##
2 # Copyright 2019 Tech Mahindra Limited
3 #
4 # All Rights Reserved.
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License"); you may
7 # not use this file except in compliance with the License. You may obtain
8 # a copy of the License at
9 #
10 #         http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 # License for the specific language governing permissions and limitations
16 # under the License.
17 ##
18
19 ## Change log:
20 # 1. Jayant Madavi, Mrityunjay Yadav : MY00514913@techmahindra.com : 21-nov-2019
21 ##
22
23 *** Keywords ***
24 Configure NBI For RBAC
25     ${rc}   ${stdout}=      Run and Return RC and Output    docker service update osm_nbi --force --env-add OSMNBI_AUTHENTICATION_BACKEND=keystone --env-add OSMNBI_AUTHENTICATION_AUTH_URL=keystone --env-add OSMNBI_AUTHENTICATION_AUTH_PORT=5000 --env-add OSMNBI_AUTHENTICATION_USER_DOMAIN_NAME=default --env-add OSMNBI_AUTHENTICATION_PROJECT_DOMAIN_NAME=default --env-add OSMNBI_AUTHENTICATION_SERVICE_USERNAME=nbi --env-add OSMNBI_AUTHENTICATION_SERVICE_PROJECT=service
26     Should Be Equal As Integers         ${rc}     ${success_return_code}
27     Sleep    30s    Wait for NBI service to be update
28
29
30 Create User
31     [Arguments]  ${user}    ${password}
32
33     ${rc}   ${stdout}=      Run and Return RC and Output    osm user-create ${user} --password ${password}
34     Should Be Equal As Integers         ${rc}     ${success_return_code}
35     log     ${stdout}
36     [Return]    ${stdout}
37
38
39 List User
40     ${rc}   ${stdout}=      Run and Return RC and Output    osm user-list
41     Should Be Equal As Integers         ${rc}     ${success_return_code}
42     log     ${stdout}
43     [Return]    ${stdout}
44
45
46 List User And Check For The Created User
47     [Arguments]  ${user}
48     ${user list}=    List User
49     Should Contain    ${user list}    ${user}
50
51
52 Get User Info By Name
53     [Arguments]  ${user_name}
54     ${rc}   ${stdout}=      Run and Return RC and Output    osm user-show ${user_name}
55     Should Be Equal As Integers         ${rc}     ${success_return_code}
56     log     ${stdout}
57
58
59 Get User Info By ID
60     [Arguments]  ${user_id}
61     ${rc}   ${stdout}=      Run and Return RC and Output    osm user-show ${user_id}
62     Should Be Equal As Integers         ${rc}     ${success_return_code}
63     log     ${stdout}
64
65
66 Update User
67     [Arguments]  ${user}    ${field}    ${value}
68     ${rc}   ${stdout}=      Run and Return RC and Output    osm user-update ${field} ${value} ${user}
69     Should Be Equal As Integers         ${rc}     ${success_return_code}
70     log     ${stdout}
71
72
73 Update User And Verify Info
74     [Arguments]    ${user}  @{args}
75     FOR    ${arg}    IN    @{args}
76         ${fields}=    Get Dictionary Items    ${arg}
77         Update User    ${user}    ${fields[0]}    ${fields[1]}
78     END
79     ${rc}   ${stdout}=      Run and Return RC and Output    osm user-show ${user}
80     Should Be Equal As Integers         ${rc}     ${success_return_code}
81     log     ${stdout}
82
83
84 Login With User And Perform Operation
85     [Arguments]  ${user}    ${password}    ${project}
86     ${rc}   ${stdout}=      Run and Return RC and Output    export OSM_USER=${user}
87     Should Be Equal As Integers         ${rc}     ${success_return_code}
88     ${rc}   ${stdout}=      Run and Return RC and Output    export OSM_PROJECT=${project}
89     Should Be Equal As Integers         ${rc}     ${success_return_code}
90     ${rc}   ${stdout}=      Run and Return RC and Output    export OSM_PASSWORD=${password}
91     Should Be Equal As Integers         ${rc}     ${success_return_code}
92     ${rc}   ${stdout}=      Run and Return RC and Output    osm ns-list
93     Should Be Equal As Integers         ${rc}     ${success_return_code}
94     log    ${stdout}
95     Logout and Login With Admin
96
97
98 Logout and Login With Admin
99     ${rc}   ${stdout}=      Run and Return RC and Output    export OSM_USER=admin
100     Should Be Equal As Integers         ${rc}     ${success_return_code}
101     ${rc}   ${stdout}=      Run and Return RC and Output    export OSM_PASSWORD=admin
102     Should Be Equal As Integers         ${rc}     ${success_return_code}
103     ${rc}   ${stdout}=      Run and Return RC and Output    osm ns-list
104     Should Be Equal As Integers         ${rc}     ${success_return_code}
105
106
107 Delete User
108     [Arguments]  ${user}
109     ${rc}   ${stdout}=      Run and Return RC and Output    osm user-delete ${user}
110     Should Be Equal As Integers         ${rc}     ${success_return_code}
111
112
113 Delete User And Check
114     [Arguments]  ${user}
115     Delete User    ${user}
116     ${rc}   ${stdout}=      Run and Return RC and Output    osm user-list
117     Should Be Equal As Integers         ${rc}     ${success_return_code}
118     Should Not Contain      ${stdout}   ${user}
119
120
121 Create Project
122     [Arguments]  ${project}
123     ${rc}   ${stdout}=      Run and Return RC and Output    osm project-create ${project}
124     Should Be Equal As Integers         ${rc}     ${success_return_code}
125     log  ${stdout}
126     [Return]  ${stdout}
127
128
129 List Project
130     ${rc}   ${stdout}=      Run and Return RC and Output    osm project-list
131     Should Be Equal As Integers         ${rc}     ${success_return_code}
132     log  ${stdout}
133     [Return]  ${stdout}
134
135
136 List Project And Verify
137     [Arguments]  ${project}
138     ${project list}=    List Project
139     Should Contain    ${project list}    ${project}
140
141
142 Get Project Info By Name
143     [Arguments]  ${project_name}
144     ${rc}   ${stdout}=      Run and Return RC and Output    osm project-show ${project_name}
145     Should Be Equal As Integers         ${rc}     ${success_return_code}
146     log  ${stdout}
147     [Return]  ${stdout}
148
149
150 Get Project Info By ID
151     [Arguments]  ${project_id}
152     ${rc}   ${stdout}=      Run and Return RC and Output    osm project-show ${project_id}
153     Should Be Equal As Integers         ${rc}     ${success_return_code}
154     log  ${stdout}
155     [Return]  ${stdout}
156
157
158 Update Project
159     [Arguments]  ${project}    ${feild}    ${value}
160     ${rc}   ${stdout}=      Run and Return RC and Output    osm project-update ${feild} ${value} ${project}
161     Should Be Equal As Integers         ${rc}     ${success_return_code}
162     log  ${stdout}
163
164
165 Update Project Name And Verify
166     [Arguments]  ${old_name}    ${new_name}
167     Update Project    ${old_name}    --name    ${new_name}
168     List Project And Verify    ${new_name}
169
170
171 Delete Project
172     [Arguments]  ${project}
173     ${rc}   ${stdout}=      Run and Return RC and Output    osm project-delete ${project}
174     Should Be Equal As Integers         ${rc}     ${success_return_code}
175
176
177 Delete Project And Verify
178     [Arguments]  ${project}
179     Delete Project    ${project}
180     ${project_list}=    List Project
181     Should Not Contain    ${project_list}    ${project}
182
183
184 Create Role
185     [Arguments]  ${role}
186     ${rc}   ${stdout}=      Run and Return RC and Output    osm role-create ${role}
187     Should Be Equal As Integers         ${rc}     ${success_return_code}
188     log  ${stdout}
189     [Return]  ${stdout}
190
191
192 List Roles
193     ${rc}   ${stdout}=      Run and Return RC and Output    osm role-list
194     Should Be Equal As Integers         ${rc}     ${success_return_code}
195     log  ${stdout}
196     [Return]  ${stdout}
197
198
199 List Roles And Verify
200     [Arguments]  ${role}
201     ${role_list}=    List Roles
202     Should Contain    ${role_list}    ${role}
203
204
205 Get Role Info By Name
206     [Arguments]  ${role}
207     ${rc}   ${stdout}=      Run and Return RC and Output    osm role-show ${role}
208     Should Be Equal As Integers         ${rc}     ${success_return_code}
209     log  ${stdout}
210     [Return]  ${stdout}
211
212
213 Get Role Info By ID
214     [Arguments]  ${role_id}
215     ${rc}   ${stdout}=      Run and Return RC and Output    osm role-show ${role_id}
216     Should Be Equal As Integers         ${rc}     ${success_return_code}
217     log  ${stdout}
218     [Return]  ${stdout}
219
220
221 Update Role
222     [Arguments]  ${role}    ${feild}    ${value}
223     ${rc}   ${stdout}=      Run and Return RC and Output    osm role-update ${feild} ${value} ${role}
224     Should Be Equal As Integers         ${rc}     ${success_return_code}
225     log  ${stdout}
226
227
228 Add Role And Verify
229     [Arguments]  ${role}    ${role_to_add}
230     Update Role    ${role}    --add    ${role_to_add}
231     ${role_info}=    Get Role Info By Name    ${role}
232 #    Should Contain    ${role_info}    ${role_to_add}
233
234
235 Delete Role
236     [Arguments]  ${role}
237     ${rc}   ${stdout}=      Run and Return RC and Output    osm role-delete ${role}
238     Should Be Equal As Integers         ${rc}     ${success_return_code}
239
240
241 Delete Role And Verify
242     [Arguments]  ${role}
243     Delete Role    ${role}
244     ${role_list}=    List Roles
245     Should Not Contain    ${role_list}    ${role}