Forum Discussion
nickspacek
15 years agoOccasional Contributor
I'm testing a WebService that uses a similar sort of authentication. The first request to the WebService is for authentication, and the response contains a token that must be sent in all the rest of the requests.
To make this work, that authentication test has to be run first (not ideal). I wrote a GroovyScript test step that saves the token to the TestSuite. I wanted to save the token to the current set of tests that are being run, but I'm not sure where to put it so that it is accessible for all the tests currently being run (any advice would be great).
It works as is, and for better or worse 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. Here's the script:
To make this work, that authentication test has to be run first (not ideal). I wrote a GroovyScript test step that saves the token to the TestSuite. I wanted to save the token to the current set of tests that are being run, but I'm not sure where to put it so that it is accessible for all the tests currently being run (any advice would be great).
It works as is, and for better or worse 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. Here's the script:
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.' );
Related Content
- 3 years ago
- 8 years ago