aboutsummaryrefslogtreecommitdiffstats
path: root/cmso-robot/robot/resources/scheduler_common.robot
blob: 1256480a237d3d3400620e3feb092a80f451bd40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
*** Settings ***
Documentation     The private interface for interacting with Openstack. It handles low level stuff like managing the authtoken and Openstack required fields

Library           Collections
Library         RequestsLibrary
Library           UUID
Library           HTTPUtils
Library           String
Resource   misc.robot
*** Variables ***
*** Variables ***
${SCHEDULER_PATH}    /cmso/v1
${CHANGE_MANAGEMENT_PATH}    ${SCHEDULER_PATH}
${valid_status_codes}    200    202    400    404    204    409
#**************** Test Case Variables ******************

*** Keywords ***


Post Change Management
    [Documentation]    Runs a scheduler POST request
    [Arguments]    ${alias}    ${resource}   ${data}={}
    ${data_path}=   Catenate   ${CHANGE_MANAGEMENT_PATH}/${resource}
    ${resp}=    Post Scheduler    ${alias}    ${data_path}   ${data}
    [Return]   ${resp}   

Delete Change Management
    [Documentation]    Runs a scheduler DELETE request (this may need to be changed for 1802 US change Delete schedule to Cancel Schedule)
    [Arguments]    ${alias}    ${resource}
    ${data_path}=   Catenate   ${CHANGE_MANAGEMENT_PATH}/${resource}
    ${resp}=    Delete Scheduler    ${alias}    ${data_path}
    [Return]   ${resp}   

Get Change Management
    [Documentation]    Runs a scheduler GET request
    [Arguments]    ${alias}    ${resource}  
    ${data_path}=   Catenate   ${CHANGE_MANAGEMENT_PATH}/${resource} 
    ${resp}=   Get Scheduler    ${alias}    ${data_path}
    [Return]   ${resp}    

Post Scheduler
    [Documentation]    Runs a scheduler POST request
    [Arguments]    ${alias}   ${data_path}   ${data}={}
    ${url}=   Catenate   ${GLOBAL_SCHEDULER_URL}
    ${uuid}=    Generate UUID
    ${proxies}=   Create Dictionary   no=pass
    ${session}=    Create Session   ${alias}   ${url}   
    ${auth_string}=   B64 Encode     ${GLOBAL_SCHEDULER_USER}:${GLOBAL_SCHEDULER_PASSWORD}
    ${headers}=  Create Dictionary   Accept=application/json    Content-Type=application/json    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}   Authorization=Basic ${auth_string}
    ${resp}=  Post Request  ${alias}  ${data_path}     headers=${headers}   data=${data}
    Log    Received response from scheduler ${resp.text}
    ${valid}=   Split String   ${valid_status_codes}
    
    Validate Status   ${resp}   ${valid}
    [Return]    ${resp}

Delete Scheduler
    [Documentation]    Runs a scheduler POST request
    [Arguments]    ${alias}   ${data_path} 
    ${url}=   Catenate   ${GLOBAL_SCHEDULER_URL}
    ${uuid}=    Generate UUID
    ${proxies}=   Create Dictionary   no=pass
    ${session}=    Create Session   ${alias}   ${url}     
    ${auth_string}=   B64 Encode    ${GLOBAL_SCHEDULER_USER}:${GLOBAL_SCHEDULER_PASSWORD}
    ${headers}=  Create Dictionary   Accept=application/json    Content-Type=application/json    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}      Authorization=Basic ${auth_string}  
    ${resp}=  Delete Request  ${alias}  ${data_path}     headers=${headers}
    Log    Received response from scheduler ${resp.text}
    ${valid}=   Split String   ${valid_status_codes}
    Validate Status   ${resp}   ${valid}
    [Return]    ${resp}

Get Scheduler
    [Documentation]    Runs a scheduler GET request
    [Arguments]    ${alias}   ${data_path} 
    ${url}=   Catenate   ${GLOBAL_SCHEDULER_URL}
    ${uuid}=    Generate UUID
    ${proxies}=   Create Dictionary   no=pass
    ${session}=    Create Session   ${alias}   ${url}     
    ${auth_string}=   B64 Encode    ${GLOBAL_SCHEDULER_USER}:${GLOBAL_SCHEDULER_PASSWORD}
    ${headers}=  Create Dictionary   Accept=application/json    Content-Type=application/json    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}      Authorization=Basic ${auth_string}
    ${resp}=  Get Request   ${alias}  ${data_path}     headers=${headers}
    Log    Received response from scheduler ${resp.json()}
    ${valid}=   Split String   ${valid_status_codes}
    Validate Status   ${resp}   ${valid}
    [Return]    ${resp}