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,20 +1,19 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
1
|
+
require "spec_helper"
|
2
|
+
require "pact_broker/webhooks/service"
|
3
|
+
require "pact_broker/webhooks/triggered_webhook"
|
4
|
+
require "pact_broker/webhooks/webhook_event"
|
5
|
+
require "webmock/rspec"
|
6
|
+
require "sucker_punch/testing/inline"
|
7
|
+
require "pact_broker/webhooks/execution_configuration"
|
8
8
|
|
9
9
|
module PactBroker
|
10
|
-
|
11
10
|
module Webhooks
|
12
11
|
describe Service do
|
13
12
|
before do
|
14
13
|
allow(Service).to receive(:logger).and_return(logger)
|
15
14
|
end
|
16
15
|
|
17
|
-
let(:logger) { double(
|
16
|
+
let(:logger) { double("logger").as_null_object }
|
18
17
|
|
19
18
|
describe "validate - integration test" do
|
20
19
|
let(:invalid_webhook) { PactBroker::Domain::Webhook.new }
|
@@ -23,21 +22,21 @@ module PactBroker
|
|
23
22
|
subject { Service.errors(invalid_webhook) }
|
24
23
|
|
25
24
|
it "does not contain an error for the uuid" do
|
26
|
-
expect(subject.messages).to_not have_key(
|
25
|
+
expect(subject.messages).to_not have_key("uuid")
|
27
26
|
end
|
28
27
|
end
|
29
28
|
|
30
29
|
context "with a uuid" do
|
31
|
-
subject { Service.errors(invalid_webhook,
|
30
|
+
subject { Service.errors(invalid_webhook, "") }
|
32
31
|
|
33
32
|
it "merges the uuid errors with the webhook errors" do
|
34
|
-
expect(subject.messages[
|
33
|
+
expect(subject.messages["uuid"].first).to include "can only contain"
|
35
34
|
end
|
36
35
|
end
|
37
36
|
end
|
38
37
|
|
39
38
|
describe ".valid_uuid_format?" do
|
40
|
-
it
|
39
|
+
it "does something" do
|
41
40
|
expect(Service.valid_uuid_format?("_-bcdefghigHIJKLMNOP")).to be true
|
42
41
|
expect(Service.valid_uuid_format?("HIJKLMNOP")).to be false
|
43
42
|
expect(Service.valid_uuid_format?("abcdefghigHIJKLMNOP\\")).to be false
|
@@ -73,8 +72,8 @@ module PactBroker
|
|
73
72
|
let(:existing_webhook) { PactBroker::Domain::Webhook.new(request: request) }
|
74
73
|
let(:params) do
|
75
74
|
{
|
76
|
-
|
77
|
-
|
75
|
+
"request" => {
|
76
|
+
"url" => "http://url"
|
78
77
|
}
|
79
78
|
}
|
80
79
|
end
|
@@ -83,58 +82,58 @@ module PactBroker
|
|
83
82
|
|
84
83
|
it "sends through the params to the repository" do
|
85
84
|
updated_webhook = nil
|
86
|
-
allow_any_instance_of(PactBroker::Webhooks::Repository).to receive(:update_by_uuid) do |
|
85
|
+
allow_any_instance_of(PactBroker::Webhooks::Repository).to receive(:update_by_uuid) do | _instance, _uuid, webhook |
|
87
86
|
updated_webhook = webhook
|
88
87
|
true
|
89
88
|
end
|
90
89
|
subject
|
91
|
-
expect(updated_webhook.request.url).to eq
|
90
|
+
expect(updated_webhook.request.url).to eq "http://url"
|
92
91
|
end
|
93
92
|
|
94
93
|
context "when the webhook has a password and the incoming parameters do not contain a password" do
|
95
|
-
let(:existing_password) {
|
94
|
+
let(:existing_password) { "password" }
|
96
95
|
|
97
96
|
it "does not overwite the password" do
|
98
97
|
updated_webhook = nil
|
99
|
-
allow_any_instance_of(PactBroker::Webhooks::Repository).to receive(:update_by_uuid) do |
|
98
|
+
allow_any_instance_of(PactBroker::Webhooks::Repository).to receive(:update_by_uuid) do | _instance, _uuid, webhook |
|
100
99
|
updated_webhook = webhook
|
101
100
|
true
|
102
101
|
end
|
103
102
|
subject
|
104
|
-
expect(updated_webhook.request.password).to eq
|
103
|
+
expect(updated_webhook.request.password).to eq "password"
|
105
104
|
end
|
106
105
|
end
|
107
106
|
|
108
107
|
context "when the webhook has a password and the incoming parameters contain a *** password" do
|
109
|
-
let(:existing_password) {
|
108
|
+
let(:existing_password) { "password" }
|
110
109
|
let(:params) do
|
111
110
|
{
|
112
|
-
|
113
|
-
|
114
|
-
|
111
|
+
"request" => {
|
112
|
+
"url" => "http://url",
|
113
|
+
"password" => "*******"
|
115
114
|
}
|
116
115
|
}
|
117
116
|
end
|
118
117
|
|
119
118
|
it "does not overwite the password" do
|
120
119
|
updated_webhook = nil
|
121
|
-
allow_any_instance_of(PactBroker::Webhooks::Repository).to receive(:update_by_uuid) do |
|
120
|
+
allow_any_instance_of(PactBroker::Webhooks::Repository).to receive(:update_by_uuid) do | _instance, _uuid, webhook |
|
122
121
|
updated_webhook = webhook
|
123
122
|
true
|
124
123
|
end
|
125
124
|
subject
|
126
|
-
expect(updated_webhook.request.password).to eq
|
125
|
+
expect(updated_webhook.request.password).to eq "password"
|
127
126
|
end
|
128
127
|
end
|
129
128
|
|
130
129
|
context "when the webhook has an authorization header and the incoming parameters contain a *** authorization header" do
|
131
|
-
let(:headers) { {
|
130
|
+
let(:headers) { { "Authorization" => "existing"} }
|
132
131
|
let(:params) do
|
133
132
|
{
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
133
|
+
"request" => {
|
134
|
+
"url" => "http://url",
|
135
|
+
"headers" => {
|
136
|
+
"authorization" => "***********"
|
138
137
|
}
|
139
138
|
}
|
140
139
|
}
|
@@ -142,238 +141,33 @@ module PactBroker
|
|
142
141
|
|
143
142
|
it "does not overwite the authorization header" do
|
144
143
|
updated_webhook = nil
|
145
|
-
allow_any_instance_of(PactBroker::Webhooks::Repository).to receive(:update_by_uuid) do |
|
144
|
+
allow_any_instance_of(PactBroker::Webhooks::Repository).to receive(:update_by_uuid) do | _instance, _uuid, webhook |
|
146
145
|
updated_webhook = webhook
|
147
146
|
true
|
148
147
|
end
|
149
148
|
subject
|
150
|
-
expect(updated_webhook.request.headers[
|
149
|
+
expect(updated_webhook.request.headers["Authorization"]).to eq "existing"
|
151
150
|
end
|
152
151
|
end
|
153
152
|
|
154
153
|
context "the incoming parameters contain a password" do
|
155
154
|
let(:params) do
|
156
155
|
{
|
157
|
-
|
158
|
-
|
156
|
+
"request" => {
|
157
|
+
"password" => "updated"
|
159
158
|
}
|
160
159
|
}
|
161
160
|
end
|
162
161
|
|
163
162
|
it "updates the password" do
|
164
163
|
updated_webhook = nil
|
165
|
-
allow_any_instance_of(PactBroker::Webhooks::Repository).to receive(:update_by_uuid) do |
|
164
|
+
allow_any_instance_of(PactBroker::Webhooks::Repository).to receive(:update_by_uuid) do | _instance, _uuid, webhook |
|
166
165
|
updated_webhook = webhook
|
167
166
|
true
|
168
167
|
end
|
169
168
|
subject
|
170
|
-
expect(updated_webhook.request.password).to eq
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
describe ".trigger_webhooks" do
|
176
|
-
let(:verification) { instance_double(PactBroker::Domain::Verification)}
|
177
|
-
let(:pact) { instance_double(PactBroker::Domain::Pact, consumer: consumer, provider: provider, consumer_version: consumer_version)}
|
178
|
-
let(:consumer_version) { PactBroker::Domain::Version.new(number: '1.2.3') }
|
179
|
-
let(:consumer) { PactBroker::Domain::Pacticipant.new(name: 'Consumer') }
|
180
|
-
let(:provider) { PactBroker::Domain::Pacticipant.new(name: 'Provider') }
|
181
|
-
let(:webhooks) { [instance_double(PactBroker::Domain::Webhook, description: 'description', uuid: '1244')]}
|
182
|
-
let(:triggered_webhook) { instance_double(PactBroker::Webhooks::TriggeredWebhook) }
|
183
|
-
let(:webhook_execution_configuration) { double('webhook_execution_configuration', webhook_context: webhook_context) }
|
184
|
-
let(:webhook_context) { { base_url: "http://example.org" } }
|
185
|
-
let(:event_context) { { some: "data" } }
|
186
|
-
let(:expected_event_context) { { some: "data", event_name: PactBroker::Webhooks::WebhookEvent::CONTRACT_CONTENT_CHANGED, base_url: "http://example.org" } }
|
187
|
-
let(:options) do
|
188
|
-
{ database_connector: double('database_connector'),
|
189
|
-
webhook_execution_configuration: webhook_execution_configuration,
|
190
|
-
logging_options: {}
|
191
|
-
}
|
192
|
-
end
|
193
|
-
|
194
|
-
before do
|
195
|
-
allow(webhook_execution_configuration).to receive(:with_webhook_context).and_return(webhook_execution_configuration)
|
196
|
-
allow_any_instance_of(PactBroker::Webhooks::Repository).to receive(:find_by_consumer_and_or_provider_and_event_name).and_return(webhooks)
|
197
|
-
allow_any_instance_of(PactBroker::Webhooks::Repository).to receive(:create_triggered_webhook).and_return(triggered_webhook)
|
198
|
-
allow(Job).to receive(:perform_in)
|
199
|
-
end
|
200
|
-
|
201
|
-
subject { Service.trigger_webhooks(pact, verification, PactBroker::Webhooks::WebhookEvent::CONTRACT_CONTENT_CHANGED, event_context, options) }
|
202
|
-
|
203
|
-
it "finds the webhooks" do
|
204
|
-
expect_any_instance_of(PactBroker::Webhooks::Repository).to receive(:find_by_consumer_and_or_provider_and_event_name).with(consumer, provider, PactBroker::Webhooks::WebhookEvent::DEFAULT_EVENT_NAME)
|
205
|
-
subject
|
206
|
-
end
|
207
|
-
|
208
|
-
context "when webhooks are found" do
|
209
|
-
it "executes the webhook" do
|
210
|
-
expect(Service).to receive(:run_later).with(webhooks, pact, verification, PactBroker::Webhooks::WebhookEvent::CONTRACT_CONTENT_CHANGED, expected_event_context, options)
|
211
|
-
subject
|
212
|
-
end
|
213
|
-
|
214
|
-
it "merges the event name in the options" do
|
215
|
-
expect(webhook_execution_configuration).to receive(:with_webhook_context).with(event_name: PactBroker::Webhooks::WebhookEvent::CONTRACT_CONTENT_CHANGED)
|
216
|
-
subject
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
context "when no webhooks are found" do
|
221
|
-
let(:webhooks) { [] }
|
222
|
-
it "does nothing" do
|
223
|
-
expect(Service).to_not receive(:run_later)
|
224
|
-
subject
|
169
|
+
expect(updated_webhook.request.password).to eq "updated"
|
225
170
|
end
|
226
|
-
|
227
|
-
it "logs that no webhook was found" do
|
228
|
-
expect(logger).to receive(:info).with(/No enabled webhooks found/)
|
229
|
-
subject
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
context "when there is a scheduling error", job: true do
|
234
|
-
before do
|
235
|
-
allow(Job).to receive(:perform_in).and_raise("an error")
|
236
|
-
end
|
237
|
-
|
238
|
-
it "logs the error" do
|
239
|
-
allow(Service.logger).to receive(:warn)
|
240
|
-
expect(Service.logger).to receive(:warn).with(/Error scheduling/, StandardError)
|
241
|
-
subject
|
242
|
-
end
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
|
-
describe ".test_execution" do
|
247
|
-
let(:webhook) do
|
248
|
-
instance_double(PactBroker::Domain::Webhook,
|
249
|
-
trigger_on_provider_verification_published?: trigger_on_verification,
|
250
|
-
consumer_name: 'consumer',
|
251
|
-
provider_name: 'provider',
|
252
|
-
execute: result
|
253
|
-
)
|
254
|
-
end
|
255
|
-
let(:pact) { instance_double(PactBroker::Domain::Pact) }
|
256
|
-
let(:verification) { instance_double(PactBroker::Domain::Verification) }
|
257
|
-
let(:trigger_on_verification) { false }
|
258
|
-
let(:result) { double('result') }
|
259
|
-
let(:execution_configuration) do
|
260
|
-
instance_double(PactBroker::Webhooks::ExecutionConfiguration, to_hash: execution_configuration_hash)
|
261
|
-
end
|
262
|
-
let(:execution_configuration_hash) { { the: 'options' } }
|
263
|
-
let(:event_context) { { some: "data" } }
|
264
|
-
|
265
|
-
before do
|
266
|
-
allow(PactBroker::Pacts::Service).to receive(:search_for_latest_pact).and_return(pact)
|
267
|
-
allow(PactBroker::Verifications::Service).to receive(:search_for_latest).and_return(verification)
|
268
|
-
allow(PactBroker.configuration).to receive(:show_webhook_response?).and_return('foo')
|
269
|
-
allow(execution_configuration).to receive(:with_failure_log_message).and_return(execution_configuration)
|
270
|
-
end
|
271
|
-
|
272
|
-
subject { Service.test_execution(webhook, event_context, execution_configuration) }
|
273
|
-
|
274
|
-
it "searches for the latest matching pact" do
|
275
|
-
expect(PactBroker::Pacts::Service).to receive(:search_for_latest_pact).with(consumer_name: 'consumer', provider_name: 'provider')
|
276
|
-
subject
|
277
|
-
end
|
278
|
-
|
279
|
-
it "returns the result" do
|
280
|
-
expect(subject).to be result
|
281
|
-
end
|
282
|
-
|
283
|
-
context "when the trigger is not for a verification" do
|
284
|
-
it "executes the webhook with the pact" do
|
285
|
-
expect(webhook).to receive(:execute).with(pact, nil, event_context.merge(event_name: "test"), execution_configuration_hash)
|
286
|
-
subject
|
287
|
-
end
|
288
|
-
end
|
289
|
-
|
290
|
-
context "when a pact cannot be found" do
|
291
|
-
let(:pact) { nil }
|
292
|
-
|
293
|
-
it "executes the webhook with a placeholder pact" do
|
294
|
-
expect(webhook).to receive(:execute).with(an_instance_of(PactBroker::Pacts::PlaceholderPact), anything, anything, anything)
|
295
|
-
subject
|
296
|
-
end
|
297
|
-
end
|
298
|
-
|
299
|
-
context "when the trigger is for a verification publication" do
|
300
|
-
let(:trigger_on_verification) { true }
|
301
|
-
|
302
|
-
it "searches for the latest matching verification" do
|
303
|
-
expect(PactBroker::Verifications::Service).to receive(:search_for_latest).with('consumer', 'provider')
|
304
|
-
subject
|
305
|
-
end
|
306
|
-
|
307
|
-
it "executes the webhook with the pact and the verification" do
|
308
|
-
expect(webhook).to receive(:execute).with(pact, verification, event_context.merge(event_name: "test"), execution_configuration_hash)
|
309
|
-
subject
|
310
|
-
end
|
311
|
-
|
312
|
-
context "when a verification cannot be found" do
|
313
|
-
let(:verification) { nil }
|
314
|
-
|
315
|
-
it "executes the webhook with a placeholder verification" do
|
316
|
-
expect(webhook).to receive(:execute).with(anything, an_instance_of(PactBroker::Verifications::PlaceholderVerification), anything, anything)
|
317
|
-
subject
|
318
|
-
end
|
319
|
-
end
|
320
|
-
end
|
321
|
-
end
|
322
|
-
|
323
|
-
describe ".trigger_webhooks integration test", job: true do
|
324
|
-
let!(:http_request) do
|
325
|
-
stub_request(:get, "http://example.org").
|
326
|
-
to_return(:status => 200)
|
327
|
-
end
|
328
|
-
|
329
|
-
let(:events) { [{ name: PactBroker::Webhooks::WebhookEvent::DEFAULT_EVENT_NAME }] }
|
330
|
-
let(:webhook_execution_configuration) do
|
331
|
-
PactBroker::Webhooks::ExecutionConfiguration.new
|
332
|
-
.with_webhook_context(base_url: 'http://example.org')
|
333
|
-
.with_show_response(true)
|
334
|
-
end
|
335
|
-
let(:event_context) { { some: "data", base_url: "http://example.org" }}
|
336
|
-
let(:options) do
|
337
|
-
{
|
338
|
-
database_connector: database_connector,
|
339
|
-
webhook_execution_configuration: webhook_execution_configuration
|
340
|
-
}
|
341
|
-
end
|
342
|
-
let(:logging_options) { { show_response: true } }
|
343
|
-
let(:database_connector) { ->(&block) { block.call } }
|
344
|
-
let(:pact) do
|
345
|
-
td.create_consumer
|
346
|
-
.create_provider
|
347
|
-
.create_consumer_version
|
348
|
-
.create_pact
|
349
|
-
.create_verification
|
350
|
-
.create_webhook(method: 'GET', url: 'http://example.org', events: events)
|
351
|
-
.and_return(:pact)
|
352
|
-
end
|
353
|
-
|
354
|
-
subject { PactBroker::Webhooks::Service.trigger_webhooks(pact, td.verification, PactBroker::Webhooks::WebhookEvent::CONTRACT_CONTENT_CHANGED, event_context, options) }
|
355
|
-
|
356
|
-
it "executes the HTTP request of the webhook" do
|
357
|
-
subject
|
358
|
-
expect(http_request).to have_been_made
|
359
|
-
end
|
360
|
-
|
361
|
-
it "executes the webhook with the correct options" do
|
362
|
-
expect_any_instance_of(PactBroker::Domain::WebhookRequest).to receive(:execute).and_call_original
|
363
|
-
subject
|
364
|
-
end
|
365
|
-
|
366
|
-
it "saves the triggered webhook" do
|
367
|
-
expect { subject }.to change { PactBroker::Webhooks::TriggeredWebhook.count }.by(1)
|
368
|
-
end
|
369
|
-
|
370
|
-
it "saves the execution" do
|
371
|
-
expect { subject }.to change { PactBroker::Webhooks::Execution.count }.by(1)
|
372
|
-
end
|
373
|
-
|
374
|
-
it "marks the triggered webhook as a success" do
|
375
|
-
subject
|
376
|
-
expect(TriggeredWebhook.first.status).to eq TriggeredWebhook::STATUS_SUCCESS
|
377
171
|
end
|
378
172
|
end
|
379
173
|
|
@@ -382,7 +176,7 @@ module PactBroker
|
|
382
176
|
|
383
177
|
it "returns a list of parameters and their descriptions" do
|
384
178
|
expect(subject.first.name).to start_with "pactbroker.consumerName"
|
385
|
-
expect(subject.first.description).to eq "
|
179
|
+
expect(subject.first.description).to eq "The consumer name"
|
386
180
|
end
|
387
181
|
end
|
388
182
|
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
require
|
1
|
+
require "pact_broker/webhooks/status"
|
2
2
|
|
3
3
|
module PactBroker
|
4
4
|
module Webhooks
|
5
5
|
describe Status do
|
6
|
-
let(:webhooks) { [double(
|
6
|
+
let(:webhooks) { [double("webhook")]}
|
7
7
|
let(:latest_triggered_webhooks) { [ triggered_webhook_1, triggered_webhook_2] }
|
8
|
-
let(:pact) { double(
|
9
|
-
let(:triggered_webhook_1) { double(
|
10
|
-
let(:triggered_webhook_2) { double(
|
8
|
+
let(:pact) { double("pact") }
|
9
|
+
let(:triggered_webhook_1) { double("triggered_webhook", status: status_1) }
|
10
|
+
let(:triggered_webhook_2) { double("triggered_webhook", status: status_2) }
|
11
11
|
let(:status_1) { TriggeredWebhook::STATUS_SUCCESS }
|
12
12
|
let(:status_2) { TriggeredWebhook::STATUS_SUCCESS }
|
13
13
|
|
@@ -1,214 +1,339 @@
|
|
1
|
-
require
|
1
|
+
require "pact_broker/webhooks/trigger_service"
|
2
2
|
|
3
3
|
module PactBroker
|
4
4
|
module Webhooks
|
5
5
|
describe TriggerService do
|
6
|
-
let(:pact) { double("pact", pact_version_sha: pact_version_sha) }
|
6
|
+
let(:pact) { double("pact", pact_version_sha: pact_version_sha, consumer_name: "foo", provider_name: "bar") }
|
7
7
|
let(:pact_version_sha) { "111" }
|
8
8
|
let(:pact_repository) { double("pact_repository", find_previous_pacts: previous_pacts) }
|
9
|
-
let(:
|
9
|
+
let(:pact_service) { class_double("PactBroker::Pacts::Service").as_stubbed_const }
|
10
10
|
let(:previous_pact) { double("previous_pact", pact_version_sha: previous_pact_version_sha) }
|
11
11
|
let(:previous_pact_version_sha) { "111" }
|
12
12
|
let(:previous_pacts) { { untagged: previous_pact } }
|
13
|
-
let(:logger) { double(
|
13
|
+
let(:logger) { double("logger").as_null_object }
|
14
14
|
let(:event_context) { { some: "data" } }
|
15
|
-
let(:webhook_options) { { the:
|
15
|
+
let(:webhook_options) { { the: "options"} }
|
16
16
|
|
17
17
|
before do
|
18
18
|
allow(TriggerService).to receive(:pact_repository).and_return(pact_repository)
|
19
|
-
allow(TriggerService).to receive(:
|
19
|
+
allow(TriggerService).to receive(:pact_service).and_return(pact_service)
|
20
20
|
allow(TriggerService).to receive(:logger).and_return(logger)
|
21
21
|
end
|
22
22
|
|
23
|
+
def find_result_with_message_including(message)
|
24
|
+
subject.find { | result | result.message.include?(message) }
|
25
|
+
end
|
26
|
+
|
23
27
|
shared_examples_for "triggering a contract_published event" do
|
24
28
|
it "triggers a contract_published webhook" do
|
25
|
-
expect(
|
29
|
+
expect(TriggerService).to receive(:trigger_webhooks).with(pact, nil, PactBroker::Webhooks::WebhookEvent::CONTRACT_PUBLISHED, event_context, webhook_options)
|
26
30
|
subject
|
27
31
|
end
|
28
32
|
end
|
29
33
|
|
30
34
|
shared_examples_for "triggering a contract_content_changed event" do
|
31
35
|
it "triggers a contract_content_changed webhook" do
|
32
|
-
expect(
|
36
|
+
expect(TriggerService).to receive(:trigger_webhooks).with(pact, nil, PactBroker::Webhooks::WebhookEvent::CONTRACT_CONTENT_CHANGED, event_context, webhook_options)
|
33
37
|
subject
|
34
38
|
end
|
35
39
|
end
|
36
40
|
|
37
41
|
shared_examples_for "not triggering a contract_content_changed event" do
|
38
42
|
it "does not trigger a contract_content_changed webhook" do
|
39
|
-
expect(
|
43
|
+
expect(TriggerService).to_not receive(:trigger_webhooks).with(anything, anything, PactBroker::Webhooks::WebhookEvent::CONTRACT_CONTENT_CHANGED, event_context, anything)
|
40
44
|
subject
|
41
45
|
end
|
42
46
|
end
|
47
|
+
end
|
43
48
|
|
44
|
-
|
45
|
-
|
49
|
+
describe TriggerService do
|
50
|
+
describe ".create_triggered_webhooks_for_event" do
|
51
|
+
before do
|
52
|
+
allow(TriggerService).to receive(:webhook_repository).and_return(webhook_repository)
|
53
|
+
allow(TriggerService).to receive(:logger).and_return(logger)
|
54
|
+
allow(TriggerService).to receive(:pact_service).and_return(pact_service)
|
55
|
+
end
|
56
|
+
let(:pact_service) { class_double("PactBroker::Pacts::Service").as_stubbed_const }
|
57
|
+
let(:logger) { double("logger").as_null_object }
|
58
|
+
let(:verification) { instance_double(PactBroker::Domain::Verification)}
|
59
|
+
let(:pact) { instance_double(PactBroker::Domain::Pact, consumer: consumer, provider: provider, consumer_version: consumer_version)}
|
60
|
+
let(:consumer_version) { PactBroker::Domain::Version.new(number: "1.2.3") }
|
61
|
+
let(:consumer) { PactBroker::Domain::Pacticipant.new(name: "Consumer") }
|
62
|
+
let(:provider) { PactBroker::Domain::Pacticipant.new(name: "Provider") }
|
63
|
+
let(:webhooks) { [webhook]}
|
64
|
+
let(:webhook) do
|
65
|
+
instance_double(PactBroker::Domain::Webhook, description: "description", uuid: "1244", expand_currently_deployed_provider_versions?: expand_currently_deployed)
|
66
|
+
end
|
67
|
+
let(:expand_currently_deployed) { false }
|
68
|
+
let(:triggered_webhook) { instance_double(PactBroker::Webhooks::TriggeredWebhook) }
|
69
|
+
let(:event_name) { PactBroker::Webhooks::WebhookEvent::CONTRACT_CONTENT_CHANGED }
|
70
|
+
let(:event_context) { { some: "data" } }
|
71
|
+
let(:expected_event_context) { { some: "data", event_name: PactBroker::Webhooks::WebhookEvent::CONTRACT_CONTENT_CHANGED } }
|
72
|
+
let(:webhook_repository) { instance_double(Repository, create_triggered_webhook: triggered_webhook, find_webhooks_to_trigger: webhooks) }
|
46
73
|
|
47
|
-
|
48
|
-
let(:previous_pact) { nil }
|
74
|
+
subject { TriggerService.create_triggered_webhooks_for_event(pact, verification, event_name, event_context) }
|
49
75
|
|
50
|
-
|
51
|
-
|
76
|
+
it "finds the webhooks" do
|
77
|
+
expect(webhook_repository).to receive(:find_webhooks_to_trigger).with(consumer: consumer, provider: provider, event_name: PactBroker::Webhooks::WebhookEvent::DEFAULT_EVENT_NAME)
|
78
|
+
subject
|
79
|
+
end
|
52
80
|
|
53
|
-
|
54
|
-
|
81
|
+
context "when webhooks are found" do
|
82
|
+
it "merges the event name in the webhook context" do
|
83
|
+
expect(webhook_repository).to receive(:create_triggered_webhook).with(anything, anything, anything, anything, anything, anything, hash_including(event_name: PactBroker::Webhooks::WebhookEvent::CONTRACT_CONTENT_CHANGED))
|
55
84
|
subject
|
56
85
|
end
|
57
|
-
end
|
58
86
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
87
|
+
context "when there should be a webhook triggered for each currently deployed version" do
|
88
|
+
before do
|
89
|
+
allow(TriggerService).to receive(:deployed_version_service).and_return(deployed_version_service)
|
90
|
+
allow(deployed_version_service).to receive(:find_currently_deployed_versions_for_pacticipant).and_return(currently_deployed_versions)
|
91
|
+
end
|
92
|
+
let(:expand_currently_deployed) { true }
|
93
|
+
let(:deployed_version_service) { class_double("PactBroker::Deployments::DeployedVersionService").as_stubbed_const }
|
94
|
+
let(:currently_deployed_version_1) { instance_double("PactBroker::Deployments::DeployedVersion", version_number: "1") }
|
95
|
+
let(:currently_deployed_version_2) { instance_double("PactBroker::Deployments::DeployedVersion", version_number: "2") }
|
96
|
+
let(:currently_deployed_versions) { [currently_deployed_version_1, currently_deployed_version_2] }
|
97
|
+
|
98
|
+
it "creates a triggered webhook for each currently deployed version" do
|
99
|
+
expect(webhook_repository).to receive(:create_triggered_webhook).with(anything, webhook, pact, verification, TriggerService::RESOURCE_CREATION, PactBroker::Webhooks::WebhookEvent::CONTRACT_CONTENT_CHANGED, expected_event_context.merge(currently_deployed_provider_version_number: "1"))
|
100
|
+
expect(webhook_repository).to receive(:create_triggered_webhook).with(anything, webhook, pact, verification, TriggerService::RESOURCE_CREATION, PactBroker::Webhooks::WebhookEvent::CONTRACT_CONTENT_CHANGED, expected_event_context.merge(currently_deployed_provider_version_number: "2"))
|
101
|
+
subject
|
102
|
+
end
|
63
103
|
|
64
|
-
|
65
|
-
|
104
|
+
context "when the same version is deployed to multiple environments" do
|
105
|
+
let(:currently_deployed_version_2) { instance_double("PactBroker::Deployments::DeployedVersion", version_number: "1") }
|
66
106
|
|
67
|
-
|
68
|
-
|
69
|
-
|
107
|
+
it "only creates one triggered webhook" do
|
108
|
+
expect(webhook_repository).to receive(:create_triggered_webhook).with(anything, anything, anything, anything, anything, anything, expected_event_context.merge(currently_deployed_provider_version_number: "1"))
|
109
|
+
subject
|
110
|
+
end
|
111
|
+
end
|
70
112
|
end
|
71
|
-
end
|
72
113
|
|
73
|
-
|
74
|
-
|
114
|
+
context "when there should be a webhook triggered for each consumer version that had a pact verified" do
|
115
|
+
# let(:triggered_webhooks) { [instance_double(TriggeredWebhook, event_context: { some: 'context'}, webhook: instance_double(Webhook, uuid: "webhook-uuid"))]}
|
75
116
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
117
|
+
before do
|
118
|
+
allow(pact_service).to receive(:find_pact).and_return(pact_for_consumer_version_1, pact_for_consumer_version_2)
|
119
|
+
# allow(pact_service).to receive(:find_pact).with(hash_including(consumer_version_number: "2")).and_return(pact_for_consumer_version_2)
|
120
|
+
end
|
121
|
+
let(:event_name) { PactBroker::Webhooks::WebhookEvent::VERIFICATION_SUCCEEDED }
|
122
|
+
let(:pact) { instance_double(PactBroker::Domain::Pact, provider_name: provider.name, consumer_name: consumer.name, consumer: consumer, provider: provider, consumer_version: consumer_version)}
|
123
|
+
let(:consumer_version) { PactBroker::Domain::Version.new(number: "1.2.3") }
|
124
|
+
let(:consumer) { PactBroker::Domain::Pacticipant.new(name: "Consumer") }
|
125
|
+
let(:provider) { PactBroker::Domain::Pacticipant.new(name: "Provider") }
|
126
|
+
|
127
|
+
# See lib/pact_broker/pacts/metadata.rb build_metadata_for_pact_for_verification
|
128
|
+
let(:selector_1) { { latest: true, consumer_version_number: "1", tag: "prod" } }
|
129
|
+
let(:selector_2) { { latest: true, consumer_version_number: "1", tag: "main" } }
|
130
|
+
let(:selector_3) { { latest: true, consumer_version_number: "2", tag: "feat/2" } }
|
131
|
+
let(:event_context) do
|
132
|
+
{
|
133
|
+
consumer_version_selectors: [selector_1, selector_2, selector_3],
|
134
|
+
other: "foo"
|
135
|
+
}
|
136
|
+
end
|
137
|
+
let(:expected_event_context_1) { { event_name: event_name, consumer_version_number: "1", consumer_version_tags: ["prod", "main"], other: "foo" } }
|
138
|
+
let(:expected_event_context_2) { { event_name: event_name, consumer_version_number: "2", consumer_version_tags: ["feat/2"], other: "foo" } }
|
139
|
+
let(:pact_for_consumer_version_1) { double("pact_for_consumer_version_1") }
|
140
|
+
let(:pact_for_consumer_version_2) { double("pact_for_consumer_version_2") }
|
141
|
+
|
142
|
+
it "finds the pact publication for each consumer version number" do
|
143
|
+
expect(pact_service).to receive(:find_pact).with(hash_including(consumer_version_number: "1")).and_return(pact_for_consumer_version_1)
|
144
|
+
expect(pact_service).to receive(:find_pact).with(hash_including(consumer_version_number: "2")).and_return(pact_for_consumer_version_2)
|
145
|
+
subject
|
146
|
+
end
|
81
147
|
|
82
|
-
|
83
|
-
|
84
|
-
|
148
|
+
context "when there are consumer_version_selectors in the event_context" do
|
149
|
+
it "creates a triggered webhook for each consumer version (ie. commit)" do
|
150
|
+
expect(webhook_repository).to receive(:create_triggered_webhook).with(anything, webhook, pact_for_consumer_version_1, verification, TriggerService::RESOURCE_CREATION, event_name, expected_event_context_1)
|
151
|
+
expect(webhook_repository).to receive(:create_triggered_webhook).with(anything, webhook, pact_for_consumer_version_2, verification, TriggerService::RESOURCE_CREATION, event_name, expected_event_context_2)
|
152
|
+
subject
|
153
|
+
end
|
154
|
+
end
|
85
155
|
|
86
|
-
|
87
|
-
|
156
|
+
context "when there are no consumer_version_selectors" do
|
157
|
+
let(:event_context) { { some: "data" } }
|
88
158
|
|
89
|
-
|
90
|
-
|
91
|
-
|
159
|
+
it "passes through the event context and only makes one triggered webhook" do
|
160
|
+
expect(webhook_repository).to receive(:create_triggered_webhook).with(anything, webhook, pact, verification, TriggerService::RESOURCE_CREATION, PactBroker::Webhooks::WebhookEvent::VERIFICATION_SUCCEEDED, event_context.merge(event_name: event_name))
|
161
|
+
subject
|
162
|
+
end
|
163
|
+
end
|
92
164
|
end
|
93
165
|
end
|
166
|
+
end
|
94
167
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
168
|
+
describe ".schedule_webhooks" do
|
169
|
+
let(:options) do
|
170
|
+
{ database_connector: double("database_connector"),
|
171
|
+
webhook_execution_configuration: webhook_execution_configuration,
|
172
|
+
logging_options: {}
|
173
|
+
}
|
174
|
+
end
|
175
|
+
let(:triggered_webhook) { instance_double(PactBroker::Webhooks::TriggeredWebhook, webhook: webhook, event_context: {}) }
|
176
|
+
let(:triggered_webhooks) { [triggered_webhook] }
|
177
|
+
let(:webhook_execution_configuration) { double("webhook_execution_configuration", webhook_context: webhook_context) }
|
178
|
+
let(:webhook_context) { { base_url: "http://example.org" } }
|
179
|
+
let(:webhook) do
|
180
|
+
instance_double(PactBroker::Domain::Webhook, description: "description", uuid: "1244")
|
101
181
|
end
|
102
182
|
|
103
|
-
|
104
|
-
|
105
|
-
|
183
|
+
subject { TriggerService.schedule_webhooks(triggered_webhooks, options) }
|
184
|
+
|
185
|
+
context "when there is a scheduling error", job: true do
|
186
|
+
before do
|
187
|
+
allow(TriggerService).to receive(:logger).and_return(logger)
|
188
|
+
end
|
189
|
+
|
190
|
+
let(:logger) { double("logger").as_null_object }
|
191
|
+
|
192
|
+
before do
|
193
|
+
allow(Job).to receive(:perform_in).and_raise("an error")
|
194
|
+
end
|
106
195
|
|
107
|
-
|
108
|
-
|
196
|
+
it "logs the error" do
|
197
|
+
allow(TriggerService.logger).to receive(:warn)
|
198
|
+
expect(TriggerService.logger).to receive(:warn).with(/Error scheduling/, StandardError)
|
199
|
+
subject
|
200
|
+
end
|
109
201
|
end
|
110
202
|
end
|
111
203
|
|
112
|
-
describe "
|
113
|
-
let(:
|
114
|
-
|
115
|
-
|
116
|
-
|
204
|
+
describe ".test_execution" do
|
205
|
+
let(:webhook) do
|
206
|
+
instance_double(PactBroker::Domain::Webhook,
|
207
|
+
trigger_on_provider_verification_published?: trigger_on_verification,
|
208
|
+
consumer_name: "consumer",
|
209
|
+
provider_name: "provider",
|
210
|
+
execute: result
|
117
211
|
)
|
118
212
|
end
|
119
|
-
let(:
|
213
|
+
let(:pact) { instance_double(PactBroker::Domain::Pact) }
|
214
|
+
let(:verification) { instance_double(PactBroker::Domain::Verification) }
|
215
|
+
let(:trigger_on_verification) { false }
|
216
|
+
let(:result) { double("result") }
|
217
|
+
let(:execution_configuration) do
|
218
|
+
instance_double(PactBroker::Webhooks::ExecutionConfiguration, to_hash: execution_configuration_hash)
|
219
|
+
end
|
220
|
+
let(:execution_configuration_hash) { { the: "options" } }
|
221
|
+
let(:event_context) { { some: "data" } }
|
222
|
+
|
223
|
+
before do
|
224
|
+
allow(PactBroker::Pacts::Service).to receive(:search_for_latest_pact).and_return(pact)
|
225
|
+
allow(PactBroker::Verifications::Service).to receive(:search_for_latest).and_return(verification)
|
226
|
+
allow(PactBroker.configuration).to receive(:show_webhook_response?).and_return("foo")
|
227
|
+
allow(execution_configuration).to receive(:with_failure_log_message).and_return(execution_configuration)
|
228
|
+
end
|
120
229
|
|
121
|
-
subject { TriggerService.
|
230
|
+
subject { TriggerService.test_execution(webhook, event_context, execution_configuration) }
|
122
231
|
|
123
|
-
|
124
|
-
|
232
|
+
it "searches for the latest matching pact" do
|
233
|
+
expect(PactBroker::Pacts::Service).to receive(:search_for_latest_pact).with(consumer_name: "consumer", provider_name: "provider")
|
234
|
+
subject
|
235
|
+
end
|
125
236
|
|
126
|
-
|
127
|
-
|
237
|
+
it "returns the result" do
|
238
|
+
expect(subject).to be result
|
239
|
+
end
|
128
240
|
|
129
|
-
|
130
|
-
|
241
|
+
context "when the trigger is not for a verification" do
|
242
|
+
it "executes the webhook with the pact" do
|
243
|
+
expect(webhook).to receive(:execute).with(pact, nil, event_context.merge(event_name: "test"), execution_configuration_hash)
|
131
244
|
subject
|
132
245
|
end
|
133
246
|
end
|
134
247
|
|
135
|
-
context "when
|
136
|
-
|
137
|
-
include_examples "not triggering a contract_content_changed event"
|
138
|
-
end
|
139
|
-
end
|
248
|
+
context "when a pact cannot be found" do
|
249
|
+
let(:pact) { nil }
|
140
250
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
let(:selector_1) { { latest: true, consumer_version_number: "1", tag: "prod" } }
|
146
|
-
let(:selector_2) { { latest: true, consumer_version_number: "1", tag: "main" } }
|
147
|
-
let(:selector_3) { { latest: true, consumer_version_number: "2", tag: "feat/2" } }
|
148
|
-
let(:event_context) do
|
149
|
-
{
|
150
|
-
consumer_version_selectors: [selector_1, selector_2, selector_3],
|
151
|
-
other: "foo"
|
152
|
-
}
|
251
|
+
it "executes the webhook with a placeholder pact" do
|
252
|
+
expect(webhook).to receive(:execute).with(an_instance_of(PactBroker::Pacts::PlaceholderPact), anything, anything, anything)
|
253
|
+
subject
|
254
|
+
end
|
153
255
|
end
|
154
|
-
let(:expected_event_context_1) { { consumer_version_number: "1", consumer_version_tags: ["prod", "main"], other: "foo" } }
|
155
|
-
let(:expected_event_context_2) { { consumer_version_number: "2", consumer_version_tags: ["feat/2"], other: "foo" } }
|
156
|
-
|
157
|
-
subject { TriggerService.trigger_webhooks_for_verification_results_publication(pact, verification, event_context, webhook_options) }
|
158
256
|
|
159
|
-
context "when the
|
257
|
+
context "when the trigger is for a verification publication" do
|
258
|
+
let(:trigger_on_verification) { true }
|
160
259
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
subject
|
166
|
-
end
|
260
|
+
it "searches for the latest matching verification" do
|
261
|
+
expect(PactBroker::Verifications::Service).to receive(:search_for_latest).with("consumer", "provider")
|
262
|
+
subject
|
263
|
+
end
|
167
264
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
subject
|
172
|
-
end
|
265
|
+
it "executes the webhook with the pact and the verification" do
|
266
|
+
expect(webhook).to receive(:execute).with(pact, verification, event_context.merge(event_name: "test"), execution_configuration_hash)
|
267
|
+
subject
|
173
268
|
end
|
174
269
|
|
175
|
-
context "when
|
176
|
-
let(:
|
270
|
+
context "when a verification cannot be found" do
|
271
|
+
let(:verification) { nil }
|
177
272
|
|
178
|
-
it "
|
179
|
-
expect(
|
180
|
-
expect(webhook_service).to receive(:trigger_webhooks).with(pact, verification, PactBroker::Webhooks::WebhookEvent::VERIFICATION_PUBLISHED, event_context, webhook_options)
|
273
|
+
it "executes the webhook with a placeholder verification" do
|
274
|
+
expect(webhook).to receive(:execute).with(anything, an_instance_of(PactBroker::Verifications::PlaceholderVerification), anything, anything)
|
181
275
|
subject
|
182
276
|
end
|
183
277
|
end
|
184
278
|
end
|
279
|
+
end
|
185
280
|
|
186
|
-
|
187
|
-
|
281
|
+
describe ".trigger_webhooks integration test", job: true do
|
282
|
+
let!(:http_request) do
|
283
|
+
stub_request(:get, "http://example.org").
|
284
|
+
to_return(:status => 200)
|
285
|
+
end
|
188
286
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
287
|
+
let(:events) { [{ name: PactBroker::Webhooks::WebhookEvent::DEFAULT_EVENT_NAME }] }
|
288
|
+
let(:webhook_execution_configuration) do
|
289
|
+
PactBroker::Webhooks::ExecutionConfiguration.new
|
290
|
+
.with_webhook_context(base_url: "http://example.org")
|
291
|
+
.with_show_response(true)
|
292
|
+
end
|
293
|
+
let(:event_context) { { some: "data", base_url: "http://example.org" }}
|
294
|
+
let(:options) do
|
295
|
+
{
|
296
|
+
database_connector: database_connector,
|
297
|
+
webhook_execution_configuration: webhook_execution_configuration
|
298
|
+
}
|
299
|
+
end
|
300
|
+
let(:logging_options) { { show_response: true } }
|
301
|
+
let(:database_connector) { ->(&block) { block.call } }
|
302
|
+
let(:pact) do
|
303
|
+
td.create_consumer
|
304
|
+
.create_provider
|
305
|
+
.create_consumer_version
|
306
|
+
.create_pact
|
307
|
+
.create_verification
|
308
|
+
.create_webhook(method: "GET", url: "http://example.org", events: events)
|
309
|
+
.and_return(:pact)
|
310
|
+
end
|
195
311
|
|
196
|
-
|
197
|
-
expect(webhook_service).to receive(:trigger_webhooks).with(pact, verification, PactBroker::Webhooks::WebhookEvent::VERIFICATION_PUBLISHED, expected_event_context_1, webhook_options)
|
198
|
-
expect(webhook_service).to receive(:trigger_webhooks).with(pact, verification, PactBroker::Webhooks::WebhookEvent::VERIFICATION_PUBLISHED, expected_event_context_2, webhook_options)
|
199
|
-
subject
|
200
|
-
end
|
201
|
-
end
|
312
|
+
let(:triggered_webhooks) { PactBroker::Webhooks::TriggerService.create_triggered_webhooks_for_event(pact, td.verification, PactBroker::Webhooks::WebhookEvent::CONTRACT_CONTENT_CHANGED, event_context) }
|
202
313
|
|
203
|
-
|
204
|
-
let(:event_context) { { some: "data" } }
|
314
|
+
subject { PactBroker::Webhooks::TriggerService.schedule_webhooks(triggered_webhooks, options) }
|
205
315
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
316
|
+
it "executes the HTTP request of the webhook" do
|
317
|
+
subject
|
318
|
+
expect(http_request).to have_been_made
|
319
|
+
end
|
320
|
+
|
321
|
+
it "executes the webhook with the correct options" do
|
322
|
+
expect_any_instance_of(PactBroker::Domain::WebhookRequest).to receive(:execute).and_call_original
|
323
|
+
subject
|
324
|
+
end
|
325
|
+
|
326
|
+
it "saves the triggered webhook" do
|
327
|
+
expect { subject }.to change { PactBroker::Webhooks::TriggeredWebhook.count }.by(1)
|
328
|
+
end
|
329
|
+
|
330
|
+
it "saves the execution" do
|
331
|
+
expect { subject }.to change { PactBroker::Webhooks::Execution.count }.by(1)
|
332
|
+
end
|
333
|
+
|
334
|
+
it "marks the triggered webhook as a success" do
|
335
|
+
subject
|
336
|
+
expect(TriggeredWebhook.first.status).to eq TriggeredWebhook::STATUS_SUCCESS
|
212
337
|
end
|
213
338
|
end
|
214
339
|
end
|