Devtest Groovy script for HMAC authentication to access AWS
book
Article ID: 280123
calendar_today
Updated On:
Products
Service Virtualization
Issue/Introduction
AWS requires HMAC authentication for a REST step to connect.
How to set the hmac authorization header string for a REST step.
Environment
All supported DevTest releases
Resolution
- Create a Groovy script with the code as attached.
- This script expects the payload to be available in the DevTest PAYLOADPROPERTY property.
- Set the values for clientId, clientSecret, httpMethod, host, port, path as required.
- Create a REST step that follows the script step.
- Confirm that the httpMethod is the same as in the script.
- Set the URL to https://{{API_HOST1}}:{{API_PORT1}}/{{API_PATH1}} and set the same values in the URL tab.
- In the Headers tab, add a header: Authorization {{hmac}}
- In the Content tab, set {{PAYLOADPROPERTY}}
- Optional: remove _logger.info lines from the script that are used for debugging
Feedback
thumb_up
Yes
thumb_down
No