I declared variables in config and I am using them in the test case below. The variables are not passing. I am not able to figure out the actual issue.
- config:
- variable_binds: {'user_id': 'ravitej', 'pass': 'password', 'auth': 'plain'}
- test:
- name:"login success"
- url: "/api/login"
- method: "POST"
- body: '{"username": "$user_id", "password": "$pass", "authtype": "$auth"}'
- headers: {Content-Type: application/json}
- expected_status: [200]
- group: "User"
In this below case: I'm running the first test set and I'm getting some auth_token in response this auth_token is saved to auth_key to use in another test set, but this auth_key is not passing to the 2nd test set. It was passing an empty variable. I tried all possible ways which are posted in GitHub still I am getting the same problem
- test:
- name: "Registration"
- url: "/api/register"
- method: "POST"
- body: '{"device_id": "0080", "device_key": "imAck", "device_name": "teja", "device_description": "Added By Ravi", "project_tag": "MYSTQ-16", "attributes": "{}"}'
- headers: {Content-Type: application/json}
- expected_status: [200]
- group: "Register"
- extract_binds:
- 'auth_key': {'jsonpath_mini': 'auth_token'}
- test:
- name: "Status"
- url: "/api/status"
- method: "POST"
- body: '{"attributes": {"num_ports": "2", "model": "Phillips", "firmware_ver": "8.0.1", "ipaddress": "192.168.0.0", "rssi": "Not Available"}}'
- headers: {Content-Type: application/json, auth_token: "$auth_key"}
- expected_status: [200]
- group: "Status"
need to use template headers, like
headers: {template: {Content-Type: application/json, auth_token: "$auth_key"}}
Example: headers: {template: {'$headername': '$headervalue', '$cache': '$cachevalue'}}
its worked fine now