55e011364f80a0498cf6e3ecff8f213656db9b76
[osm/tests.git] / robot-systest / testsuite / basic_15-rbac_configurations.robot
1 #   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 *** Settings ***
14 Documentation     [BASIC-15] RBAC Configurations.
15
16 Library   OperatingSystem
17 Library   String
18 Library   Collections
19
20 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/user_lib.robot
21 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/project_lib.robot
22 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/role_lib.robot
23
24 Variables   %{ROBOT_DEVOPS_FOLDER}/resources/basic_15-rbac_configurations_data.py
25
26 Force Tags   basic_15   cluster_main   daily   regression
27
28 Suite Teardown   Run Keyword And Ignore Error   Suite Cleanup
29
30
31 *** Variables ***
32 ${success_return_code}   0
33
34 *** Test Cases ***
35 Create And Validate User
36
37     Create User   ${user_name}   ${user_password}
38     Check If User Exists   ${user_name}
39
40
41 Assign Role To User
42
43     Update User Role   ${user_name}  ${user_project}  ${user_role}
44     Check If User Is Assigned To Project   ${user_name}   ${user_project}
45     Check If User Has Role   ${user_name}  ${user_role}  ${user_project}
46
47
48 Run Action As User
49
50     ${rc}   ${stdout}=   Run And Return RC And Output   OSM_USER=${user_name} OSM_PROJECT=${user_project} OSM_PASSWORD=${user_password} osm ns-list
51     Should Be Equal As Integers   ${rc}   ${success_return_code}
52
53
54 Create And Update Project
55
56     Create Project   ${project_name}
57     Update Project Name   ${project_name}   ${new_project_name}
58
59
60 Create And Validate Role
61
62     Create Role   ${role_name}
63     Check If Role Exists   ${role_name}
64
65
66 Update Role Information
67
68     Update Role   ${role_name}   add='vims: true'
69     Check If Role Exists   ${role_name}
70
71
72 Delete Allocated Resources
73     [Tags]   cleanup
74
75     Delete User   ${user_name}
76     Delete Project   ${new_project_name}
77     Delete Role   ${role_name}
78
79
80 *** Keywords ***
81 Suite Cleanup
82     Run Keyword If Any Tests Failed  Run Keyword And Ignore Error  Delete User  ${user_name}
83     Run Keyword If Any Tests Failed  Run Keyword And Ignore Error  Delete Role  ${role_name}
84     Run Keyword If Any Tests Failed  Run Keyword And Ignore Error  Delete Project  ${project_name}
85     Run Keyword If Any Tests Failed  Run Keyword And Ignore Error  Delete Project  ${new_project_name}