下面是用于测试设备上的休息接口的脚本的开头,该设备具有带摘要认证的https服务器。 这是我在下面遇到问题的地方我已经设置了我没有得到错误所以我假设 Set Digest Auth admin secret有效
如果我无法进行身份验证:
#script
*** Settings ***
Resource variablesreal.txt
Library HttpLibrary.HTTP
Library PycURLLibrary
Library OperatingSystem
Test Setup Create HTTP Context ${HOST} https
*** Variables ***
${HEADER1} Content-Type: text/xml; charset=UTF-8
*** Test Cases ***
Set Digest Auth
Log Variables
Verbose
Add Header ${HEADER1}
Add Header version:1
Next Request Should Not Succeed
GET https://${HOST}/views
Set Digest Auth admin secret
GET https://${HOST}/views
Response Status Code Should Equal 200
Response Body Should Contain views
Log Response Status
Log Response
here is the out put from pybot hls.txt
==============================================================================
Hls
==============================================================================
Set Digest Auth | FAIL |
Request should have succeeded, but was "401 Unauthorized".
------------------------------------------------------------------------------
Hls | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================
Output: /home/robm/code/BDD/pycurl/hl/output.xml
Log: /home/robm/code/BDD/pycurl/hl/log.html
Report: /home/robm/code/BDD/pycurl/hl/report.html
关于摘要式身份验证的任何想法?
答案 0 :(得分:0)
我最终将此添加到RequestKeywords.py
def create_digest_session(self, alias, url, auth, headers={}, cookies=None, timeout=None, proxies=None, verify=False):
""" Create Session: create a HTTP session to a server
`url` Base url of the server
`alias` Robot Framework alias to identify the session
`headers` Dictionary of default headers
`auth` List of username & password for HTTP Digest Auth
`timeout` connection timeout
`proxies` proxy server url
`verify` set to True if Requests should verify the certificate
"""
digest_auth = requests.auth.HTTPDigestAuth(*auth) if auth else None
return self._create_session_local(alias, url, headers, cookies, digest_auth, timeout, proxies, verify)