2281b1eb5766fdd19791875222e97889cb3c89be
[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         ExtendedSelenium2Library
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
63     [Documentation]   Logs in to Portal GUI
64     [Arguments]     ${loginId}    ${password}
65     # Setup Browser Now being managed by test case
66     ### revert to local Setup Browser for Login test
67     Setup Browser
68     Go To    ${PORTAL_LOGIN_URL}
69     #Maximize Browser Window
70     Set Selenium Speed    ${GLOBAL_SELENIUM_DELAY}
71     Set Browser Implicit Wait    ${GLOBAL_SELENIUM_BROWSER_IMPLICIT_WAIT}
72     Log    Logging in to ${PORTAL_ENDPOINT}${PORTAL_ENV}
73     Handle Proxy Warning
74     Title Should Be    Login
75     Input Text    xpath=//input[@ng-model='loginId']    ${loginId}
76     Input Password    xpath=//input[@ng-model='password']    ${password}
77     #Click Button    xpath=//a[@ng-click='loginExternal();']
78     Click Element    xpath=//a[@id='loginBtn']
79     Wait Until Page Contains  Applications   ${GLOBAL_SELENIUM_BROWSER_WAIT_TIMEOUT}
80     Log    Logged in to ${PORTAL_ENDPOINT}${PORTAL_ENV}
81     Log To Console  ${loginId} SUCCESS
82
83 Run Portal Application Login Test
84     [Documentation]    Login to Portal Application
85     [Arguments]   ${loginId}   ${password}   ${click_element}    ${tabframe}   ${match_string}
86     # Setup Browser Now being managed by test case
87     ### revert to local Setup Browser for Login test
88     Setup Browser
89     Go To    ${PORTAL_LOGIN_URL}
90     #Maximize Browser Window
91     Set Selenium Speed    ${GLOBAL_SELENIUM_DELAY}
92     Set Browser Implicit Wait    ${GLOBAL_SELENIUM_BROWSER_IMPLICIT_WAIT}
93     Log    Logging in to ${PORTAL_ENDPOINT}${PORTAL_ENV}
94     Handle Proxy Warning
95     Title Should Be    Login
96     Input Text    xpath=//input[@ng-model='loginId']    ${loginId}
97     Input Password    xpath=//input[@ng-model='password']    ${password}
98     Click Element    xpath=//a[@id='loginBtn']
99     Wait Until Page Contains  Applications   ${GLOBAL_SELENIUM_BROWSER_WAIT_TIMEOUT}
100     Log    Logged in to ${PORTAL_ENDPOINT}${PORTAL_ENV}
101     Log To Console  ${loginId} SUCCESS
102     Sleep  5
103     Click Element    id=${click_element}
104     Sleep  5
105     Select Frame  id=${tabframe}
106     Sleep  5
107     Page Should Contain  ${match_string}
108     Log To Console   Portal Application Access SUCCESS ${click_element}
109
110 Go To Portal HOME
111     [Documentation]    Naviage to Portal Home
112     Go To    ${PORTAL_HOME_URL}
113     Wait Until Page Contains  Applications    ${GLOBAL_SELENIUM_BROWSER_WAIT_TIMEOUT}
114
115 Click On Button When Enabled
116     [Arguments]     ${xpath}    ${timeout}=${GLOBAL_VID_UI_TIMEOUT_MEDIUM}
117     Wait Until Page Contains Element    xpath=${xpath}    ${timeout}
118     Wait Until Element Is Enabled    xpath=${xpath}    ${timeout}
119     Click Button      xpath=${xpath}
120
121 Click On Element When Visible
122     [Arguments]     ${xpath}    ${timeout}=${GLOBAL_VID_UI_TIMEOUT_MEDIUM}
123     Wait Until Page Contains Element    xpath=${xpath}    ${timeout}
124     Wait Until Element Is Visible    xpath=${xpath}    ${timeout}
125     Click Element      xpath=${xpath}
126
127 Select From List When Enabled
128     [Arguments]     ${xpath}    ${value}    ${timeout}=${GLOBAL_VID_UI_TIMEOUT_MEDIUM}
129     Wait Until Page Contains Element    xpath=${xpath}    ${timeout}
130     Wait Until Element Is Enabled    xpath=${xpath}    ${timeout}
131     Select From List     xpath=${xpath}    ${value}
132
133 Input Text When Enabled
134     [Arguments]     ${xpath}    ${value}    ${timeout}=${GLOBAL_VID_UI_TIMEOUT_MEDIUM}
135     Wait Until Page Contains Element    xpath=${xpath}    ${timeout}
136     Wait Until Element Is Enabled    xpath=${xpath}    ${timeout}
137     Input Text    xpath=${xpath}    ${value}
138