Is it possible to use encrypted properties in karate?

874 Views Asked by At

I have an application.properties file with an encrypted property:

test.username='testUser'
test.password=ENC(3ncryp73dp@$$w0rd)

And I want to use the decrypted value in a feature file, kind of like:

Feature: Login

Scenario: Test login at myurl.com
Given url 'myurl.com/login'
And param username = testUsername
And param password = testPassword
When method GET
[etc]

Normally Spring-boot handles decrypting those properties and I can just use

@Value(${test.username})
protected String testUsername;

in my step definitions class to get a property from the application.properties file.

How can I do that with Karate?

1

There are 1 best solutions below

0
On BEST ANSWER

There is no direct support for this. My suggestion is use Java interop. You may be even able to tap into the code that Spring Boot uses if you add that to the classpath / maven dependencies. So you can end up with something like this:

And param username = MyUtil.decode(testUserName)
And param password = MyUtil.decode(testPassword)