Created
March 8, 2017 22:42
-
-
Save heitortsergent/551cfad6b0b8819860f86736d1445b2c to your computer and use it in GitHub Desktop.
Import this test as "Runscope API Test" to your Runscope account to get a quick start on updating shared environment variables. For more information: https://blog.runscope.com/posts/how-to-use-subtest-steps-to-handle-oauth2-access-tokens-runscope-api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"trigger_url": "https://api.runscope.com/radar/2e9ff15c-ef6d-46b2-9815-65f05812e02e/trigger", | |
"name": "Refresh Access Token Template", | |
"version": "1.0", | |
"exported_at": 1483638296, | |
"steps": [ | |
{ | |
"url": "https://yourapihere.com?dummyNewToken=theNewGeneratedToken", | |
"variables": [ | |
{ | |
"source": "response_json", | |
"property": "args.dummyNewToken", | |
"name": "newAccessToken" | |
} | |
], | |
"step_type": "request", | |
"auth": {}, | |
"note": "Get New Token (sample)", | |
"headers": {}, | |
"assertions": [ | |
{ | |
"comparison": "equal_number", | |
"value": 200, | |
"source": "response_status" | |
} | |
], | |
"scripts": [], | |
"before_scripts": [], | |
"method": "GET" | |
}, | |
{ | |
"url": "https://api.runscope.com/buckets/{{runscope_bucket}}/environments/{{shared_environment}}", | |
"variables": [ | |
{ | |
"source": "response_json", | |
"property": "data", | |
"name": "envSettings" | |
} | |
], | |
"step_type": "request", | |
"auth": {}, | |
"fragment": "", | |
"note": "Get Shared Environment Configuration", | |
"headers": { | |
"Authorization": "Bearer {{runscope_token}}" | |
}, | |
"assertions": [ | |
{ | |
"comparison": "equal_number", | |
"value": 200, | |
"source": "response_status" | |
} | |
], | |
"scripts": [], | |
"before_scripts": [], | |
"method": "GET" | |
}, | |
{ | |
"body": "", | |
"form": {}, | |
"url": "https://api.runscope.com/buckets/{{runscope_bucket}}/environments/{{shared_environment}}", | |
"variables": [], | |
"step_type": "request", | |
"auth": {}, | |
"fragment": "", | |
"note": "Update Shared Environment Configuration", | |
"headers": { | |
"Authorization": "Bearer {{runscope_token}}" | |
}, | |
"assertions": [ | |
{ | |
"comparison": "equal_number", | |
"value": 200, | |
"source": "response_status" | |
} | |
], | |
"scripts": [], | |
"before_scripts": [ | |
"var envSettings = JSON.parse(variables.get(\"envSettings\"));\nenvSettings.initial_variables.accessToken = variables.get(\"newAccessToken\");\nrequest.body = JSON.stringify(envSettings);" | |
], | |
"method": "PUT" | |
} | |
], | |
"description": "" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment