Skip to content

Commit 0c1af06

Browse files
committed
fix: replace basic auth pact broker with bearer token
1 parent b238fd0 commit 0c1af06

File tree

16 files changed

+59
-61
lines changed

16 files changed

+59
-61
lines changed

.github/workflows/build-and-test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ env:
1111
GIT_REF: ${{ github.ref }}
1212
GIT_BRANCH: ${{ github.head_ref || github.ref_name }}
1313
LOG_LEVEL: info
14+
PACT_BROKER_BASE_URL: ${{ secrets.PACT_BROKER_BASE_URL }}
15+
PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}
1416

1517
jobs:
1618
build-and-test:

.github/workflows/publish.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ env:
1010
GIT_COMMIT: ${{ github.sha }}
1111
GIT_REF: ${{ github.ref }}
1212
LOG_LEVEL: info
13+
PACT_BROKER_BASE_URL: ${{ secrets.PACT_BROKER_BASE_URL }}
14+
PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}
1315

1416
jobs:
1517
release:

examples/e2e/README.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,4 @@ curl -X GET http://localhost:8080/suggestions/1
109109

110110
## Viewing contracts with the Pact Broker
111111

112-
A test [Pact Boker](https://github.com/pact-foundation/pact_broker) is running at https://test.pactflow.io - very kindly provided by PactFlow:
113-
114-
- Username: `dXfltyFMgNOFZAxr8io9wJ37iUpY42M`
115-
- Password: `O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1`
116-
117-
Or use the API:
118-
119-
```
120-
curl -v -u 'dXfltyFMgNOFZAxr8io9wJ37iUpY42M:O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1' https://test.pactflow.io
121-
```
112+
A test [Pact Boker](https://github.com/pact-foundation/pact_broker) is running at https://testdemo.pactflow.io/login?code=88f7810e-c7dc-493b-9c3d-7849952f1d9a

examples/e2e/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
"test": "npm run test:consumer && npm run test:publish && npm run test:provider",
77
"test:no:publish": "npm run test:consumer && npm run test:provider",
88
"test:consumer": "mocha test/consumer.spec.js",
9-
"test:publish": "pact-broker publish ./pacts --consumer-app-version=\"$(npx absolute-version)\" --auto-detect-version-properties --broker-base-url=https://test.pactflow.io --broker-username dXfltyFMgNOFZAxr8io9wJ37iUpY42M --broker-password O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1",
9+
"test:publish": "pact-broker publish ./pacts --consumer-app-version=\"$(npx absolute-version)\" --auto-detect-version-properties --broker-base-url=https://testdemo.pactflow.io",
1010
"test:provider": "mocha test/provider.spec.js",
1111
"can-i-deploy": "npm run can-i-deploy:consumer && npm run can-i-deploy:provider",
12-
"can-i-deploy:consumer": "pact-broker can-i-deploy --pacticipant 'Matching Service' --latest --broker-base-url https://test.pactflow.io --broker-username dXfltyFMgNOFZAxr8io9wJ37iUpY42M --broker-password O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1",
13-
"can-i-deploy:provider": "pact-broker can-i-deploy --pacticipant 'Animal Profile Service' --latest --broker-base-url https://test.pactflow.io --broker-username dXfltyFMgNOFZAxr8io9wJ37iUpY42M --broker-password O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1",
12+
"can-i-deploy:consumer": "pact-broker can-i-deploy --pacticipant 'Matching Service' --latest --broker-base-url https://testdemo.pactflow.io",
13+
"can-i-deploy:provider": "pact-broker can-i-deploy --pacticipant 'Animal Profile Service' --latest --broker-base-url https://testdemo.pactflow.io",
1414
"api": "concurrently 'npm run provider' 'npm run consumer'",
1515
"consumer": "node ./consumerService.js",
1616
"provider": "node ./providerService.js"

examples/e2e/test/provider.spec.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe('Pact Verification', () => {
6060
},
6161

6262
// Fetch pacts from broker
63-
pactBrokerUrl: 'https://test.pactflow.io/',
63+
pactBrokerUrl: process.env.PACT_BROKER_BASE_URL,
6464

6565
// Fetch from broker with given tags
6666
// consumerVersionTags: ['master', 'test', 'prod', 'feat/v3.0.0'],
@@ -96,14 +96,13 @@ describe('Pact Verification', () => {
9696
// ],
9797

9898
// If you're using the open source Pact Broker, use the username/password option as per below
99-
pactBrokerUsername:
100-
process.env.PACT_BROKER_USERNAME || 'dXfltyFMgNOFZAxr8io9wJ37iUpY42M',
101-
pactBrokerPassword:
102-
process.env.PACT_BROKER_PASSWORD || 'O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1',
103-
99+
// pactBrokerUsername: process.env.PACT_BROKER_USERNAME
100+
// pactBrokerPassword: process.env.PACT_BROKER_PASSWORD
101+
//
104102
// if you're using a PactFlow broker, you must authenticate using the bearer token option
105103
// You can obtain the token from https://<your broker>.pactflow.io/settings/api-tokens
106-
// pactBrokerToken: "<insert your token here"
104+
pactBrokerToken: process.env.PACT_BROKER_TOKEN,
105+
107106
publishVerificationResult: true,
108107
// Your version numbers need to be unique for every different version of your provider
109108
// see https://docs.pact.io/getting_started/versioning_in_the_pact_broker/ for details.

examples/graphql/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"test": "npm run clean && npm run test:consumer && npm run test:publish && npm run test:provider",
1010
"test:no:publish": "npm run test:consumer && npm run test:provider",
1111
"test:consumer": "nyc --reporter=text-summary mocha src/consumer.spec.ts",
12-
"test:publish": "pact-broker publish ./pacts --consumer-app-version=\"$(npx absolute-version)\" --auto-detect-version-properties --broker-base-url=https://test.pactflow.io --broker-username dXfltyFMgNOFZAxr8io9wJ37iUpY42M --broker-password O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1",
12+
"test:publish": "pact-broker publish ./pacts --consumer-app-version=\"$(npx absolute-version)\" --auto-detect-version-properties --broker-base-url=https://testdemo.pactflow.io",
1313
"test:provider": "nyc --reporter=text-summary mocha -t 30000 src/provider.spec.ts"
1414
},
1515
"keywords": [

examples/graphql/src/provider.spec.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@ describe('Pact Verification', () => {
1818
const opts = {
1919
// Local pacts
2020
// pactUrls: [path.resolve(process.cwd(), "./pacts/graphqlconsumer-graphqlprovider.json")],
21-
pactBrokerUrl: 'https://test.pactflow.io/',
22-
pactBrokerUsername:
23-
process.env.PACT_BROKER_USERNAME || 'dXfltyFMgNOFZAxr8io9wJ37iUpY42M',
24-
pactBrokerPassword:
25-
process.env.PACT_BROKER_PASSWORD || 'O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1',
21+
pactBrokerUrl: process.env.PACT_BROKER_BASE_URL,
22+
// If you're using the open source Pact Broker, use the username/password option as per below
23+
// pactBrokerUsername: process.env.PACT_BROKER_USERNAME
24+
// pactBrokerPassword: process.env.PACT_BROKER_PASSWORD
25+
//
26+
// if you're using a PactFlow broker, you must authenticate using the bearer token option
27+
// You can obtain the token from https://<your broker>.pactflow.io/settings/api-tokens
28+
pactBrokerToken: process.env.PACT_BROKER_TOKEN,
2629
provider: 'GraphQLProvider',
2730
providerBaseUrl: 'http://localhost:4000/graphql',
2831
// Your version numbers need to be unique for every different version of your provider

examples/jest/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "index.js",
66
"scripts": {
77
"test": "rimraf pact && jest __tests__/ --runInBand",
8-
"test:publish": "pact-broker publish pact/pacts --consumer-app-version=\"$(npx absolute-version)\" --auto-detect-version-properties --broker-base-url=https://test.pactflow.io --broker-username dXfltyFMgNOFZAxr8io9wJ37iUpY42M --broker-password O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1"
8+
"test:publish": "pact-broker publish pact/pacts --consumer-app-version=\"$(npx absolute-version)\" --auto-detect-version-properties --broker-base-url=https://testdemo.pactflow.io"
99
},
1010
"license": "MIT",
1111
"jest": {

examples/messages/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"test:no:publish": "npm run test:consumer && npm run test:provider",
1111
"test:consumer": "mocha consumer/*.spec.ts",
1212
"test:provider": "mocha -t 20000 provider/*.spec.ts",
13-
"test:publish": "pact-broker publish ./pacts --consumer-app-version=\"$(npx absolute-version)\" --auto-detect-version-properties --broker-base-url=https://test.pactflow.io --broker-username dXfltyFMgNOFZAxr8io9wJ37iUpY42M --broker-password O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1"
13+
"test:publish": "pact-broker publish ./pacts --consumer-app-version=\"$(npx absolute-version)\" --auto-detect-version-properties --broker-base-url=https://testdemo.pactflow.io"
1414
},
1515
"author": "",
1616
"license": "MIT",

examples/messages/provider/message-provider.spec.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@ describe('Message provider tests', () => {
3131
// For local validation
3232
// pactUrls: [path.resolve(process.cwd(), "pacts", "myjsmessageconsumer-myjsmessageprovider.json")],
3333
// Broker validation
34-
pactBrokerUrl: 'https://test.pactflow.io/',
35-
pactBrokerUsername:
36-
process.env.PACT_BROKER_USERNAME || 'dXfltyFMgNOFZAxr8io9wJ37iUpY42M',
37-
pactBrokerPassword:
38-
process.env.PACT_BROKER_PASSWORD || 'O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1',
34+
pactBrokerUrl: process.env.PACT_BROKER_BASE_URL,
35+
// If you're using the open source Pact Broker, use the username/password option as per below
36+
// pactBrokerUsername: process.env.PACT_BROKER_USERNAME
37+
// pactBrokerPassword: process.env.PACT_BROKER_PASSWORD
38+
//
39+
// if you're using a PactFlow broker, you must authenticate using the bearer token option
40+
// You can obtain the token from https://<your broker>.pactflow.io/settings/api-tokens
41+
pactBrokerToken: process.env.PACT_BROKER_TOKEN,
3942
providerVersionBranch: process.env.GIT_BRANCH || 'master',
4043

4144
// Find _all_ pacts that match the current provider branch

0 commit comments

Comments
 (0)