pact-foundation / pact-js

JS version of Pact. Pact is a contract testing framework for HTTP APIs and non-HTTP asynchronous messaging systems.
https://pact.io
Other
1.59k stars 343 forks source link

pactBrokerToken missing in MessageProviderOptions #436

Closed Safiyya closed 4 years ago

Safiyya commented 4 years ago

Software versions

Confirm the following:

I cannot make my async API testing work while using Pactflow as a pact broker. The pactBrokerToken is missing from the list of options and I get a 401 as a result when verifying my contracts on the provider side.

Here is the provider.pact.test.ts :

import { MessageProviderPact } from '@pact-foundation/pact';

describe('Publishes event on  topic', () => {

  const p = new MessageProviderPact({
    messageProviders: {
      'an event': () => {
        return Promise.resolve({
          slug: 'xxxxxx',
        });
      },
    },
    consumer: 'consumer-service',
    provider: 'provider-service',
    providerVersion: '1.0.0',
    pactBrokerUrl: 'https://xxx.pact.dius.com.au',
    publishVerificationResult: true,
    logLevel: 'debug',
  });

  describe('publishing to consumer service', () => {
    it('sends payload', () => {
      return p.verify();
    });
  });
});

Relevant log files

[2020-04-17T15:02:22.361Z] DEBUG: pact-node@10.9.0/77401 on local: 
    /Users/me/node_modules/@pact-foundation/pact-node/standalone/darwin-1.82.3/pact/lib/vendor/ruby/2.2.0/gems/pact-1.49.2/lib/pact/hal/entity.rb:102:in `assert_success!': Error retrieving https://xxx.pact.dius.com.au status=401  (Pact::Hal::ErrorResponseReturned)
        from /Users/me/Source/node_modules/@pact-foundation/pact-node/standalone/darwin-1.82.3/pact/lib/vendor/ruby/2.2.0/gems/pact-1.49.2/lib/pact/pact_broker/fetch_pact_uris_for_verification.rb:48:in `index'
        from /Users/me/Source/node_modules/@pact-foundation/pact-node/standalone/darwin-1.82.3/pact/lib/vendor/ruby/2.2.0/gems/pact-1.49.2/lib/pact/pact_broker/fetch_pact_uris_for_verification.rb:35:in `call'
        from /Users/me/Source/node_modules/@pact-foundation/pact-node/standalone/darwin-1.82.3/pact/lib/vendor/ruby/2.2.0/gems/pact-1.49.2/lib/pact/pact_broker/fetch_pact_uris_for_verification.rb:31:in `call'
        from /Users/me/Source/node_modules/@pact-foundation/pact-node/standalone/darwin-1.82.3/pact/lib/vendor/ruby/2.2.0/gems/pact-1.49.2/lib/pact/pact_broker.rb:18:in `fetch_pact_uris_for_verification'
        from /Users/me/Source/node_modules/@pact-foundation/pact-node/standalone/darwin-1.82.3/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.30.0/lib/pact/provider_verifier/aggregate_pact_configs.rb:45:in `pacts_for_verification'
        from /Users/me/Source/node_modules/@pact-foundation/pact-node/standalone/darwin-1.82.3/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.30.0/lib/pact/provider_verifier/aggregate_pact_configs.rb:38:in `pacts_urls_from_broker'
        from /Users/me/Source/node_modules/@pact-foundation/pact-node/standalone/darwin-1.82.3/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.30.0/lib/pact/provider_verifier/aggregate_pact_configs.rb:25:in `call'
mefellows commented 4 years ago

See #437 for PR that will address this. Apologies, had some issues with a build setup which is now resolved.

Safiyya commented 4 years ago

Thanks for looking into it @mefellows! Any idea when the PR could be merged in ?

mefellows commented 4 years ago

Just waiting for a collaborator to review, some time this week is likely.

Safiyya commented 4 years ago

Perfect, thank you!

mefellows commented 4 years ago

This should now be fixed in v9.10.0 - please let me know how you go.