Service Virtualization

 View Only
  • 1.  How do you use encrypted properties in a Script test step?

    Broadcom Employee
    Posted May 31, 2018 03:40 PM

    I am working on a test that uses the Beanshell Script test step. In the scripting code I am referencing a Java API that uses a Login object to authenticate to an external system. In the project.config I have created properties for the username and password to log into the external system. I have checked the "encrypt" checkbox to encrypt the password so it is not visible to users who have access to the project. When attempting to use the password in the Script object by calling TestExec.getStatObject (property key), the password is not returned in the Script code to use in in the Login method. I have tried other methods such as getStateString and lookupLisaPropsValue.

     

    How can I access the encrypted password in a Script step? Assuming the test step must be a Script step, what is the best method to secure credentials that may be used within the Script step?

     

    Thank you,

     

    Mark



  • 2.  Re: How do you use encrypted properties in a Script test step?

    Posted Jun 01, 2018 07:03 AM

    Assuming you, for the sake of argument, created an encrypted password in a property called PASSWORD, then

     

    testExec.getStateValue("PASSWORD") would return the unencrypted password. 

     

    Internally in the config, the password would be stored as a property named PASSWORD_enc - the "_enc" can be considered as a flag to tell DevTest to decrypt the property on retrieval.



  • 3.  Re: How do you use encrypted properties in a Script test step?

    Broadcom Employee
    Posted Jun 01, 2018 07:57 AM

    HI Dave,

     

    I do see that the password property name is now stored as password_enc. When I try to use the password in the Script code using testExec.getStateValue (password), no value is returned. Are you suggesting to use testExec.getStateValue (password_enc) and DevTest should return the password decrypted?

     

    Thank you,

     

    Mark



  • 4.  Re: How do you use encrypted properties in a Script test step?
    Best Answer

    Posted Jun 01, 2018 08:11 AM

    The key name must be in quotes.

     

    Since a picture is worth a thousand words, here are two...

     

    Property setting

     

    Script to retrieve password

     

    The PASSWORD property was, indeed, set to the UK meta-variable of "fred"



  • 5.  Re: How do you use encrypted properties in a Script test step?

    Broadcom Employee
    Posted Jun 01, 2018 09:19 AM

    Thank you Dave for the "thousand words" and clarification. I was able to try it and works as expected. Thank you!