I have used the below code to run from SoapUI, but I still get a missing property exception:
No such property exists for class request
How do I resolve this issue?
def project = com.eviware.soapui.model.support.ModelSupport.getModelItemProject( request )
// initialize OAuth consumer
def consumer = new oauth.signpost.commonshttp.CommonsHttpOAuthConsumer( project.getPropertyValue( "oauth_consumer_key" ), project.getPropertyValue( "oauth_consumer_secret" ));
consumer.setTokenWithSecret( project.getPropertyValue( "oauth_access_token" ), project.getPropertyValue( "oauth_access_token_secret" ));
// sign the request
consumer.sign( context.httpMethod )
EDIT: took a look at the API guide, and it appears that you have the following:
def project = com.eviware.soapui.model.support.ModelSupport.getModelItemProject( request )
Then you call project.getPropertyValue
. According to the API guide, there is no such method called getPropertyValue
for com.eviware.soapui.model.support.ModelSupport
.
There is a interface called com.eviware.soapui.model.project. Unless you're inheriting from interface com.eviware.soapui.model.TestPropertyHolder, you're not going to get getPropertyValue
.
To help resolve your issue, you'll need to debug into your code. Depending on the results from 'request' on your first line, you might very well not have the property oauth_consumer_key
, oauth_consumer_secret
, oauth_access_token
or oauth_access_token_secret
. Output the contents of request
(or just set a break point in SoapUI at the def project
and work through validating if you have the property).
Otherwise, there are a couple of alternate ways to tackle your problem. These are solutions geared towards using OAuth with SoapUI.
Try the following:
def gu = new com.eviware.soapui.support.GroovyUtils( context );
def xml = gu.getXmlHolder( 'Authenticate - Default#Response' );
def token = xml.getNodeValue( '/auth/token' );
log.info( 'Got token: ' + token );
def suite = context.testCase.testSuite;
suite.setPropertyValue( 'auth_token', token );
log.info( 'Saved auth_token to suite.' );
The benefit of this code is that "the token sticks around in the TestSuite properties permanently. This has the side-effect/benefit of allowing me to run tests after the authentication test".
If that doesn't work, there's a great article here explaining how to do the OAuth against Vimeo; this should be very similar to the Twitter OAuth.
Neither of these solutions require SoapUI Pro.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With