How to test a REST service that uses JWT in SoapUI?

I am implementing some REST services. All my tests are done using SoapUI. I recently decided to use JSON Web Token (JWT) for authentication, but I could not find support for this in SoapUI (native installation or plugins, nothing).

I found some online generators, such as http://jwtbuilder.jamiekurtz.com/ , but all the fields to copy / paste in SoapUI again and again for each test test are ineffective at all.

I am wondering if there is a way to test JWT stuff in SoapUI or maybe I need another tool. Any tips?

Thanks!

+5
source share
1 answer

I found a semi-automatic way to save a valid JWT token in TestCase without wasting too much time using an external file containing the token.

  • Have an external tool generating a valid JWT token in a file.
  • Open the project in SoapUI and add the jwt variable with the value ${=new File('/path/to/token_file.txt').text}

  • In your queries, specify your variable as a JWT header with the value ${#Project#jwt}

When the token expires, just restart the script generator and SoapUI will automatically load the new token.

+2
source

Source: https://habr.com/ru/post/1235259/


All Articles