2017-07-15 80 views
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

回答

0

使用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」 是正確的。 –

相關問題