blob: e3241a66e578f96dfe0442dcd728cd8752719304 [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}
garciadeblasf4ebaa82022-06-23 13:33:26 +020025 [Return] ${stdout}
garciaaledce1fa82020-07-22 22:14:08 +000026
27
28Update Role
garciadeblasf4ebaa82022-06-23 13:33:26 +020029 [Documentation] Updates a role in OSM.
garciaaledce1fa82020-07-22 22:14:08 +000030 ... 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:
garciadeblasf4ebaa82022-06-23 13:33:26 +020032 ... Update Role \${role_name} add='vims: true'
garciaaledce1fa82020-07-22 22:14:08 +000033
garciadeblasf4ebaa82022-06-23 13:33:26 +020034 [Arguments] ${role_name} @{optional_parameters}
garciaaledce1fa82020-07-22 22:14:08 +000035
garciadeblasf4ebaa82022-06-23 13:33:26 +020036 ${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}
garciaaledce1fa82020-07-22 22:14:08 +000040 END
garciadeblasf4ebaa82022-06-23 13:33:26 +020041 ${rc} ${stdout}= Run and Return RC and Output ${osm_update_command}
42 log ${stdout}
43 Should Be Equal As Integers ${rc} ${success_return_code}
garciaaledce1fa82020-07-22 22:14:08 +000044
45
46Check If Role Exists
garciadeblasf4ebaa82022-06-23 13:33:26 +020047 [Arguments] ${role_name}
garciaaledce1fa82020-07-22 22:14:08 +000048
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
garciadeblasf4ebaa82022-06-23 13:33:26 +020056 [Arguments] ${user_name} ${role_name} ${project_name}
garciaaledce1fa82020-07-22 22:14:08 +000057
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
garciadeblasf4ebaa82022-06-23 13:33:26 +020067 [Arguments] ${role_name}
garciaaledce1fa82020-07-22 22:14:08 +000068
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}