Karate: NTLM support for Karate

Created on 13 Apr 2018  路  9Comments  路  Source: intuit/karate

Below is the snippet from Jenkins.feature file:

**Feature: Web Service Testing
Background:

  • configure ssl = true
    Scenario: Verify that Product service gives the response when searched with particular SKU
    Given url 'URL'
    When method get
    Then status 200**

When I run this, below error is thrown:

**SEVERE: 1 * Client response received on thread main
1 < 401
1 < Content-Length: 1293
1 < Content-Type: text/html
1 < Date: Fri, 13 Apr 2018 13:01:33 GMT
1 < Server: Microsoft-IIS/8.5
1 < WWW-Authenticate: Negotiate,NTLM
1 < X-Powered-By: ASP.NET




401 - Unauthorized: Access is denied due to invalid credentials.


401 - Unauthorized: Access is denied due to invalid credentials.

You do not have permission to view this directory or page using the credentials that you supplied.


**

When I tried to hit the same URL with POSTMAN, i am getting 3 entries in Fiddler, where two entries are with response code 401 and the third one is 200. It is using NTLM method for authentication.

But in Karate I am getting only one 401 response.

Is there any way in Karate to handle NTLM?

enhancement help wanted

Most helpful comment

I'm reopening this ticket as a "help wanted" ticket

All 9 comments

not directly. if you look at the fiddler calls you should be easily able to make those 3 calls in Karate. all the best.

actually this may be more complicated. you may need to write a Java helper based on the info here for example: https://hc.apache.org/httpcomponents-client-ga/ntlm.html

the project developers will not be able to implement this as part of karate. this will have to come from you or the community. if you manage to find a solution, please post it back here so that it can help others.

I'm reopening this ticket as a "help wanted" ticket

closing due to inactivity

Hi Peter

I don't suppose you have any more thoughts on how this could be implemented? I understand how to use java classes in my karate tests but not sure how I should be implementing a java class for NTLM.

Cheers

Paul

@paulmccormack unfortunately I don't have much idea either, would love for someone to contribute this.

thinking aloud, if you can implement a command-line executable in .NET that does this, you can scrape the result using Java's System.exec: https://www.mkyong.com/java/how-to-execute-shell-command-from-java/

Thanks for the quick response. I will review the link you have provided.
Cheers
Paul

Anyone found a solution for this issue ?

@chandru9050 besides the info in this thread, see if this Stack Overflow post gives you ideas: https://stackoverflow.com/a/51150286/143475 - in my opinion it is worth asking your .NET team to write a small command-line utility to get you the right header / token values.

else sorry, karate does not support NTLM natively.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hascode picture hascode  路  3Comments

JuliaSv picture JuliaSv  路  5Comments

IsaoTakahashi picture IsaoTakahashi  路  3Comments

bAmrish picture bAmrish  路  3Comments

76creates picture 76creates  路  3Comments