Bug 2327 fix to verify ipaddress in sol003_02 testsuite
[osm/tests.git] / robot-systest / testsuite / basic_15-rbac_configurations.robot
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   [BASIC-15] RBAC Configurations.
17
18 Library   OperatingSystem
19 Library   String
20 Library   Collections
21
22 Resource   ../lib/user_lib.resource
23 Resource   ../lib/project_lib.resource
24 Resource   ../lib/role_lib.resource
25
26 Test Tags   basic_15   cluster_main   daily   regression   azure
27
28 Suite Teardown   Run Keyword And Ignore Error   Suite Cleanup
29
30
31 *** Variables ***
32 # User, project and roles to use
33 ${USERNAME}   basic_15_test_user
34 ${USER_PASSWORD}   Basic_15_user_pass
35 ${USER_NEW_PASSWORD}   Basic_15_new_pass
36 ${USER_ROLE}   project_user
37 ${USER_PROJECT}   admin
38 ${PROJECT_NAME}   basic_15_test_project
39 ${NEW_PROJECT_NAME}   basic_15_project_test
40 ${ROLE_NAME}   test_role
41 ${SUCCESS_RETURN_CODE}   0
42
43
44 *** Test Cases ***
45 Create And Validate User
46     [Documentation]   Create a user in OSM.
47     Create User   ${USERNAME}   ${USER_PASSWORD}
48     Check If User Exists   ${USERNAME}
49
50 Assign Role To User
51     [Documentation]   Assign a user to a project with a role
52     Update User Role   ${USERNAME}   ${USER_PROJECT}   ${USER_ROLE}
53     Check If User Is Assigned To Project   ${USERNAME}   ${USER_PROJECT}
54     Check If User Has Role   ${USERNAME}   ${USER_ROLE}   ${USER_PROJECT}
55
56 Run Action As User
57     [Documentation]   Update the password of the user.
58     Update User Password   ${USERNAME}   ${USER_PASSWORD}   ${USER_NEW_PASSWORD}
59     ${rc}   ${stdout}=   Run And Return RC And Output   OSM_USER=${USERNAME} OSM_PROJECT=${USER_PROJECT} OSM_PASSWORD=${USER_NEW_PASSWORD} osm ns-list
60     Log   ${rc}
61     Log   ${stdout}
62     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
63
64 Create And Update Project
65     [Documentation]   Create a project and update its name.
66     Create Project   ${PROJECT_NAME}
67     Update Project Name   ${PROJECT_NAME}   ${NEW_PROJECT_NAME}
68
69 Create And Validate Role
70     [Documentation]   Create a role and check that exists in OSM.
71     Create Role   ${ROLE_NAME}
72     Check If Role Exists   ${ROLE_NAME}
73
74 Update Role Information
75     [Documentation]   Update a role with a capability.
76     Update Role   ${ROLE_NAME}   add='vims: true'
77     Check If Role Exists   ${ROLE_NAME}
78
79 Delete Allocated Resources
80     [Documentation]   Delete user, project and role.
81     [Tags]   cleanup
82     Delete User   ${USERNAME}
83     Delete Project   ${NEW_PROJECT_NAME}
84     Delete Role   ${ROLE_NAME}
85
86
87 *** Keywords ***
88 Suite Cleanup
89     [Documentation]   Test Suite Cleanup: Deleting users, roles and projects.
90     Run Keyword If Any Tests Failed   Run Keyword And Ignore Error   Delete User   ${USERNAME}
91     Run Keyword If Any Tests Failed   Run Keyword And Ignore Error   Delete Role   ${ROLE_NAME}
92     Run Keyword If Any Tests Failed   Run Keyword And Ignore Error   Delete Project   ${PROJECT_NAME}
93     Run Keyword If Any Tests Failed   Run Keyword And Ignore Error   Delete Project   ${NEW_PROJECT_NAME}