如何处理401未经授权的回复i Jmeter V3.0或更低版本?

问题描述:

我正在尝试使用admin:admin作为凭据登录the-internet.herokuapp.com/basic_auth。如何处理401未经授权的回复i Jmeter V3.0或更低版本?

我使用的是Jmeter v3.0,我添加了HTTP授权管理器,Cookie管理器,并在头像管理器中添加了名称和值,如图所示,但我仍然收到401未经授权的响应。

我在与Jmeter v3.1及其工作不同的系统中尝试过同样的事情。

有谁知道如何解决Jmeter v3.0或更低版本的问题?

enter image description here

使用JMeter的3.0,只有具有HTTP Authorization Manager从HTTP请求中添加的除了我无法重现你的问题:

enter image description here

这里是一个充满Test Plan以防万一:

<?xml version="1.0" encoding="UTF-8"?> 
<jmeterTestPlan version="1.2" properties="2.9" jmeter="3.0 r1743807"> 
<hashTree> 
    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true"> 
    <stringProp name="TestPlan.comments"></stringProp> 
    <boolProp name="TestPlan.functional_mode">false</boolProp> 
    <boolProp name="TestPlan.serialize_threadgroups">false</boolProp> 
    <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true"> 
     <collectionProp name="Arguments.arguments"/> 
    </elementProp> 
    <stringProp name="TestPlan.user_define_classpath"></stringProp> 
    </TestPlan> 
    <hashTree> 
    <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true"> 
     <stringProp name="ThreadGroup.on_sample_error">continue</stringProp> 
     <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true"> 
     <boolProp name="LoopController.continue_forever">false</boolProp> 
     <stringProp name="LoopController.loops">1</stringProp> 
     </elementProp> 
     <stringProp name="ThreadGroup.num_threads">1</stringProp> 
     <stringProp name="ThreadGroup.ramp_time">1</stringProp> 
     <longProp name="ThreadGroup.start_time">1500191430000</longProp> 
     <longProp name="ThreadGroup.end_time">1500191430000</longProp> 
     <boolProp name="ThreadGroup.scheduler">false</boolProp> 
     <stringProp name="ThreadGroup.duration"></stringProp> 
     <stringProp name="ThreadGroup.delay"></stringProp> 
    </ThreadGroup> 
    <hashTree> 
     <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Request" enabled="true"> 
     <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true"> 
      <collectionProp name="Arguments.arguments"/> 
     </elementProp> 
     <stringProp name="HTTPSampler.domain">the-internet.herokuapp.com</stringProp> 
     <stringProp name="HTTPSampler.port"></stringProp> 
     <stringProp name="HTTPSampler.connect_timeout"></stringProp> 
     <stringProp name="HTTPSampler.response_timeout"></stringProp> 
     <stringProp name="HTTPSampler.protocol"></stringProp> 
     <stringProp name="HTTPSampler.contentEncoding"></stringProp> 
     <stringProp name="HTTPSampler.path">/basic_auth</stringProp> 
     <stringProp name="HTTPSampler.method">GET</stringProp> 
     <boolProp name="HTTPSampler.follow_redirects">true</boolProp> 
     <boolProp name="HTTPSampler.auto_redirects">false</boolProp> 
     <boolProp name="HTTPSampler.use_keepalive">true</boolProp> 
     <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> 
     <boolProp name="HTTPSampler.monitor">false</boolProp> 
     <stringProp name="HTTPSampler.embedded_url_re"></stringProp> 
     </HTTPSamplerProxy> 
     <hashTree> 
     <AuthManager guiclass="AuthPanel" testclass="AuthManager" testname="HTTP Authorization Manager" enabled="true"> 
      <collectionProp name="AuthManager.auth_list"> 
      <elementProp name="" elementType="Authorization"> 
       <stringProp name="Authorization.url"></stringProp> 
       <stringProp name="Authorization.username">admin</stringProp> 
       <stringProp name="Authorization.password">admin</stringProp> 
       <stringProp name="Authorization.domain"></stringProp> 
       <stringProp name="Authorization.realm"></stringProp> 
      </elementProp> 
      </collectionProp> 
     </AuthManager> 
     <hashTree/> 
     </hashTree> 
     <ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true"> 
     <boolProp name="ResultCollector.error_logging">false</boolProp> 
     <objProp> 
      <name>saveConfig</name> 
      <value class="SampleSaveConfiguration"> 
      <time>true</time> 
      <latency>true</latency> 
      <timestamp>true</timestamp> 
      <success>true</success> 
      <label>true</label> 
      <code>true</code> 
      <message>true</message> 
      <threadName>true</threadName> 
      <dataType>true</dataType> 
      <encoding>false</encoding> 
      <assertions>true</assertions> 
      <subresults>true</subresults> 
      <responseData>false</responseData> 
      <samplerData>false</samplerData> 
      <xml>false</xml> 
      <fieldNames>true</fieldNames> 
      <responseHeaders>false</responseHeaders> 
      <requestHeaders>false</requestHeaders> 
      <responseDataOnError>false</responseDataOnError> 
      <saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage> 
      <assertionsResultsToSave>0</assertionsResultsToSave> 
      <bytes>true</bytes> 
      <threadCounts>true</threadCounts> 
      <idleTime>true</idleTime> 
      </value> 
     </objProp> 
     <stringProp name="filename"></stringProp> 
     </ResultCollector> 
     <hashTree/> 
    </hashTree> 
    </hashTree> 
</hashTree> 
</jmeterTestPlan> 

我会建议删除您的Authorization他以防万一。

请参阅How to Use HTTP Basic Authentication in JMeter文章,了解有关在JMeter测试中绕过基本访问身份验证的更多详细信息。


据hightly推荐使用最新的JMeter版本在可能情况下在新的版本通常配有bug修复,性能改进和全新的功能,所以可以考虑升级到JMeter的3.2(或任何可用的最新版本的JMeter Downloads page)

+0

感谢您的回应德米特里。我从HTTP标题管理器中删除了授权标头,并使用了HTTP授权管理器。 以下是我的授权经理的详细信息。 url =“the-internet.herokuapp.com/basic_auth”\t用户名“admin”密码“admin”\t \t \t mehcnism“BASIC_DIGEST” 是正确的。 –