2017-02-23 23 views
1

我正在使用pact java> Pact验证在提供者主机为localhost时有效。 如何提供其他主机详细信息? 当我指定这样的供应商,Pact >>除localhost之外的契约提供者主机


<serviceProvider> 
    <name>provider1</name> 
    <protocol>http</protocol> 
    **<host>**google.com**</host>** 
    <path>/</path> 

    <consumers> 
    <consumer> 
    <name>consumer1</name> 
    <pactFile>../pacts/test_consumer-test_provider.json</pactFile> 
    </consumer> 
    </consumers> 
</serviceProvider> 

我收到响应


Verifying a pact between consumer1 and provider1 
    [Using file ../pacts/test_consumer-test_provider.json] 
    Given test state 
     WARNING: State Change ignored as there is no stateChange URL 
    Invalid Information Model 
     Request Failed - google.com 

如何提供一些其他的主机详细信息?

回答

2

google.com不是有效的主机,它是Google的基本域名。你应该提供一个实际的主机名来发送请求。

例如,使用卷曲google.com

$ curl -v http://google.com 
* Rebuilt URL to: http://google.com/ 
* Trying 216.58.203.110... 
* Connected to google.com (216.58.203.110) port 80 (#0) 
> GET/HTTP/1.1 
> Host: google.com 
> User-Agent: curl/7.47.0 
> Accept: */* 
> 
< HTTP/1.1 302 Found 
< Cache-Control: private 
< Content-Type: text/html; charset=UTF-8 
< Referrer-Policy: no-referrer 
< Location: http://www.google.com.au/?gfe_rd=cr&ei=ckz9WMKPDYTr8weL36iABA 
< Content-Length: 262 
< Date: Mon, 24 Apr 2017 00:53:06 GMT 
< 
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8"> 
<TITLE>302 Moved</TITLE></HEAD><BODY> 
<H1>302 Moved</H1> 
The document has moved 
<A HREF="http://www.google.com.au/?gfe_rd=cr&amp;ei=ckz9WMKPDYTr8weL36iABA">here</A>. 
</BODY></HTML> 

返回一个响应302 Moved

如果在启用调试日志记录的情况下运行(maven的-X参数),则应该获取更多细节,以便验证者将请求视为失败。

0

主机是提供商的IP或主机名地址。因此,如果您的供应商允许说某处已部署,则必须提供该部署的IP地址。您不能随意提供HOSTNAME作为google.com。

相关问题