| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 1 | *** Comments *** |
| garciaale | dce1fa8 | 2020-07-22 22:14:08 +0000 | [diff] [blame] | 2 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | # you may not use this file except in compliance with the License. |
| 4 | # You may obtain a copy of the License at |
| 5 | # |
| 6 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | # |
| 8 | # Unless required by applicable law or agreed to in writing, software |
| 9 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | # See the License for the specific language governing permissions and |
| 12 | # limitations under the License. |
| 13 | |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 14 | |
| 15 | *** Settings *** |
| 16 | Documentation Library providing keywords for CRUD operations over roles with OSM client. |
| 17 | Library OperatingSystem |
| 18 | |
| 19 | |
| garciaale | dce1fa8 | 2020-07-22 22:14:08 +0000 | [diff] [blame] | 20 | *** Variables *** |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 21 | ${SUCCESS_RETURN_CODE} 0 |
| garciaale | dce1fa8 | 2020-07-22 22:14:08 +0000 | [diff] [blame] | 22 | |
| 23 | |
| 24 | *** Keywords *** |
| 25 | Create Role |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 26 | [Documentation] Create a role in OSM with the name passed as argument, and return the role id. |
| garciaale | dce1fa8 | 2020-07-22 22:14:08 +0000 | [diff] [blame] | 27 | [Arguments] ${role_name} |
| garciaale | dce1fa8 | 2020-07-22 22:14:08 +0000 | [diff] [blame] | 28 | Should Not Be Empty ${role_name} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 29 | ${rc} ${stdout}= Run And Return Rc And Output osm role-create ${role_name} |
| garciaale | dce1fa8 | 2020-07-22 22:14:08 +0000 | [diff] [blame] | 30 | Log ${stdout} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 31 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| 32 | RETURN ${stdout} |
| garciaale | dce1fa8 | 2020-07-22 22:14:08 +0000 | [diff] [blame] | 33 | |
| 34 | Update Role |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 35 | [Documentation] Update a role in OSM. |
| garciaale | dce1fa8 | 2020-07-22 22:14:08 +0000 | [diff] [blame] | 36 | ... 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 |
| 37 | ... Example of execution: |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 38 | ... Update Role \${role_name} add='vims: true' |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 39 | [Arguments] ${role_name} @{optional_parameters} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 40 | ${osm_update_command}= Set Variable osm role-update ${role_name} |
| 41 | FOR ${param} IN @{optional_parameters} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 42 | ${match} ${param_name} ${param_value}= Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in optional parameters |
| 43 | Log ${match},${param_name},${param_value} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 44 | ${osm_update_command}= Catenate ${osm_update_command} --${param_name}=${param_value} |
| garciaale | dce1fa8 | 2020-07-22 22:14:08 +0000 | [diff] [blame] | 45 | END |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 46 | ${rc} ${stdout}= Run And Return Rc And Output ${osm_update_command} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 47 | Log ${stdout} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 48 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| garciaale | dce1fa8 | 2020-07-22 22:14:08 +0000 | [diff] [blame] | 49 | |
| 50 | Check If Role Exists |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 51 | [Documentation] Check if a role exists in OSM. |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 52 | [Arguments] ${role_name} |
| garciaale | dce1fa8 | 2020-07-22 22:14:08 +0000 | [diff] [blame] | 53 | Should Not Be Empty ${role_name} |
| 54 | ${rc} ${stdout}= Run And Return RC And Output osm role-list | awk 'NR>3 {print $2}' | grep "${role_name}" |
| 55 | Log ${stdout} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 56 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| garciaale | dce1fa8 | 2020-07-22 22:14:08 +0000 | [diff] [blame] | 57 | |
| 58 | Check If User Has Role |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 59 | [Documentation] Check if a user has a role in a specific project in OSM. |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 60 | [Arguments] ${user_name} ${role_name} ${project_name} |
| garciaale | dce1fa8 | 2020-07-22 22:14:08 +0000 | [diff] [blame] | 61 | Should Not Be Empty ${user_name} |
| 62 | Should Not Be Empty ${role_name} |
| 63 | Should Not Be Empty ${project_name} |
| 64 | ${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}" |
| 65 | Log ${stdout} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 66 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| garciaale | dce1fa8 | 2020-07-22 22:14:08 +0000 | [diff] [blame] | 67 | |
| 68 | Delete Role |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 69 | [Documentation] Delete from OSM the role passed as argument. |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 70 | [Arguments] ${role_name} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 71 | ${rc} ${stdout}= Run And Return Rc And Output osm role-delete ${role_name} |
| garciaale | dce1fa8 | 2020-07-22 22:14:08 +0000 | [diff] [blame] | 72 | Log ${stdout} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 73 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |