upgrade to python3 libraries
[testsuite.git] / robot / resources / portal_interface.robot
1 *** Settings ***
2 Documentation     The main interface for interacting with Portal. It handles low level stuff like managing the http request library and Portal required fields
3 Library         RequestsClientCert
4 Library         RequestsLibrary
5 Library         UUID      
6 Library         SeleniumLibrary
7 Library         Collections
8 Library         String
9
10 Resource        global_properties.robot
11 Resource        browser_setup.robot
12
13 *** Variables ***
14 ${PORTAL_HEALTH_CHECK_PATH}        /ONAPPORTAL/portalApi/healthCheck
15 ${PORTAL_ENDPOINT}     ${GLOBAL_PORTAL_SERVER_PROTOCOL}://${GLOBAL_INJECTED_PORTAL_IP_ADDR}:${GLOBAL_PORTAL_SERVER_PORT}
16 ${PORTAL_GUI_ENDPOINT}     ${GLOBAL_PORTAL_SERVER_PROTOCOL}://portal.api.simpledemo.onap.org:${GLOBAL_PORTAL_SERVER_PORT}
17 ${PORTAL_ENV}            /ONAPPORTAL
18 ${PORTAL_LOGIN_URL}                ${PORTAL_GUI_ENDPOINT}${PORTAL_ENV}/login.htm
19 ${PORTAL_HOME_URL}                ${PORTAL_GUI_ENDPOINT}${PORTAL_ENV}/applicationsHome
20
21 *** Keywords ***
22 Run Portal Health Check
23      [Documentation]    Runs Portal Health check
24      ${resp}=    Run Portal Get Request    ${PORTAL_HEALTH_CHECK_PATH}    
25      Should Be Equal As Strings         ${resp.status_code}     200
26      Should Be Equal As Strings         ${resp.json()['statusCode']}    200
27          
28 Run Portal Get Request
29      [Documentation]    Runs Portal Get request
30      [Arguments]    ${data_path}
31      ${session}=    Create Session      portal  ${PORTAL_ENDPOINT}
32      ${uuid}=    Generate UUID
33      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
34      ${resp}=   Get Request     portal  ${data_path}     headers=${headers}
35      Log    Received response from portal ${resp.text}
36      [Return]    ${resp}
37
38 Run Portal Login Tests
39      [Documentation]    Runs Portal Login Tests
40      Close All Browsers
41      Login To Portal GUI   demo   demo123456!
42      Close All Browsers
43      Login To Portal GUI   cs0008  demo123456!
44      Close All Browsers
45      Login To Portal GUI   jm0007  demo123456!
46      Close All Browsers
47      Login To Portal GUI   gv0001  demo123456!
48      Close All Browsers
49      Login To Portal GUI   op0001  demo123456!
50      Close All Browsers
51
52 Run Portal Application Access Tests
53      [Documentation]    Runs Portal Application Access Tests
54      Log To Console    Testing SDC,VID,Policy
55      Run Portal Application Login Test   cs0008   demo123456!   gridster-SDC-icon-link   tabframe-SDC    Welcome to SDC
56      Close All Browsers
57      Run Portal Application Login Test   demo    demo123456!  gridster-Virtual-Infrastructure-Deployment-icon-link   tabframe-Virtual-Infrastructure-Deployment    Welcome to VID
58      Close All Browsers
59      Run Portal Application Login Test   demo    demo123456!  gridster-Policy-icon-link   tabframe-Policy    Policy Editor
60      Close All Browsers
61
62 Login To Portal GUI And Go Home
63     [Documentation]   Logs in to Portal GUI
64     [Arguments]     ${loginId}    ${password}
65     Login To Portal GUI    ${loginId}    ${password}
66     Go To Portal HOME
67
68 Login To Portal GUI
69     [Documentation]   Logs in to Portal GUI
70     [Arguments]     ${loginId}    ${password}
71     # Setup Browser Now being managed by test case
72     ### revert to local Setup Browser for Login test
73     Setup Browser
74     Go To    ${PORTAL_LOGIN_URL}
75     Set Selenium Speed    ${GLOBAL_SELENIUM_DELAY}
76     Set Browser Implicit Wait    ${GLOBAL_SELENIUM_BROWSER_IMPLICIT_WAIT}
77     Log    Logging in to ${PORTAL_ENDPOINT}${PORTAL_ENV}
78     Handle Proxy Warning
79     Title Should Be    Login
80     Input Text    xpath=//input[@ng-model='loginId']    ${loginId}
81     Input Password    xpath=//input[@ng-model='password']    ${password}
82     Click Element    xpath=//a[@id='loginBtn']
83     Wait Until Page Contains  Applications   ${GLOBAL_SELENIUM_BROWSER_WAIT_TIMEOUT}
84     Log    Logged in to ${PORTAL_ENDPOINT}${PORTAL_ENV}
85     Log To Console  ${loginId} SUCCESS
86     
87 Logout From Portal GUI
88     [Documentation]   Logs out of Portal GUI
89     Go To    ${PORTAL_LOGIN_URL}
90     Click Element    xpath=//div[@id='header-user-icon']
91     Run Keyword And Ignore Error    Click Button    xpath=//button[contains(.,'Log out')]
92     Log    Logged out of ${PORTAL_ENDPOINT}${PORTAL_ENV}
93
94 Run Portal Application Login Test
95     [Documentation]    Login to Portal Application
96     [Arguments]   ${loginId}   ${password}   ${click_element}    ${tabframe}   ${match_string}
97     # Setup Browser Now being managed by test case
98     ### revert to local Setup Browser for Login test
99     Setup Browser
100     Go To    ${PORTAL_LOGIN_URL}
101     #Maximize Browser Window
102     Set Selenium Speed    ${GLOBAL_SELENIUM_DELAY}
103     Set Browser Implicit Wait    ${GLOBAL_SELENIUM_BROWSER_IMPLICIT_WAIT}
104     Log    Logging in to ${PORTAL_ENDPOINT}${PORTAL_ENV}
105     Handle Proxy Warning
106     Title Should Be    Login
107     Input Text    xpath=//input[@ng-model='loginId']    ${loginId}
108     Input Password    xpath=//input[@ng-model='password']    ${password}
109     Click Element    xpath=//a[@id='loginBtn']
110     Wait Until Page Contains  Applications   ${GLOBAL_SELENIUM_BROWSER_WAIT_TIMEOUT}
111     Log    Logged in to ${PORTAL_ENDPOINT}${PORTAL_ENV}
112     Log To Console  ${loginId} SUCCESS
113     Sleep  5
114     Click Element    id=${click_element}
115     Sleep  5
116     Select Frame  id=${tabframe}
117     Sleep  5
118     Page Should Contain  ${match_string}
119     Log To Console   Portal Application Access SUCCESS ${click_element}
120
121 Go To Portal HOME
122     [Documentation]    Naviage to Portal Home
123     Go To    ${PORTAL_HOME_URL}
124     Wait Until Page Contains  Applications    ${GLOBAL_SELENIUM_BROWSER_WAIT_TIMEOUT}
125
126 Click On Button When Enabled
127     [Arguments]     ${xpath}    ${timeout}=${GLOBAL_VID_UI_TIMEOUT_MEDIUM}
128     Wait Until Page Contains Element    xpath=${xpath}    ${timeout}
129     Wait Until Element Is Enabled    xpath=${xpath}    ${timeout}
130     Click Button      xpath=${xpath}
131
132 Click On Element When Visible
133     [Arguments]     ${xpath}    ${timeout}=${GLOBAL_VID_UI_TIMEOUT_MEDIUM}
134     Wait Until Page Contains Element    xpath=${xpath}    ${timeout}
135     Wait Until Element Is Visible    xpath=${xpath}    ${timeout}
136     Click Element      xpath=${xpath}
137
138 Select From List When Enabled
139     [Arguments]     ${xpath}    ${value}    ${timeout}=${GLOBAL_VID_UI_TIMEOUT_MEDIUM}
140     Wait Until Page Contains Element    xpath=${xpath}    ${timeout}
141     Wait Until Element Is Enabled    xpath=${xpath}    ${timeout}
142     Select From List     xpath=${xpath}    ${value}
143
144 Input Text When Enabled
145     [Arguments]     ${xpath}    ${value}    ${timeout}=${GLOBAL_VID_UI_TIMEOUT_MEDIUM}
146     Wait Until Page Contains Element    xpath=${xpath}    ${timeout}
147     Wait Until Element Is Enabled    xpath=${xpath}    ${timeout}
148     Input Text    xpath=${xpath}    ${value}
149