Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects

Draft: :sparkles: Add redirect changes to RPS plugin

Open Frederico SEQUEIRA requested to merge v3_rps_redirect_changes into develop
@@ -3,6 +3,7 @@ Test Tags mac
Library RequestsLibrary
Library OperatingSystem
Library Collections
Library DateTime
Variables ../variables.yaml
*** Variables ***
@@ -47,51 +48,85 @@ Create Duplicaded Redirect
${NOW}= get time
${payload} Create Dictionary source http://testsource.com/A target http://testtarget.com/B mapping ${MAPPING_ID} redirect_type 1-1 activation_date ${NOW}
${response}= POST ${BASE_URL}${REDIRECT_ENDPOINT} json=${payload} headers=${HEADERS} expected_status=400
${json} Set Variable ${response.json()}
Convert to Dictionary ${json}
${ERROR} Get From Dictionary ${json} source
Should Contain ${ERROR} A Redirect with the same source and overlapping timespan already exists.
Create Incomplete Redirect- Missing Source
${HEADERS} Create Dictionary Content-Type ${CONTENT_TYPE} Authorization ${TOKEN}
${NOW}= get time
${payload} Create Dictionary target http://testtarget.com/B mapping ${MAPPING_ID} redirect_type 1-1 activation_date ${NOW}
${response}= POST ${BASE_URL}${REDIRECT_ENDPOINT} json=${payload} headers=${HEADERS} expected_status=400
${json} Set Variable ${response.json()}
Convert to Dictionary ${json}
${ERROR} Get From Dictionary ${json} source
Should Contain ${ERROR} This field is required.
Create Incomplete Redirect- Missing Target
${HEADERS} Create Dictionary Content-Type ${CONTENT_TYPE} Authorization ${TOKEN}
${NOW}= get time
${payload} Create Dictionary source http://testsource.com/C mapping ${MAPPING_ID} redirect_type 1-1 activation_date ${NOW}
${response}= POST ${BASE_URL}${REDIRECT_ENDPOINT} json=${payload} headers=${HEADERS} expected_status=400
${json} Set Variable ${response.json()}
Convert to Dictionary ${json}
${ERROR} Get From Dictionary ${json} target
Should Contain ${ERROR} This field is required.
Create Incomplete Redirect- Missing Mapping
${HEADERS} Create Dictionary Content-Type ${CONTENT_TYPE} Authorization ${TOKEN}
${NOW}= get time
${payload} Create Dictionary source http://testsource.com/C target http://testtarget.com/B redirect_type 1-1 activation_date ${NOW}
${response}= POST ${BASE_URL}${REDIRECT_ENDPOINT} json=${payload} headers=${HEADERS} expected_status=400
${json} Set Variable ${response.json()}
Convert to Dictionary ${json}
${ERROR} Get From Dictionary ${json} mapping
Should Contain ${ERROR} This field is required.
Create Incomplete Redirect- Check Date Default
${HEADERS} Create Dictionary Content-Type ${CONTENT_TYPE} Authorization ${TOKEN}
${NOW}= get time
${payload} Create Dictionary source http://testsource.com/datedefault target http://testtarget.com/B mapping ${MAPPING_ID} redirect_type 1-1
${response}= POST ${BASE_URL}${REDIRECT_ENDPOINT} json=${payload} headers=${HEADERS} expected_status=201
${json} Set Variable ${response.json()}
Convert to Dictionary ${json}
${DATE_DEFAULT} Get From Dictionary ${json} activation_date
${CONVERTED_DATE_DEFAULT} Convert Date ${DATE_DEFAULT} result_format=%d %b %Y %I:%M %p
${CONVERTED_NOW} Convert Date ${NOW} result_format=%d %b %Y %I:%M %p
Should Be Equal As Strings ${CONVERTED_DATE_DEFAULT} ${CONVERTED_NOW}
Create Incomplete Redirect- Check Type Default
${HEADERS} Create Dictionary Content-Type ${CONTENT_TYPE} Authorization ${TOKEN}
${NOW}= get time
${payload} Create Dictionary source http://testsource.com/typedefault target http://testtarget.com/B mapping ${MAPPING_ID} activation_date ${NOW}
${response}= POST ${BASE_URL}${REDIRECT_ENDPOINT} json=${payload} headers=${HEADERS} expected_status=201
${json} Set Variable ${response.json()}
Convert to Dictionary ${json}
${TYPE_DEFAULT} Get From Dictionary ${json} redirect_type
Should Be Equal As Strings ${TYPE_DEFAULT} 1-1
Create Invalid (Not the same source) Redirect
${HEADERS} Create Dictionary Content-Type ${CONTENT_TYPE} Authorization ${TOKEN}
${NOW}= get time
${payload} Create Dictionary source http://testsource_wrong.com/A target http://testtarget.com/B mapping ${MAPPING_ID} redirect_type 1-1 activation_date ${NOW}
${response}= POST ${BASE_URL}${REDIRECT_ENDPOINT} json=${payload} headers=${HEADERS} expected_status=400
${json} Set Variable ${response.json()}
Convert to Dictionary ${json}
${ERROR} Get From Dictionary ${json} source
Should Contain ${ERROR} Redirect source must start with the mapping's source.
Create Overlaped Dates Redirect
${HEADERS} Create Dictionary Content-Type ${CONTENT_TYPE} Authorization ${TOKEN}
${NOW}= get time
${payload} Create Dictionary source http://testsource.com/Z target http://testtarget.com/B mapping ${MAPPING_ID} redirect_type 1-1 activation_date ${NOW} deactivation_date 2500-01-01T15:53:01.622818Z
${response}= POST ${BASE_URL}${REDIRECT_ENDPOINT} json=${payload} headers=${HEADERS} expected_status=400
${json} Set Variable ${response.json()}
Convert to Dictionary ${json}
${ERROR} Get From Dictionary ${json} source
Should Contain ${ERROR} A Redirect with the same source and overlapping timespan already exists.
# Clean up
Delete Mac Address assigned to VLAN
Delete Mapping
${HEADERS} Create Dictionary Content-Type ${CONTENT_TYPE} Authorization ${TOKEN}
${response}= DELETE ${BASE_URL}${MAPPING_ENDPOINT}${MAPPING_ID} headers=${HEADERS} expected_status=204
Loading