pact_broker 2.77.0 → 2.80.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release_gem.yml +1 -0
- data/.github/workflows/test.yml +37 -11
- data/.rubocop.yml +37 -879
- data/.ruby-version +1 -1
- data/CHANGELOG.md +102 -0
- data/DEVELOPER_DOCUMENTATION.md +13 -0
- data/DEVELOPER_SETUP.md +6 -0
- data/Dockerfile +1 -1
- data/Gemfile +30 -28
- data/Rakefile +8 -6
- data/config.ru +11 -11
- data/config/boot.rb +6 -6
- data/db/ddl_statements/latest_pact_consumer_version_orders.rb +1 -1
- data/db/ddl_statements/latest_pact_publications_by_consumer_versions.rb +2 -2
- data/db/migrations/000001_create_pacticipant_table.rb +1 -1
- data/db/migrations/000002_create_versions_table.rb +1 -1
- data/db/migrations/000003_create_pacts_table.rb +1 -1
- data/db/migrations/000004_create_tags_table.rb +1 -1
- data/db/migrations/000007_increase_json_content_length.rb +1 -1
- data/db/migrations/000012_create_webhooks_table.rb +6 -6
- data/db/migrations/000015_create_pact_version_content.rb +4 -4
- data/db/migrations/000016_add_pact_content_foreign_key_to_pacts.rb +3 -3
- data/db/migrations/000017_migrate_json_content_to_pact_version_content_table.rb +2 -2
- data/db/migrations/000018_drop_json_content_column_from_pacts.rb +2 -2
- data/db/migrations/000019_make_pact_version_content_sha_not_nullable.rb +2 -2
- data/db/migrations/000020_add_pact_version_content_sha_to_all_pacts_view.rb +2 -2
- data/db/migrations/000021_recreate_latest_pacts_view.rb +2 -2
- data/db/migrations/000023_create_pact_versions_table.rb +3 -3
- data/db/migrations/000026_create_pact_publications.rb +3 -3
- data/db/migrations/000031_create_verifications.rb +1 -1
- data/db/migrations/000033_create_config_table.rb +3 -3
- data/db/migrations/000034_create_index_on_consumer_version_order.rb +3 -3
- data/db/migrations/000035_create_index_on_names.rb +2 -2
- data/db/migrations/000036_create_webhook_execution.rb +2 -2
- data/db/migrations/000037_create_labels_table.rb +1 -1
- data/db/migrations/000038_create_triggered_webhooks_table.rb +3 -3
- data/db/migrations/000041_migrate_execution_data.rb +3 -3
- data/db/migrations/000043_add_provider_version_to_verification.rb +1 -1
- data/db/migrations/000044_populate_verifications_provider_version_id.rb +9 -9
- data/db/migrations/20171112_add_test_results.rb +1 -1
- data/db/migrations/20171117_create_webhook_events.rb +3 -3
- data/db/migrations/20171118_create_webhook_events.rb +2 -2
- data/db/migrations/20180108_create_certificates_table.rb +3 -3
- data/db/migrations/20180109_migrate_trigger_type.rb +2 -2
- data/db/migrations/20180119_update_latest_triggered_webhooks.rb +1 -1
- data/db/migrations/20180123_create_tags_with_latest_flag.rb +1 -1
- data/db/migrations/20180130_create_materialized_matrix.rb +4 -4
- data/db/migrations/20180131_create_materialized_latest_matrix.rb +4 -4
- data/db/migrations/20180202_create_materialized_head_matrix.rb +4 -4
- data/db/migrations/20180205_drop_materialized_latest_matrix.rb +4 -4
- data/db/migrations/20180210_fix_latest_matrix_for_cv_and_pv_again.rb +2 -2
- data/db/migrations/20180311_optimise_head_matrix.rb +2 -3
- data/db/migrations/20180523_create_latest_verifications_for_consumer_version_tags.rb +1 -1
- data/db/migrations/20180524_create_latest_verifications_for_consumer_and_provider.rb +1 -1
- data/db/migrations/20180613_migrate_pacticipant_ids_for_verifications.rb +1 -1
- data/db/migrations/20180614_update_latest_verification_ids_for_consumer_and_provider.rb +1 -1
- data/db/migrations/20180616_migrate_consumer_ids_for_pact_publications.rb +1 -1
- data/db/migrations/20180720_create_latest_pact_publication_ids.rb +1 -1
- data/db/migrations/20180722_recreate_views.rb +1 -1
- data/db/migrations/20180723_create_latest_verification_ids.rb +6 -6
- data/db/migrations/20180729_create_latest_verification_ids_for_provider_versions.rb +1 -1
- data/db/migrations/20190509_create_version_sequence.rb +1 -1
- data/db/migrations/20190510_set_version_sequence.rb +1 -1
- data/db/migrations/20190524_set_webhooks_enabled.rb +1 -1
- data/db/migrations/20190603_migrate_webhook_headers.rb +1 -1
- data/db/migrations/20191025_optimise_latest_verification_ids_for_cv_tags.rb +1 -1
- data/db/migrations/20191028_optimise_latest_tagged_pact_cv_orders.rb +1 -1
- data/db/migrations/20191030_optimise_latest_pact_publications_by_consumer_versions_.rb +1 -1
- data/db/migrations/20191031_optimise_latest_verification_ids_for_consumer_version_tags.rb +1 -1
- data/db/migrations/20191101_create_head_pact_tags.rb +1 -1
- data/db/migrations/20200930_update_latest_triggered_webhooks.rb +2 -2
- data/db/migrations/20201023_create_verification_number_sequence.rb +1 -1
- data/db/migrations/20201024_create_version_order_sequence.rb +1 -1
- data/db/migrations/20201026_update_latest_verification_ids_for_consumer_and_provider.rb +2 -2
- data/db/migrations/20210115_add_webhook_foreign_key_indexes.rb +1 -1
- data/db/migrations/20210116_add_context_to_triggered_webhook.rb +1 -1
- data/db/migrations/20210202_add_created_at_to_head_pact_tags.rb +2 -2
- data/db/migrations/20210205_add_pacticipant_id_to_tag.rb +1 -1
- data/db/migrations/20210206_add_index_to_tags_and_versions.rb +1 -1
- data/db/migrations/20210207_optimise_latest_verification_ids_for_consumer_version_tags.rb +1 -1
- data/db/migrations/20210208_optimise_latest_tagged_pact_cv_orders.rb +1 -1
- data/db/migrations/20210210_create_environments_table.rb +16 -0
- data/db/migrations/20210216_create_deployed_versions_table.rb +18 -0
- data/db/migrations/20210226_set_deployment_columns_not_null.rb +31 -0
- data/db/migrations/20210301_add_pacticipant_columns.rb +10 -0
- data/db/migrations/20210413_create_currently_deployed_version_ids_table.rb +13 -0
- data/db/migrations/20210415_add_target_column_to_deployed_version.rb +21 -0
- data/db/migrations/20210419_create_released_versions_table.rb +17 -0
- data/db/migrations/20210529_add_main_branch_to_pacticipant.rb +18 -0
- data/db/migrations/20210608_add_uuid_to_webhook.rb +14 -0
- data/db/migrations/20210609_set_webhook_uuid.rb +11 -0
- data/db/migrations/20210702_drop_unused_columns_from_deployed_versions.rb +15 -0
- data/db/migrations/migration_helper.rb +3 -3
- data/db/test/backwards_compatibility/Gemfile +11 -11
- data/db/test/backwards_compatibility/Rakefile +17 -17
- data/db/test/backwards_compatibility/config.ru +6 -6
- data/db/test/backwards_compatibility/spec/publish_pact_spec.rb +13 -13
- data/db/test/backwards_compatibility/spec/spec_helper.rb +3 -3
- data/db/test/backwards_compatibility/spec/support/fixture_helpers.rb +2 -2
- data/db/test/backwards_compatibility/spec/support/request_helpers.rb +3 -4
- data/db/test/change_migration_strategy/Rakefile +6 -6
- data/db/test/change_migration_strategy/before/Gemfile +1 -1
- data/docker-compose-dev-postgres.yml +9 -1
- data/example/Gemfile +4 -4
- data/example/basic_auth/Gemfile +1 -1
- data/example/basic_auth/config.ru +7 -7
- data/example/config.ru +7 -7
- data/issue-reproduction/Dockerfile-pact-broker +1 -1
- data/lib/db.rb +18 -12
- data/lib/pact/doc/generator.rb +3 -3
- data/lib/pact/doc/interaction_view_model.rb +13 -13
- data/lib/pact/doc/markdown/consumer_contract_renderer.rb +4 -4
- data/lib/pact/doc/markdown/generator.rb +6 -6
- data/lib/pact/doc/markdown/interaction_renderer.rb +4 -4
- data/lib/pact/doc/sort_interactions.rb +0 -1
- data/lib/pact_broker.rb +4 -4
- data/lib/pact_broker/api.rb +102 -78
- data/lib/pact_broker/api/contracts/base_contract.rb +2 -2
- data/lib/pact_broker/api/contracts/dry_validation_predicates.rb +18 -1
- data/lib/pact_broker/api/contracts/dry_validation_workarounds.rb +3 -2
- data/lib/pact_broker/api/contracts/environment_schema.rb +49 -0
- data/lib/pact_broker/api/contracts/pacticipant_name_contract.rb +1 -1
- data/lib/pact_broker/api/contracts/pacticipant_name_validation.rb +2 -2
- data/lib/pact_broker/api/contracts/pacticipant_schema.rb +34 -0
- data/lib/pact_broker/api/contracts/publish_contracts_schema.rb +104 -0
- data/lib/pact_broker/api/contracts/put_pact_params_contract.rb +1 -1
- data/lib/pact_broker/api/contracts/request_validations.rb +2 -2
- data/lib/pact_broker/api/contracts/verifiable_pacts_json_query_schema.rb +70 -15
- data/lib/pact_broker/api/contracts/verifiable_pacts_query_schema.rb +3 -3
- data/lib/pact_broker/api/contracts/verification_contract.rb +2 -2
- data/lib/pact_broker/api/contracts/webhook_contract.rb +10 -7
- data/lib/pact_broker/api/decorators/base_decorator.rb +20 -5
- data/lib/pact_broker/api/decorators/basic_pacticipant_decorator.rb +1 -1
- data/lib/pact_broker/api/decorators/configuration.rb +2 -2
- data/lib/pact_broker/api/decorators/dashboard_decorator.rb +8 -8
- data/lib/pact_broker/api/decorators/dashboard_text_decorator.rb +3 -3
- data/lib/pact_broker/api/decorators/decorator_context.rb +1 -1
- data/lib/pact_broker/api/decorators/decorator_context_creator.rb +1 -1
- data/lib/pact_broker/api/decorators/deployed_version_decorator.rb +26 -0
- data/lib/pact_broker/api/decorators/deployed_versions_decorator.rb +20 -0
- data/lib/pact_broker/api/decorators/embedded_label_decorator.rb +2 -2
- data/lib/pact_broker/api/decorators/embedded_pacticipant_decorator.rb +17 -0
- data/lib/pact_broker/api/decorators/embedded_tag_decorator.rb +4 -4
- data/lib/pact_broker/api/decorators/embedded_version_decorator.rb +7 -2
- data/lib/pact_broker/api/decorators/environment_decorator.rb +51 -0
- data/lib/pact_broker/api/decorators/environments_decorator.rb +31 -0
- data/lib/pact_broker/api/decorators/extended_pact_decorator.rb +2 -2
- data/lib/pact_broker/api/decorators/extended_verification_decorator.rb +2 -2
- data/lib/pact_broker/api/decorators/integration_decorator.rb +2 -2
- data/lib/pact_broker/api/decorators/integrations_decorator.rb +2 -2
- data/lib/pact_broker/api/decorators/label_decorator.rb +5 -5
- data/lib/pact_broker/api/decorators/latest_pact_decorator.rb +2 -2
- data/lib/pact_broker/api/decorators/matrix_decorator.rb +26 -11
- data/lib/pact_broker/api/decorators/matrix_text_decorator.rb +5 -5
- data/lib/pact_broker/api/decorators/pact_collection_decorator.rb +6 -6
- data/lib/pact_broker/api/decorators/pact_decorator.rb +5 -5
- data/lib/pact_broker/api/decorators/pact_details_decorator.rb +2 -2
- data/lib/pact_broker/api/decorators/pact_pacticipant_decorator.rb +3 -3
- data/lib/pact_broker/api/decorators/pact_version_decorator.rb +3 -3
- data/lib/pact_broker/api/decorators/pact_versions_decorator.rb +2 -2
- data/lib/pact_broker/api/decorators/pact_webhooks_status_decorator.rb +6 -6
- data/lib/pact_broker/api/decorators/pacticipant_collection_decorator.rb +8 -8
- data/lib/pact_broker/api/decorators/pacticipant_decorator.rb +29 -13
- data/lib/pact_broker/api/decorators/pagination_links.rb +2 -2
- data/lib/pact_broker/api/decorators/provider_pacts_decorator.rb +2 -3
- data/lib/pact_broker/api/decorators/publish_contract_decorator.rb +19 -0
- data/lib/pact_broker/api/decorators/publish_contracts_decorator.rb +21 -0
- data/lib/pact_broker/api/decorators/publish_contracts_results_decorator.rb +55 -0
- data/lib/pact_broker/api/decorators/reason_decorator.rb +30 -14
- data/lib/pact_broker/api/decorators/relationships_csv_decorator.rb +3 -1
- data/lib/pact_broker/api/decorators/released_version_decorator.rb +25 -0
- data/lib/pact_broker/api/decorators/released_versions_decorator.rb +20 -0
- data/lib/pact_broker/api/decorators/representable_pact.rb +1 -1
- data/lib/pact_broker/api/decorators/tag_decorator.rb +6 -6
- data/lib/pact_broker/api/decorators/tagged_pact_versions_decorator.rb +2 -2
- data/lib/pact_broker/api/decorators/timestamps.rb +2 -2
- data/lib/pact_broker/api/decorators/triggered_webhook_decorator.rb +8 -6
- data/lib/pact_broker/api/decorators/triggered_webhooks_decorator.rb +2 -2
- data/lib/pact_broker/api/decorators/verifiable_pact_decorator.rb +4 -4
- data/lib/pact_broker/api/decorators/verifiable_pacts_decorator.rb +3 -3
- data/lib/pact_broker/api/decorators/verifiable_pacts_query_decorator.rb +16 -9
- data/lib/pact_broker/api/decorators/verification_decorator.rb +6 -6
- data/lib/pact_broker/api/decorators/verification_summary_decorator.rb +4 -4
- data/lib/pact_broker/api/decorators/version_decorator.rb +38 -7
- data/lib/pact_broker/api/decorators/versions_decorator.rb +5 -5
- data/lib/pact_broker/api/decorators/webhook_decorator.rb +10 -8
- data/lib/pact_broker/api/decorators/webhook_execution_result_decorator.rb +7 -7
- data/lib/pact_broker/api/decorators/webhook_request_template_decorator.rb +1 -1
- data/lib/pact_broker/api/decorators/webhooks_decorator.rb +3 -3
- data/lib/pact_broker/api/pact_broker_urls.rb +125 -69
- data/lib/pact_broker/api/paths.rb +2 -2
- data/lib/pact_broker/api/renderers/html_pact_renderer.rb +16 -17
- data/lib/pact_broker/api/resources.rb +1 -1
- data/lib/pact_broker/api/resources/all_webhooks.rb +14 -6
- data/lib/pact_broker/api/resources/authentication.rb +1 -1
- data/lib/pact_broker/api/resources/authorization.rb +37 -0
- data/lib/pact_broker/api/resources/badge.rb +8 -8
- data/lib/pact_broker/api/resources/base_resource.rb +1 -1
- data/lib/pact_broker/api/resources/can_i_deploy.rb +13 -13
- data/lib/pact_broker/api/resources/can_i_deploy_badge.rb +7 -7
- data/lib/pact_broker/api/resources/can_i_deploy_pacticipant_version.rb +23 -18
- data/lib/pact_broker/api/resources/clean.rb +3 -3
- data/lib/pact_broker/api/resources/currently_deployed_versions_for_environment.rb +75 -0
- data/lib/pact_broker/api/resources/currently_supported_versions_for_environment.rb +70 -0
- data/lib/pact_broker/api/resources/dashboard.rb +3 -3
- data/lib/pact_broker/api/resources/default_base_resource.rb +47 -20
- data/lib/pact_broker/api/resources/deployed_version.rb +94 -0
- data/lib/pact_broker/api/resources/deployed_versions_for_version_and_environment.rb +89 -0
- data/lib/pact_broker/api/resources/environment.rb +76 -0
- data/lib/pact_broker/api/resources/environments.rb +79 -0
- data/lib/pact_broker/api/resources/error_handler.rb +4 -4
- data/lib/pact_broker/api/resources/error_response_body_generator.rb +3 -3
- data/lib/pact_broker/api/resources/error_test.rb +2 -2
- data/lib/pact_broker/api/resources/group.rb +2 -2
- data/lib/pact_broker/api/resources/index.rb +91 -70
- data/lib/pact_broker/api/resources/integration.rb +1 -1
- data/lib/pact_broker/api/resources/integrations.rb +3 -3
- data/lib/pact_broker/api/resources/label.rb +2 -2
- data/lib/pact_broker/api/resources/latest_pact.rb +5 -5
- data/lib/pact_broker/api/resources/latest_pacts.rb +1 -1
- data/lib/pact_broker/api/resources/latest_provider_pacts.rb +3 -3
- data/lib/pact_broker/api/resources/latest_verification_for_latest_pact.rb +5 -1
- data/lib/pact_broker/api/resources/latest_verification_for_pact.rb +5 -1
- data/lib/pact_broker/api/resources/latest_verifications_for_consumer_version.rb +5 -5
- data/lib/pact_broker/api/resources/latest_version.rb +1 -1
- data/lib/pact_broker/api/resources/matrix.rb +18 -13
- data/lib/pact_broker/api/resources/matrix_badge.rb +1 -1
- data/lib/pact_broker/api/resources/matrix_for_consumer_and_provider.rb +2 -2
- data/lib/pact_broker/api/resources/metadata_resource_methods.rb +2 -2
- data/lib/pact_broker/api/resources/metrics.rb +1 -1
- data/lib/pact_broker/api/resources/pact.rb +17 -27
- data/lib/pact_broker/api/resources/pact_content_diff.rb +3 -3
- data/lib/pact_broker/api/resources/pact_triggered_webhooks.rb +7 -3
- data/lib/pact_broker/api/resources/pact_version.rb +2 -2
- data/lib/pact_broker/api/resources/pact_versions.rb +3 -3
- data/lib/pact_broker/api/resources/pact_webhooks.rb +7 -8
- data/lib/pact_broker/api/resources/pact_webhooks_status.rb +2 -2
- data/lib/pact_broker/api/resources/pacticipant.rb +51 -15
- data/lib/pact_broker/api/resources/pacticipant_resource_methods.rb +1 -1
- data/lib/pact_broker/api/resources/{webhooks.rb → pacticipant_webhooks.rb} +12 -8
- data/lib/pact_broker/api/resources/pacticipants.rb +13 -8
- data/lib/pact_broker/api/resources/pacticipants_for_label.rb +2 -2
- data/lib/pact_broker/api/resources/previous_distinct_pact_version.rb +4 -4
- data/lib/pact_broker/api/resources/provider_pacts.rb +3 -3
- data/lib/pact_broker/api/resources/provider_pacts_for_verification.rb +10 -6
- data/lib/pact_broker/api/resources/publish_contracts.rb +81 -0
- data/lib/pact_broker/api/resources/relationships.rb +2 -2
- data/lib/pact_broker/api/resources/released_version.rb +84 -0
- data/lib/pact_broker/api/resources/released_versions_for_version_and_environment.rb +94 -0
- data/lib/pact_broker/api/resources/tag.rb +1 -1
- data/lib/pact_broker/api/resources/tagged_pact_versions.rb +4 -4
- data/lib/pact_broker/api/resources/triggered_webhook_logs.rb +16 -8
- data/lib/pact_broker/api/resources/verification.rb +17 -7
- data/lib/pact_broker/api/resources/verification_triggered_webhooks.rb +7 -3
- data/lib/pact_broker/api/resources/verifications.rb +13 -18
- data/lib/pact_broker/api/resources/version.rb +49 -11
- data/lib/pact_broker/api/resources/versions.rb +6 -6
- data/lib/pact_broker/api/resources/webhook.rb +17 -9
- data/lib/pact_broker/api/resources/webhook_execution.rb +18 -14
- data/lib/pact_broker/api/resources/webhook_execution_methods.rb +31 -0
- data/lib/pact_broker/app.rb +37 -35
- data/lib/pact_broker/application_context.rb +5 -5
- data/lib/pact_broker/badges/service.rb +22 -22
- data/lib/pact_broker/build_http_options.rb +2 -2
- data/lib/pact_broker/certificates/service.rb +4 -4
- data/lib/pact_broker/config/load.rb +4 -4
- data/lib/pact_broker/config/repository.rb +1 -1
- data/lib/pact_broker/config/save.rb +4 -4
- data/lib/pact_broker/config/setting.rb +28 -24
- data/lib/pact_broker/config/space_delimited_integer_list.rb +3 -3
- data/lib/pact_broker/config/space_delimited_string_list.rb +3 -3
- data/lib/pact_broker/configuration.rb +27 -20
- data/lib/pact_broker/constants.rb +2 -2
- data/lib/pact_broker/contracts/contract_to_publish.rb +19 -0
- data/lib/pact_broker/contracts/contracts_publication_results.rb +14 -0
- data/lib/pact_broker/contracts/contracts_to_publish.rb +11 -0
- data/lib/pact_broker/contracts/notice.rb +21 -0
- data/lib/pact_broker/contracts/service.rb +264 -0
- data/lib/pact_broker/date_helper.rb +48 -46
- data/lib/pact_broker/db.rb +11 -7
- data/lib/pact_broker/db/clean.rb +4 -8
- data/lib/pact_broker/db/clean_incremental.rb +8 -6
- data/lib/pact_broker/db/data_migrations/delete_deprecated_webhook_executions.rb +1 -1
- data/lib/pact_broker/db/data_migrations/migrate_webhook_headers.rb +1 -1
- data/lib/pact_broker/db/data_migrations/set_consumer_ids_for_pact_publications.rb +1 -1
- data/lib/pact_broker/db/data_migrations/set_created_at_for_latest_pact_publications.rb +1 -1
- data/lib/pact_broker/db/data_migrations/set_created_at_for_latest_verifications.rb +1 -1
- data/lib/pact_broker/db/data_migrations/set_extra_columns_for_tags.rb +3 -3
- data/lib/pact_broker/db/data_migrations/set_latest_version_sequence_value.rb +1 -1
- data/lib/pact_broker/db/data_migrations/set_pacticipant_display_name.rb +23 -0
- data/lib/pact_broker/db/data_migrations/set_pacticipant_ids_for_verifications.rb +1 -1
- data/lib/pact_broker/db/data_migrations/set_pacticipant_main_branch.rb +53 -0
- data/lib/pact_broker/db/data_migrations/set_webhook_uuid.rb +24 -0
- data/lib/pact_broker/db/data_migrations/set_webhooks_enabled.rb +1 -1
- data/lib/pact_broker/db/delete_overwritten_data.rb +7 -7
- data/lib/pact_broker/db/log_quietener.rb +1 -1
- data/lib/pact_broker/db/migrate.rb +4 -4
- data/lib/pact_broker/db/migrate_data.rb +4 -1
- data/lib/pact_broker/db/models.rb +17 -12
- data/lib/pact_broker/db/seed_example_data.rb +9 -4
- data/lib/pact_broker/db/validate_encoding.rb +4 -4
- data/lib/pact_broker/db/version.rb +1 -1
- data/lib/pact_broker/deployments/currently_deployed_version_id.rb +30 -0
- data/lib/pact_broker/deployments/deployed_version.rb +115 -0
- data/lib/pact_broker/deployments/deployed_version_service.rb +85 -0
- data/lib/pact_broker/deployments/environment.rb +49 -0
- data/lib/pact_broker/deployments/environment_service.rb +52 -0
- data/lib/pact_broker/deployments/released_version.rb +83 -0
- data/lib/pact_broker/deployments/released_version_service.rb +47 -0
- data/lib/pact_broker/diagnostic/app.rb +8 -8
- data/lib/pact_broker/diagnostic/resources/base_resource.rb +2 -2
- data/lib/pact_broker/diagnostic/resources/dependencies.rb +3 -3
- data/lib/pact_broker/diagnostic/resources/heartbeat.rb +1 -1
- data/lib/pact_broker/doc/controllers/app.rb +10 -10
- data/lib/pact_broker/doc/views/can-i-deploy.markdown +4 -2
- 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/pacticipants.markdown +25 -3
- data/lib/pact_broker/doc/views/index/publish-contracts.markdown +120 -0
- data/lib/pact_broker/doc/views/provider-pacts-for-verification.markdown +22 -11
- data/lib/pact_broker/doc/views/webhooks.markdown +5 -3
- data/lib/pact_broker/domain.rb +6 -6
- data/lib/pact_broker/domain/index_item.rb +27 -8
- data/lib/pact_broker/domain/label.rb +1 -2
- data/lib/pact_broker/domain/order_versions.rb +2 -2
- data/lib/pact_broker/domain/pact.rb +14 -7
- data/lib/pact_broker/domain/pacticipant.rb +27 -18
- data/lib/pact_broker/domain/tag.rb +5 -3
- data/lib/pact_broker/domain/verification.rb +8 -8
- data/lib/pact_broker/domain/version.rb +55 -10
- data/lib/pact_broker/domain/webhook.rb +14 -15
- data/lib/pact_broker/domain/webhook_request.rb +14 -18
- data/lib/pact_broker/errors.rb +7 -7
- data/lib/pact_broker/errors/error_logger.rb +3 -3
- data/lib/pact_broker/events/event.rb +5 -0
- data/lib/pact_broker/events/publisher.rb +9 -0
- data/lib/pact_broker/events/subscriber.rb +42 -0
- data/lib/pact_broker/feature_toggle.rb +2 -2
- data/lib/pact_broker/groups/service.rb +2 -2
- data/lib/pact_broker/hash_refinements.rb +12 -12
- data/lib/pact_broker/index/service.rb +69 -36
- data/lib/pact_broker/integrations/integration.rb +5 -5
- data/lib/pact_broker/integrations/service.rb +11 -7
- data/lib/pact_broker/labels/repository.rb +2 -2
- data/lib/pact_broker/labels/service.rb +1 -1
- data/lib/pact_broker/locale/en.yml +54 -14
- data/lib/pact_broker/logging.rb +3 -3
- data/lib/pact_broker/logging/default_formatter.rb +3 -3
- data/lib/pact_broker/matrix/aggregated_row.rb +4 -4
- data/lib/pact_broker/matrix/can_i_deploy_query_schema.rb +17 -2
- data/lib/pact_broker/matrix/deployment_status_summary.rb +78 -38
- data/lib/pact_broker/matrix/every_row.rb +2 -2
- data/lib/pact_broker/matrix/head_row.rb +2 -2
- data/lib/pact_broker/matrix/integration.rb +6 -6
- data/lib/pact_broker/matrix/parse_can_i_deploy_query.rb +19 -3
- data/lib/pact_broker/matrix/parse_query.rb +47 -24
- data/lib/pact_broker/matrix/query_builder.rb +10 -10
- data/lib/pact_broker/matrix/query_results.rb +9 -4
- data/lib/pact_broker/matrix/query_results_with_deployment_status_summary.rb +3 -3
- data/lib/pact_broker/matrix/quick_row.rb +32 -34
- data/lib/pact_broker/matrix/reason.rb +88 -1
- data/lib/pact_broker/matrix/repository.rb +137 -66
- data/lib/pact_broker/matrix/resolved_selector.rb +82 -7
- data/lib/pact_broker/matrix/row.rb +6 -6
- data/lib/pact_broker/matrix/service.rb +44 -14
- data/lib/pact_broker/matrix/unresolved_selector.rb +22 -2
- data/lib/pact_broker/messages.rb +17 -5
- data/lib/pact_broker/metrics/service.rb +16 -15
- data/lib/pact_broker/pacticipants/find_potential_duplicate_pacticipant_names.rb +5 -5
- data/lib/pact_broker/pacticipants/generate_display_name.rb +27 -0
- data/lib/pact_broker/pacticipants/repository.rb +34 -16
- data/lib/pact_broker/pacticipants/service.rb +19 -19
- data/lib/pact_broker/pacts/all_pact_publications.rb +6 -6
- data/lib/pact_broker/pacts/build_verifiable_pact_notices.rb +8 -8
- data/lib/pact_broker/pacts/content.rb +23 -21
- data/lib/pact_broker/pacts/create_formatted_diff.rb +3 -3
- data/lib/pact_broker/pacts/diff.rb +8 -8
- data/lib/pact_broker/pacts/eager_loaders.rb +1 -1
- data/lib/pact_broker/pacts/generate_interaction_sha.rb +2 -2
- data/lib/pact_broker/pacts/generate_sha.rb +10 -10
- data/lib/pact_broker/pacts/head_pact.rb +1 -1
- data/lib/pact_broker/pacts/latest_pact_publication_id_for_consumer_version.rb +2 -2
- data/lib/pact_broker/pacts/latest_pact_publications.rb +2 -2
- data/lib/pact_broker/pacts/latest_pact_publications_by_consumer_version.rb +1 -1
- data/lib/pact_broker/pacts/latest_tagged_pact_publications.rb +2 -2
- data/lib/pact_broker/pacts/lazy_loaders.rb +2 -2
- data/lib/pact_broker/pacts/merger.rb +2 -2
- data/lib/pact_broker/pacts/order_hash_keys.rb +1 -1
- data/lib/pact_broker/pacts/pact_params.rb +7 -7
- data/lib/pact_broker/pacts/pact_publication.rb +19 -13
- data/lib/pact_broker/pacts/pact_publication_dataset_module.rb +7 -49
- data/lib/pact_broker/pacts/pact_publication_selector_dataset_module.rb +70 -0
- data/lib/pact_broker/pacts/pact_publication_wip_dataset_module.rb +106 -0
- data/lib/pact_broker/pacts/pact_version.rb +46 -14
- data/lib/pact_broker/pacts/pacts_for_verification_repository.rb +51 -47
- data/lib/pact_broker/pacts/parse.rb +1 -1
- data/lib/pact_broker/pacts/placeholder_pact.rb +1 -1
- data/lib/pact_broker/pacts/repository.rb +27 -23
- data/lib/pact_broker/pacts/selected_pact.rb +5 -1
- data/lib/pact_broker/pacts/selector.rb +124 -6
- data/lib/pact_broker/pacts/selectors.rb +5 -1
- data/lib/pact_broker/pacts/service.rb +102 -32
- data/lib/pact_broker/pacts/sort_content.rb +14 -9
- data/lib/pact_broker/pacts/squash_pacts_for_verification.rb +0 -1
- data/lib/pact_broker/pacts/verifiable_pact.rb +5 -3
- data/lib/pact_broker/pacts/verifiable_pact_messages.rb +82 -37
- data/lib/pact_broker/policies.rb +1 -1
- data/lib/pact_broker/project_root.rb +2 -2
- data/lib/pact_broker/relationships/groupify.rb +1 -1
- data/lib/pact_broker/repositories.rb +9 -9
- data/lib/pact_broker/services.rb +53 -15
- data/lib/pact_broker/string_refinements.rb +10 -4
- data/lib/pact_broker/tags/eager_loaders.rb +2 -2
- data/lib/pact_broker/tags/head_pact_tags.rb +2 -2
- data/lib/pact_broker/tags/repository.rb +2 -2
- data/lib/pact_broker/tags/service.rb +1 -1
- data/lib/pact_broker/tags/tag_with_latest_flag.rb +2 -2
- data/lib/pact_broker/tasks.rb +5 -5
- data/lib/pact_broker/tasks/clean_task.rb +12 -12
- data/lib/pact_broker/tasks/data_migration_task.rb +4 -4
- data/lib/pact_broker/tasks/delete_overwritten_data_task.rb +8 -8
- data/lib/pact_broker/tasks/migration_task.rb +5 -5
- data/lib/pact_broker/tasks/version_task.rb +3 -3
- data/lib/pact_broker/test/http_test_data_builder.rb +72 -31
- data/lib/pact_broker/test/test_data_builder.rb +119 -52
- data/lib/pact_broker/ui.rb +3 -3
- data/lib/pact_broker/ui/app.rb +9 -9
- data/lib/pact_broker/ui/controllers/base_controller.rb +6 -6
- data/lib/pact_broker/ui/controllers/can_i_deploy.rb +9 -9
- data/lib/pact_broker/ui/controllers/clusters.rb +5 -5
- data/lib/pact_broker/ui/controllers/error_test.rb +3 -3
- data/lib/pact_broker/ui/controllers/groups.rb +4 -4
- data/lib/pact_broker/ui/controllers/index.rb +28 -15
- data/lib/pact_broker/ui/controllers/matrix.rb +11 -11
- data/lib/pact_broker/ui/controllers/pacts.rb +1 -1
- data/lib/pact_broker/ui/helpers/matrix_helper.rb +12 -8
- data/lib/pact_broker/ui/helpers/url_helper.rb +3 -3
- data/lib/pact_broker/ui/view_models/index_item.rb +29 -15
- data/lib/pact_broker/ui/view_models/index_items.rb +2 -2
- data/lib/pact_broker/ui/view_models/matrix_deployed_version.rb +37 -0
- data/lib/pact_broker/ui/view_models/matrix_line.rb +45 -11
- data/lib/pact_broker/ui/view_models/matrix_lines.rb +1 -1
- data/lib/pact_broker/ui/view_models/matrix_released_version.rb +37 -0
- data/lib/pact_broker/ui/view_models/matrix_tag.rb +3 -3
- data/lib/pact_broker/ui/views/index/show-with-tags.haml +60 -14
- data/lib/pact_broker/ui/views/index/show.haml +23 -2
- data/lib/pact_broker/ui/views/matrix/show.haml +33 -9
- data/lib/pact_broker/verifications/latest_verification_for_consumer_and_provider.rb +1 -1
- data/lib/pact_broker/verifications/latest_verification_for_consumer_version_tag.rb +1 -1
- data/lib/pact_broker/verifications/latest_verification_for_pact_version.rb +1 -1
- data/lib/pact_broker/verifications/latest_verification_id_for_pact_version_and_provider_version.rb +1 -1
- data/lib/pact_broker/verifications/repository.rb +9 -5
- data/lib/pact_broker/verifications/sequence.rb +2 -2
- data/lib/pact_broker/verifications/service.rb +33 -17
- data/lib/pact_broker/version.rb +1 -1
- data/lib/pact_broker/versions/eager_loaders.rb +6 -6
- data/lib/pact_broker/versions/latest_version.rb +1 -1
- data/lib/pact_broker/versions/parse_semantic_version.rb +2 -2
- data/lib/pact_broker/versions/repository.rb +47 -15
- data/lib/pact_broker/versions/sequence.rb +1 -1
- data/lib/pact_broker/versions/service.rb +25 -2
- data/lib/pact_broker/webhooks/check_host_whitelist.rb +1 -1
- data/lib/pact_broker/webhooks/event_listener.rb +86 -0
- data/lib/pact_broker/webhooks/execution.rb +3 -3
- data/lib/pact_broker/webhooks/execution_configuration.rb +1 -1
- data/lib/pact_broker/webhooks/execution_configuration_creator.rb +2 -2
- data/lib/pact_broker/webhooks/http_request_with_redacted_headers.rb +1 -1
- data/lib/pact_broker/webhooks/http_response_with_utf_8_safe_body.rb +1 -1
- data/lib/pact_broker/webhooks/job.rb +5 -5
- data/lib/pact_broker/webhooks/latest_triggered_webhook.rb +17 -2
- data/lib/pact_broker/webhooks/pact_and_verification_parameters.rb +57 -15
- data/lib/pact_broker/webhooks/redact_logs.rb +3 -3
- data/lib/pact_broker/webhooks/render.rb +4 -5
- data/lib/pact_broker/webhooks/repository.rb +69 -75
- data/lib/pact_broker/webhooks/service.rb +52 -134
- data/lib/pact_broker/webhooks/status.rb +3 -1
- data/lib/pact_broker/webhooks/trigger_service.rb +75 -70
- data/lib/pact_broker/webhooks/triggered_webhook.rb +15 -12
- data/lib/pact_broker/webhooks/webhook.rb +43 -6
- data/lib/pact_broker/webhooks/webhook_event.rb +7 -7
- data/lib/pact_broker/webhooks/webhook_execution_result.rb +8 -3
- data/lib/pact_broker/webhooks/webhook_request_logger.rb +9 -7
- data/lib/pact_broker/webhooks/webhook_request_template.rb +41 -6
- data/lib/rack/hal_browser.rb +1 -1
- data/lib/rack/hal_browser/redirect.rb +9 -9
- data/lib/rack/pact_broker/add_pact_broker_version_header.rb +2 -2
- data/lib/rack/pact_broker/convert_404_to_hal.rb +2 -2
- data/lib/rack/pact_broker/convert_file_extension_to_accept_header.rb +1 -1
- data/lib/rack/pact_broker/database_transaction.rb +3 -3
- data/lib/rack/pact_broker/invalid_uri_protection.rb +5 -5
- data/lib/rack/pact_broker/no_auth.rb +1 -1
- data/lib/rack/pact_broker/request_target.rb +8 -8
- data/lib/rack/pact_broker/reset_thread_data.rb +1 -1
- data/lib/rack/pact_broker/set_base_url.rb +35 -5
- data/lib/rack/pact_broker/ui_authentication.rb +3 -3
- data/lib/rack/pact_broker/ui_request_filter.rb +1 -1
- data/lib/sequel/extensions/statement_timeout.rb +9 -9
- data/pact_broker.gemspec +26 -25
- data/public/javascripts/clipboard.js +8 -2
- data/public/javascripts/matrix.js +11 -6
- data/public/stylesheets/index.css +14 -1
- data/regression/can_i_deploy_spec.rb +1 -1
- data/regression/index_spec.rb +3 -3
- data/regression/regression_helper.rb +9 -9
- data/scaffolding/README.md +23 -0
- data/scaffolding/run.rb +242 -0
- data/scaffolding/templates/decorator.rb.erb +13 -0
- data/scaffolding/templates/decorator_spec.erb.rb +0 -0
- data/scaffolding/templates/migration.erb +12 -0
- data/scaffolding/templates/model.erb +14 -0
- data/scaffolding/templates/repository.rb.erb +18 -0
- data/scaffolding/templates/repository_spec.rb.erb +9 -0
- data/scaffolding/templates/resource.erb +46 -0
- data/scaffolding/templates/resource_spec.rb.erb +78 -0
- data/scaffolding/templates/service.rb.erb +22 -0
- data/scaffolding/templates/service_spec.rb.erb +9 -0
- data/script/data/environments.rb +45 -0
- data/script/demonstrate-version-branches.rb +2 -2
- data/script/docker-container/test.sh +1 -1
- data/script/generate-certificates-for-webooks-certificate-spec.rb +1 -1
- data/script/insert-self-signed-certificate-from-url.rb +5 -5
- data/script/pry.rb +18 -12
- data/script/query.rb +5 -5
- data/script/reproduce-issue-can-i-deploy-ignore.rb +48 -0
- data/script/reproduce-issue-expand-currently-deployed.rb +47 -0
- data/script/reproduce-issue-starting-up.rb +12 -7
- data/script/reproduce-issue.rb +7 -2
- data/script/run-with-ssl.rb +8 -8
- data/script/seed-example-matrix.rb +11 -11
- data/script/seed-for-webhook-test.rb +22 -22
- data/script/seed-matrix.rb +20 -20
- data/script/seed.rb +25 -25
- data/script/test/approval-all.sh +6 -0
- data/script/webhook-server.ru +3 -3
- data/spec/features/base_equality_only_on_content_that_affects_verification_results_spec.rb +3 -3
- data/spec/features/can_i_deploy_spec.rb +1 -1
- data/spec/features/create_environment_spec.rb +47 -0
- data/spec/features/create_pacticipant_spec.rb +13 -7
- data/spec/features/create_tag_spec.rb +32 -0
- data/spec/features/create_version_spec.rb +40 -26
- data/spec/features/create_webhook_spec.rb +10 -10
- data/spec/features/delete_environment_spec.rb +16 -0
- data/spec/features/delete_label_spec.rb +1 -1
- data/spec/features/delete_pact_spec.rb +1 -1
- data/spec/features/delete_verification_spec.rb +3 -3
- data/spec/features/delete_version_spec.rb +1 -1
- data/spec/features/delete_webhook_spec.rb +5 -1
- data/spec/features/edit_webhook_spec.rb +8 -8
- data/spec/features/end_deployment_spec.rb +29 -0
- data/spec/features/end_support_spec.rb +67 -0
- data/spec/features/execute_unsaved_webhook_spec.rb +7 -10
- data/spec/features/execute_webhook_spec.rb +5 -5
- data/spec/features/get_can_i_deploy_badge_spec.rb +2 -2
- data/spec/features/get_currently_deployed_versions_for_environment_spec.rb +59 -0
- data/spec/features/get_currently_deployed_versions_for_version_spec.rb +27 -0
- data/spec/features/get_currently_supported_versions_for_environment_spec.rb +57 -0
- data/spec/features/get_dashboard_spec.rb +1 -1
- data/spec/features/get_deployed_versions_for_version_and_environment.rb +27 -0
- data/spec/features/get_diff_spec.rb +5 -5
- data/spec/features/get_environment_spec.rb +19 -0
- data/spec/features/get_environments_spec.rb +30 -0
- data/spec/features/get_integrations_dot_file_spec.rb +2 -2
- data/spec/features/get_integrations_spec.rb +1 -1
- data/spec/features/get_label_spec.rb +1 -1
- data/spec/features/get_latest_pact_badge_spec.rb +7 -7
- data/spec/features/get_latest_tagged_pact_badge_spec.rb +8 -8
- data/spec/features/get_latest_untagged_pact_badge_spec.rb +8 -8
- data/spec/features/get_latest_untagged_pact_spec.rb +1 -1
- data/spec/features/get_latest_verification_for_pact_spec.rb +2 -2
- data/spec/features/get_matrix_badge_spec.rb +10 -10
- data/spec/features/get_matrix_for_consumer_and_provider_spec.rb +3 -6
- data/spec/features/get_matrix_spec.rb +5 -5
- data/spec/features/get_pact_version.rb +2 -2
- data/spec/features/get_pact_versions_spec.rb +1 -1
- data/spec/features/get_previous_distinct_version.rb +5 -5
- data/spec/features/get_provider_pacts_for_verification_spec.rb +16 -5
- data/spec/features/get_released_versions_for_version_and_environment.rb +27 -0
- data/spec/features/get_tagged_pact_versions_spec.rb +1 -1
- data/spec/features/get_triggered_webhooks_for_pact_spec.rb +1 -1
- data/spec/features/get_triggered_webhooks_for_verification_spec.rb +1 -1
- data/spec/features/get_verifications_for_consumer_version_spec.rb +1 -1
- data/spec/features/get_version_spec.rb +2 -2
- data/spec/features/get_versions_spec.rb +2 -2
- data/spec/features/label_pacticipant_spec.rb +3 -3
- data/spec/features/merge_pact_spec.rb +8 -8
- data/spec/features/pending_pacts_with_tags_spec.rb +138 -0
- data/spec/features/publish_not_a_pact_spec.rb +5 -5
- data/spec/features/publish_pact_all_in_one_approval_spec.rb +72 -0
- data/spec/features/publish_pact_all_in_one_spec.rb +43 -0
- data/spec/features/publish_pact_spec.rb +41 -6
- data/spec/features/publish_verification_spec.rb +11 -11
- data/spec/features/record_deployment_spec.rb +93 -0
- data/spec/features/record_release_spec.rb +84 -0
- data/spec/features/record_undeployment_spec.rb +67 -0
- data/spec/features/tag_version_spec.rb +2 -2
- data/spec/features/update_environment_spec.rb +44 -0
- data/spec/features/update_matrix_spec.rb +5 -5
- data/spec/features/update_pacticipant_spec.rb +87 -12
- data/spec/features/update_version_spec.rb +155 -0
- data/spec/features/update_webhook_spec.rb +6 -6
- data/spec/features/wip_pacts_spec.rb +64 -43
- data/spec/fixtures/approvals/get_provider_pacts_for_verification.approved.json +57 -0
- data/spec/fixtures/approvals/modifiable_resources.approved.json +24 -3
- data/spec/fixtures/approvals/publish_contract_no_branch.approved.json +166 -0
- data/spec/fixtures/approvals/publish_contract_nothing_exists.approved.json +158 -0
- data/spec/fixtures/approvals/publish_contract_nothing_exists_with_webhook.approved.json +158 -0
- data/spec/fixtures/approvals/publish_contract_verification_already_exists.approved.json +149 -0
- data/spec/fixtures/approvals/publish_contract_with_validation_error.approved.json +42 -0
- data/spec/fixtures/approvals/publish_contracts_results_decorator.approved.json +61 -0
- data/spec/integration/app_spec.rb +41 -41
- data/spec/integration/ui/index_spec.rb +4 -4
- data/spec/integration/ui/matrix_spec.rb +3 -3
- data/spec/integration/webhooks/certificate_spec.rb +7 -7
- data/spec/lib/pact/doc/generator_spec.rb +7 -7
- data/spec/lib/pact/doc/interaction_view_model_spec.rb +16 -16
- data/spec/lib/pact/doc/markdown/consumer_contract_renderer_spec.rb +9 -9
- data/spec/lib/pact/doc/markdown/index_renderer_spec.rb +3 -3
- data/spec/lib/pact_broker/api/contracts/environment_schema_spec.rb +91 -0
- data/spec/lib/pact_broker/api/contracts/pacticipant_schema_spec.rb +46 -0
- data/spec/lib/pact_broker/api/contracts/publish_contracts_schema_spec.rb +114 -0
- data/spec/lib/pact_broker/api/contracts/put_pact_params_contract_spec.rb +6 -6
- data/spec/lib/pact_broker/api/contracts/verifiable_pacts_json_query_schema_combinations_spec.rb +76 -0
- data/spec/lib/pact_broker/api/contracts/verifiable_pacts_json_query_schema_spec.rb +158 -4
- data/spec/lib/pact_broker/api/contracts/verifiable_pacts_query_schema_spec.rb +1 -1
- data/spec/lib/pact_broker/api/contracts/verification_contract_spec.rb +4 -4
- data/spec/lib/pact_broker/api/contracts/webhook_contract_spec.rb +26 -26
- data/spec/lib/pact_broker/api/decorators/dashboard_decorator_spec.rb +30 -30
- data/spec/lib/pact_broker/api/decorators/embedded_label_decorator_spec.rb +2 -2
- data/spec/lib/pact_broker/api/decorators/embedded_tag_decorator_spec.rb +5 -5
- data/spec/lib/pact_broker/api/decorators/embedded_version_decorator_spec.rb +3 -3
- data/spec/lib/pact_broker/api/decorators/extended_pact_decorator_spec.rb +17 -17
- data/spec/lib/pact_broker/api/decorators/integration_decorator_spec.rb +3 -3
- data/spec/lib/pact_broker/api/decorators/integrations_decorator_spec.rb +3 -3
- data/spec/lib/pact_broker/api/decorators/label_decorator_spec.rb +2 -2
- data/spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb +4 -4
- data/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb +50 -25
- data/spec/lib/pact_broker/api/decorators/pact_collection_decorator_spec.rb +6 -6
- data/spec/lib/pact_broker/api/decorators/pact_decorator_spec.rb +25 -25
- data/spec/lib/pact_broker/api/decorators/pact_version_decorator_spec.rb +22 -17
- data/spec/lib/pact_broker/api/decorators/pact_webhooks_status_decorator_spec.rb +17 -14
- data/spec/lib/pact_broker/api/decorators/pacticipant_collection_decorator_spec.rb +7 -7
- data/spec/lib/pact_broker/api/decorators/pacticipant_decorator_spec.rb +63 -50
- data/spec/lib/pact_broker/api/decorators/provider_pacts_decorator_spec.rb +7 -7
- data/spec/lib/pact_broker/api/decorators/publish_contracts_results_decorator_spec.rb +53 -0
- data/spec/lib/pact_broker/api/decorators/reason_decorator_spec.rb +27 -8
- data/spec/lib/pact_broker/api/decorators/relationships_csv_decorator_spec.rb +4 -4
- data/spec/lib/pact_broker/api/decorators/representable_pact_spec.rb +7 -7
- data/spec/lib/pact_broker/api/decorators/tag_decorator_spec.rb +4 -4
- data/spec/lib/pact_broker/api/decorators/tagged_pact_versions_decorator_spec.rb +4 -4
- data/spec/lib/pact_broker/api/decorators/triggered_webhook_decorator_spec.rb +18 -15
- data/spec/lib/pact_broker/api/decorators/triggered_webhooks_decorator_spec.rb +5 -5
- data/spec/lib/pact_broker/api/decorators/verifiable_pact_decorator_spec.rb +11 -11
- data/spec/lib/pact_broker/api/decorators/verifiable_pacts_decorator_spec.rb +3 -3
- data/spec/lib/pact_broker/api/decorators/verifiable_pacts_query_decorator_spec.rb +44 -1
- data/spec/lib/pact_broker/api/decorators/verification_decorator_spec.rb +15 -15
- data/spec/lib/pact_broker/api/decorators/verification_summary_decorator_spec.rb +9 -9
- data/spec/lib/pact_broker/api/decorators/version_decorator_spec.rb +93 -48
- data/spec/lib/pact_broker/api/decorators/versions_decorator_spec.rb +7 -7
- data/spec/lib/pact_broker/api/decorators/webhook_decorator_spec.rb +59 -59
- data/spec/lib/pact_broker/api/decorators/webhook_execution_result_decorator_spec.rb +15 -15
- data/spec/lib/pact_broker/api/decorators/webhook_request_template_decorator_spec.rb +13 -13
- data/spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb +10 -10
- data/spec/lib/pact_broker/api/pact_broker_urls_spec.rb +36 -10
- data/spec/lib/pact_broker/api/renderers/html_pact_renderer_spec.rb +30 -30
- data/spec/lib/pact_broker/api/renderers/integrations_dot_renderer_spec.rb +4 -4
- data/spec/lib/pact_broker/api/resources/all_webhooks_spec.rb +32 -41
- data/spec/lib/pact_broker/api/resources/badge_spec.rb +17 -17
- data/spec/lib/pact_broker/api/resources/can_i_deploy_badge_spec.rb +6 -6
- data/spec/lib/pact_broker/api/resources/can_i_deploy_pacticipant_version_spec.rb +9 -9
- data/spec/lib/pact_broker/api/resources/can_i_deploy_spec.rb +7 -7
- data/spec/lib/pact_broker/api/resources/dashboard_spec.rb +1 -1
- data/spec/lib/pact_broker/api/resources/default_base_resource_approval_spec.rb +12 -11
- data/spec/lib/pact_broker/api/resources/default_base_resource_spec.rb +25 -24
- data/spec/lib/pact_broker/api/resources/error_response_body_generator_spec.rb +11 -11
- data/spec/lib/pact_broker/api/resources/group_spec.rb +11 -11
- data/spec/lib/pact_broker/api/resources/latest_pact_spec.rb +15 -15
- data/spec/lib/pact_broker/api/resources/latest_provider_pacts_spec.rb +6 -6
- data/spec/lib/pact_broker/api/resources/latest_verifications_for_consumer_version_spec.rb +8 -8
- data/spec/lib/pact_broker/api/resources/matrix_badge_spec.rb +1 -1
- data/spec/lib/pact_broker/api/resources/matrix_spec.rb +10 -10
- data/spec/lib/pact_broker/api/resources/pact_spec.rb +24 -24
- data/spec/lib/pact_broker/api/resources/pact_triggered_webhooks_spec.rb +4 -4
- data/spec/lib/pact_broker/api/resources/pacticipant_spec.rb +2 -5
- data/spec/lib/pact_broker/api/resources/{webhooks_spec.rb → pacticipant_webhooks_spec.rb} +19 -19
- data/spec/lib/pact_broker/api/resources/pacticipants_spec.rb +18 -22
- data/spec/lib/pact_broker/api/resources/provider_pacts_for_verification_spec.rb +17 -17
- data/spec/lib/pact_broker/api/resources/provider_pacts_spec.rb +8 -8
- data/spec/lib/pact_broker/api/resources/released_version_spec.rb +61 -0
- data/spec/lib/pact_broker/api/resources/tag_spec.rb +3 -3
- data/spec/lib/pact_broker/api/resources/tagged_pact_versions_spec.rb +7 -7
- data/spec/lib/pact_broker/api/resources/triggered_webhook_logs_spec.rb +9 -6
- data/spec/lib/pact_broker/api/resources/verification_spec.rb +76 -7
- data/spec/lib/pact_broker/api/resources/verification_triggered_webhooks_spec.rb +4 -4
- data/spec/lib/pact_broker/api/resources/verifications_spec.rb +22 -28
- data/spec/lib/pact_broker/api/resources/webhook_execution_result_spec.rb +56 -0
- data/spec/lib/pact_broker/api/resources/webhook_execution_spec.rb +10 -10
- data/spec/lib/pact_broker/api/resources/webhook_spec.rb +15 -15
- data/spec/lib/pact_broker/app_spec.rb +43 -43
- data/spec/lib/pact_broker/badges/service_spec.rb +6 -6
- data/spec/lib/pact_broker/build_http_options_spec.rb +5 -5
- data/spec/lib/pact_broker/certificates/service_spec.rb +7 -7
- data/spec/lib/pact_broker/config/load_spec.rb +11 -11
- data/spec/lib/pact_broker/config/save_and_load_spec.rb +2 -2
- data/spec/lib/pact_broker/config/save_spec.rb +29 -29
- data/spec/lib/pact_broker/config/space_delimited_integer_list_spec.rb +1 -1
- data/spec/lib/pact_broker/config/space_delimited_string_list_spec.rb +1 -1
- data/spec/lib/pact_broker/configuration_spec.rb +9 -9
- data/spec/lib/pact_broker/contracts/service_spec.rb +108 -0
- data/spec/lib/pact_broker/db/clean_incremental_spec.rb +12 -11
- data/spec/lib/pact_broker/db/clean_old_spec.rb +2 -4
- data/spec/lib/pact_broker/db/clean_spec.rb +5 -7
- data/spec/lib/pact_broker/db/data_migrations/migrate_webhook_headers_spec.rb +1 -1
- data/spec/lib/pact_broker/db/data_migrations/set_consumer_ids_for_pact_publications_spec.rb +6 -6
- data/spec/lib/pact_broker/db/data_migrations/set_latest_version_sequence_value_spec.rb +8 -8
- data/spec/lib/pact_broker/db/data_migrations/set_pacticipant_main_branch_spec.rb +41 -0
- data/spec/lib/pact_broker/db/delete_overwritten_data_spec.rb +1 -1
- data/spec/lib/pact_broker/db/log_quietener_spec.rb +1 -1
- data/spec/lib/pact_broker/db/validate_encoding_spec.rb +8 -8
- data/spec/lib/pact_broker/deployments/deployed_version_spec.rb +109 -0
- data/spec/lib/pact_broker/deployments/environment_service_spec.rb +37 -0
- data/spec/lib/pact_broker/deployments/environment_spec.rb +27 -0
- data/spec/lib/pact_broker/diagnostic/resources/dependencies_spec.rb +9 -9
- data/spec/lib/pact_broker/diagnostic/resources/heartbeat_spec.rb +5 -5
- data/spec/lib/pact_broker/doc/controllers/app_spec.rb +4 -4
- data/spec/lib/pact_broker/doc/coverage_spec.rb +5 -5
- data/spec/lib/pact_broker/domain/group_spec.rb +7 -7
- data/spec/lib/pact_broker/domain/index_item_spec.rb +3 -3
- data/spec/lib/pact_broker/domain/order_versions_spec.rb +26 -26
- data/spec/lib/pact_broker/domain/pact_spec.rb +3 -3
- data/spec/lib/pact_broker/domain/tag_spec.rb +1 -1
- data/spec/lib/pact_broker/domain/verification_spec.rb +3 -3
- data/spec/lib/pact_broker/domain/version_spec.rb +118 -7
- data/spec/lib/pact_broker/domain/webhook_request_spec.rb +36 -36
- data/spec/lib/pact_broker/domain/webhook_spec.rb +11 -11
- data/spec/lib/pact_broker/errors/error_logger_spec.rb +4 -4
- data/spec/lib/pact_broker/errors_spec.rb +7 -8
- data/spec/lib/pact_broker/events/subscriber_spec.rb +43 -0
- data/spec/lib/pact_broker/feature_toggle_spec.rb +9 -9
- data/spec/lib/pact_broker/groups/service_spec.rb +8 -8
- data/spec/lib/pact_broker/hash_refinements_spec.rb +1 -1
- data/spec/lib/pact_broker/index/service_spec.rb +13 -14
- data/spec/lib/pact_broker/integrations/integration_spec.rb +1 -1
- data/spec/lib/pact_broker/integrations/service_spec.rb +17 -6
- data/spec/lib/pact_broker/labels/repository_spec.rb +2 -2
- data/spec/lib/pact_broker/labels/service_spec.rb +1 -1
- data/spec/lib/pact_broker/matrix/aggregated_row_spec.rb +14 -14
- data/spec/lib/pact_broker/matrix/can_i_deploy_query_schema_spec.rb +72 -0
- data/spec/lib/pact_broker/matrix/deployment_status_summary_spec.rb +100 -20
- data/spec/lib/pact_broker/matrix/every_row_spec.rb +5 -5
- data/spec/lib/pact_broker/matrix/head_row_spec.rb +1 -1
- data/spec/lib/pact_broker/matrix/integration_environment_spec.rb +175 -0
- data/spec/lib/pact_broker/matrix/integration_ignore_spec.rb +226 -0
- data/spec/lib/pact_broker/matrix/integration_spec.rb +11 -13
- data/spec/lib/pact_broker/matrix/parse_can_i_deploy_query_spec.rb +49 -0
- data/spec/lib/pact_broker/matrix/parse_query_spec.rb +28 -6
- data/spec/lib/pact_broker/matrix/quick_row_spec.rb +7 -7
- data/spec/lib/pact_broker/matrix/repository_dependency_spec.rb +2 -2
- data/spec/lib/pact_broker/matrix/repository_query_limit_spec.rb +9 -9
- data/spec/lib/pact_broker/matrix/repository_spec.rb +44 -211
- data/spec/lib/pact_broker/matrix/row_spec.rb +7 -7
- data/spec/lib/pact_broker/matrix/service_spec.rb +83 -20
- data/spec/lib/pact_broker/messages_spec.rb +6 -6
- data/spec/lib/pact_broker/metrics/service_spec.rb +1 -1
- data/spec/lib/pact_broker/pacticipants/find_potential_duplicate_pacticipant_names_spec.rb +10 -10
- data/spec/lib/pact_broker/pacticipants/generate_display_name_spec.rb +39 -0
- data/spec/lib/pact_broker/pacticipants/repository_spec.rb +86 -15
- data/spec/lib/pact_broker/pacticipants/service_spec.rb +27 -73
- data/spec/lib/pact_broker/pacts/build_verifiable_pact_notices_spec.rb +10 -10
- data/spec/lib/pact_broker/pacts/content_spec.rb +55 -55
- data/spec/lib/pact_broker/pacts/create_formatted_diff_spec.rb +10 -10
- data/spec/lib/pact_broker/pacts/diff_spec.rb +23 -23
- data/spec/lib/pact_broker/pacts/generate_interaction_sha_spec.rb +1 -1
- data/spec/lib/pact_broker/pacts/generate_sha_spec.rb +7 -7
- data/spec/lib/pact_broker/pacts/latest_tagged_pact_publications_spec.rb +1 -1
- data/spec/lib/pact_broker/pacts/merger_spec.rb +7 -7
- data/spec/lib/pact_broker/pacts/metadata_spec.rb +3 -3
- data/spec/lib/pact_broker/pacts/pact_params_spec.rb +12 -12
- data/spec/lib/pact_broker/pacts/pact_publication_dataset_module_spec.rb +8 -8
- data/spec/lib/pact_broker/pacts/pact_publication_selector_dataset_module_spec.rb +120 -0
- data/spec/lib/pact_broker/pacts/pact_publication_spec.rb +9 -9
- data/spec/lib/pact_broker/pacts/pact_version_spec.rb +47 -3
- data/spec/lib/pact_broker/pacts/repository_find_for_currently_deployed_spec.rb +124 -0
- data/spec/lib/pact_broker/pacts/repository_find_for_currently_supported_releases_spec.rb +159 -0
- 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 +19 -19
- data/spec/lib/pact_broker/pacts/repository_find_wip_pact_versions_for_provider_branch_spec.rb +59 -1
- data/spec/lib/pact_broker/pacts/repository_find_wip_pact_versions_for_provider_spec.rb +81 -22
- data/spec/lib/pact_broker/pacts/repository_spec.rb +39 -39
- data/spec/lib/pact_broker/pacts/selected_pact_spec.rb +1 -1
- data/spec/lib/pact_broker/pacts/selector_spec.rb +14 -11
- data/spec/lib/pact_broker/pacts/selectors_spec.rb +3 -3
- data/spec/lib/pact_broker/pacts/service_find_for_verification_spec.rb +5 -5
- data/spec/lib/pact_broker/pacts/service_spec.rb +111 -39
- data/spec/lib/pact_broker/pacts/sort_content_spec.rb +21 -8
- data/spec/lib/pact_broker/pacts/squash_pacts_for_verification_spec.rb +3 -3
- data/spec/lib/pact_broker/pacts/verifiable_pact_messages_spec.rb +99 -35
- data/spec/lib/pact_broker/relationships/groupify_spec.rb +12 -12
- data/spec/lib/pact_broker/tags/repository_spec.rb +2 -2
- data/spec/lib/pact_broker/tags/service_spec.rb +2 -2
- data/spec/lib/pact_broker/ui/controllers/can_i_deploy_spec.rb +1 -1
- data/spec/lib/pact_broker/ui/controllers/clusters_spec.rb +3 -3
- data/spec/lib/pact_broker/ui/controllers/index_spec.rb +47 -8
- data/spec/lib/pact_broker/ui/view_models/index_item_spec.rb +9 -9
- data/spec/lib/pact_broker/ui/view_models/index_items_spec.rb +3 -3
- data/spec/lib/pact_broker/ui/view_models/matrix_deployed_version_spec.rb +29 -0
- data/spec/lib/pact_broker/verifications/pseudo_branch_status_spec.rb +5 -5
- data/spec/lib/pact_broker/verifications/repository_spec.rb +4 -4
- data/spec/lib/pact_broker/verifications/sequence_spec.rb +1 -1
- data/spec/lib/pact_broker/verifications/service_spec.rb +30 -25
- data/spec/lib/pact_broker/verifications/summary_for_consumer_version_spec.rb +6 -6
- data/spec/lib/pact_broker/versions/abbreviate_number_spec.rb +5 -5
- data/spec/lib/pact_broker/versions/parse_semantic_version_spec.rb +2 -2
- data/spec/lib/pact_broker/versions/repository_spec.rb +16 -6
- data/spec/lib/pact_broker/versions/service_spec.rb +1 -1
- data/spec/lib/pact_broker/webhooks/check_host_whitelist_spec.rb +1 -1
- data/spec/lib/pact_broker/webhooks/execution_configuration_spec.rb +1 -1
- data/spec/lib/pact_broker/webhooks/job_spec.rb +10 -10
- data/spec/lib/pact_broker/webhooks/pact_and_verification_parameters_spec.rb +16 -0
- data/spec/lib/pact_broker/webhooks/redact_logs_spec.rb +1 -1
- data/spec/lib/pact_broker/webhooks/render_spec.rb +19 -10
- data/spec/lib/pact_broker/webhooks/repository_spec.rb +203 -177
- data/spec/lib/pact_broker/webhooks/service_spec.rb +37 -243
- data/spec/lib/pact_broker/webhooks/status_spec.rb +5 -5
- data/spec/lib/pact_broker/webhooks/trigger_service_spec.rb +252 -127
- data/spec/lib/pact_broker/webhooks/triggered_webhook_spec.rb +2 -2
- data/spec/lib/pact_broker/webhooks/webhook_request_logger_spec.rb +11 -11
- data/spec/lib/pact_broker/webhooks/webhook_request_template_spec.rb +70 -28
- data/spec/lib/pact_broker/webhooks/webhook_spec.rb +2 -5
- data/spec/lib/rack/hal_browser/redirect_spec.rb +18 -18
- data/spec/lib/rack/pact_broker/add_pact_broker_version_header_spec.rb +3 -3
- data/spec/lib/rack/pact_broker/database_transaction_spec.rb +10 -15
- data/spec/lib/rack/pact_broker/invalid_uri_protection_spec.rb +2 -2
- data/spec/lib/rack/pact_broker/request_target_spec.rb +5 -5
- data/spec/lib/rack/pact_broker/set_base_url_spec.rb +86 -0
- data/spec/lib/rack/pact_broker/use_when_spec.rb +6 -6
- data/spec/lib/sequel/plugins/insert_ignore_spec.rb +2 -2
- data/spec/lib/sequel/plugins/upsert_spec.rb +3 -3
- data/spec/lib/webmachine/rack_adapter_monkey_patch_spec.rb +7 -8
- data/spec/migrations/23_pact_versions_spec.rb +11 -13
- data/spec/migrations/24_populate_pact_contents_spec.rb +7 -7
- data/spec/migrations/34_latest_tagged_pacts_spec.rb +23 -23
- data/spec/migrations/34_pact_revisions_spec.rb +10 -10
- data/spec/migrations/41_migrate_execution_data_spec.rb +11 -11
- data/spec/migrations/42_delete_ophan_webhook_data_spec.rb +17 -17
- data/spec/migrations/44_add_provider_version_to_verification_spec.rb +9 -9
- data/spec/migrations/50_create_latest_matrix_spec.rb +15 -15
- data/spec/migrations/change_migration_strategy_spec.rb +21 -21
- data/spec/migrations/rollback_spec.rb +2 -0
- data/spec/service_consumers/hal_relation_proxy_app.rb +30 -7
- data/spec/service_consumers/pact_helper.rb +24 -11
- data/spec/service_consumers/provider_states_for_pact_broker_client.rb +101 -18
- data/spec/service_consumers/provider_states_for_pact_broker_client_2.rb +36 -0
- data/spec/service_consumers/provider_states_for_pact_ruby.rb +64 -64
- data/spec/spec_helper.rb +13 -25
- data/spec/support/approvals.rb +9 -7
- data/spec/support/database.rb +8 -4
- data/spec/support/database_cleaner.rb +2 -2
- data/spec/support/fixture_helpers.rb +1 -1
- data/spec/support/logging.rb +2 -2
- data/spec/support/metadata_test_server.rb +7 -7
- data/spec/support/migration_helpers.rb +1 -1
- data/spec/support/rack_helpers.rb +20 -0
- data/spec/support/rspec_matchers.rb +1 -1
- data/spec/support/shared_context.rb +1 -1
- data/spec/support/shared_examples_for_responses.rb +15 -4
- data/spec/support/simplecov.rb +20 -7
- data/spec/support/ssl_pact_broker_server.rb +8 -8
- data/spec/support/ssl_webhook_server.rb +8 -8
- data/spec/support/test_data_builder.rb +1 -1
- data/spec/support/verification_job.rb +8 -8
- data/spec/support/webhook_endpoint_middleware.rb +4 -4
- data/tasks/audit.rake +1 -1
- data/tasks/database.rb +23 -23
- data/tasks/database/annotate.rb +2 -2
- data/tasks/database/table_dependency_calculator.rb +1 -1
- data/tasks/db.rake +34 -39
- data/tasks/development.rake +38 -6
- data/tasks/docker_database.rb +9 -9
- data/tasks/pact.rake +5 -5
- data/tasks/release.rake +2 -2
- data/tasks/rspec.rake +16 -16
- data/tasks/test_db.rake +11 -11
- data/vendor/hal-browser/styles.css +6 -0
- metadata +209 -21
- data/.travis.yml +0 -31
- data/lib/pact_broker/domain/webhook_request_header.rb +0 -13
- data/lib/webmachine/rack_adapter_monkey_patch.rb +0 -38
- data/spec/lib/pact_broker/domain/pacticipant_spec.rb +0 -26
@@ -1,14 +1,14 @@
|
|
1
|
-
require
|
1
|
+
require "pact_broker/versions/abbreviate_number"
|
2
2
|
|
3
3
|
module PactBroker
|
4
4
|
module Versions
|
5
5
|
describe AbbreviateNumber do
|
6
6
|
describe "#call" do
|
7
7
|
TEST_CASES = [
|
8
|
-
[
|
9
|
-
[
|
10
|
-
[
|
11
|
-
[
|
8
|
+
["202326572516dea6998a7f311fcaa161c0768fc2", "2023265"],
|
9
|
+
["1.2.3+areallyreallyreallylongexplanation", "1.2.3+areallyreallyreallylongexplanation"],
|
10
|
+
["2516dea6998a7f", "2516dea6998a7f"],
|
11
|
+
["1.2.3+202326572516dea6998a7f311fcaa161c0768fc2", "1.2.3+2023265"]
|
12
12
|
]
|
13
13
|
|
14
14
|
TEST_CASES.each do |(input, output)|
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "spec_helper"
|
2
|
+
require "pact_broker/versions/repository"
|
3
3
|
|
4
4
|
module PactBroker
|
5
5
|
module Versions
|
@@ -123,7 +123,7 @@ module PactBroker
|
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
-
describe "#
|
126
|
+
describe "#create_or_overwrite" do
|
127
127
|
before do
|
128
128
|
td.subtract_day
|
129
129
|
.create_consumer("Foo")
|
@@ -133,9 +133,10 @@ module PactBroker
|
|
133
133
|
|
134
134
|
let(:pacticipant) { td.and_return(:consumer) }
|
135
135
|
let(:version_number) { "1234" }
|
136
|
-
let(:
|
136
|
+
let(:tags) { nil }
|
137
|
+
let(:open_struct_version) { OpenStruct.new(branch: "new-branch", tags: tags) }
|
137
138
|
|
138
|
-
subject { Repository.new.
|
139
|
+
subject { Repository.new.create_or_overwrite(pacticipant, version_number, open_struct_version) }
|
139
140
|
|
140
141
|
it "overwrites the values" do
|
141
142
|
expect(subject.branch).to eq "new-branch"
|
@@ -146,6 +147,15 @@ module PactBroker
|
|
146
147
|
expect { subject }.to_not change { PactBroker::Domain::Version.for("Foo", "1234").tags }
|
147
148
|
end
|
148
149
|
|
150
|
+
context "when there are tags specified" do
|
151
|
+
let(:tags) { [ OpenStruct.new(name: "main")] }
|
152
|
+
|
153
|
+
it "overwrites the tags" do
|
154
|
+
expect(subject.tags.count).to eq 1
|
155
|
+
expect(subject.tags.first.name).to eq "main"
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
149
159
|
it "does not change the created date" do
|
150
160
|
expect { subject }.to_not change { PactBroker::Domain::Version.for("Foo", "1234").created_at }
|
151
161
|
end
|
@@ -159,7 +169,7 @@ module PactBroker
|
|
159
169
|
end
|
160
170
|
|
161
171
|
context "when the version does not already exist" do
|
162
|
-
let(:version) {
|
172
|
+
let(:version) { OpenStruct.new(number: "555", branch: "new-branch") }
|
163
173
|
|
164
174
|
it "sets the order" do
|
165
175
|
expect(subject.order).to_not be nil
|
@@ -1,12 +1,12 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "pact_broker/webhooks/job"
|
2
|
+
require "pact_broker/webhooks/execution_configuration"
|
3
3
|
|
4
4
|
module PactBroker
|
5
5
|
module Webhooks
|
6
6
|
describe Job do
|
7
7
|
before do
|
8
8
|
PactBroker.configuration.webhook_retry_schedule = [10, 60, 120, 300, 600, 1200]
|
9
|
-
allow(PactBroker::Webhooks::
|
9
|
+
allow(PactBroker::Webhooks::TriggerService).to receive(:execute_triggered_webhook_now).and_return(result)
|
10
10
|
allow(PactBroker::Webhooks::Service).to receive(:update_triggered_webhook_status)
|
11
11
|
allow(PactBroker::Webhooks::TriggeredWebhook).to receive(:find).and_return(triggered_webhook)
|
12
12
|
allow(Job).to receive(:logger).and_return(logger)
|
@@ -15,12 +15,12 @@ module PactBroker
|
|
15
15
|
end
|
16
16
|
|
17
17
|
let(:base_url) { "http://broker" }
|
18
|
-
let(:triggered_webhook) { instance_double("PactBroker::Webhooks::TriggeredWebhook", webhook_uuid:
|
18
|
+
let(:triggered_webhook) { instance_double("PactBroker::Webhooks::TriggeredWebhook", webhook_uuid: "1234", id: 1) }
|
19
19
|
let(:result) { instance_double("PactBroker::Domain::WebhookExecutionResult", success?: success) }
|
20
20
|
let(:webhook_execution_configuration) { instance_double(PactBroker::Webhooks::ExecutionConfiguration, to_hash: webhook_execution_configuration_hash) }
|
21
|
-
let(:webhook_execution_configuration_hash) { { the:
|
21
|
+
let(:webhook_execution_configuration_hash) { { the: "options" } }
|
22
22
|
let(:success) { true }
|
23
|
-
let(:logger) { double(
|
23
|
+
let(:logger) { double("logger").as_null_object }
|
24
24
|
let(:database_connector) { ->(&block) { block.call } }
|
25
25
|
let(:webhook_context) { { the: "context" } }
|
26
26
|
let(:job_params) do
|
@@ -53,7 +53,7 @@ module PactBroker
|
|
53
53
|
|
54
54
|
context "when an error occurs for the first time" do
|
55
55
|
before do
|
56
|
-
allow(PactBroker::Webhooks::
|
56
|
+
allow(PactBroker::Webhooks::TriggerService).to receive(:execute_triggered_webhook_now).and_raise(error)
|
57
57
|
end
|
58
58
|
|
59
59
|
let(:error) { "an error" }
|
@@ -107,7 +107,7 @@ module PactBroker
|
|
107
107
|
end
|
108
108
|
|
109
109
|
it "executes the job with an log message indicating that the webhook will be retried" do
|
110
|
-
expect(PactBroker::Webhooks::
|
110
|
+
expect(PactBroker::Webhooks::TriggerService).to receive(:execute_triggered_webhook_now)
|
111
111
|
.with(triggered_webhook, webhook_execution_configuration_hash)
|
112
112
|
subject
|
113
113
|
end
|
@@ -121,7 +121,7 @@ module PactBroker
|
|
121
121
|
|
122
122
|
context "when an error occurs for the second time" do
|
123
123
|
before do
|
124
|
-
allow(PactBroker::Webhooks::
|
124
|
+
allow(PactBroker::Webhooks::TriggerService).to receive(:execute_triggered_webhook_now).and_raise("an error")
|
125
125
|
job_params[:error_count] = 1
|
126
126
|
end
|
127
127
|
|
@@ -150,7 +150,7 @@ module PactBroker
|
|
150
150
|
expect(webhook_execution_configuration).to receive(:with_failure_log_message).with("Webhook execution failed after 7 attempts")
|
151
151
|
expect(webhook_execution_configuration).to receive(:with_success_log_message).with("Successfully executed webhook")
|
152
152
|
|
153
|
-
expect(PactBroker::Webhooks::
|
153
|
+
expect(PactBroker::Webhooks::TriggerService).to receive(:execute_triggered_webhook_now)
|
154
154
|
.with(triggered_webhook, webhook_execution_configuration_hash)
|
155
155
|
subject
|
156
156
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "pact_broker/webhooks/pact_and_verification_parameters"
|
2
|
+
require "pact_broker/messages"
|
3
|
+
|
4
|
+
module PactBroker
|
5
|
+
module Webhooks
|
6
|
+
describe PactAndVerificationParameters do
|
7
|
+
PactAndVerificationParameters::ALL.each do | parameter |
|
8
|
+
describe parameter do
|
9
|
+
it "has a description in lib/pact_broker/locale/en.yml" do
|
10
|
+
expect(PactBroker::Messages.message("messages.webhooks.parameters.#{parameter}", default: nil)).to_not be_nil
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "pact_broker/webhooks/render"
|
2
|
+
require "pact_broker/pacts/placeholder_pact"
|
3
|
+
require "pact_broker/verifications/placeholder_verification"
|
4
|
+
require "pact_broker/webhooks/pact_and_verification_parameters"
|
5
5
|
|
6
|
-
require
|
6
|
+
require "cgi"
|
7
7
|
|
8
8
|
module PactBroker
|
9
9
|
module Webhooks
|
@@ -11,7 +11,7 @@ module PactBroker
|
|
11
11
|
describe "#call" do
|
12
12
|
before do
|
13
13
|
allow(PactBroker::Api::PactBrokerUrls).to receive(:pact_version_url_with_webhook_metadata).and_return("http://foo")
|
14
|
-
allow(PactBroker::Api::PactBrokerUrls).to receive(:verification_url) do | verification,
|
14
|
+
allow(PactBroker::Api::PactBrokerUrls).to receive(:verification_url) do | verification, _base_url |
|
15
15
|
expect(verification).to_not be nil
|
16
16
|
"http://verification"
|
17
17
|
end
|
@@ -54,11 +54,11 @@ module PactBroker
|
|
54
54
|
latest_verification: failed_verification)
|
55
55
|
end
|
56
56
|
|
57
|
-
let
|
57
|
+
let(:provider) do
|
58
58
|
double("provider", labels: provider_labels)
|
59
59
|
end
|
60
60
|
|
61
|
-
let
|
61
|
+
let(:consumer) do
|
62
62
|
double("consumer", labels: consumer_labels)
|
63
63
|
end
|
64
64
|
|
@@ -71,11 +71,11 @@ module PactBroker
|
|
71
71
|
end
|
72
72
|
|
73
73
|
let(:provider_version) do
|
74
|
-
double("version", tags: provider_tags)
|
74
|
+
double("version", tags: provider_tags, branch: "provider-branch")
|
75
75
|
end
|
76
76
|
|
77
77
|
let(:consumer_version) do
|
78
|
-
double("version", tags: consumer_tags)
|
78
|
+
double("version", tags: consumer_tags, branch: "consumer-branch")
|
79
79
|
end
|
80
80
|
|
81
81
|
let(:provider_tags) do
|
@@ -118,11 +118,20 @@ module PactBroker
|
|
118
118
|
["${pactbroker.bitbucketVerificationStatus}", "INPROGRESS", :pact_with_no_verification, :nil_verification],
|
119
119
|
["${pactbroker.bitbucketVerificationStatus}", "SUCCESSFUL", :pact_with_successful_verification, :nil_verification],
|
120
120
|
["${pactbroker.bitbucketVerificationStatus}", "FAILED", :pact_with_failed_verification, :nil_verification],
|
121
|
+
["${pactbroker.azureDevOpsVerificationStatus}", "succeeded", :pact, :verification],
|
122
|
+
["${pactbroker.azureDevOpsVerificationStatus}", "failed", :pact, :failed_verification],
|
123
|
+
["${pactbroker.azureDevOpsVerificationStatus}", "pending", :nil_pact, :nil_verification],
|
124
|
+
["${pactbroker.azureDevOpsVerificationStatus}", "pending", :pact_with_no_verification, :nil_verification],
|
125
|
+
["${pactbroker.azureDevOpsVerificationStatus}", "succeeded", :pact_with_successful_verification, :nil_verification],
|
126
|
+
["${pactbroker.azureDevOpsVerificationStatus}", "failed", :pact_with_failed_verification, :nil_verification],
|
121
127
|
["${pactbroker.verificationResultUrl}", "", :pact_with_no_verification, :nil_verification],
|
122
128
|
["${pactbroker.verificationResultUrl}", "http://verification", :pact_with_successful_verification, :nil_verification],
|
123
129
|
["${pactbroker.verificationResultUrl}", "http://verification", :pact_with_successful_verification, :verification],
|
124
130
|
["${pactbroker.providerVersionTags}", "test, prod", :pact_with_successful_verification, :verification],
|
131
|
+
["${pactbroker.providerVersionBranch}", "provider-branch", :pact_with_successful_verification, :verification],
|
132
|
+
["${pactbroker.providerVersionBranch}", "", :pact_with_no_verification, :nil_verification],
|
125
133
|
["${pactbroker.consumerVersionTags}", "test", :pact_with_successful_verification, :verification],
|
134
|
+
["${pactbroker.consumerVersionBranch}", "consumer-branch", :pact_with_successful_verification, :verification],
|
126
135
|
["${pactbroker.consumerLabels}", "foo, bar", :pact_with_successful_verification, :verification],
|
127
136
|
["${pactbroker.providerLabels}", "finance, IT", :pact, :nil_verification],
|
128
137
|
]
|
@@ -1,29 +1,29 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "spec_helper"
|
2
|
+
require "pact_broker/webhooks/repository"
|
3
3
|
|
4
4
|
module PactBroker
|
5
5
|
module Webhooks
|
6
6
|
describe Repository do
|
7
|
-
let(:url) {
|
8
|
-
let(:body) { {
|
9
|
-
let(:headers) { {
|
7
|
+
let(:url) { "http://example.org" }
|
8
|
+
let(:body) { {"some" => "json" } }
|
9
|
+
let(:headers) { {"Content-Type" => "application/json", "Accept" => "application/json"} }
|
10
10
|
let(:request) do
|
11
11
|
Webhooks::WebhookRequestTemplate.new(
|
12
|
-
method:
|
12
|
+
method: "post",
|
13
13
|
url: url,
|
14
14
|
headers: headers,
|
15
|
-
username:
|
16
|
-
password:
|
15
|
+
username: "username",
|
16
|
+
password: "password",
|
17
17
|
body: body)
|
18
18
|
end
|
19
19
|
let(:event) do
|
20
|
-
PactBroker::Webhooks::WebhookEvent.new(name:
|
20
|
+
PactBroker::Webhooks::WebhookEvent.new(name: "something_happened")
|
21
21
|
end
|
22
22
|
let(:events) { [event]}
|
23
23
|
let(:webhook) { Domain::Webhook.new(request: request, events: events) }
|
24
|
-
let(:consumer) { td.create_pacticipant(
|
25
|
-
let(:provider) { td.create_pacticipant(
|
26
|
-
let(:uuid) {
|
24
|
+
let(:consumer) { td.create_pacticipant("Consumer").and_return(:pacticipant) }
|
25
|
+
let(:provider) { td.create_pacticipant("Provider").and_return(:pacticipant) }
|
26
|
+
let(:uuid) { "the-uuid" }
|
27
27
|
let(:created_webhook_record) { ::DB::PACT_BROKER_DB[:webhooks].order(:id).last }
|
28
28
|
let(:created_events) { ::DB::PACT_BROKER_DB[:webhook_events].where(webhook_id: created_webhook_record[:id]).order(:name).all }
|
29
29
|
let(:expected_webhook_record) do
|
@@ -31,7 +31,7 @@ module PactBroker
|
|
31
31
|
uuid: "the-uuid",
|
32
32
|
method: "post",
|
33
33
|
url: "http://example.org",
|
34
|
-
username:
|
34
|
+
username: "username",
|
35
35
|
password: "cGFzc3dvcmQ=",
|
36
36
|
body: body.to_json,
|
37
37
|
consumer_id: consumer.id,
|
@@ -71,47 +71,109 @@ module PactBroker
|
|
71
71
|
describe "delete_by_uuid" do
|
72
72
|
before do
|
73
73
|
Repository.new.create uuid, webhook, consumer, provider
|
74
|
-
Repository.new.create
|
74
|
+
Repository.new.create "another-uuid", webhook, consumer, provider
|
75
75
|
end
|
76
76
|
|
77
77
|
subject { Repository.new.delete_by_uuid(uuid) }
|
78
78
|
|
79
79
|
it "deletes the webhook" do
|
80
|
-
expect { subject }.to change {
|
81
|
-
::DB::PACT_BROKER_DB[:webhooks].where(uuid: uuid).count
|
82
|
-
}.by(-1)
|
80
|
+
expect { subject }.to change { ::DB::PACT_BROKER_DB[:webhooks].where(uuid: uuid).count }.by(-1)
|
83
81
|
end
|
84
82
|
end
|
85
83
|
|
86
84
|
describe "delete_by_pacticipant" do
|
87
|
-
|
88
85
|
before do
|
89
|
-
|
90
|
-
|
86
|
+
td.create_consumer("other-consumer")
|
87
|
+
.create_provider("other-provider")
|
88
|
+
.create_consumer_version
|
89
|
+
.create_pact
|
90
|
+
.create_webhook(uuid: "other-uuid")
|
91
|
+
.create_triggered_webhook
|
92
|
+
.create_webhook_execution
|
93
|
+
.create_consumer("foo")
|
94
|
+
.create_provider("bar")
|
95
|
+
.create_consumer_version
|
96
|
+
.create_pact
|
97
|
+
.create_webhook(uuid: "1234")
|
98
|
+
.create_triggered_webhook
|
99
|
+
.create_webhook_execution
|
100
|
+
.create_webhook(uuid: "5555")
|
101
|
+
.create_triggered_webhook
|
102
|
+
.create_webhook_execution
|
103
|
+
# simulate resource already deleted
|
104
|
+
Webhook.where(uuid: "5555").delete
|
91
105
|
end
|
92
106
|
|
93
107
|
context "when the pacticipant is the consumer" do
|
94
108
|
|
95
|
-
subject { Repository.new.delete_by_pacticipant consumer }
|
109
|
+
subject { Repository.new.delete_by_pacticipant td.consumer }
|
96
110
|
|
97
|
-
it "deletes the webhook" do
|
98
|
-
expect { subject }.to change {
|
99
|
-
|
100
|
-
|
111
|
+
it "deletes the matching webhook" do
|
112
|
+
expect { subject }.to change { Webhook.where(uuid: "1234").count }.by(-1)
|
113
|
+
end
|
114
|
+
|
115
|
+
it "does not delete the unmatching webhooks" do
|
116
|
+
expect { subject }.to change { Webhook.count }.by(-1)
|
117
|
+
end
|
118
|
+
|
119
|
+
it "deletes the triggered webhooks" do
|
120
|
+
expect { subject }.to change { TriggeredWebhook.count }.by(-2)
|
101
121
|
end
|
102
122
|
end
|
103
123
|
|
104
124
|
context "when the pacticipant is the provider" do
|
125
|
+
subject { Repository.new.delete_by_pacticipant(td.provider) }
|
105
126
|
|
106
|
-
|
127
|
+
it "deletes the matching webhooks" do
|
128
|
+
expect { subject }.to change { Webhook.where(uuid: "1234").count }.by(-1)
|
129
|
+
end
|
107
130
|
|
108
|
-
it "
|
109
|
-
expect { subject }.to change {
|
110
|
-
|
111
|
-
|
131
|
+
it "does not delete the unmatching webhooks" do
|
132
|
+
expect { subject }.to change { Webhook.count }.by(-1)
|
133
|
+
end
|
134
|
+
|
135
|
+
it "deletes the triggered webhooks" do
|
136
|
+
expect { subject }.to change { TriggeredWebhook.count }.by(-2)
|
112
137
|
end
|
113
138
|
end
|
139
|
+
end
|
114
140
|
|
141
|
+
describe "delete_by_consumer_and_provider" do
|
142
|
+
before do
|
143
|
+
td.create_consumer("foo")
|
144
|
+
.create_provider("other-provider")
|
145
|
+
.create_consumer_version
|
146
|
+
.create_pact
|
147
|
+
.create_webhook(uuid: "other-uuid")
|
148
|
+
.comment("kept because doesn't match provider")
|
149
|
+
.create_triggered_webhook
|
150
|
+
.create_webhook_execution
|
151
|
+
.create_provider("bar")
|
152
|
+
.create_consumer_version
|
153
|
+
.create_pact
|
154
|
+
.create_webhook(uuid: "1234")
|
155
|
+
.create_triggered_webhook
|
156
|
+
.create_webhook_execution
|
157
|
+
.create_webhook(uuid: "5555")
|
158
|
+
.create_triggered_webhook
|
159
|
+
.create_webhook_execution
|
160
|
+
# simulate resource already deleted
|
161
|
+
Webhook.where(uuid: "5555").delete
|
162
|
+
end
|
163
|
+
|
164
|
+
subject { Repository.new.delete_by_consumer_and_provider(td.consumer, td.provider) }
|
165
|
+
|
166
|
+
it "deletes the webhooks that match both consumer and provider" do
|
167
|
+
expect { subject }.to change { Webhook.where(uuid: "1234").count }.by(-1)
|
168
|
+
end
|
169
|
+
|
170
|
+
it "does not delete the unmatching webhooks" do
|
171
|
+
expect { subject }.to change { Webhook.count }.by(-1)
|
172
|
+
end
|
173
|
+
|
174
|
+
it "deletes the triggered webhooks" do
|
175
|
+
expect { subject }.to change { TriggeredWebhook.count }.by(-2)
|
176
|
+
end
|
115
177
|
end
|
116
178
|
|
117
179
|
describe "find_by_uuid" do
|
@@ -145,11 +207,11 @@ module PactBroker
|
|
145
207
|
end
|
146
208
|
|
147
209
|
it "returns a webhook with the username set" do
|
148
|
-
expect(subject.request.username).to eq
|
210
|
+
expect(subject.request.username).to eq "username"
|
149
211
|
end
|
150
212
|
|
151
213
|
it "returns a webhook with the password set" do
|
152
|
-
expect(subject.request.password).to eq
|
214
|
+
expect(subject.request.password).to eq "password"
|
153
215
|
end
|
154
216
|
|
155
217
|
it "returns a webhook with the url set" do
|
@@ -199,30 +261,30 @@ module PactBroker
|
|
199
261
|
.create_consumer("Foo2")
|
200
262
|
end
|
201
263
|
|
202
|
-
let(:uuid) {
|
264
|
+
let(:uuid) { "1234" }
|
203
265
|
let(:old_webhook_params) do
|
204
266
|
{
|
205
|
-
events: [{ name:
|
267
|
+
events: [{ name: "something" }],
|
206
268
|
uuid: uuid,
|
207
|
-
method:
|
208
|
-
url:
|
269
|
+
method: "POST",
|
270
|
+
url: "http://example.org",
|
209
271
|
body: '{"foo":1}',
|
210
|
-
headers: {
|
211
|
-
username:
|
212
|
-
password:
|
272
|
+
headers: {"Content-Type" => "application/json"},
|
273
|
+
username: "username",
|
274
|
+
password: "password"
|
213
275
|
}
|
214
276
|
end
|
215
277
|
let(:new_request_webhook_params) do
|
216
278
|
{
|
217
|
-
method:
|
218
|
-
url:
|
219
|
-
body:
|
220
|
-
headers: {
|
279
|
+
method: "GET",
|
280
|
+
url: "http://example.com",
|
281
|
+
body: "foo",
|
282
|
+
headers: {"Content-Type" => "text/plain"}
|
221
283
|
}
|
222
284
|
end
|
223
285
|
let(:new_request) { PactBroker::Domain::WebhookRequest.new(new_request_webhook_params) }
|
224
286
|
let(:new_event) do
|
225
|
-
PactBroker::Webhooks::WebhookEvent.new(name:
|
287
|
+
PactBroker::Webhooks::WebhookEvent.new(name: "something_else")
|
226
288
|
end
|
227
289
|
let(:new_consumer) { PactBroker::Domain::Pacticipant.new(name: "Foo2") }
|
228
290
|
let(:new_webhook) do
|
@@ -237,13 +299,13 @@ module PactBroker
|
|
237
299
|
|
238
300
|
it "updates the webhook" do
|
239
301
|
expect(subject.uuid).to eq uuid
|
240
|
-
expect(subject.request.method).to eq
|
241
|
-
expect(subject.request.url).to eq
|
242
|
-
expect(subject.request.body).to eq
|
243
|
-
expect(subject.request.headers).to eq
|
302
|
+
expect(subject.request.method).to eq "GET"
|
303
|
+
expect(subject.request.url).to eq "http://example.com"
|
304
|
+
expect(subject.request.body).to eq "foo"
|
305
|
+
expect(subject.request.headers).to eq "Content-Type" => "text/plain"
|
244
306
|
expect(subject.request.username).to eq nil
|
245
307
|
expect(subject.request.password).to eq nil
|
246
|
-
expect(subject.events.first.name).to eq
|
308
|
+
expect(subject.events.first.name).to eq "something_else"
|
247
309
|
expect(subject.consumer.name).to eq "Foo2"
|
248
310
|
end
|
249
311
|
|
@@ -263,8 +325,9 @@ module PactBroker
|
|
263
325
|
|
264
326
|
describe "find_all" do
|
265
327
|
before do
|
328
|
+
allow(PactBroker).to receive(:policy_scope!).and_call_original
|
266
329
|
Repository.new.create uuid, webhook, consumer, provider
|
267
|
-
Repository.new.create
|
330
|
+
Repository.new.create "some-other-uuid", webhook, consumer, provider
|
268
331
|
end
|
269
332
|
|
270
333
|
subject { Repository.new.find_all }
|
@@ -273,6 +336,11 @@ module PactBroker
|
|
273
336
|
expect(subject.size).to be 2
|
274
337
|
expect(subject.first).to be_instance_of Domain::Webhook
|
275
338
|
end
|
339
|
+
|
340
|
+
it "uses the policy" do
|
341
|
+
expect(PactBroker).to receive(:policy_scope!)
|
342
|
+
subject
|
343
|
+
end
|
276
344
|
end
|
277
345
|
|
278
346
|
describe "find_by_consumer_and_provider" do
|
@@ -345,35 +413,58 @@ module PactBroker
|
|
345
413
|
end
|
346
414
|
end
|
347
415
|
|
348
|
-
describe "
|
349
|
-
|
416
|
+
describe "find_webhooks_to_trigger" do
|
417
|
+
before do
|
418
|
+
allow(PactBroker).to receive(:policy_scope!).and_call_original
|
419
|
+
end
|
420
|
+
|
421
|
+
let(:enabled) { true }
|
422
|
+
|
423
|
+
subject { Repository.new.find_webhooks_to_trigger(consumer: td.consumer, provider: td.provider, event_name: "contract_published") }
|
350
424
|
|
351
|
-
|
425
|
+
it "does not use a policy" do
|
426
|
+
td.create_webhook(event_names: ["contract_published"], enabled: enabled)
|
427
|
+
.create_consumer("Foo")
|
428
|
+
.create_provider("Bar")
|
429
|
+
expect(PactBroker).to_not receive(:policy_scope!)
|
430
|
+
expect(subject.size).to eq 1
|
431
|
+
end
|
432
|
+
|
433
|
+
context "when the webhook is disabled" do
|
352
434
|
before do
|
353
|
-
td
|
354
|
-
.create_consumer("
|
355
|
-
.create_provider("
|
356
|
-
.create_webhook
|
357
|
-
.create_provider("Provider")
|
358
|
-
.create_webhook(uuid: '1', events: [{ name: 'something_happened' }])
|
359
|
-
.create_webhook(uuid: '2', events: [{ name: 'something_happened' }])
|
360
|
-
.create_webhook(uuid: '3', events: [{ name: 'something_else_happened' }])
|
435
|
+
td.create_webhook(event_names: ["contract_published"], enabled: enabled)
|
436
|
+
.create_consumer("Foo")
|
437
|
+
.create_provider("Bar")
|
361
438
|
end
|
439
|
+
let(:enabled) { false }
|
440
|
+
its(:size) { is_expected.to eq 0 }
|
441
|
+
end
|
362
442
|
|
363
|
-
|
364
|
-
|
443
|
+
context "when the webhook is specified for a consumer and all providers" do
|
444
|
+
before do
|
445
|
+
td.create_consumer("Foo1")
|
446
|
+
.create_provider("Bar1")
|
447
|
+
.create_webhook(provider: nil, event_names: ["contract_published"])
|
365
448
|
end
|
366
449
|
|
367
|
-
|
368
|
-
before do
|
369
|
-
Webhook.where(uuid: '2').update(enabled: false)
|
370
|
-
end
|
450
|
+
its(:size) { is_expected.to eq 1 }
|
371
451
|
|
372
|
-
|
373
|
-
|
374
|
-
|
452
|
+
it "returns the right webhook" do
|
453
|
+
expect(subject.first.consumer).to eq td.consumer
|
454
|
+
expect(subject.first.provider).to be nil
|
375
455
|
end
|
376
456
|
end
|
457
|
+
|
458
|
+
context "when the webhook is specified for matching consumer but not provider" do
|
459
|
+
before do
|
460
|
+
td.create_consumer("Foo1")
|
461
|
+
.create_provider("Bar1")
|
462
|
+
.create_webhook(event_names: ["contract_published"])
|
463
|
+
.create_provider("Bar3")
|
464
|
+
end
|
465
|
+
|
466
|
+
its(:size) { is_expected.to eq 0 }
|
467
|
+
end
|
377
468
|
end
|
378
469
|
|
379
470
|
describe "create_triggered_webhook" do
|
@@ -386,18 +477,18 @@ module PactBroker
|
|
386
477
|
.create_verification
|
387
478
|
end
|
388
479
|
|
389
|
-
let(:event_context) { {
|
480
|
+
let(:event_context) { { "some" => "info" } }
|
390
481
|
|
391
|
-
subject { Repository.new.create_triggered_webhook
|
482
|
+
subject { Repository.new.create_triggered_webhook "1234", td.webhook, td.pact, td.verification, "publication", "some_event", event_context }
|
392
483
|
|
393
484
|
it "creates a TriggeredWebhook" do
|
394
485
|
expect(subject.webhook_uuid ).to eq td.webhook.uuid
|
395
486
|
expect(subject.consumer).to eq td.consumer
|
396
487
|
expect(subject.provider).to eq td.provider
|
397
488
|
expect(subject.verification).to eq td.verification
|
398
|
-
expect(subject.
|
399
|
-
expect(subject.trigger_type).to eq
|
400
|
-
expect(subject.event_name).to eq
|
489
|
+
expect(subject.uuid).to eq "1234"
|
490
|
+
expect(subject.trigger_type).to eq "publication"
|
491
|
+
expect(subject.event_name).to eq "some_event"
|
401
492
|
expect(subject.event_context).to eq event_context
|
402
493
|
end
|
403
494
|
|
@@ -422,7 +513,7 @@ module PactBroker
|
|
422
513
|
end
|
423
514
|
|
424
515
|
context "without a verification" do
|
425
|
-
subject { Repository.new.create_triggered_webhook
|
516
|
+
subject { Repository.new.create_triggered_webhook "1234", td.webhook, td.pact, nil, "publication", "some_event", {} }
|
426
517
|
|
427
518
|
it "does not set the verification" do
|
428
519
|
expect(subject.verification).to be nil
|
@@ -464,7 +555,7 @@ module PactBroker
|
|
464
555
|
allow(repository).to receive(:logger).and_return(logger)
|
465
556
|
end
|
466
557
|
|
467
|
-
let(:logger) { double(
|
558
|
+
let(:logger) { double("logger") }
|
468
559
|
|
469
560
|
it "just logs the error" do
|
470
561
|
expect(logger).to receive(:info).with(/triggered webhook with id #{td.triggered_webhook.id}/)
|
@@ -473,73 +564,6 @@ module PactBroker
|
|
473
564
|
end
|
474
565
|
end
|
475
566
|
|
476
|
-
describe "delete_triggered_webhooks_by_webhook_uuid" do
|
477
|
-
before do
|
478
|
-
td.create_consumer
|
479
|
-
.create_provider
|
480
|
-
.create_consumer_version
|
481
|
-
.create_pact
|
482
|
-
.create_webhook
|
483
|
-
.create_triggered_webhook
|
484
|
-
.create_webhook_execution
|
485
|
-
.create_webhook
|
486
|
-
.create_triggered_webhook
|
487
|
-
.create_webhook_execution
|
488
|
-
end
|
489
|
-
let(:webhook_id) { Webhook.find(uuid: td.webhook.uuid).id }
|
490
|
-
|
491
|
-
subject { Repository.new.delete_triggered_webhooks_by_webhook_uuid td.webhook.uuid }
|
492
|
-
|
493
|
-
it "deletes the related triggered webhooks" do
|
494
|
-
expect { subject }.to change {
|
495
|
-
TriggeredWebhook.where(id: td.triggered_webhook.id).count
|
496
|
-
}.from(1).to(0)
|
497
|
-
end
|
498
|
-
|
499
|
-
it "does not delete the unrelated triggered webhooks" do
|
500
|
-
expect { subject }.to_not change {
|
501
|
-
TriggeredWebhook.exclude(id: td.triggered_webhook.id).count
|
502
|
-
}
|
503
|
-
end
|
504
|
-
|
505
|
-
it "deletes the related webhook executions" do
|
506
|
-
expect { subject }.to change {
|
507
|
-
Execution.count
|
508
|
-
}.by(-1)
|
509
|
-
end
|
510
|
-
end
|
511
|
-
|
512
|
-
describe "delete_executions_by_pacticipant" do
|
513
|
-
before do
|
514
|
-
td.create_consumer
|
515
|
-
.create_provider
|
516
|
-
.create_webhook
|
517
|
-
.create_consumer_version
|
518
|
-
.create_pact
|
519
|
-
.create_triggered_webhook
|
520
|
-
.create_webhook_execution
|
521
|
-
# Replicate the old way of doing it
|
522
|
-
end
|
523
|
-
|
524
|
-
context "with triggered webhooks" do
|
525
|
-
it "deletes the execution by consumer" do
|
526
|
-
expect { Repository.new.delete_executions_by_pacticipant td.consumer }
|
527
|
-
.to change { Execution.count }.by(-1)
|
528
|
-
end
|
529
|
-
|
530
|
-
it "deletes the execution by provider" do
|
531
|
-
expect { Repository.new.delete_executions_by_pacticipant td.provider }
|
532
|
-
.to change { Execution.count }.by(-1)
|
533
|
-
end
|
534
|
-
|
535
|
-
it "does not delete executions for non related pacticipants" do
|
536
|
-
another_consumer = td.create_consumer.and_return(:consumer)
|
537
|
-
expect { Repository.new.delete_executions_by_pacticipant another_consumer }
|
538
|
-
.to change { Execution.count }.by(0)
|
539
|
-
end
|
540
|
-
end
|
541
|
-
end
|
542
|
-
|
543
567
|
describe "find_latest_triggered_webhooks" do
|
544
568
|
before do
|
545
569
|
td
|
@@ -548,52 +572,54 @@ module PactBroker
|
|
548
572
|
.create_triggered_webhook
|
549
573
|
.create_webhook_execution
|
550
574
|
.create_pact_with_hierarchy
|
551
|
-
.create_webhook(uuid:
|
552
|
-
.create_triggered_webhook(
|
575
|
+
.create_webhook(uuid: "123")
|
576
|
+
.create_triggered_webhook(uuid: "256", created_at: DateTime.new(2016))
|
553
577
|
.create_webhook_execution
|
554
|
-
.create_triggered_webhook(
|
578
|
+
.create_triggered_webhook(uuid: "332", created_at: DateTime.new(2017))
|
555
579
|
.create_webhook_execution
|
556
|
-
.create_webhook(uuid:
|
557
|
-
.create_triggered_webhook(
|
580
|
+
.create_webhook(uuid: "987")
|
581
|
+
.create_triggered_webhook(uuid: "876", created_at: DateTime.new(2017))
|
558
582
|
.create_webhook_execution
|
559
|
-
.create_triggered_webhook(
|
583
|
+
.create_triggered_webhook(uuid: "638", created_at: DateTime.new(2018))
|
560
584
|
.create_webhook_execution
|
561
585
|
end
|
562
586
|
|
563
587
|
subject { Repository.new.find_latest_triggered_webhooks(td.consumer, td.provider) }
|
564
588
|
|
565
589
|
it "finds the latest triggered webhooks" do
|
566
|
-
expect(subject.collect(&:
|
590
|
+
expect(subject.collect(&:uuid).sort).to eq ["332", "638"]
|
567
591
|
end
|
568
592
|
|
569
593
|
context "when a webhook has been triggered by different events" do
|
570
594
|
before do
|
571
595
|
td.create_pact_with_hierarchy("Foo2", "1.0.0", "Bar2")
|
572
596
|
.create_webhook
|
573
|
-
.create_triggered_webhook(
|
574
|
-
.create_triggered_webhook(
|
597
|
+
.create_triggered_webhook(uuid: "333", event_name: "foo")
|
598
|
+
.create_triggered_webhook(uuid: "555", event_name: "foo")
|
575
599
|
.create_webhook_execution
|
576
|
-
.create_triggered_webhook(
|
577
|
-
.create_triggered_webhook(
|
600
|
+
.create_triggered_webhook(uuid: "444", event_name: "bar")
|
601
|
+
.create_triggered_webhook(uuid: "777", event_name: "bar")
|
578
602
|
.create_webhook_execution
|
579
|
-
.create_triggered_webhook(
|
580
|
-
.create_triggered_webhook(
|
603
|
+
.create_triggered_webhook(uuid: "111", event_name: nil)
|
604
|
+
.create_triggered_webhook(uuid: "888", event_name: nil)
|
581
605
|
.create_webhook_execution
|
582
606
|
end
|
583
607
|
|
584
608
|
it "returns one for each event" do
|
585
|
-
|
609
|
+
# ignoring the ones with nil event_names because they're old data, and shouldn't be
|
610
|
+
# considered as a separate "group"
|
611
|
+
expect(subject.collect(&:uuid).sort).to eq ["555", "777"]
|
586
612
|
end
|
587
613
|
end
|
588
614
|
|
589
615
|
context "when there are two 'latest' triggered webhooks at the same time" do
|
590
616
|
before do
|
591
|
-
td.create_triggered_webhook(
|
617
|
+
td.create_triggered_webhook(uuid: "888", created_at: DateTime.new(2018))
|
592
618
|
.create_webhook_execution
|
593
619
|
end
|
594
620
|
|
595
621
|
it "returns the one with the bigger ID" do
|
596
|
-
expect(subject.collect(&:
|
622
|
+
expect(subject.collect(&:uuid).sort).to eq ["332", "888"]
|
597
623
|
end
|
598
624
|
end
|
599
625
|
|
@@ -618,26 +644,26 @@ module PactBroker
|
|
618
644
|
.create_webhook_execution
|
619
645
|
.create_pact_with_hierarchy
|
620
646
|
.create_webhook
|
621
|
-
.create_triggered_webhook(
|
647
|
+
.create_triggered_webhook(uuid: "256", created_at: DateTime.new(2016))
|
622
648
|
.create_webhook_execution
|
623
|
-
.create_triggered_webhook(
|
649
|
+
.create_triggered_webhook(uuid: "332", created_at: DateTime.new(2017))
|
624
650
|
.create_webhook_execution
|
625
|
-
.create_provider_webhook(
|
626
|
-
.create_triggered_webhook(
|
651
|
+
.create_provider_webhook(uuidd: "987")
|
652
|
+
.create_triggered_webhook(uuid: "876", created_at: DateTime.new(2017))
|
627
653
|
.create_webhook_execution
|
628
|
-
.create_triggered_webhook(
|
654
|
+
.create_triggered_webhook(uuid: "638", created_at: DateTime.new(2018))
|
629
655
|
.create_webhook_execution
|
630
656
|
.create_consumer_webhook
|
631
|
-
.create_triggered_webhook(
|
657
|
+
.create_triggered_webhook(uuid: "555", created_at: DateTime.new(2017))
|
632
658
|
.create_webhook_execution
|
633
|
-
.create_triggered_webhook(
|
659
|
+
.create_triggered_webhook(uuid: "777", created_at: DateTime.new(2018))
|
634
660
|
.create_webhook_execution
|
635
661
|
end
|
636
662
|
|
637
663
|
subject { Repository.new.find_latest_triggered_webhooks_for_pact(td.pact) }
|
638
664
|
|
639
665
|
it "finds the latest triggered webhooks" do
|
640
|
-
expect(subject.collect(&:
|
666
|
+
expect(subject.collect(&:uuid).sort).to eq ["332", "638", "777"]
|
641
667
|
end
|
642
668
|
end
|
643
669
|
|
@@ -646,18 +672,18 @@ module PactBroker
|
|
646
672
|
td
|
647
673
|
.create_pact_with_hierarchy("Foo", "1", "Bar")
|
648
674
|
.create_webhook
|
649
|
-
.create_triggered_webhook(
|
675
|
+
.create_triggered_webhook(uuid: "1")
|
650
676
|
.create_webhook_execution
|
651
677
|
.create_consumer_version("2")
|
652
678
|
.create_pact
|
653
|
-
.create_triggered_webhook(
|
679
|
+
.create_triggered_webhook(uuid: "2")
|
654
680
|
.create_webhook_execution
|
655
681
|
end
|
656
682
|
|
657
683
|
subject { Repository.new.find_triggered_webhooks_for_pact(td.pact) }
|
658
684
|
|
659
685
|
it "finds the triggered webhooks" do
|
660
|
-
expect(subject.collect(&:
|
686
|
+
expect(subject.collect(&:uuid).sort).to eq ["2"]
|
661
687
|
end
|
662
688
|
end
|
663
689
|
|
@@ -667,15 +693,15 @@ module PactBroker
|
|
667
693
|
.create_pact_with_hierarchy("Foo", "1", "Bar")
|
668
694
|
.create_verification_webhook
|
669
695
|
.create_verification(provider_version: "1")
|
670
|
-
.create_triggered_webhook(
|
696
|
+
.create_triggered_webhook(uuid: "1")
|
671
697
|
.create_verification(provider_version: "2", number: 2)
|
672
|
-
.create_triggered_webhook(
|
698
|
+
.create_triggered_webhook(uuid: "2")
|
673
699
|
end
|
674
700
|
|
675
701
|
subject { Repository.new.find_triggered_webhooks_for_verification(td.verification) }
|
676
702
|
|
677
703
|
it "finds the triggered webhooks" do
|
678
|
-
expect(subject.collect(&:
|
704
|
+
expect(subject.collect(&:uuid).sort).to eq ["2"]
|
679
705
|
end
|
680
706
|
end
|
681
707
|
|
@@ -739,7 +765,7 @@ module PactBroker
|
|
739
765
|
end
|
740
766
|
|
741
767
|
it "deletes the webhooks belonging to the consumer version" do
|
742
|
-
expect { subject }.to change{ TriggeredWebhook.count }.by
|
768
|
+
expect { subject }.to change{ TriggeredWebhook.count }.by(-1)
|
743
769
|
end
|
744
770
|
end
|
745
771
|
|
@@ -748,14 +774,14 @@ module PactBroker
|
|
748
774
|
td
|
749
775
|
.create_pact_with_hierarchy
|
750
776
|
.create_verification(provider_version: "1")
|
751
|
-
.create_provider_webhook(event_names: [
|
777
|
+
.create_provider_webhook(event_names: ["provider_verification_published"])
|
752
778
|
.create_triggered_webhook
|
753
779
|
.create_webhook_execution
|
754
780
|
.and_return(:provider_version)
|
755
781
|
end
|
756
782
|
|
757
783
|
it "deletes the webhooks belonging to the consumer version" do
|
758
|
-
expect { subject }.to change{ TriggeredWebhook.count }.by
|
784
|
+
expect { subject }.to change{ TriggeredWebhook.count }.by(-1)
|
759
785
|
end
|
760
786
|
end
|
761
787
|
end
|