pact_broker 2.76.2 → 2.79.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +12 -0
- data/.github/workflows/release_gem.yml +1 -0
- data/.github/workflows/test-ruby-3.yml +19 -0
- data/.github/workflows/test.yml +16 -7
- data/.gitignore +3 -1
- data/CHANGELOG.md +53 -0
- data/DEVELOPER_DOCUMENTATION.md +13 -0
- data/DEVELOPER_SETUP.md +62 -3
- data/Dockerfile +1 -0
- data/ISSUES.md +7 -7
- data/config.ru +2 -1
- data/db/ddl_statements/head_pact_tags.rb +24 -1
- data/db/ddl_statements/latest_tagged_pact_consumer_version_orders.rb +11 -0
- data/db/ddl_statements/latest_tagged_pact_publications.rb +6 -0
- data/db/ddl_statements/latest_verification_ids_for_consumer_version_tags.rb +13 -0
- data/db/migrations/20210117_add_branch_to_version.rb +9 -0
- data/db/migrations/20210202_add_created_at_to_head_pact_tags.rb +14 -0
- data/db/migrations/20210205_add_pacticipant_id_to_tag.rb +17 -0
- data/db/migrations/20210206_add_index_to_tags_and_versions.rb +27 -0
- data/db/migrations/20210207_optimise_latest_verification_ids_for_consumer_version_tags.rb +13 -0
- data/db/migrations/20210208_optimise_latest_tagged_pact_cv_orders.rb +13 -0
- data/db/migrations/20210210_create_environments_table.rb +16 -0
- data/docker-compose-dev-postgres.yml +9 -1
- data/lib/pact_broker/api.rb +7 -2
- data/lib/pact_broker/api/contracts/dry_validation_predicates.rb +8 -0
- data/lib/pact_broker/api/contracts/environment_schema.rb +49 -0
- data/lib/pact_broker/api/decorators/base_decorator.rb +11 -0
- data/lib/pact_broker/api/decorators/dashboard_decorator.rb +5 -1
- data/lib/pact_broker/api/decorators/environment_decorator.rb +30 -0
- data/lib/pact_broker/api/decorators/environments_decorator.rb +21 -0
- data/lib/pact_broker/api/decorators/matrix_decorator.rb +3 -1
- data/lib/pact_broker/api/decorators/verifiable_pacts_query_decorator.rb +2 -0
- data/lib/pact_broker/api/decorators/version_decorator.rb +15 -2
- data/lib/pact_broker/api/pact_broker_urls.rb +8 -0
- data/lib/pact_broker/api/resources/default_base_resource.rb +18 -0
- data/lib/pact_broker/api/resources/environment.rb +76 -0
- data/lib/pact_broker/api/resources/environments.rb +75 -0
- data/lib/pact_broker/api/resources/index.rb +20 -0
- data/lib/pact_broker/api/resources/latest_version.rb +27 -0
- data/lib/pact_broker/api/resources/provider_pacts_for_verification.rb +1 -0
- data/lib/pact_broker/api/resources/version.rb +15 -9
- data/lib/pact_broker/app.rb +1 -1
- data/lib/pact_broker/certificates/certificate.rb +1 -1
- data/lib/pact_broker/config/setting.rb +1 -1
- data/lib/pact_broker/config/space_delimited_integer_list.rb +25 -0
- data/lib/pact_broker/configuration.rb +22 -1
- data/lib/pact_broker/db/data_migrations/helpers.rb +4 -0
- data/lib/pact_broker/db/data_migrations/set_extra_columns_for_tags.rb +29 -0
- data/lib/pact_broker/db/migrate_data.rb +1 -0
- data/lib/pact_broker/db/seed_example_data.rb +13 -13
- data/lib/pact_broker/deployments/environment.rb +15 -0
- data/lib/pact_broker/deployments/environment_service.rb +39 -0
- data/lib/pact_broker/doc/views/index/environment.markdown +37 -0
- data/lib/pact_broker/doc/views/index/environments.markdown +53 -0
- data/lib/pact_broker/doc/views/index/latest-pact-versions.markdown +1 -1
- data/lib/pact_broker/doc/views/index/pacticipant-version-tag.markdown +1 -0
- data/lib/pact_broker/doc/views/index/pacticipant-version.markdown +13 -0
- data/lib/pact_broker/domain/index_item.rb +18 -4
- data/lib/pact_broker/domain/pacticipant.rb +9 -5
- data/lib/pact_broker/domain/tag.rb +131 -71
- data/lib/pact_broker/domain/verification.rb +3 -2
- data/lib/pact_broker/domain/version.rb +58 -23
- data/lib/pact_broker/domain/webhook.rb +6 -3
- data/lib/pact_broker/index/service.rb +55 -49
- data/lib/pact_broker/locale/en.yml +3 -1
- data/lib/pact_broker/matrix/quick_row.rb +8 -0
- data/lib/pact_broker/metrics/service.rb +1 -1
- data/lib/pact_broker/pacts/eager_loaders.rb +52 -0
- data/lib/pact_broker/pacts/latest_pact_publication_id_for_consumer_version.rb +18 -13
- data/lib/pact_broker/pacts/lazy_loaders.rb +14 -0
- data/lib/pact_broker/pacts/pact_publication.rb +38 -84
- data/lib/pact_broker/pacts/pact_publication_dataset_module.rb +297 -0
- data/lib/pact_broker/pacts/pact_version.rb +1 -2
- data/lib/pact_broker/pacts/pacts_for_verification_repository.rb +286 -0
- data/lib/pact_broker/pacts/repository.rb +5 -240
- data/lib/pact_broker/pacts/selected_pact.rb +4 -0
- data/lib/pact_broker/pacts/selector.rb +56 -1
- data/lib/pact_broker/pacts/selectors.rb +16 -0
- data/lib/pact_broker/pacts/service.rb +2 -6
- data/lib/pact_broker/pacts/squash_pacts_for_verification.rb +1 -4
- data/lib/pact_broker/pacts/verifiable_pact.rb +23 -2
- data/lib/pact_broker/pacts/verifiable_pact_messages.rb +56 -16
- data/lib/pact_broker/repositories/helpers.rb +4 -0
- data/lib/pact_broker/services.rb +9 -0
- data/lib/pact_broker/tags/eager_loaders.rb +47 -0
- data/lib/pact_broker/tags/repository.rb +3 -1
- data/lib/pact_broker/tags/service.rb +0 -3
- data/lib/pact_broker/tags/tag_with_latest_flag.rb +1 -0
- data/lib/pact_broker/test/http_test_data_builder.rb +23 -7
- data/lib/pact_broker/test/test_data_builder.rb +50 -3
- data/lib/pact_broker/ui/view_models/index_item.rb +19 -2
- data/lib/pact_broker/ui/view_models/matrix_line.rb +38 -2
- data/lib/pact_broker/ui/views/index/show-with-tags.haml +14 -6
- data/lib/pact_broker/ui/views/matrix/show.haml +12 -2
- data/lib/pact_broker/verifications/latest_verification_id_for_pact_version_and_provider_version.rb +7 -5
- data/lib/pact_broker/version.rb +1 -1
- data/lib/pact_broker/versions/eager_loaders.rb +71 -0
- data/lib/pact_broker/versions/lazy_loaders.rb +13 -0
- data/lib/pact_broker/versions/repository.rb +22 -2
- data/lib/pact_broker/versions/service.rb +5 -1
- data/lib/pact_broker/webhooks/execution.rb +3 -2
- data/lib/pact_broker/webhooks/latest_triggered_webhook.rb +2 -0
- data/lib/pact_broker/webhooks/triggered_webhook.rb +11 -4
- data/lib/pact_broker/webhooks/webhook.rb +1 -1
- data/lib/pact_broker/webhooks/webhook_event.rb +1 -1
- data/lib/pact_broker/webhooks/webhook_execution_result.rb +6 -1
- data/lib/pact_broker/webhooks/webhook_request_logger.rb +7 -1
- data/lib/rack/pact_broker/set_base_url.rb +35 -5
- data/lib/sequel/plugins/upsert.rb +18 -4
- data/pact_broker.gemspec +1 -1
- data/public/javascripts/clipboard.js +8 -2
- data/public/stylesheets/index.css +26 -2
- data/public/stylesheets/matrix.css +0 -21
- data/regression/can_i_deploy_spec.rb +5 -4
- data/regression/index_spec.rb +26 -0
- data/regression/regression_helper.rb +29 -3
- data/regression/script/clear.sh +3 -0
- data/regression/script/run.sh +3 -0
- data/script/demonstrate-version-branches.rb +33 -0
- data/script/pry.rb +2 -2
- data/spec/features/create_environment_spec.rb +47 -0
- data/spec/features/create_tag_spec.rb +32 -0
- data/spec/features/create_version_spec.rb +70 -0
- data/spec/features/delete_environment_spec.rb +16 -0
- data/spec/features/end_deployment_spec.rb +29 -0
- data/spec/features/get_environment_spec.rb +19 -0
- data/spec/features/get_environments_spec.rb +20 -0
- data/spec/features/record_deployment_spec.rb +28 -0
- data/spec/features/update_environment_spec.rb +44 -0
- data/spec/fixtures/approvals/modifiable_resources.approved.json +6 -0
- data/spec/fixtures/dashboard.json +4 -2
- data/spec/lib/pact_broker/api/contracts/environment_schema_spec.rb +83 -0
- data/spec/lib/pact_broker/api/decorators/dashboard_decorator_spec.rb +4 -2
- data/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb +11 -6
- data/spec/lib/pact_broker/api/decorators/verifiable_pacts_query_decorator_spec.rb +6 -0
- data/spec/lib/pact_broker/api/decorators/version_decorator_spec.rb +18 -0
- data/spec/lib/pact_broker/api/resources/default_base_resource_approval_spec.rb +1 -1
- data/spec/lib/pact_broker/api/resources/provider_pacts_for_verification_spec.rb +4 -0
- data/spec/lib/pact_broker/api/resources/webhook_execution_result_spec.rb +56 -0
- data/spec/lib/pact_broker/config/space_delimited_integer_list_spec.rb +47 -0
- data/spec/lib/pact_broker/configuration_spec.rb +12 -0
- data/spec/lib/pact_broker/domain/tag_spec.rb +101 -27
- data/spec/lib/pact_broker/domain/version_spec.rb +103 -15
- data/spec/lib/pact_broker/domain/webhook_spec.rb +1 -1
- data/spec/lib/pact_broker/index/service_spec.rb +89 -15
- data/spec/lib/pact_broker/pacts/pact_publication_dataset_module_spec.rb +400 -0
- data/spec/lib/pact_broker/pacts/pact_publication_spec.rb +434 -14
- data/spec/lib/pact_broker/pacts/repository_find_for_verification_fallback_spec.rb +1 -1
- data/spec/lib/pact_broker/pacts/repository_find_for_verification_spec.rb +1 -1
- data/spec/lib/pact_broker/pacts/repository_find_wip_pact_versions_for_provider_branch_spec.rb +224 -0
- data/spec/lib/pact_broker/pacts/repository_find_wip_pact_versions_for_provider_spec.rb +20 -7
- data/spec/lib/pact_broker/pacts/selector_spec.rb +3 -2
- data/spec/lib/pact_broker/pacts/service_find_for_verification_spec.rb +2 -3
- data/spec/lib/pact_broker/pacts/service_spec.rb +2 -2
- data/spec/lib/pact_broker/pacts/verifiable_pact_messages_spec.rb +57 -10
- data/spec/lib/pact_broker/tags/repository_spec.rb +2 -0
- data/spec/lib/pact_broker/versions/repository_spec.rb +54 -0
- data/spec/lib/pact_broker/webhooks/webhook_request_logger_spec.rb +8 -0
- data/spec/lib/rack/pact_broker/set_base_url_spec.rb +86 -0
- data/spec/lib/sequel/plugins/upsert_spec.rb +31 -3
- data/spec/migrations/change_migration_strategy_spec.rb +3 -3
- data/spec/service_consumers/hal_relation_proxy_app.rb +3 -1
- data/spec/service_consumers/provider_states_for_pact_broker_client.rb +16 -0
- data/spec/spec_helper.rb +17 -5
- data/spec/support/approvals.rb +24 -0
- data/spec/support/shared_examples_for_responses.rb +11 -0
- data/tasks/database.rb +1 -1
- data/tasks/db.rake +1 -0
- data/tasks/rspec.rake +1 -1
- data/vendor/hal-browser/styles.css +6 -0
- metadata +70 -11
@@ -24,9 +24,15 @@ function initializeClipper(selector) {
|
|
24
24
|
.children(".clippy")
|
25
25
|
.click(function() {
|
26
26
|
const clippyButton = $(this);
|
27
|
-
const
|
27
|
+
const clipTarget = clippyButton.closest(selector);
|
28
|
+
let text = null;
|
29
|
+
if(clipTarget.data('clippable')) {
|
30
|
+
text = clipTarget.data('clippable');
|
31
|
+
} else {
|
32
|
+
text = clippyButton.closest(selector).text();
|
33
|
+
}
|
34
|
+
copyToClipboard($.trim(text));
|
28
35
|
|
29
|
-
copyToClipboard(text);
|
30
36
|
flashClipped(clippyButton);
|
31
37
|
});
|
32
38
|
}
|
@@ -52,7 +52,10 @@ body { padding-top: 10px; }
|
|
52
52
|
word-wrap: break-word;
|
53
53
|
}
|
54
54
|
|
55
|
-
.consumer-version
|
55
|
+
.consumer-version,
|
56
|
+
.provider-version,
|
57
|
+
.consumer-version-number,
|
58
|
+
.provider-version-number {
|
56
59
|
word-wrap: break-word;
|
57
60
|
}
|
58
61
|
|
@@ -207,4 +210,25 @@ span.warning-icon {
|
|
207
210
|
padding-bottom: 9px;
|
208
211
|
margin: 40px 0 20px;
|
209
212
|
border-bottom: 1px solid #eee;
|
210
|
-
}
|
213
|
+
}
|
214
|
+
|
215
|
+
span.copy-icon {
|
216
|
+
background-image: url('/images/copy.svg');
|
217
|
+
background-size: 16px 16px;
|
218
|
+
background-repeat: no-repeat;
|
219
|
+
display:block;
|
220
|
+
position: relative;
|
221
|
+
width: 16px;
|
222
|
+
height: 16px;
|
223
|
+
cursor: pointer;
|
224
|
+
}
|
225
|
+
|
226
|
+
span.copy-success-icon {
|
227
|
+
background-image: url('/images/check.svg');
|
228
|
+
background-size: 16px 16px;
|
229
|
+
background-repeat: no-repeat;
|
230
|
+
display:block;
|
231
|
+
position: relative;
|
232
|
+
width: 16px;
|
233
|
+
height: 16px;
|
234
|
+
}
|
@@ -70,24 +70,3 @@ img.pact_badge {
|
|
70
70
|
display: flex;
|
71
71
|
justify-content: flex-start;
|
72
72
|
}
|
73
|
-
|
74
|
-
span.copy-icon {
|
75
|
-
background-image: url('/images/copy.svg');
|
76
|
-
background-size: 16px 16px;
|
77
|
-
background-repeat: no-repeat;
|
78
|
-
display:block;
|
79
|
-
position: relative;
|
80
|
-
width: 16px;
|
81
|
-
height: 16px;
|
82
|
-
cursor: pointer;
|
83
|
-
}
|
84
|
-
|
85
|
-
span.copy-success-icon {
|
86
|
-
background-image: url('/images/check.svg');
|
87
|
-
background-size: 16px 16px;
|
88
|
-
background-repeat: no-repeat;
|
89
|
-
display:block;
|
90
|
-
position: relative;
|
91
|
-
width: 16px;
|
92
|
-
height: 16px;
|
93
|
-
}
|
@@ -1,9 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'pact_broker/domain'
|
2
|
+
PACTICIPANT_LIMIT = 10
|
3
|
+
VERSION_LIMIT = 10
|
3
4
|
|
4
|
-
PACTICIPANTS = PactBroker::Domain::Pacticipant.order(:id).limit(PACTICIPANT_LIMIT).all
|
5
|
+
PACTICIPANTS = PactBroker::Domain::Pacticipant.order(Sequel.desc(:id)).limit(PACTICIPANT_LIMIT).all
|
5
6
|
|
6
|
-
RSpec.describe "regression tests"
|
7
|
+
RSpec.describe "regression tests" do
|
7
8
|
|
8
9
|
def can_i_deploy(pacticipant_name, version_number, to_tag)
|
9
10
|
get("/can-i-deploy", { pacticipant: pacticipant_name, version: version_number, to: to_tag }, { "HTTP_ACCEPT" => "application/hal+json" })
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'pact_broker/domain'
|
2
|
+
require 'pact_broker/policies'
|
3
|
+
require 'pact_broker/ui/app'
|
4
|
+
|
5
|
+
RSpec.describe "regression tests for index page" do
|
6
|
+
context "HTML" do
|
7
|
+
let(:app) { PactBroker::UI::App.new }
|
8
|
+
|
9
|
+
it "has the same response without tags" do
|
10
|
+
response = get("/", nil, { "HTTP_ACCEPT" => "text/html" } )
|
11
|
+
Approvals.verify(response.body, :name => "index_html", format: :html)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "has the same response with tags" do
|
15
|
+
response = get("/", { "tags" => "true", "pageNumber" => "1", "pageSize" => "100"}, { "HTTP_ACCEPT" => "text/html" } )
|
16
|
+
Approvals.verify(response.body, :name => "index_html_with_tags", format: :html)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "JSON" do
|
21
|
+
it "has the same response" do
|
22
|
+
response = get("/dashboard", { "HTTP_ACCEPT" => "application/hal+json" } )
|
23
|
+
Approvals.verify(JSON.parse(response.body), :name => "index_json", format: :json)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,10 +1,19 @@
|
|
1
|
-
ENV[
|
2
|
-
ENV[
|
1
|
+
raise "Must set INSTALL_PG=true" unless ENV["INSTALL_PG"] == "true"
|
2
|
+
raise "Must set DATABASE_ADAPTER=docker_postgres" unless ENV["DATABASE_ADAPTER"] == "docker_postgres"
|
3
|
+
raise "Must set RACK_ENV=development" unless ENV["RACK_ENV"] == "development"
|
3
4
|
|
4
|
-
|
5
|
+
$LOAD_PATH << "."
|
6
|
+
|
7
|
+
require 'sequel'
|
8
|
+
|
9
|
+
load 'lib/db.rb'
|
5
10
|
require 'tasks/database'
|
6
11
|
require 'pact_broker/db'
|
7
12
|
PactBroker::DB.connection = PactBroker::Database.database = DB::PACT_BROKER_DB
|
13
|
+
PactBroker::DB::Migrate.call(PactBroker::DB.connection)
|
14
|
+
require 'approvals'
|
15
|
+
require 'rack/test'
|
16
|
+
require 'pact_broker/api'
|
8
17
|
|
9
18
|
Approvals.configure do |c|
|
10
19
|
c.approvals_path = 'regression/fixtures/approvals/'
|
@@ -25,10 +34,27 @@ RSpec.configure do | config |
|
|
25
34
|
|
26
35
|
config.example_status_persistence_file_path = "./regression/.examples.txt"
|
27
36
|
config.filter_run_excluding skip: true
|
37
|
+
config.filter_run focus: true
|
38
|
+
config.run_all_when_everything_filtered = true
|
28
39
|
|
29
40
|
def app
|
30
41
|
PactBroker::API
|
31
42
|
end
|
43
|
+
|
44
|
+
config.after(:each) do | example, something |
|
45
|
+
if ENV["SHOW_REGRESSION_DIFF"] == "true"
|
46
|
+
if example.exception.is_a?(Approvals::ApprovalError)
|
47
|
+
require "pact/support"
|
48
|
+
parts = example.exception.message.split('"')
|
49
|
+
received_file = parts[1]
|
50
|
+
approved_file = parts[3]
|
51
|
+
received_hash = JSON.parse(File.read(received_file))
|
52
|
+
approved_hash = JSON.parse(File.read(approved_file))
|
53
|
+
diff = Pact::Matchers.diff(approved_hash, received_hash)
|
54
|
+
puts Pact::Matchers::UnixDiffFormatter.call(diff)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
32
58
|
end
|
33
59
|
|
34
60
|
if ENV["DEBUG"] == "true"
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
begin
|
3
|
+
|
4
|
+
$LOAD_PATH << "#{Dir.pwd}/lib"
|
5
|
+
require 'pact_broker/test/http_test_data_builder'
|
6
|
+
base_url = ENV['PACT_BROKER_BASE_URL'] || 'http://localhost:9292'
|
7
|
+
|
8
|
+
td = PactBroker::Test::HttpTestDataBuilder.new(base_url)
|
9
|
+
td.delete_integration(consumer: "Foo", provider: "Bar")
|
10
|
+
.delete_integration(consumer: "foo-consumer", provider: "bar-provider")
|
11
|
+
.publish_pact(consumer: "foo-consumer", consumer_version: "1", provider: "bar-provider", content_id: "111", branch: "main")
|
12
|
+
.publish_pact(consumer: "foo-consumer", consumer_version: "2", provider: "bar-provider", content_id: "222", tag: "feat/x")
|
13
|
+
.get_pacts_for_verification(
|
14
|
+
enable_pending: true,
|
15
|
+
provider_version_branch: "main",
|
16
|
+
provider_version_tag: "dev",
|
17
|
+
include_wip_pacts_since: "2020-01-01",
|
18
|
+
consumer_version_selectors: [{ branch: "main", latest: true }])
|
19
|
+
.verify_pact(
|
20
|
+
index: 0,
|
21
|
+
provider_version: "1",
|
22
|
+
success: true
|
23
|
+
)
|
24
|
+
.can_i_deploy(pacticipant: "bar-provider", version: "1", to: "prod")
|
25
|
+
.deploy_to_prod(pacticipant: "bar-provider", version: "1")
|
26
|
+
.can_i_deploy(pacticipant: "foo-consumer", version: "1", to: "prod")
|
27
|
+
.deploy_to_prod(pacticipant: "foo-consumer", version: "1")
|
28
|
+
|
29
|
+
rescue StandardError => e
|
30
|
+
puts "#{e.class} #{e.message}"
|
31
|
+
puts e.backtrace
|
32
|
+
exit 1
|
33
|
+
end
|
data/script/pry.rb
CHANGED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'pact_broker/api/pact_broker_urls'
|
2
|
+
|
3
|
+
describe "Creating an environment" do
|
4
|
+
let(:path) { PactBroker::Api::PactBrokerUrls.environments_url }
|
5
|
+
let(:headers) { { "CONTENT_TYPE" => "application/json" } }
|
6
|
+
let(:response_body) { JSON.parse(subject.body, symbolize_names: true)}
|
7
|
+
let(:environment_hash) do
|
8
|
+
{
|
9
|
+
name: "test",
|
10
|
+
displayName: "Test",
|
11
|
+
production: false,
|
12
|
+
contacts: [
|
13
|
+
{ name: "Team Awesome", details: { email: "foo@bar.com", arbitraryThing: "thing" } }
|
14
|
+
]
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
subject { post(path, environment_hash.to_json, headers) }
|
19
|
+
|
20
|
+
it "returns a 201 response" do
|
21
|
+
expect(subject.status).to be 201
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns the Location header" do
|
25
|
+
expect(subject.headers["Location"]).to eq PactBroker::Api::PactBrokerUrls.environment_url(PactBroker::Deployments::Environment.order(:id).last, "http://example.org")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns a JSON Content Type" do
|
29
|
+
expect(subject.headers["Content-Type"]).to eq "application/hal+json;charset=utf-8"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "returns the newly created environment" do
|
33
|
+
expect(response_body).to include environment_hash.merge(name: "test")
|
34
|
+
expect(response_body[:uuid]).to_not be nil
|
35
|
+
end
|
36
|
+
|
37
|
+
context "with invalid params" do
|
38
|
+
before do
|
39
|
+
td.create_environment("test")
|
40
|
+
end
|
41
|
+
|
42
|
+
it "returns a 400 response" do
|
43
|
+
expect(subject.status).to be 400
|
44
|
+
expect(response_body[:errors]).to_not be nil
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
describe "Creating a tag" do
|
2
|
+
let(:path) { "/pacticipants/Foo/versions/1234/tags/foo" }
|
3
|
+
let(:headers) { { 'CONTENT_TYPE' => 'application/json' } }
|
4
|
+
let(:response_body) { JSON.parse(subject.body, symbolize_names: true)}
|
5
|
+
|
6
|
+
subject { put(path, {}, headers) }
|
7
|
+
|
8
|
+
it "returns a 201 response" do
|
9
|
+
expect(subject.status).to be 201
|
10
|
+
end
|
11
|
+
|
12
|
+
it "returns a HAL JSON Content Type" do
|
13
|
+
expect(subject.headers['Content-Type']).to eq 'application/hal+json;charset=utf-8'
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns the newly created tag" do
|
17
|
+
expect(response_body).to include name: "foo"
|
18
|
+
end
|
19
|
+
|
20
|
+
context "when the tag already exists" do
|
21
|
+
before do
|
22
|
+
td.subtract_day
|
23
|
+
.create_consumer("Foo")
|
24
|
+
.create_consumer_version("1234")
|
25
|
+
.create_consumer_version_tag("foo")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns a 200 response" do
|
29
|
+
expect(subject.status).to be 200
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
describe "Creating a pacticipant version" do
|
2
|
+
let(:path) { "/pacticipants/Foo/versions/1234" }
|
3
|
+
let(:headers) { { 'CONTENT_TYPE' => 'application/json' } }
|
4
|
+
let(:response_body) { JSON.parse(subject.body, symbolize_names: true)}
|
5
|
+
let(:version_hash) do
|
6
|
+
{
|
7
|
+
branch: "main",
|
8
|
+
buildUrl: "http://build",
|
9
|
+
tags: [{ name: "foo" }, { name: "bar" }]
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
subject { put(path, version_hash.to_json, headers) }
|
14
|
+
|
15
|
+
it "returns a 201 response" do
|
16
|
+
expect(subject.status).to be 201
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns a HAL JSON Content Type" do
|
20
|
+
expect(subject.headers['Content-Type']).to eq 'application/hal+json;charset=utf-8'
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns the newly created version" do
|
24
|
+
expect(response_body).to include branch: "main", buildUrl: "http://build"
|
25
|
+
expect(response_body[:_embedded][:tags].size).to eq 2
|
26
|
+
end
|
27
|
+
|
28
|
+
it "creates the specified tags" do
|
29
|
+
expect { subject }.to change { PactBroker::Domain::Tag.count }.by(2)
|
30
|
+
end
|
31
|
+
|
32
|
+
context "when the version already exists" do
|
33
|
+
before do
|
34
|
+
td.subtract_day
|
35
|
+
.create_consumer("Foo")
|
36
|
+
.create_consumer_version("1234", branch: "original-branch", build_url: "original-build-url")
|
37
|
+
.create_consumer_version_tag("dev")
|
38
|
+
end
|
39
|
+
|
40
|
+
let(:version_hash) { { branch: "new-branch" } }
|
41
|
+
|
42
|
+
it "returns a 200" do
|
43
|
+
expect(subject.status).to be 200
|
44
|
+
end
|
45
|
+
|
46
|
+
it "overwrites the direct properties" do
|
47
|
+
expect(response_body[:branch]).to eq "new-branch"
|
48
|
+
expect(response_body).to_not have_key(:buildUrl)
|
49
|
+
end
|
50
|
+
|
51
|
+
context "when not tags are specified" do
|
52
|
+
it "does not change the tags" do
|
53
|
+
expect { subject }.to_not change { PactBroker::Domain::Version.for("Foo", "1234").tags }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "when tags are specified" do
|
58
|
+
let(:version_hash) { { branch: "new-branch", tags: [ { name: "main" }] } }
|
59
|
+
|
60
|
+
it "overwrites the tags" do
|
61
|
+
expect(response_body[:_embedded][:tags].size).to eq 1
|
62
|
+
expect(response_body[:_embedded][:tags].first[:name]).to eq "main"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
it "does not change the created date" do
|
67
|
+
expect { subject }.to_not change { PactBroker::Domain::Version.for("Foo", "1234").created_at }
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'pact_broker/api/pact_broker_urls'
|
2
|
+
|
3
|
+
describe "Deleting an environment" do
|
4
|
+
before do
|
5
|
+
td.create_environment("test", uuid: "1234")
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:path) { PactBroker::Api::PactBrokerUrls.environment_url(td.and_return(:environment)) }
|
9
|
+
|
10
|
+
subject { delete(path, nil) }
|
11
|
+
|
12
|
+
it "returns a 204 response" do
|
13
|
+
subject
|
14
|
+
expect(last_response.status).to be 204
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#
|
2
|
+
# RPC style seems cleaner than REST here, as setting the endedAt parameter directly
|
3
|
+
# seems likely to end in Timezone tears
|
4
|
+
# This endpoint would be called by the pact broker client during `record-deployment` if the
|
5
|
+
# --end-previous-deployment (on by default) was specified.
|
6
|
+
# This allows us to know exactly what is deployed to a particular environment at a given time,
|
7
|
+
# (eg. /environments/test/deployments/current)
|
8
|
+
# and provides first class support for mobile clients that have multiple versions in prod
|
9
|
+
# at once.
|
10
|
+
|
11
|
+
describe "Record deployment ended", skip: "Not yet implemented" do
|
12
|
+
before do
|
13
|
+
td.create_environment("test")
|
14
|
+
.create_pacticipant("Foo")
|
15
|
+
.create_pacticipant_version("1")
|
16
|
+
.create_deployment("test")
|
17
|
+
end
|
18
|
+
let(:path) { "/pacticipants/Foo/deployments/test/latest/end" }
|
19
|
+
let(:headers) { {} }
|
20
|
+
let(:response_body) { JSON.parse(last_response.body, symbolize_names: true) }
|
21
|
+
|
22
|
+
subject { post(path, nil, headers) }
|
23
|
+
|
24
|
+
it { is_expected.be_a_hal_json_success_response }
|
25
|
+
|
26
|
+
it "returns the updated deployment" do
|
27
|
+
expect(subject[:endedAt]).to_not be nil
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'pact_broker/api/pact_broker_urls'
|
2
|
+
|
3
|
+
describe "Get an environment" do
|
4
|
+
before do
|
5
|
+
td.create_environment("test", display_name: "Test", uuid: "1234", contacts: [ { name: "Foo" } ] )
|
6
|
+
end
|
7
|
+
let(:path) { PactBroker::Api::PactBrokerUrls.environment_url(td.and_return(:environment)) }
|
8
|
+
let(:headers) { {'HTTP_ACCEPT' => 'application/hal+json'} }
|
9
|
+
let(:response_body) { JSON.parse(subject.body, symbolize_names: true)}
|
10
|
+
|
11
|
+
subject { get(path, nil, headers) }
|
12
|
+
|
13
|
+
it { is_expected.to be_a_hal_json_success_response }
|
14
|
+
|
15
|
+
it "returns the environment" do
|
16
|
+
expect(response_body[:uuid]).to eq "1234"
|
17
|
+
expect(response_body[:name]).to eq "test"
|
18
|
+
end
|
19
|
+
end
|