Devtest Groovy script for HMAC authentication to access AWS
search cancel

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

  1. Create a Groovy script with the code as attached.
  2. This script expects the payload to be available in the DevTest PAYLOADPROPERTY property.
  3. Set the values for clientId, clientSecret, httpMethod, host, port, path as required.
  4. Create a REST step that follows the script step.
  5. Confirm that the httpMethod is the same as in the script.
  6. Set the URL to https://{{API_HOST1}}:{{API_PORT1}}/{{API_PATH1}} and set the same values in the URL tab.
  7. In the Headers tab, add a header: Authorization {{hmac}}
  8. In the Content tab, set {{PAYLOADPROPERTY}}
  9. Optional: remove _logger.info lines from the script that are used for debugging

Attachments

Groovyscript.txt get_app