Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(verify): support broker bearer token #147

Merged
merged 1 commit into from
Mar 7, 2019

Conversation

mefellows
Copy link
Member

@mefellows mefellows commented Mar 6, 2019

  • Upgrade standalone to 1.64.0
  • The CLI verifier has all of the logic needed to fetch pacts
    from the Broker. This change removes the use of the Broker
    class to fetch Pacts during verification, delegating to the underlying binary
  • Broker class removed completely.
  • Adds support for bearer token authentication mode in the Pact Broker

@mefellows mefellows force-pushed the feat/broker-bearer-token-support branch from 314836a to 4182866 Compare March 6, 2019 08:59
@mefellows mefellows changed the title chore(verify): defer pact fetching to the CLI tools feat(verify): support broker bearer token Mar 6, 2019
@@ -251,8 +253,7 @@ pact.verifyPacts({
| Parameter | Required? | Type | Description |
| --------------------------- | --------- | ------- | ---------------------------------------------------------------------------------------------------------- |
| `providerBaseUrl` | true | string | Running API provider host endpoint. |
| `pactBrokerBaseUrl` | false | string | Base URL of the Pact Broker from which to retrieve the pacts. |
| `pactBrokerUrl` | false | string | URL of your Pact Broker to dynamically discover relevent pacts to verify. Required if `pactUrls` not given |
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've deprecated this field. So whilst it is still supported, I've removed it from the docs here and have provided a warning if it's used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why it should be deprecated. They do exactly the same thing no? Just the name that's different and I did that on purpose since base doesn't really add any value.

@mefellows mefellows requested a review from mboudreau March 6, 2019 10:49
@mefellows
Copy link
Member Author

@mboudreau I thought about removing the Broker class entirely. We don't really document it, but technically it is still a public, usable API. If we want to keep with the idea that you can use a Node API to do certain pact things, then perhaps it's still worth keeping, otherwise I think we could make a case to remove it.

@mboudreau
Copy link
Contributor

@mefellows That looks pretty good. I'd remove the broker class if I were you; even if it's exported, that's not how the API should be used as it's meant to be an internal class.

src/verifier.ts Outdated
@@ -68,12 +70,16 @@ export class Verifier {

checkTypes.assert.nonEmptyString(options.providerBaseUrl, "Must provide the providerBaseUrl argument");

if (checkTypes.emptyArray(options.pactUrls) && !options.pactBrokerUrl) {
throw new Error("Must provide the pactUrls argument if no brokerUrl provided");
if (options.pactBrokerUrl) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused, why are we changing the name from pactBrokerUrl to pactBrokerBaseUrl?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with all of the other languages and the CLI. Alternatively, I can just leave it as is and map to the new CLI arg?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was already pactBrokerUrl, leave it as is. No need to add another.

src/broker.ts Outdated
"user": this.options.username,
"password": this.options.password
};
} else if (this.options.token) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just create 2 ifs instead of having an else if. Might be good to type this function's return object like TokenAuth | UserPassAuth

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No probs. I'm going to remove the class as suggested.

@mboudreau
Copy link
Contributor

@mefellows increment the version number to 7.1.0

@mefellows
Copy link
Member Author

Thanks for the feedback. I'm going to delete the broker class, map the field back to pactBrokerUrl (i.e. remove the "base" bit) and bump the major version due to breaking API change (that will happen as part of release).

- Upgrade standalone to 1.64.0
- The CLI verifier has all of the logic needed to fetch pacts
  from the Broker. This change removes the use of the Broker
  class to fetch Pacts
- Broker class removed as not required for public consumption
- Adds support for bearer token authentication mode
@mefellows mefellows force-pushed the feat/broker-bearer-token-support branch from 4182866 to f060b78 Compare March 7, 2019 03:44
@mboudreau
Copy link
Contributor

@mefellows only the minor version, not the major since you're not breaking the API if you don't change that argument name.

@mefellows mefellows merged commit 579f528 into master Mar 7, 2019
@mefellows mefellows deleted the feat/broker-bearer-token-support branch March 7, 2019 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants