java - QAF:运行带有 NTLM 请求的脚本时出现“401 未经授权:访问被拒绝”
问题描述
我已经实现了 NTLMAuthClient 类
rest.client.impl=com.qmetry.qaf.automation.ws.client.NTLMAuthClient
进入项目属性,但仍然出现上述错误。
这是我正在使用的 JSON 请求模板,我不确定该结构是否是导致错误的原因:
{
"headers":
{
"Authorization":
[
{
"username": "${ntlm.user}",
"password": "${ntlm.password}"
},
{
"domain": "${ntlm.domain}"
}
],
"Content-Type":"application/json"
},
"endPoint": "",
"baseUrl": "${base_url}/api/data/v4/contacts(integrationkey='${clientNumber}')",
"method": "PATCH",
"body":
{
"userid": ""
}
}
以下是 QMetry 报告的回复:
要求
客户端出站请求 PATCH https://xxxx.com/CRMDEV2/api/data/v4/contacts(integrationkey='xxxx') 授权:[{username=xxxx, password=xxxx}, {domain=xxxx}] 内容-类型:应用程序/json {"userid":""}
回应
客户端入站响应 401 REQ_ID:3d391170-40d7-4ea6-80ca-2531a7fe73ff 服务器:WWW-Authenticate:NTLM WWW-Authenticate:Negotiate Set-Cookie:ReqClientId=21490c2c-bdfe-4c00-9330-401ca0bb5811;到期=格林威治标准时间 2071 年 10 月 22 日星期四 11:59:11;路径=/; 安全的; HttpOnly 内容长度:49 日期:2021 年 10 月 22 日星期五 11:59:11 GMT 内容类型:文本/纯 HTTP 错误 401 - 未经授权:访问被拒绝
感谢帮助。
我正在使用的 QAF 和 Selenium 版本:
QAF 版本:2.1.14
硒:3.141.59
解决方案
请参阅NTLMAuthClient java-doc。而不是请求调用标头中的授权,您应该尝试提供由NTLMAuthClient
.
NTLMAuthClient
类使用以下属性:
ntlm.user - The user name. This should not include the domain to authenticate with. For example: "user" is correct whereas "DOMAIN\\user" is not.
ntlm.password - The password
ntlm.workstation - workstation (default is blank) The workstation the authentication request is originating from. Essentially, the computer name for this machine.
ntlm.domain- domain The domain to authenticate within (default is blank).
#register NTLMAuthClient
rest.client.impl=com.qmetry.qaf.automation.ws.client.NTLMAuthClient
在您的属性文件中设置上述属性,然后在请求调用标头中尝试未经授权。
推荐阅读
- vim - 如何在不关闭的情况下安装 vim 插件并重新打开我正在处理的文件?
- html - XPath:嵌套的方括号是什么意思?
- ruby-on-rails - 某些页面未加载公共资产
- php - xml child 中的图像名称不止一个,并受到 php 的限制
- c# - 使用 Entity Framework Core 和 C# 根据行号加载更多记录
- pandas - 计算差异选择元素熊猫数据框列
- python - Numba 的运行速度比原始 Python 慢很多
- html - 当我将页面调整为小屏幕时,标签控件与文本框重叠
- reactjs - 反应:将动态 id 分配给按钮/tr,以便我只能为选定行打开表单
- android - 并非所有属性都可以在 Android Studio 中以编程方式更改