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?
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.
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?
The key name must be in quotes.
Since a picture is worth a thousand words, here are two...
The PASSWORD property was, indeed, set to the UK meta-variable of "fred"
Thank you Dave for the "thousand words" and clarification. I was able to try it and works as expected. Thank you!