我在IIS上运行带有Core 2.2 api后端(启用Windows身份验证)的角度应用程序。我有测试环境:量角器茉莉花。 Selenium服务器在本地启动。
测试项目package.json:
{
"name": "protractorautotests",
"version": "1.0.0",
"description": "protractor autotesting setup",
"scripts": {
"wdupdate": "node ./node_modules/protractor/bin/webdriver-manager update --proxy=http://127.0.0.1:3128",
"tsc": "tsc",
"test": "tsc && protractor tmp/protractor.config.js"
},
"author": "KPI",
"license": "ISC",
"dependencies": {
"@types/jasmine": "3.4.6",
"@types/jasminewd2": "2.0.8",
"@types/node": "12.7.12",
"jasmine": "3.5.0",
"jasmine-reporters": "2.3.2",
"protractor": "5.4.2",
"protractor-beautiful-reporter": "1.3.6",
"ts-node": "8.5.2",
"typescript": "3.6.4"
}
}
我需要从API获取一些数据以用于测试。因此,我尝试使用“请求”进行API调用:
var request = require('request');
beforeAll( () => {
request('htt://localhost/api/permission/rls', (err, resp, body) => {
console.log('error:', err);
console.log('statusCode:', resp && resp.statusCode);
console.log('body:', body);
});
});
它将返回带有注释的401.2:“由于无效的验证标头,您无权查看此页面。”请提供有关如何正确配置请求的建议。
谢谢!