elysialock
11 years agoOccasional Contributor
Best approach for handling URLs without hard coding?
Hi everyone,
While I'm a seasoned SoapUI user, I'm new to the Pro version, and thus new to the concept of how environments work within SoapUI Pro. I'm working on a RESTFUL API that uses HATEOAS principles. HATEOAS testing is also new to me.
I'm trying to avoid hard-coding URLs into each of my test steps in order to make it easy to run in various dev, staging, and QA environments.
Originally my approach was to grab the URL from a response and transfer it to the endpoint of subsequent test steps. It's great when the response looks like this:
but when I have a response that looks like this, with the parameters included:
It doesn't work because {?page,size,sort,name,status} is included in the endpoint for subsequent tests. I need to pass just http://dev.foo.com/web-rest/webapi/clients so the request can complete without a 400, 401, or 404.
So, how should I handle this? Is this response format common for REST APIs using HATEOAS? Is there a way for me to use the links provided in the responses in subsequent test steps so that I only have to specify the domain/starting endpoint at the beginning of my test runs? Should I ask the developer to change the way the response is laid out so that the possible parameters are not included in the links? Can environments take care of this for me? Halp!!1!
Thanks!
-E
While I'm a seasoned SoapUI user, I'm new to the Pro version, and thus new to the concept of how environments work within SoapUI Pro. I'm working on a RESTFUL API that uses HATEOAS principles. HATEOAS testing is also new to me.
I'm trying to avoid hard-coding URLs into each of my test steps in order to make it easy to run in various dev, staging, and QA environments.
Originally my approach was to grab the URL from a response and transfer it to the endpoint of subsequent test steps. It's great when the response looks like this:
{
"link" : [ {
"rel" : "self",
"href" : "http://dev.foo.com/web-rest/webapi/authenticated"
}
but when I have a response that looks like this, with the parameters included:
{
"rel" : "clients",
"href" : "http://dev.foo.com/web-rest/webapi/clients{?page,size,sort,name,status}"
}
It doesn't work because {?page,size,sort,name,status} is included in the endpoint for subsequent tests. I need to pass just http://dev.foo.com/web-rest/webapi/clients so the request can complete without a 400, 401, or 404.
So, how should I handle this? Is this response format common for REST APIs using HATEOAS? Is there a way for me to use the links provided in the responses in subsequent test steps so that I only have to specify the domain/starting endpoint at the beginning of my test runs? Should I ask the developer to change the way the response is laid out so that the possible parameters are not included in the links? Can environments take care of this for me? Halp!!1!
Thanks!
-E