ROBOTFRAMEWORK 的摘要式身份验证
Posted
技术标签:
【中文标题】ROBOTFRAMEWORK 的摘要式身份验证【英文标题】:Digest Authentication for ROBOTFRAMEWORK 【发布时间】:2015-03-20 13:45:38 【问题描述】:下面是在设备上测试 rest 接口的脚本的开头,该设备有一个带有摘要式身份验证的 https 服务器。 这是我在下面遇到问题的地方我已经设置了我没有收到错误所以我假设 设置 Digest Auth 管理员密码有效
如果是我无法验证的内容:
#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
关于摘要式身份验证的任何想法?
【问题讨论】:
bump...有人使用 RobotFramework 进行过 Digest 身份验证吗? 【参考方案1】:我最终将它添加到 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)
【讨论】:
以上是关于ROBOTFRAMEWORK 的摘要式身份验证的主要内容,如果未能解决你的问题,请参考以下文章