ZenWave360 / karate-ide

The Best OpenSource IDE for KarateDSL.
https://marketplace.visualstudio.com/items?itemName=KarateIDE.karate-ide
Other
9 stars 4 forks source link

Improvements #28

Closed Mohitkrishna12 closed 1 year ago

Mohitkrishna12 commented 1 year ago

Hi @ivangsa ,

I think it would be great if it is possible to pass 'args' as a parameter directly in call read('classpath:karate-auth.js') args instead of passing it as 'args.auth'. So that in 'karate-auth.js' file we can write our own authentication logic with the help of other args. Like passing wrong access token based on the status code to get 404 error.

* def authHeader = call read('classpath:karate-auth.js') args.auth
* def headers = karate.merge(args.headers || {}, authHeader || {})

(Code snippet taken from the auto generated file).

ivangsa commented 1 year ago

Hi @Mohitkrishna12

thanks for this idea, I'm all in favor of flexibility

I think you can already achieve that logic inside karate-auth.js:

* def auth = { username: '', password: '', otherinfo: '' }
image

This works...

Let me know if this can solve your use case.

Mohitkrishna12 commented 1 year ago

Thanks a lot @ivangsa karate.get("any karate property") works fine as I expected it helps.