0

I downloaded Karate as a stand alone executable, and it's working well.

I want to mask sensitive headers in the 'log' output. I gather that the way to do that is via configuring a logModifier.

But, I can't figure out to make it effective.

I tried the following:

  1. put this snippet in my karate-config.js :
  var LM = Java.type('demo.headers.DemoLogModifier');
  karate.configure('logModifier', LM.INSTANCE);
  1. in the root of where the karate stand-alone binary exists, i made the directory src/demo/headers/, and then put my DemoLogModifier.java in that dir. I also tried putting the .java in a different tree: src/test/java/demo/headers. I also tried putting in that same directory hierarchy at the root of where my *.feature files are. In every case, karate fails every Scenario, saying "TypeError: Access to host class demo.headers.DemoLogModifier is not allowed or does not exist".

Is this possible to do with the stand alone executable? If so, how?

If not, how then? I'm a java newbie, and i can't tell from the documentation how to make my own stand-alone jar and include my custom DemoLogModifier.java class.

Thanks!

Jon Detert
  • 51
  • 4

1 Answers1

0

Yes, when you need to use a LogModifier, it requires you to build Java code.

Can you refer to this answer, it should get you on your way: https://stackoverflow.com/a/56458094/143475

The good thing is that the Java side is a one-time effort, so do consider getting the help of someone else just for that part. Then you will be up and running.

Feel free to submit a feature request for making this easier for the standalone JAR in the future.

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248