Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

Commit

Permalink
Enable Basic Auth for pact broker.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmacik committed Oct 15, 2018
1 parent 6d5fcbc commit ceb190a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion test/contracts/auth/publish-contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

. ./setenv.sh

PACT_BROKER_BASIC_AUTH=$(echo -n "${PACT_BROKER_USERNAME}:${PACT_BROKER_PASSWORD}" | base64)

for PACT_FILE in $(find "$PACT_DIR" -name "*.json"); do
echo "Publishing $PACT_FILE to a Pact broker at $PACT_BROKER_URL"

PACT_CONSUMER=$(jq '.["consumer"]["name"]' "$PACT_FILE" | tr -d '"')
PACT_PROVIDER=$(jq '.["provider"]["name"]' "$PACT_FILE" | tr -d '"')

result=$(curl -L --silent -XPUT -H "Content-Type: application/json" -d@$PACT_FILE "$PACT_BROKER_URL/pacts/provider/$PACT_PROVIDER/consumer/$PACT_CONSUMER/version/$PACT_VERSION")
result=$(curl --silent -XPUT -H "Content-Type: application/json" -H "Authorization: Basic ${PACT_BROKER_BASIC_AUTH}" -d@$PACT_FILE "$PACT_BROKER_URL/pacts/provider/$PACT_PROVIDER/consumer/$PACT_CONSUMER/version/$PACT_VERSION")

if [[ $result = *'"consumer":{"name":"'$PACT_CONSUMER'"},"provider":{"name":"'$PACT_PROVIDER'"}'* ]]; then
echo "Pact successfully published."
Expand Down
6 changes: 6 additions & 0 deletions test/contracts/auth/setenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ GOPATH="$GOPATH:$(pwd)"
PACT_DIR="${PACT_DIR:-pacts}"
PACT_CONSUMER="${PACT_CONSUMER:-Fabric8TenantService}"
PACT_PROVIDER="${PACT_PROVIDER:-Fabric8AuthService}"

PACT_BROKER_URL="${PACT_BROKER_URL:-http://pact-broker-pact-broker.193b.starter-ca-central-1.openshiftapps.com}"
PACT_BROKER_USERNAME="${PACT_BROKER_USERNAME:-pact_broker}"
PACT_BROKER_PASSWORD="${PACT_BROKER_PASSWORD:-}"

PACT_PROVIDER_BASE_URL="${PACT_PROVIDER_BASE_URL:-https://auth.openshift.io}"
2 changes: 1 addition & 1 deletion test/contracts/auth/verify-contracts-broker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ for PACT_FILE in $(find "$PACT_DIR" -name "*.json"); do
PACT_CONSUMER=$(jq '.["consumer"]["name"]' "$PACT_FILE" | tr -d '"')
PACT_PROVIDER=$(jq '.["provider"]["name"]' "$PACT_FILE" | tr -d '"')

pact-provider-verifier "$PACT_BROKER_URL/pacts/provider/$PACT_PROVIDER/consumer/$PACT_CONSUMER/versions/$PACT_VERSION" --provider-base-url "$PACT_PROVIDER_BASE_URL"
pact-provider-verifier "$PACT_BROKER_URL/pacts/provider/$PACT_PROVIDER/consumer/$PACT_CONSUMER/versions/$PACT_VERSION" --broker-username="$PACT_BROKER_USERNAME" --broker-password="$PACT_BROKER_PASSWORD" --provider-base-url "$PACT_PROVIDER_BASE_URL"
done

0 comments on commit ceb190a

Please sign in to comment.