blob: 8f873fa805c3f6101d1f95e15e43e69c6635239a [file] [log] [blame]
garciaaledce1fa82020-07-22 22:14:08 +00001# Licensed under the Apache License, Version 2.0 (the "License");
2# you may not use this file except in compliance with the License.
3# You may obtain a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS,
9# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10# See the License for the specific language governing permissions and
11# limitations under the License.
12
13*** Variables ***
14${success_return_code} 0
15
16
17*** Keywords ***
18Create Role
19 [Arguments] ${role_name}
20
21 Should Not Be Empty ${role_name}
22 ${rc} ${stdout}= Run and Return RC and Output osm role-create ${role_name}
23 Log ${stdout}
24 Should Be Equal As Integers ${rc} ${success_return_code}
25 [Return] ${stdout}
26
27
28Update Role
29 [Documentation] Updates a role in OSM.
30 ... The extra parameters (like '--add') are given to this function in name=value format. These parameters will be appended to the 'osm role-update' command with the next syntax: --param_name=param_value
31 ... Example of execution:
32 ... Update Role \${role_name} add='vims: true'
33
34 [Arguments] ${role_name} @{optional_parameters}
35
36 ${osm_update_command}= Set Variable osm role-update ${role_name}
37 FOR ${param} IN @{optional_parameters}
38 ${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in optional parameters
39 ${osm_update_command}= Catenate ${osm_update_command} --${param_name}=${param_value}
40 END
41 ${rc} ${stdout}= Run and Return RC and Output ${osm_update_command}
42 log ${stdout}
43 Should Be Equal As Integers ${rc} ${success_return_code}
44
45
46Check If Role Exists
47 [Arguments] ${role_name}
48
49 Should Not Be Empty ${role_name}
50 ${rc} ${stdout}= Run And Return RC And Output osm role-list | awk 'NR>3 {print $2}' | grep "${role_name}"
51 Log ${stdout}
52 Should Be Equal As Integers ${rc} ${success_return_code}
53
54
55Check If User Has Role
56 [Arguments] ${user_name} ${role_name} ${project_name}
57
58 Should Not Be Empty ${user_name}
59 Should Not Be Empty ${role_name}
60 Should Not Be Empty ${project_name}
61 ${rc} ${stdout}= Run And Return RC And Output osm user-show ${user_name} | grep -B1 "role_name" | grep -B1 "${role_name}" | grep "project_name" | grep "${project_name}"
62 Log ${stdout}
63 Should Be Equal As Integers ${rc} ${success_return_code}
64
65
66Delete Role
67 [Arguments] ${role_name}
68
69 ${rc} ${stdout}= Run and Return RC and Output osm role-delete ${role_name}
70 Log ${stdout}
71 Should Be Equal As Integers ${rc} ${success_return_code}