Feature 11001: Robot framework linting for E2E tests
[osm/tests.git] / robot-systest / lib / user_lib.resource
1 *** Comments ***
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
14
15 *** Settings ***
16 Documentation   Library providing keywords for CRUD operations over Network Slice Templates with OSM client.
17 Library   OperatingSystem
18
19
20 *** Variables ***
21 ${SUCCESS_RETURN_CODE}   0
22
23
24 *** Keywords ***
25 Create User
26     [Documentation]   Create a user in OSM with the name and password passed as arguments, and return the user id.
27     [Arguments]   ${user_name}   ${user_password}
28     Should Not Be Empty   ${user_name}
29     Should Not Be Empty   ${user_password}
30     ${rc}   ${stdout}=   Run And Return Rc And Output   osm user-create ${user_name} --password ${user_password}
31     Log   ${stdout}
32     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
33     RETURN   ${stdout}
34
35 Update User Password
36     [Documentation]   Update the password of a user in OSM.
37     [Arguments]   ${user_name}   ${user_password}   ${user_new_password}
38     Should Not Be Empty   ${user_name}
39     Should Not Be Empty   ${user_password}
40     Should Not Be Empty   ${user_new_password}
41     ${rc}   ${stdout}=   Run And Return Rc And Output   osm user-update ${user_name} --current-password ${user_password} --new-password ${user_new_password}
42     Log   ${stdout}
43     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
44
45 Update User Role
46     [Documentation]   Update the role of a user in a project in OSM.
47     [Arguments]   ${user_name}   ${project_name}   ${role_name}
48     Should Not Be Empty   ${user_name}
49     Should Not Be Empty   ${project_name}
50     Should Not Be Empty   ${role_name}
51     ${rc}   ${stdout}=   Run And Return Rc And Output   osm user-update --add-project-role '${project_name},${role_name}' ${user_name}
52     Log   ${stdout}
53     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
54
55 Check If User Exists
56     [Documentation]   Check if a user exists in OSM.
57     [Arguments]   ${user_name}
58     Should Not Be Empty   ${user_name}
59     ${rc}   ${stdout}=   Run And Return RC And Output   osm user-list | awk 'NR>3 {print $2}' | grep "${user_name}"
60     Log   ${stdout}
61     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
62
63 Delete User
64     [Documentation]   Delete from OSM the user passed as argument.
65     [Arguments]   ${user_name}
66     ${rc}   ${stdout}=   Run And Return Rc And Output   osm user-delete ${user_name}
67     Log   ${stdout}
68     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}