The record and playback of the NTLM authenticated server are not straightforward in DevTest.
NTLM is actually a 3 request handshake where the client (browsers, apps, etc.) don't send any credentials on their first request for a resource. This means that the first request is anonymous, even if credentials have been configured for that resource. This anonymous request, when Windows Auth is enabled and Anonymous Auth is disabled, results in an HTTP 401 status.
The 2nd request would be the NTLM challenge where the client re-sends the original request with an additional "Authorization" header, containing the NTLM Type-1 message. The server then sends the NTLM challenge (Type-2 message) back to the client with HTTP 401 status.
The 3rd request would be the original request where the client sends it one more time by adding the challenge response (NTLM Type-3 message) in the "Authorization" header. The server then authenticates the user and sends back the response with HTTP 200 status (if successful).
See below:
Release : 10.6
Component : CA Service Virtualization
As NTLM authenticated web service makes 3 requests (in fact all are the same 'EXACT' requests including arguments in the 'DevTest' world) for a single transaction with(or without) Authorization header depending on the response during the handshake, the current default matching logic in DevTest would fail to give the correct responses during playback. Also, it depends on how the client is executing the calls during playback. It can be a full handshake(3 requests) for every call or 2 requests by preemptively sending the NTLM web authentication type-1 message or just one request by sending NTLM type-2 message directly( as obtained from a separate login call) without repeating handshake. So it becomes challenging for DevTest to perform the matching of incoming requests from clients with an appropriate response.
Add an explicit matching logic to handle NTLM authentication during playback using any of the below methods.
Request#1 (Anonymous Request)
Request#2 NTLM Challenge
Request#3 Original Request
%beanshell%
import
com.itko.util.ParameterList;
import
com.itko.util.Parameter;
import
com.itko.lisa.vse.stateful.model.ArgumentType;
incomingMetaData = lisa_vse_request.getMetaData();
ParameterList args = lisa_vse_request.getArguments();
if
(!incomingMetaData.containsKey(
"Authorization"
) || !incomingMetaData.
get
(
"Authorization"
).startsWith(
"Negotiate"
)) {
args.addParameter(
new
Parameter(
"auth"
,
null
));
}
else
if
(incomingMetaData.containsKey(
"Authorization"
) && incomingMetaData.
get
(
"Authorization"
).startsWith(
"Negotiate"
))
{
authValue = incomingMetaData.
get
(
"Authorization"
);
result =
new
sun.misc.BASE64Decoder().decodeBuffer(incomingMetaData.
get
(
"Authorization"
).substring(
10
));
if
(result[
8
]==
1
) {
args.addParameter(
new
Parameter(
"auth"
, authValue));
}
else
if
(result[
8
]==
3
) {
ArgumentType type =
new
ArgumentType();
type.setOperator(ArgumentType.Operator.ANY);
args.addParameter(
new
Parameter(
"auth"
, authValue, type));
//args.addParameter(new Parameter("auth", authValue));
}
}
lisa_vse_request.setArguments(args);
Perform full handshake (3 requests) as shown below and verify the responses:
. Raw Traffic file: NTLM_raw_traffic.xml - use this sample file to record the NTLM authenticated service.