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

Skip to content
Snippets Groups Projects
Commit d2b13880 authored by Frederico SEQUEIRA's avatar Frederico SEQUEIRA
Browse files

:white_check_mark: Add Mapping redirect robot testing

parent 7c872902
No related branches found
No related tags found
1 merge request!149Draft: ✨ Add redirect changes to RPS plugin
Pipeline #280453 passed
*** Settings ***
Test Tags mac
Library RequestsLibrary
Library OperatingSystem
Library Collections
Variables ../variables.yaml
*** Variables ***
${BASE_URL} http://${HOST}:${PORT}
${MAPPING_ENDPOINT} /api/plugins/rps/mapping/
${REDIRECT_ENDPOINT} /api/plugins/rps/redirect/
${TOKEN} Token ${API_TOKEN}
*** Test Cases ***
Create Mapping for testing
${HEADERS} Create Dictionary Content-Type ${CONTENT_TYPE} Authorization ${TOKEN}
${payload} Create Dictionary source http://testsource.com target http://testtarget.com
${response}= POST ${BASE_URL}${MAPPING_ENDPOINT} json=${payload} headers=${HEADERS} expected_status=201
${json} Set Variable ${response.json()}
Convert to Dictionary ${json}
${MAPPING_ID} Get From Dictionary ${json} id
Set Global Variable ${MAPPING_ID}
Create Valid Mapping Redirect
${HEADERS} Create Dictionary Content-Type ${CONTENT_TYPE} Authorization ${TOKEN}
${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=201
${json} Set Variable ${response.json()}
Convert to Dictionary ${json}
${REDIRECT_ID} Get From Dictionary ${json} id
Set Global Variable ${REDIRECT_ID}
Create 2nd Valid Mapping 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 2999-01-01T15:53:01.622818Z
${response}= POST ${BASE_URL}${REDIRECT_ENDPOINT} json=${payload} headers=${HEADERS} expected_status=201
${json} Set Variable ${response.json()}
Convert to Dictionary ${json}
${REDIRECT_ID} Get From Dictionary ${json} id
Set Global Variable ${REDIRECT_ID}
Create Duplicaded Redirect
${HEADERS} Create Dictionary Content-Type ${CONTENT_TYPE} Authorization ${TOKEN}
${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
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
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
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
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
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
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
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
# Clean up
Delete Mac Address assigned to VLAN
${HEADERS} Create Dictionary Content-Type ${CONTENT_TYPE} Authorization ${TOKEN}
${response}= DELETE ${BASE_URL}${MAPPING_ENDPOINT}${MAPPING_ID} headers=${HEADERS} expected_status=204
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment