pact_broker 2.38.1 → 2.39.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/ISSUE_TEMPLATE.md +2 -2
- data/CHANGELOG.md +45 -0
- data/DEVELOPER_DOCUMENTATION.md +9 -0
- data/Dockerfile +2 -0
- data/Gemfile +1 -1
- data/README.md +10 -3
- data/config/database.yml +10 -2
- data/docs/images/Pactflow logo - black small.png +0 -0
- data/lib/pact_broker/api.rb +5 -2
- data/lib/pact_broker/api/contracts/verifiable_pacts_query_schema.rb +41 -0
- data/lib/pact_broker/api/decorators/dashboard_decorator.rb +1 -1
- data/lib/pact_broker/api/decorators/dashboard_text_decorator.rb +1 -1
- data/lib/pact_broker/api/decorators/integration_decorator.rb +2 -0
- data/lib/pact_broker/api/decorators/verifiable_pact_decorator.rb +34 -0
- data/lib/pact_broker/api/decorators/verifiable_pacts_query_decorator.rb +27 -0
- data/lib/pact_broker/api/resources/badge.rb +4 -4
- data/lib/pact_broker/api/resources/can_i_deploy.rb +41 -0
- data/lib/pact_broker/api/resources/dashboard.rb +1 -1
- data/lib/pact_broker/api/resources/index.rb +15 -4
- data/lib/pact_broker/api/resources/latest_pact.rb +10 -4
- data/lib/pact_broker/api/resources/latest_verification_for_latest_pact.rb +19 -0
- data/lib/pact_broker/api/resources/pact.rb +5 -4
- data/lib/pact_broker/api/resources/provider_pacts_for_verification.rb +54 -0
- data/lib/pact_broker/api/resources/verification.rb +6 -1
- data/lib/pact_broker/badges/service.rb +11 -11
- data/lib/pact_broker/db/clean.rb +72 -12
- data/lib/pact_broker/doc/controllers/app.rb +3 -1
- data/lib/pact_broker/doc/views/can-i-deploy.markdown +14 -0
- data/lib/pact_broker/doc/views/index/pacticipant-version-tag.markdown +8 -0
- data/lib/pact_broker/doc/views/integrations.markdown +1 -1
- data/lib/pact_broker/doc/views/matrix.markdown +7 -0
- data/lib/pact_broker/doc/views/metrics.markdown +5 -0
- data/lib/pact_broker/domain/index_item.rb +3 -3
- data/lib/pact_broker/domain/pact.rb +28 -1
- data/lib/pact_broker/index/service.rb +38 -20
- data/lib/pact_broker/integrations/integration.rb +16 -0
- data/lib/pact_broker/integrations/service.rb +15 -1
- data/lib/pact_broker/matrix/can_i_deploy_query_schema.rb +25 -0
- data/lib/pact_broker/matrix/parse_can_i_deploy_query.rb +29 -0
- data/lib/pact_broker/matrix/quick_row.rb +255 -0
- data/lib/pact_broker/matrix/repository.rb +5 -17
- data/lib/pact_broker/matrix/row.rb +0 -1
- data/lib/pact_broker/metrics/service.rb +36 -2
- data/lib/pact_broker/pacts/all_pact_publications.rb +3 -2
- data/lib/pact_broker/pacts/head_pact.rb +30 -0
- data/lib/pact_broker/pacts/latest_pact_publications.rb +8 -1
- data/lib/pact_broker/pacts/latest_tagged_pact_publications.rb +5 -1
- data/lib/pact_broker/pacts/pact_publication.rb +2 -1
- data/lib/pact_broker/pacts/pact_version.rb +20 -0
- data/lib/pact_broker/pacts/repository.rb +33 -4
- data/lib/pact_broker/pacts/service.rb +15 -2
- data/lib/pact_broker/pacts/squash_pacts_for_verification.rb +37 -0
- data/lib/pact_broker/pacts/verifiable_pact.rb +30 -0
- data/lib/pact_broker/pacts/verifiable_pact_messages.rb +75 -0
- data/lib/pact_broker/test/test_data_builder.rb +30 -2
- data/lib/pact_broker/ui/view_models/index_item.rb +4 -4
- data/lib/pact_broker/ui/view_models/matrix_line.rb +1 -1
- data/lib/pact_broker/ui/views/index/show-with-tags.haml +1 -1
- data/lib/pact_broker/ui/views/index/show.haml +1 -1
- data/lib/pact_broker/ui/views/matrix/show.haml +2 -2
- data/lib/pact_broker/verifications/{verification_status.rb → pseudo_branch_status.rb} +10 -4
- data/lib/pact_broker/version.rb +1 -1
- data/script/docker/mysql-db-start.sh +10 -0
- data/spec/features/can_i_deploy_spec.rb +31 -0
- data/spec/features/get_latest_verification_for_pact_spec.rb +17 -0
- data/spec/features/get_provider_pacts_for_verification_spec.rb +39 -0
- data/spec/features/metrics_spec.rb +1 -1
- data/spec/features/pending_pacts_spec.rb +109 -0
- data/spec/integration/ui/matrix_spec.rb +30 -0
- data/spec/lib/pact_broker/api/contracts/verifiable_pacts_query_schema_spec.rb +62 -0
- data/spec/lib/pact_broker/api/decorators/dashboard_decorator_spec.rb +1 -1
- data/spec/lib/pact_broker/api/decorators/integration_decorator_spec.rb +5 -1
- data/spec/lib/pact_broker/api/decorators/verifiable_pact_decorator_spec.rb +30 -5
- data/spec/lib/pact_broker/api/decorators/verifiable_pacts_query_decorator_spec.rb +46 -0
- data/spec/lib/pact_broker/api/resources/badge_spec.rb +3 -3
- data/spec/lib/pact_broker/api/resources/provider_pacts_for_verification_spec.rb +35 -0
- data/spec/lib/pact_broker/api/resources/verification_spec.rb +18 -0
- data/spec/lib/pact_broker/badges/service_spec.rb +18 -18
- data/spec/lib/pact_broker/db/clean_spec.rb +69 -8
- data/spec/lib/pact_broker/doc/coverage_spec.rb +8 -2
- data/spec/lib/pact_broker/index/service_spec.rb +28 -14
- data/spec/lib/pact_broker/integrations/integration_spec.rb +60 -0
- data/spec/lib/pact_broker/integrations/service_spec.rb +27 -0
- data/spec/lib/pact_broker/matrix/quick_row_spec.rb +31 -0
- data/spec/lib/pact_broker/matrix/repository_spec.rb +8 -8
- data/spec/lib/pact_broker/matrix/service_spec.rb +4 -4
- data/spec/lib/pact_broker/metrics/service_spec.rb +56 -0
- data/spec/lib/pact_broker/pacts/pact_version_spec.rb +69 -0
- data/spec/lib/pact_broker/pacts/repository_find_for_verification_spec.rb +65 -0
- data/spec/lib/pact_broker/pacts/repository_find_wip_pact_versions_for_provider_spec.rb +54 -24
- data/spec/lib/pact_broker/pacts/service_find_for_verification_spec.rb +51 -0
- data/spec/lib/pact_broker/pacts/squash_pacts_for_verification_spec.rb +92 -0
- data/spec/lib/pact_broker/pacts/verifiable_pact_messages_spec.rb +93 -0
- data/spec/lib/pact_broker/pacts/verifiable_pact_spec.rb +0 -0
- data/spec/lib/pact_broker/ui/view_models/index_item_spec.rb +10 -10
- data/spec/lib/pact_broker/verifications/{verification_status_spec.rb → pseudo_branch_status_spec.rb} +4 -4
- data/spec/support/shared_examples_for_responses.rb +7 -1
- metadata +56 -13
- data/lib/pact_broker/api/resources/pending_provider_pacts.rb +0 -21
- data/spec/features/get_pacts_to_verify_spec.rb +0 -41
- data/spec/features/get_wip_provider_pacts_spec.rb +0 -26
- data/spec/lib/pact_broker/api/resources/pending_provider_pacts_spec.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7e280e7c13bd55791cab9e6133c2a63c62e18c89
|
4
|
+
data.tar.gz: 34f9831b62572f892ccd85a4a71f8f05e0660210
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 358dff2b700249596936bf1cd380568a01220941a0f63e4d70ed3366f5e69b1a8fa2855976011779439dfd01e43cae4e2c79b370a9f1920bcb98a199da92f132
|
7
|
+
data.tar.gz: f5a45fde10fde4d65afef8cc1ce3202da9dd46163c5f0096f6c421a305dc87a1f0528502bfcc0a15d4771b7a95e0e42864a6de1f218e56a1daadee73e5b69225
|
data/.github/ISSUE_TEMPLATE.md
CHANGED
@@ -25,8 +25,8 @@ TBC
|
|
25
25
|
|
26
26
|
## Steps to reproduce
|
27
27
|
|
28
|
-
Provide a repository, gist or
|
28
|
+
Provide a repository, gist or reproducible code snippet so that we can test the problem.
|
29
29
|
|
30
|
-
##
|
30
|
+
## Relevant log files
|
31
31
|
|
32
32
|
Please ensure you set logging to `DEBUG` and attach any relevant log files here (or link from a gist).
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,48 @@
|
|
1
|
+
<a name="v2.39.0"></a>
|
2
|
+
### v2.39.0 (2019-10-21)
|
3
|
+
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* **matrix**
|
8
|
+
* optimise query for can-i-deploy, again ([78b8a5d5](/../../commit/78b8a5d5))
|
9
|
+
* handle overwritten revisions in database rather than code ([1459b46a](/../../commit/1459b46a))
|
10
|
+
|
11
|
+
* **clean**
|
12
|
+
* allow date to be specified for data to clean and return counts of deleted and kept rows ([29dcbacd](/../../commit/29dcbacd))
|
13
|
+
|
14
|
+
* update db clean to remove webhooks triggered by verifications ([f38eeaea](/../../commit/f38eeaea))
|
15
|
+
* add revisions per consumer version and verifications per pact version to metrics ([f764fbca](/../../commit/f764fbca))
|
16
|
+
* show more helpful error message when someone tries to get /all verifications for a pact ([bea59518](/../../commit/bea59518))
|
17
|
+
* add missing HAL docs for various relations and correct test that should have identified their absence ([a057427c](/../../commit/a057427c))
|
18
|
+
* add can-i-deploy endpoint to expose a simplified interface to the /matrix resource that accepts the same parameters as the can-i-deploy CLI. ([02443f39](/../../commit/02443f39))
|
19
|
+
* add 'pacts for verification' endpoint (#308) ([31fb8aa7](/../../commit/31fb8aa7))
|
20
|
+
|
21
|
+
* **metrics**
|
22
|
+
* add revision count ([4369f227](/../../commit/4369f227))
|
23
|
+
* add matrix and head matrix row counts ([5fb705ec](/../../commit/5fb705ec))
|
24
|
+
|
25
|
+
* **dashboard api**
|
26
|
+
* eager load the pact_version ([b6b5c900](/../../commit/b6b5c900))
|
27
|
+
|
28
|
+
* **integrations**
|
29
|
+
* sort by integration with most recent activity first ([35bdbb92](/../../commit/35bdbb92))
|
30
|
+
* add verification status to integrations endpoint ([437ba769](/../../commit/437ba769))
|
31
|
+
|
32
|
+
|
33
|
+
#### Bug Fixes
|
34
|
+
|
35
|
+
* typos on ISSUE_TEMPLATE (#311) ([a10b4792](/../../commit/a10b4792))
|
36
|
+
* add endpoints to get latest verification for latest pact ([73413727](/../../commit/73413727))
|
37
|
+
* support application/vnd.pactbrokerextended.v1+json for latest pact resource ([476ff595](/../../commit/476ff595))
|
38
|
+
|
39
|
+
* **matrix**
|
40
|
+
* undefined method ([b365c64b](/../../commit/b365c64b))
|
41
|
+
|
42
|
+
* **dashboard api**
|
43
|
+
* remove expensive queries for unused data ([07206559](/../../commit/07206559))
|
44
|
+
|
45
|
+
|
1
46
|
<a name="v2.38.1"></a>
|
2
47
|
### v2.38.1 (2019-09-23)
|
3
48
|
|
data/DEVELOPER_DOCUMENTATION.md
CHANGED
@@ -31,6 +31,15 @@
|
|
31
31
|
|
32
32
|
Domain classes are found in `lib/pact_broker/domain`. Many of these classes are Sequel models, as the difference between the Sequel model and the functionality required for the domain logic is similar enough to share the class. Some classes separate the domain and database logic, as the concerns are too different. Where there is a separate database model, this will be kept in a module with the pluralized name of the model eg. `PactBroker::Webhooks`. Unfortunately, this sometimes makes it difficult to tell in the calling code whether you have a domain or a database model. I haven't worked out a clean way to handle this yet.
|
33
33
|
|
34
|
+
### Domain terminology
|
35
|
+
|
36
|
+
* `pacticipant` - an application that participates in a pact. A very bad pun which I deeply regret.
|
37
|
+
* `pact` - this term is confusing and overloaded. It generally means a `pact publication` in the code.
|
38
|
+
* `pact publication` - the resource that gets created when a PUT request is sent to the Pact Broker to /pacts/provider/PROVIDER/consumer/CONSUMER/version/VERSION.
|
39
|
+
* `pact version` - the JSON contents of the pact publication. One pact version may belong to many pact publications. That is, if a pact publication with exactly the same contents is published twice, then a new
|
40
|
+
pact publication resource will be created, but it will reuse the existing pact version.
|
41
|
+
* `pseudo branch` - A time ordered list of pacts that are related to a particular tag. The most recent pact for each pseudo branch is a "head" pact.
|
42
|
+
|
34
43
|
### Tables
|
35
44
|
* `pact_versions` - the JSON content of each UNIQUE pact document is stored in this table. The same content is likely to be published over and over again by the CI builds, so deduplicating the content saves us a lot of disk space. Once created, a row is never modified. Uniqueness is just done on string equality - no special pact logic. This means that pacts with randomly generated values or orders (most of pact-jvm pacts!) will get a new version record every time they publish.
|
36
45
|
|
data/Dockerfile
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
FROM ruby:2.5.3-alpine
|
2
2
|
|
3
|
+
ENV INSTALL_MYSQL=true
|
3
4
|
RUN apk update \
|
4
5
|
&& apk --no-cache add \
|
5
6
|
"build-base>=0.5" \
|
@@ -10,6 +11,7 @@ RUN apk update \
|
|
10
11
|
"sqlite-dev>=3.28" \
|
11
12
|
"sqlite>=3.28" \
|
12
13
|
"tzdata>=2019" \
|
14
|
+
"mariadb-dev>=10.3" \
|
13
15
|
&& rm -rf /var/cache/apk/*
|
14
16
|
|
15
17
|
WORKDIR /app
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -8,7 +8,13 @@
|
|
8
8
|
|
9
9
|
The Pact Broker is an application for sharing for consumer driven contracts and verification results. It is optimised for use with "pacts" (contracts created by the [Pact][pact-docs] framework), but can be used for any type of contract that can be serialized to JSON.
|
10
10
|
|
11
|
-
|
11
|
+
<br/>
|
12
|
+
<a href="https:/pactflow.io/?utm_source=github&utm_campaign=pact_broker_intro"><img src="docs/images/Pactflow logo - black small.png"></a>
|
13
|
+
<br/>
|
14
|
+
|
15
|
+
You can try out a Pact Broker for free at <a href="https:/pactflow.io/?utm_source=github&utm_campaign=pact_broker_intro"/>pactflow.io</a>. Built by a group of core Pact maintainers, Pactflow is a fork of the OSS Pact Broker with extra goodies like an improved UI, field level verification results and federated login.
|
16
|
+
|
17
|
+
**Why do I need a Pact Broker?**
|
12
18
|
|
13
19
|
Contract testing is an alternative approach to traditional integration testing that gives you tests that are quicker to execute, and that are more maintainable at scale. One down side of the approach is that the important information that would be available all in one place at the end of an integration test suite execution (that is, the version numbers of all the applications that were tested together, and whether the tests passed or failed) is now spread out across many different builds. The Pact Broker is a tool that brings all this information back together again, and allows you to deploy with safety.
|
14
20
|
|
@@ -38,6 +44,7 @@ Features:
|
|
38
44
|
* [Docker Pact Broker][docker]
|
39
45
|
* A [CLI][cli] for encorporating the Pact workflow into your continuous integration process.
|
40
46
|
|
47
|
+
|
41
48
|
### How would I use the Pact Broker?
|
42
49
|
|
43
50
|
#### Step 1. Consumer CI build
|
@@ -128,7 +135,7 @@ Use the HAL browser to view documentation as you browse.
|
|
128
135
|
|
129
136
|
#### Hosted
|
130
137
|
|
131
|
-
In a hurry? Hate having to run your own infrastructure? Check out
|
138
|
+
In a hurry? Hate having to run your own infrastructure? Check out [pactflow.io][pactflow] - it's fast, it's secure and it's free to trial!
|
132
139
|
|
133
140
|
#### Container solutions
|
134
141
|
|
@@ -161,7 +168,7 @@ Please read the [UPGRADING.md](UPGRADING.md) documentation before upgrading your
|
|
161
168
|
[different-teams]: https://github.com/pact-foundation/pact-ruby/wiki/Using-pact-where-the-consumer-team-is-different-from-the-provider-team
|
162
169
|
[docker]: https://hub.docker.com/r/dius/pact-broker
|
163
170
|
[terraform]: https://github.com/nadnerb/terraform-pact-broker
|
164
|
-
[
|
171
|
+
[pactflow]: https:/pactflow.io/?utm_source=github&utm_campaign=pact_broker_usage
|
165
172
|
[wiki]: https://github.com/pact-foundation/pact_broker/wiki
|
166
173
|
[reverse-proxy-docs]: https://github.com/pact-foundation/pact_broker/wiki/Configuration#running-the-broker-behind-a-reverse-proxy
|
167
174
|
[stackoverflow]: http://stackoverflow.com/questions/tagged/pact-broker
|
data/config/database.yml
CHANGED
@@ -16,11 +16,15 @@ test:
|
|
16
16
|
database: postgres
|
17
17
|
username: postgres
|
18
18
|
password: postgres
|
19
|
-
host:
|
19
|
+
host: localhost
|
20
20
|
port: "5433"
|
21
21
|
mysql:
|
22
22
|
<<: *default
|
23
23
|
adapter: mysql2
|
24
|
+
docker_mysql:
|
25
|
+
<<: *default
|
26
|
+
adapter: mysql2
|
27
|
+
host: "192.168.0.9"
|
24
28
|
|
25
29
|
development:
|
26
30
|
default:
|
@@ -34,11 +38,15 @@ development:
|
|
34
38
|
database: postgres
|
35
39
|
username: postgres
|
36
40
|
password: postgres
|
37
|
-
host:
|
41
|
+
host: localhost
|
38
42
|
port: "5432"
|
39
43
|
mysql:
|
40
44
|
<<: *default
|
41
45
|
adapter: mysql2
|
46
|
+
docker_mysql:
|
47
|
+
<<: *default
|
48
|
+
adapter: mysql2
|
49
|
+
host: localhost
|
42
50
|
|
43
51
|
production:
|
44
52
|
default:
|
Binary file
|
data/lib/pact_broker/api.rb
CHANGED
@@ -30,6 +30,8 @@ module PactBroker
|
|
30
30
|
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'pact-version', :pact_version_sha, 'verification-results', 'latest'], Api::Resources::LatestVerificationForPact, {resource_name: "latest_verification_results_for_pact_version"}
|
31
31
|
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'pact-version', :pact_version_sha, 'verification-results', :verification_number], Api::Resources::Verification, {resource_name: "verification_result"}
|
32
32
|
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'pact-version', :pact_version_sha, 'verification-results', :verification_number, 'triggered-webhooks'], Api::Resources::VerificationTriggeredWebhooks, {resource_name: "verification_result_triggered_webhooks"}
|
33
|
+
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'latest', 'verification-results','latest'], Api::Resources::LatestVerificationForLatestPact, {resource_name: "latest_verification_results_for_latest_pact_publication"}
|
34
|
+
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'latest', :tag, 'verification-results','latest'], Api::Resources::LatestVerificationForLatestPact, {resource_name: "latest_verification_results_for_latest_tagged_pact_publication"}
|
33
35
|
add ['verification-results', 'consumer', :consumer_name, 'version', :consumer_version_number,'latest'], Api::Resources::LatestVerificationsForConsumerVersion, {resource_name: "verification_results_for_consumer_version"}
|
34
36
|
|
35
37
|
# Badges
|
@@ -47,8 +49,8 @@ module PactBroker
|
|
47
49
|
add ['pacts', 'provider', :provider_name, 'latest', :tag], Api::Resources::LatestProviderPacts, {resource_name: "latest_tagged_provider_pact_publications"}
|
48
50
|
add ['pacts', 'latest'], Api::Resources::LatestPacts, {resource_name: "latest_pacts"}
|
49
51
|
|
50
|
-
#
|
51
|
-
add ['pacts', 'provider', :provider_name, '
|
52
|
+
# Pacts for verification
|
53
|
+
add ['pacts', 'provider', :provider_name, 'for-verification'], Api::Resources::ProviderPactsForVerification, {resource_name: "pacts_for_verification"}
|
52
54
|
|
53
55
|
# Deprecated pact
|
54
56
|
add ['pact', 'provider', :provider_name, 'consumer', :consumer_name, 'version', :consumer_version_number], Api::Resources::Pact, {resource_name: "pact_publications", deprecated: "true"} # Deprecate, singular /pact
|
@@ -86,6 +88,7 @@ module PactBroker
|
|
86
88
|
add ['matrix', 'provider', :provider_name, 'consumer', :consumer_name], Api::Resources::MatrixForConsumerAndProvider, {resource_name: "matrix_consumer_provider"}
|
87
89
|
add ['matrix', 'provider', :provider_name, 'latest', :provider_tag, 'consumer', :consumer_name, 'latest', :tag, 'badge'], Api::Resources::MatrixBadge, {resource_name: "matrix_tag_badge"}
|
88
90
|
add ['matrix'], Api::Resources::Matrix, {resource_name: "matrix"}
|
91
|
+
add ['can-i-deploy'], Api::Resources::CanIDeploy, {resource_name: "can-i-deploy"}
|
89
92
|
|
90
93
|
add ['dashboard'], Api::Resources::Dashboard, {resource_name: "dashboard"}
|
91
94
|
add ['dashboard', 'provider', :provider_name, 'consumer', :consumer_name ], Api::Resources::Dashboard, {resource_name: "integration_dashboard"}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'dry-validation'
|
2
|
+
|
3
|
+
module PactBroker
|
4
|
+
module Api
|
5
|
+
module Contracts
|
6
|
+
class VerifiablePactsQuerySchema
|
7
|
+
SCHEMA = Dry::Validation.Schema do
|
8
|
+
optional(:provider_version_tags).maybe(:array?)
|
9
|
+
# optional(:exclude_other_pending).filled(included_in?: ["true", "false"])
|
10
|
+
optional(:consumer_version_selectors).each do
|
11
|
+
schema do
|
12
|
+
required(:tag).filled(:str?)
|
13
|
+
optional(:latest).filled(included_in?: ["true", "false"])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.call(params)
|
19
|
+
select_first_message(flatten_index_messages(SCHEMA.call(params).messages(full: true)))
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.select_first_message(messages)
|
23
|
+
messages.each_with_object({}) do | (key, value), new_messages |
|
24
|
+
new_messages[key] = [value.first]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.flatten_index_messages(messages)
|
29
|
+
if messages[:consumer_version_selectors]
|
30
|
+
new_messages = messages[:consumer_version_selectors].collect do | index, value |
|
31
|
+
value.values.flatten.collect { | text | "#{text} at index #{index}"}
|
32
|
+
end.flatten
|
33
|
+
messages.merge(consumer_version_selectors: new_messages)
|
34
|
+
else
|
35
|
+
messages
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -45,7 +45,7 @@ module PactBroker
|
|
45
45
|
pactTags: pact_tags(index_item, base_url),
|
46
46
|
latestVerificationResult: verification_hash(index_item, base_url),
|
47
47
|
latestVerificationResultTags: verification_tags(index_item, base_url),
|
48
|
-
verificationStatus: index_item.
|
48
|
+
verificationStatus: index_item.pseudo_branch_verification_status.to_s,
|
49
49
|
webhookStatus: index_item.webhook_status.to_s,
|
50
50
|
latestWebhookExecution: latest_webhook_execution(index_item, base_url),
|
51
51
|
_links: links(index_item, base_url)
|
@@ -41,7 +41,7 @@ module PactBroker
|
|
41
41
|
index_item.provider_name,
|
42
42
|
index_item.provider_version_number,
|
43
43
|
index_item.latest_verification_latest_tags.collect(&:name).sort.join(", "),
|
44
|
-
index_item.
|
44
|
+
index_item.pseudo_branch_verification_status.to_s
|
45
45
|
)
|
46
46
|
end
|
47
47
|
end
|
@@ -15,6 +15,8 @@ module PactBroker
|
|
15
15
|
property :name
|
16
16
|
end
|
17
17
|
|
18
|
+
property :verificationStatus, getter: ->(represented:, **) { represented.verification_status_for_latest_pact.to_s }
|
19
|
+
|
18
20
|
link "pb:dashboard" do | options |
|
19
21
|
{
|
20
22
|
title: "BETA: Pacts to show on the dashboard",
|
@@ -1,11 +1,45 @@
|
|
1
1
|
require_relative 'base_decorator'
|
2
2
|
require 'pact_broker/api/pact_broker_urls'
|
3
|
+
require 'delegate'
|
4
|
+
require 'pact_broker/pacts/verifiable_pact_messages'
|
3
5
|
|
4
6
|
module PactBroker
|
5
7
|
module Api
|
6
8
|
module Decorators
|
7
9
|
class VerifiablePactDecorator < BaseDecorator
|
8
10
|
|
11
|
+
# Allows a "flat" VerifiablePact to look like it has
|
12
|
+
# a nested verification_properties object for Reform
|
13
|
+
class Reshaper < SimpleDelegator
|
14
|
+
def verification_properties
|
15
|
+
__getobj__()
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(verifiable_pact)
|
20
|
+
super(Reshaper.new(verifiable_pact))
|
21
|
+
end
|
22
|
+
|
23
|
+
property :verification_properties, as: :verificationProperties do
|
24
|
+
property :pending
|
25
|
+
property :pending_reason, as: :pendingReason, exec_context: :decorator
|
26
|
+
property :inclusion_reason, as: :inclusionReason, exec_context: :decorator
|
27
|
+
|
28
|
+
def inclusion_reason
|
29
|
+
PactBroker::Pacts::VerifiablePactMessages.new(represented).inclusion_reason
|
30
|
+
end
|
31
|
+
|
32
|
+
def pending_reason
|
33
|
+
PactBroker::Pacts::VerifiablePactMessages.new(represented).pending_reason
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
link :self do | context |
|
38
|
+
{
|
39
|
+
href: pact_version_url(represented, context[:base_url]),
|
40
|
+
name: represented.name
|
41
|
+
}
|
42
|
+
end
|
9
43
|
end
|
10
44
|
end
|
11
45
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative 'base_decorator'
|
2
|
+
require_relative 'verifiable_pact_decorator'
|
3
|
+
require 'pact_broker/api/pact_broker_urls'
|
4
|
+
|
5
|
+
module PactBroker
|
6
|
+
module Api
|
7
|
+
module Decorators
|
8
|
+
class VerifiablePactsQueryDecorator < BaseDecorator
|
9
|
+
collection :provider_version_tags
|
10
|
+
|
11
|
+
collection :consumer_version_selectors, class: OpenStruct do
|
12
|
+
property :tag
|
13
|
+
property :latest, setter: ->(fragment:, represented:, **) { represented.latest = (fragment == 'true') }
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
def from_hash(*args)
|
18
|
+
# Should remember how to do this via Representable...
|
19
|
+
result = super
|
20
|
+
result.consumer_version_selectors = [] if result.consumer_version_selectors.nil?
|
21
|
+
result.provider_version_tags = [] if result.provider_version_tags.nil?
|
22
|
+
result
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'pact_broker/api/resources/base_resource'
|
2
|
-
require 'pact_broker/verifications/
|
2
|
+
require 'pact_broker/verifications/pseudo_branch_status'
|
3
3
|
require 'pact_broker/configuration'
|
4
4
|
|
5
5
|
module PactBroker
|
@@ -32,7 +32,7 @@ module PactBroker
|
|
32
32
|
|
33
33
|
def to_svg
|
34
34
|
response.headers['Cache-Control'] = 'no-cache'
|
35
|
-
comment + badge_service.pact_verification_badge(pact, label, initials,
|
35
|
+
comment + badge_service.pact_verification_badge(pact, label, initials, pseudo_branch_verification_status)
|
36
36
|
end
|
37
37
|
|
38
38
|
def pact
|
@@ -44,8 +44,8 @@ module PactBroker
|
|
44
44
|
@verification ||= verification_service.find_latest_verification_for(pact.consumer, pact.provider, identifier_from_path[:tag])
|
45
45
|
end
|
46
46
|
|
47
|
-
def
|
48
|
-
@
|
47
|
+
def pseudo_branch_verification_status
|
48
|
+
@pseudo_branch_verification_status ||= PactBroker::Verifications::PseudoBranchStatus.new(pact, latest_verification).to_sym
|
49
49
|
end
|
50
50
|
|
51
51
|
def label
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'pact_broker/api/resources/matrix'
|
2
|
+
require 'pact_broker/matrix/can_i_deploy_query_schema'
|
3
|
+
require 'pact_broker/matrix/parse_can_i_deploy_query'
|
4
|
+
|
5
|
+
module PactBroker
|
6
|
+
module Api
|
7
|
+
module Resources
|
8
|
+
class CanIDeploy < Matrix
|
9
|
+
def initialize
|
10
|
+
@query_params = JSON.parse(Rack::Utils.parse_nested_query(request.uri.query).to_json, symbolize_names: true)
|
11
|
+
@selectors, @options = PactBroker::Matrix::ParseCanIDeployQuery.call(query_params)
|
12
|
+
end
|
13
|
+
|
14
|
+
def malformed_request?
|
15
|
+
if (errors = query_schema.call(query_params)).any?
|
16
|
+
set_json_validation_error_messages(errors)
|
17
|
+
true
|
18
|
+
else
|
19
|
+
false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
attr_reader :query_params
|
26
|
+
|
27
|
+
def query_schema
|
28
|
+
PactBroker::Api::Contracts::CanIDeployQuerySchema
|
29
|
+
end
|
30
|
+
|
31
|
+
def selectors
|
32
|
+
@selectors
|
33
|
+
end
|
34
|
+
|
35
|
+
def options
|
36
|
+
@options
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|