user7609556
user7609556

Reputation: 11

Pact >> Pact Provider host other than localhost

I'm using pact java > Pact verify works when the provider host is localhost. How do I provide some other host details? When I specify a provider like this,


<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>

I receive a response


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

How do I provide some other host details?

Upvotes: 1

Views: 808

Answers (2)

cotnic
cotnic

Reputation: 168

The host is the IP or hostname address of the Provider. So if you have your provider lets say somewhere deployed, you have to provide the IP address of that deployment. You can not just randomly provide HOSTNAMEs as google.com.

Upvotes: 0

Ronald Holshausen
Ronald Holshausen

Reputation: 931

google.com is not a valid host, it is Google's base domain name. You should provide an actual host name to send the requests to.

For example, using curl to 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>

returns a 302 Moved response.

If you run with debug logging enabled (-X parameter for maven), you should get more details as why the verifier treated the request as a failure.

Upvotes: 4

Related Questions