Forum Discussion
PLandhage
12 years agoNew Contributor
Thank you for answer. I managed to fix this according to your instructions.
Problem is that is I have to hard code the value ie
digest.update("11941141".getBytes())
digest.update("AUTHORIZATION".getBytes())
...
Since I will use this code for many teststeps it would be much easier if I can loop the fields and get the values (and field name)
Checked API documentation (and forum) and found this to get a reference to the test step but do not know how to go any further.
This is the psedocode to explain what I want to do. The highlighted code in red needs to be replaced.
import java.security.MessageDigest
def digest = MessageDigest.getInstance("MD5")
def testStep = context.testCase.getTestStepByName("Initialize8")
def fields = testStep.getFields()
fields.each() {
name = fields.current.getName()
if ( ! name == "pxor:hash" ) {
def value = fields.current.getValue()
digest.update( value.getBytes() )
}
}
def hashValue = new BigInteger(1,digest.digest()).toString(16).padLeft(32,"0")
testRunner.testCase.setPropertyValue( "request_hash", hashValue )
Problem is that is I have to hard code the value ie
digest.update("11941141".getBytes())
digest.update("AUTHORIZATION".getBytes())
...
Since I will use this code for many teststeps it would be much easier if I can loop the fields and get the values (and field name)
Checked API documentation (and forum) and found this to get a reference to the test step but do not know how to go any further.
This is the psedocode to explain what I want to do. The highlighted code in red needs to be replaced.
import java.security.MessageDigest
def digest = MessageDigest.getInstance("MD5")
def testStep = context.testCase.getTestStepByName("Initialize8")
def fields = testStep.getFields()
fields.each() {
name = fields.current.getName()
if ( ! name == "pxor:hash" ) {
def value = fields.current.getValue()
digest.update( value.getBytes() )
}
}
def hashValue = new BigInteger(1,digest.digest()).toString(16).padLeft(32,"0")
testRunner.testCase.setPropertyValue( "request_hash", hashValue )
Related Content
- 5 years ago
- 2 years ago
Recent Discussions
- 22 days ago