Testing MobileFirst Adapters with SoapUI
DougBreaux 270007SMYJ Visits (9526)
The key concepts are described in that article, and they including obtaining a Security Token before making subsequent calls, if your Resources are protected.
The section on testing with Postman covers the activities in detail, so I won't repeat most of that here. Just enough for a bit easier copy/paste.
Mainly I wanted to add some screenshots and steps specific to configuring SoapUI for this testing.
Get the Token
After creating a new REST project, you want to get the security token.
For starters, here's the "top" of my SoapUI project, with the "api" resource and "token" sub-resource under it:
The resource URL (as listed in the above article) is: http
You only need one message for this, which I've named "Request Token". It looks like this:
For the Basic Auth Username and Password, specify a user you've configured in the MFP Console. (The referenced article mentions a default user/pass that exists in a development environment, but my test environment is a separate server, so I had to create a user for this purpose.)
When you run this, the response will be JSON with a long token in the access_token field:
Add the Token to Adapter Requests
Now you need to add that token value as a custom HTTP header named "Authorization", not as an HTTP Basic Auth header.
But you don't want to have to add that header individually to every message, and you also don't want to have to update it all over the place when it expires and you have to generate a new one.
SoapUI Project Properties
So I added a Bearer property at the top level of my SoapUI project:
Whenever I need to generate a new Token, I update the value here.
Add the Authorization Header to Messages
Now, for each of my protected Resources - or even at a parent Resource above them, if that makes sense - I added a "Header" type request parameter, in the Resource itself, rather than in individual HTTP Methods or Messages. In this case, at the highlighted level:
Add a HEADER type parameter named Authorization, with the value:
to pull the value from the Project Property above.
Now all Messages under that Resource will automatically add that Header to their Requests.
(Any Messages which were created before you added this parameter, though, might not automatically pick it up.)