Forum Discussion

jvane123tcs's avatar
jvane123tcs
New Contributor
8 years ago

Generating SHA1 based on fields of XML request and including it in DataSource Loop

Hello all,

 

I've been setting up a testCase with multiple steps. Below are the steps I currently have. (Note that both scripts aren't working completely yet)

The topic of this post is on the GenerateHash script. In that script I need to generate a SHA1 hash of the fields represented in the CardInfo SOAP request. I've already managed to obtain the data which will be used in the fields with the use of:

def requestID = context.expand('${DB_Remote_Conn#XMLData_RequestID}')

However I still need an API to generate the SHA1 hash, which I have been unable to find. Therefore the first part of my request is whether any of you know which API I should use.

 

A second part of my question is how I should then enter the generated SHA1 hash in the (I think it is) context, so that I may use it again in the request in the same way as the other fields. I have been unable to find a clear cut example, for me to emulate. This is what I currently use. (Note: this is not working)

testRunner.testCase.setPropertyValue('HASH_request', '<GENERATED_HASH>')

 

My third and final question is where I should place this step so that it is executed every iteration the DataSource Loop makes. Can it stay in a seperate step script, or must I include it somehow in the SOAP request of CardInfo?

 

Thank you for time.

1 Reply

  • jvane123tcs's avatar
    jvane123tcs
    New Contributor

    I believe I have already solved the first and third part of my questions.

     

    For the first part I have found a code snippet, which was relevant for me and generated a sha1 hash. The snippet was located here: https://gist.github.com/pditommaso/cf724c1d2353342784f0

     

    For the third part, I found I was able to change the 'Target Step' property of the DataSource Loop. Which solved my problem readily.

     

    I still haven't found an answer yet to my second question, so if anyone would be able to answer it, I'd really appreciate it.

     

    Thanks for being my rubber duckies.