Open contactcuong opened 6 years ago
when you removing - validators:
the test passes? Because it says ERROR:Validator/Error details:Traceback (most recent call last):
When you using other validator, does it work?
Also ERROR:Test Failure, failure type: Extractor Exception, Reason: Extractor threw exception
maybe you need to change something in here jmespath: 'enrollmentState',
@mvitiuk yes that's correct, the test has passed when removing - validators:
Adding another kind of - validators:
should work too.
But both are not my initial expected as extra of data inputs would be required, i.e curl -vL -X POST -H "content-type: application/json" -d '{"carrierSubscriberNetworkId": "xxx", "countryCode": xxx, "hardwareId": "xxx"}' https://<my_url>:xxx/hls/services/1.0/service/discover
- validators:
[root@cuongnguyen ~]# cat payload_test1.yaml
---
- config:
- testset: "Payload_set"
- timeout: 100
- test:
- group: "[Payload Group]"
- name: "Payload_test"
- headers: {'Content-Type': 'application/json'}
- url: "/hls/services/1.0/service/discover"
- method: "POST"
- body: '{"carrierSubscriberNetworkId": "xxx", "countryCode": xxx, "hardwareId": "xxx"}'
- expected_status: [200, 201, 301, 302, 307]
[root@cuongnguyen ~]#
[root@cuongnguyen ~]#
[root@cuongnguyen ~]#
[root@cuongnguyen ~]# pyresttest https://xxx:8443 payload_test1.yaml --verbose --print-bodies true --print-headers true
...
<omit part>
...
[('server', 'nginx'), ('date', 'Fri, 08 Dec 2017 11:52:33 GMT'), ('content-type', 'application/json'), ('content-length', '0'), ('connection', 'close'), ('location', 'https://xxx:8443/hls/services/1.0/service/discover')]
Test Group [Payload Group] SUCCEEDED: : 1/1 Tests Passed!
[root@cuongnguyen ~]#
- validators:
[root@cuongnguyen ~]# cat payload_test2.yaml
---
- config:
- testset: "Payload_set"
- timeout: 100
- test:
- group: "[Payload Group]"
- name: "Payload_test"
- headers: {'Content-Type': 'application/json'}
- url: "/hls/services/1.0/service/discover"
- method: "POST"
- body: '{"carrierSubscriberNetworkId": "xxx", "countryCode": xxx, "hardwareId": "xxx"}'
- expected_status: [200, 201, 301, 302, 307]
- validators:
- compare: {header: 'Content-Type', expected: 'application/json'}
[root@cuongnguyen ~]#
[root@cuongnguyen ~]#
[root@cuongnguyen ~]#
[root@cuongnguyen ~]# pyresttest https://xxx:8443 payload_test2.yaml --verbose --print-bodies true --print-headers true
...
<omit part>
...
[('server', 'nginx'), ('date', 'Fri, 08 Dec 2017 11:54:40 GMT'), ('content-type', 'application/json'), ('content-length', '0'), ('connection', 'close'), ('location', 'https://xxx:8443/hls/services/1.0/service/discover')] Test Group [Payload Group] SUCCEEDED: : 1/1 Tests Passed! [root@cuongnguyen ~]#
Don't really follow, sorry. Do you want it as - body: '{"carrierSubscriberNetworkId": "generated1", "countryCode": generated2, "hardwareId": "generated3"}
In this case you can use:
- body: { template: '{ "carrierSubscriberNetworkId": "generated1",.....}' }
and add a generator function in config or so
- generators:
- 'urlvalue': { type: 'env' }```
@mvitiuk I am not sure for the declaration inside body:
, please forget my body:
section, my expectation is what is the best practice of yaml file for following REST, with condition: if stdout of "enrollmentState" contains "Provisioned" string ; then test should PASS!
.
Your help would be highest appreciated. Thank you!
$ curl -vL -X POST -H "content-type: application/json" -d '{"carrierSubscriberNetworkId": "xxx", "countryCode": yyy, "hardwareId": "zzz"}' https://<my_url>:xxx/hls/services/1.0/service/discover
{
"enrollmentState": "Provisioned",
"serviceData": {
"partnerId": "xxx",
"tenantId": "xxx",
"subscriberNetworkId": "xxx",
"deviceId": "xxx",
"subscriberEndpoint": "xxx",
"otpEndpoint": "xxx",
"operatorEndpoint": "xxx",
"notifyEndpoint": "xxx",
"scepEndpoint": "xxx",
"ntpEndpoint": "xxx",
"snidJoined": false,
"utcTimestamp": 1507615533293,
"authenticationMode": "io",
"homeEndpoint": "xxx",
"countryCode": xxx,
"di": xxx
},
"retryInterval": 86400
}
Hi,
My REST requires couple of data inputs (json format) in order pass the test but I cannot deal with this inside the yaml file. I firstly tried to seeking similar issue around and no luck.
Thanks for help!