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