decidim-restfull-core 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/app/commands/decidim/rest_full/core/create_api_client.rb +40 -0
- data/app/commands/decidim/rest_full/core/impersonate_resource_owner_from_credentials.rb +151 -0
- data/app/commands/decidim/rest_full/core/syncronize_unconfirmed_host.rb +45 -0
- data/app/controllers/concerns/decidim/api/rest_full/async_api_job_enqueuing.rb +69 -0
- data/app/controllers/concerns/decidim/api/rest_full/collection_pagination.rb +78 -0
- data/app/controllers/concerns/decidim/api/rest_full/collection_pagination_meta.rb +25 -0
- data/app/controllers/concerns/decidim/api/rest_full/conditional_get_rendering.rb +49 -0
- data/app/controllers/concerns/decidim/api/rest_full/extended_data_endpoints.rb +96 -0
- data/app/controllers/concerns/decidim/api/rest_full/job_response_linking.rb +31 -0
- data/app/controllers/decidim/api/rest_full/application_controller.rb +245 -0
- data/app/controllers/decidim/api/rest_full/attachments/attachments_controller.rb +81 -0
- data/app/controllers/decidim/api/rest_full/components/component_extended_data_controller.rb +31 -0
- data/app/controllers/decidim/api/rest_full/components/components_controller.rb +68 -0
- data/app/controllers/decidim/api/rest_full/core/resources_controller.rb +142 -0
- data/app/controllers/decidim/api/rest_full/core.rb +11 -0
- data/app/controllers/decidim/api/rest_full/jobs/jobs_controller.rb +109 -0
- data/app/controllers/decidim/api/rest_full/organizations/organization_extended_data_controller.rb +31 -0
- data/app/controllers/decidim/api/rest_full/organizations/organizations_controller.rb +234 -0
- data/app/controllers/decidim/api/rest_full/roles/roles_controller.rb +125 -0
- data/app/controllers/decidim/api/rest_full/spaces/space_extended_data_controller.rb +29 -0
- data/app/controllers/decidim/api/rest_full/spaces/spaces_controller.rb +225 -0
- data/app/controllers/decidim/api/rest_full/users/magic_links_controller.rb +81 -0
- data/app/controllers/decidim/api/rest_full/users/user_extended_data_controller.rb +92 -0
- data/app/controllers/decidim/api/rest_full/users/users_controller.rb +40 -0
- data/app/controllers/decidim/api/rest_full/webhooks/webhook_events_controller.rb +33 -0
- data/app/controllers/decidim/api/rest_full/webhooks/webhook_registrations_controller.rb +106 -0
- data/app/controllers/decidim/rest_full/pages_controller.rb +9 -0
- data/app/controllers/decidim/rest_full/system/api_clients_controller.rb +69 -0
- data/app/controllers/decidim/rest_full/system/permissions_controller.rb +30 -0
- data/app/controllers/decidim/rest_full/system/webhook_registrations_controller.rb +49 -0
- data/app/forms/decidim/rest_full/core/admin/config_form.rb +49 -0
- data/app/forms/decidim/rest_full/core/api_client_form.rb +20 -0
- data/app/forms/decidim/rest_full/core/api_permissions.rb +18 -0
- data/app/forms/decidim/rest_full/core/magic_link_redirect_url_form.rb +114 -0
- data/app/forms/decidim/rest_full/core/webhook_event_form.rb +35 -0
- data/app/forms/decidim/rest_full/core/webhook_registration_form.rb +49 -0
- data/app/jobs/decidim/rest_full/application_job.rb +10 -0
- data/app/jobs/decidim/rest_full/core/space_webhook_job.rb +60 -0
- data/app/jobs/decidim/rest_full/core/syncronize_unconfirmed_host_job.rb +18 -0
- data/app/jobs/decidim/rest_full/core/webhook_job.rb +13 -0
- data/app/jobs/decidim/rest_full/execute_api_job_job.rb +55 -0
- data/app/models/decidim/rest_full/api_job.rb +74 -0
- data/app/models/decidim/rest_full/core/ability.rb +195 -0
- data/app/models/decidim/rest_full/core/api_client.rb +56 -0
- data/app/models/decidim/rest_full/core/magic_token.rb +45 -0
- data/app/models/decidim/rest_full/core/permission.rb +15 -0
- data/app/models/decidim/rest_full/core/resource_extended_data.rb +16 -0
- data/app/models/decidim/rest_full/core/webhook_registration.rb +61 -0
- data/app/overrides/system_host_input.rb +40 -0
- data/app/serializers/decidim/api/rest_full/core/application_serializer.rb +19 -0
- data/app/serializers/decidim/api/rest_full/core/assembly_serializer.rb +13 -0
- data/app/serializers/decidim/api/rest_full/core/attachment_serializer.rb +76 -0
- data/app/serializers/decidim/api/rest_full/core/awesome_iframe_component_serializer.rb +12 -0
- data/app/serializers/decidim/api/rest_full/core/awesome_map_component_serializer.rb +12 -0
- data/app/serializers/decidim/api/rest_full/core/component_serializer.rb +97 -0
- data/app/serializers/decidim/api/rest_full/core/helpers/resource_links_helper.rb +48 -0
- data/app/serializers/decidim/api/rest_full/core/magic_link_redirect_serializer.rb +43 -0
- data/app/serializers/decidim/api/rest_full/core/magic_link_serializer.rb +44 -0
- data/app/serializers/decidim/api/rest_full/core/organization_serializer.rb +60 -0
- data/app/serializers/decidim/api/rest_full/core/organization_webhook_serializer.rb +21 -0
- data/app/serializers/decidim/api/rest_full/core/page_component_serializer.rb +20 -0
- data/app/serializers/decidim/api/rest_full/core/page_serializer.rb +12 -0
- data/app/serializers/decidim/api/rest_full/core/participatory_process_serializer.rb +13 -0
- data/app/serializers/decidim/api/rest_full/core/resource_serializer.rb +84 -0
- data/app/serializers/decidim/api/rest_full/core/role_serializer.rb +21 -0
- data/app/serializers/decidim/api/rest_full/core/serializer_lookup.rb +55 -0
- data/app/serializers/decidim/api/rest_full/core/space_serializer.rb +117 -0
- data/app/serializers/decidim/api/rest_full/core/space_webhook_serializer.rb +64 -0
- data/app/serializers/decidim/api/rest_full/core/user_serializer.rb +43 -0
- data/app/serializers/decidim/api/rest_full/core/user_webhook_serializer.rb +21 -0
- data/app/serializers/decidim/api/rest_full/core/webhook_registration_serializer.rb +25 -0
- data/app/serializers/decidim/api/rest_full/core/webhook_serializer.rb +68 -0
- data/app/serializers/decidim/api/rest_full/core.rb +10 -0
- data/app/services/decidim/rest_full/core/api_system_operations.rb +505 -0
- data/app/services/decidim/rest_full/core/fire_webhook.rb +114 -0
- data/app/services/decidim/rest_full/core/participatory_process_step_activated_webhook_handler.rb +39 -0
- data/app/services/decidim/rest_full/participatory_space_visibility.rb +64 -0
- data/app/views/decidim/rest_full/core/admin/_organization_settings_tab.html.erb +35 -0
- data/app/views/decidim/rest_full/pages/show.html.erb +60 -0
- data/app/views/decidim/rest_full/system/api_clients/_edit_info_tab.erb +261 -0
- data/app/views/decidim/rest_full/system/api_clients/_edit_webhook_tab.erb +74 -0
- data/app/views/decidim/rest_full/system/api_clients/_form.html.erb +23 -0
- data/app/views/decidim/rest_full/system/api_clients/_permissions_scope.html.erb +22 -0
- data/app/views/decidim/rest_full/system/api_clients/edit.html.erb +53 -0
- data/app/views/decidim/rest_full/system/api_clients/index.html.erb +37 -0
- data/app/views/decidim/rest_full/system/api_clients/new.html.erb +13 -0
- data/app/views/decidim/rest_full/system/api_clients/show.html.erb +10 -0
- data/config/i18n-tasks.yml +381 -0
- data/config/locales/decidim_rest_full.en.yml +184 -0
- data/config/routes.rb +116 -0
- data/db/migrate/20241125061513_create_api_client_permissions.rb +12 -0
- data/db/migrate/20250112155305_create_proposal_application_id.rb +11 -0
- data/db/migrate/20250131155931_add_users_magic_token.rb +14 -0
- data/db/migrate/20250609083335_create_webhooks_table.rb +16 -0
- data/db/migrate/20250609091039_add_is_event_to_api_client_permissions.rb +7 -0
- data/db/migrate/20250624080106_create_organization_extended_data.rb +11 -0
- data/db/migrate/20260321120000_add_redirect_url_to_decidim_rest_full_user_magic_tokens.rb +7 -0
- data/db/migrate/20260511120000_create_decidim_rest_full_api_jobs.rb +23 -0
- data/db/migrate/20260515120000_add_poll_and_oauth_context_to_rest_full_api_jobs.rb +38 -0
- data/db/migrate/20260516153000_remove_poll_secret_from_decidim_rest_full_api_jobs.rb +7 -0
- data/db/migrate/20260516160000_add_org_status_index_to_rest_full_api_jobs.rb +9 -0
- data/db/migrate/20260805070000_create_resource_extended_data.rb +44 -0
- data/lib/decidim/rest_full/api_execution_context.rb +58 -0
- data/lib/decidim/rest_full/api_job_command_runner.rb +48 -0
- data/lib/decidim/rest_full/api_job_payload.rb +19 -0
- data/lib/decidim/rest_full/cli/base.rb +84 -0
- data/lib/decidim/rest_full/cli/create.rb +122 -0
- data/lib/decidim/rest_full/cli/delete.rb +48 -0
- data/lib/decidim/rest_full/cli/get.rb +53 -0
- data/lib/decidim/rest_full/cli/grant.rb +58 -0
- data/lib/decidim/rest_full/cli/revoke.rb +53 -0
- data/lib/decidim/rest_full/cli.rb +70 -0
- data/lib/decidim/rest_full/core/apartment_tenant_switch.rb +23 -0
- data/lib/decidim/rest_full/core/api_exception.rb +179 -0
- data/lib/decidim/rest_full/core/attachments_operations.rb +232 -0
- data/lib/decidim/rest_full/core/configuration.rb +116 -0
- data/lib/decidim/rest_full/core/definition_registry.rb +509 -0
- data/lib/decidim/rest_full/core/doorkeeper_config.rb +130 -0
- data/lib/decidim/rest_full/core/engine.rb +167 -0
- data/lib/decidim/rest_full/core/extended_data_at_path.rb +22 -0
- data/lib/decidim/rest_full/core/gem_spec_paths.rb +56 -0
- data/lib/decidim/rest_full/core/has_extended_data.rb +70 -0
- data/lib/decidim/rest_full/core/http_cache/collection_fingerprint.rb +97 -0
- data/lib/decidim/rest_full/core/http_cache/fingerprint_contributor_registry.rb +53 -0
- data/lib/decidim/rest_full/core/http_cache/request_oauth_context.rb +34 -0
- data/lib/decidim/rest_full/core/http_cache/resource_show_fingerprint.rb +74 -0
- data/lib/decidim/rest_full/core/menu.rb +18 -0
- data/lib/decidim/rest_full/core/module_availability.rb +181 -0
- data/lib/decidim/rest_full/core/open_api_definition_paths.rb +59 -0
- data/lib/decidim/rest_full/core/overrides/application_mailer_override.rb +50 -0
- data/lib/decidim/rest_full/core/overrides/organization_client_ids_override.rb +17 -0
- data/lib/decidim/rest_full/core/overrides/update_organization_command_override.rb +27 -0
- data/lib/decidim/rest_full/core/overrides/update_organization_form_override.rb +46 -0
- data/lib/decidim/rest_full/core/overrides/user_extended_data_ransack.rb +15 -0
- data/lib/decidim/rest_full/core/overrides/user_magic_token_override.rb +27 -0
- data/lib/decidim/rest_full/core/permission_registry.rb +65 -0
- data/lib/decidim/rest_full/core/ransackers.rb +99 -0
- data/lib/decidim/rest_full/core/rest_enhancement_builder.rb +115 -0
- data/lib/decidim/rest_full/core/rest_enhancement_registration.rb +21 -0
- data/lib/decidim/rest_full/core/roles/role_id_codec.rb +50 -0
- data/lib/decidim/rest_full/core/roles/roles_aggregator.rb +203 -0
- data/lib/decidim/rest_full/core/roles/roles_writer.rb +343 -0
- data/lib/decidim/rest_full/core/route_registry.rb +123 -0
- data/lib/decidim/rest_full/core/serializer_additions_registry.rb +100 -0
- data/lib/decidim/rest_full/core/settings_tab.rb +22 -0
- data/lib/decidim/rest_full/core/swagger_spec_paths.rb +61 -0
- data/lib/decidim/rest_full/core/tokens_availability.rb +23 -0
- data/lib/decidim/rest_full/core/webhook_dispatcher.rb +55 -0
- data/lib/decidim/rest_full/core/webhook_event_catalog.rb +136 -0
- data/lib/decidim/rest_full/extension.rb +276 -0
- data/lib/decidim/rest_full/rest_full.rb +12 -0
- data/lib/decidim/rest_full/routes.rb +58 -0
- data/lib/decidim/rest_full/routing.rb +53 -0
- data/lib/decidim/rest_full/sync_runner.rb +14 -0
- data/lib/decidim/rest_full/test/apartment.rb +52 -0
- data/lib/decidim/rest_full/test/definitions/README.md +96 -0
- data/lib/decidim/rest_full/test/definitions/attachment.rb +64 -0
- data/lib/decidim/rest_full/test/definitions/collection_meta.rb +20 -0
- data/lib/decidim/rest_full/test/definitions/component.rb +99 -0
- data/lib/decidim/rest_full/test/definitions/component_type.rb +8 -0
- data/lib/decidim/rest_full/test/definitions/core.rb +16 -0
- data/lib/decidim/rest_full/test/definitions/creation_date.rb +11 -0
- data/lib/decidim/rest_full/test/definitions/edition_date.rb +11 -0
- data/lib/decidim/rest_full/test/definitions/error.rb +40 -0
- data/lib/decidim/rest_full/test/definitions/filter_param.rb +105 -0
- data/lib/decidim/rest_full/test/definitions/grant_param.rb +82 -0
- data/lib/decidim/rest_full/test/definitions/health.rb +12 -0
- data/lib/decidim/rest_full/test/definitions/introspect_data.rb +67 -0
- data/lib/decidim/rest_full/test/definitions/job.rb +130 -0
- data/lib/decidim/rest_full/test/definitions/locales_param.rb +19 -0
- data/lib/decidim/rest_full/test/definitions/magic_link.rb +37 -0
- data/lib/decidim/rest_full/test/definitions/magic_link_redirect.rb +32 -0
- data/lib/decidim/rest_full/test/definitions/manifests.rb +28 -0
- data/lib/decidim/rest_full/test/definitions/oauth_token_response.rb +18 -0
- data/lib/decidim/rest_full/test/definitions/organization.rb +75 -0
- data/lib/decidim/rest_full/test/definitions/organization_extended_data.rb +19 -0
- data/lib/decidim/rest_full/test/definitions/publication_date.rb +11 -0
- data/lib/decidim/rest_full/test/definitions/relationship_identifier.rb +29 -0
- data/lib/decidim/rest_full/test/definitions/resource_extended_data.rb +20 -0
- data/lib/decidim/rest_full/test/definitions/role.rb +61 -0
- data/lib/decidim/rest_full/test/definitions/shared.rb +22 -0
- data/lib/decidim/rest_full/test/definitions/space.rb +112 -0
- data/lib/decidim/rest_full/test/definitions/tags/attachments_tag.rb +26 -0
- data/lib/decidim/rest_full/test/definitions/tags/component_tag.rb +26 -0
- data/lib/decidim/rest_full/test/definitions/tags/jobs_tag.rb +20 -0
- data/lib/decidim/rest_full/test/definitions/tags/oauth_tag.rb +28 -0
- data/lib/decidim/rest_full/test/definitions/tags/organization_extended_data_tag.rb +22 -0
- data/lib/decidim/rest_full/test/definitions/tags/organizations_tag.rb +24 -0
- data/lib/decidim/rest_full/test/definitions/tags/roles_tag.rb +14 -0
- data/lib/decidim/rest_full/test/definitions/tags/space_tag.rb +22 -0
- data/lib/decidim/rest_full/test/definitions/tags/users_tag.rb +14 -0
- data/lib/decidim/rest_full/test/definitions/tags/webhooks_tag.rb +31 -0
- data/lib/decidim/rest_full/test/definitions/tags.rb +12 -0
- data/lib/decidim/rest_full/test/definitions/time_zone.rb +10 -0
- data/lib/decidim/rest_full/test/definitions/translated_prop.rb +11 -0
- data/lib/decidim/rest_full/test/definitions/user.rb +93 -0
- data/lib/decidim/rest_full/test/definitions/user_extended_data.rb +14 -0
- data/lib/decidim/rest_full/test/definitions/webhook.rb +95 -0
- data/lib/decidim/rest_full/test/definitions.rb +15 -0
- data/lib/decidim/rest_full/test/factories/api_client.rb +16 -0
- data/lib/decidim/rest_full/test/factories/magic_token.rb +13 -0
- data/lib/decidim/rest_full/test/factories/webhook_registration.rb +10 -0
- data/lib/decidim/rest_full/test/factories.rb +5 -0
- data/lib/decidim/rest_full/test/global_context.rb +11 -0
- data/lib/decidim/rest_full/test/on_api_endpoint_methods.rb +190 -0
- data/lib/decidim/rest_full/test/open_api_tag_registry.rb +25 -0
- data/lib/decidim/rest_full/test/openapi_specs.rb +107 -0
- data/lib/decidim/rest_full/test/shared_examples/has_extended_data.rb +41 -0
- data/lib/decidim/rest_full/test/shared_examples.rb +345 -0
- data/lib/decidim/rest_full/version.rb +27 -0
- data/lib/decidim/rest_full.rb +99 -0
- data/lib/decidim-restfull-core.rb +3 -0
- data/lib/tasks/decidim/rest_full/fire_webhook.rake +52 -0
- data/lib/tasks/decidim/rest_full/integrator_sandbox.rake +37 -0
- data/lib/tasks/decidim/rest_full/rest_full_upgrade.rake +64 -0
- data/lib/tasks/decidim/rest_full/rest_full_webpacker.rake +58 -0
- data/spec/commands/decidim/rest_full/core/impersonate_resource_owner_from_credentials_spec.rb +159 -0
- data/spec/commands/decidim/rest_full/core/syncronize_unconfirmed_host_spec.rb +117 -0
- data/spec/controllers/concerns/decidim/api/rest_full/collection_pagination_spec.rb +128 -0
- data/spec/decidim/rest_full/core/configuration_engine_disabled_routes_spec.rb +24 -0
- data/spec/forms/decidim/rest_full/core/magic_link_redirect_url_form_spec.rb +69 -0
- data/spec/forms/decidim/rest_full/core/webhook_registration_form_spec.rb +42 -0
- data/spec/jobs/decidim/rest_full/core/space_webhook_job_spec.rb +62 -0
- data/spec/jobs/decidim/rest_full/core/syncronize_unconfirmed_host_job_spec.rb +34 -0
- data/spec/jobs/decidim/rest_full/core/webhook_job_spec.rb +29 -0
- data/spec/jobs/decidim/rest_full/execute_api_job_job_spec.rb +45 -0
- data/spec/lib/decidim/rest_full/core/apartment_tenant_switch_spec.rb +26 -0
- data/spec/lib/decidim/rest_full/core/api_exception/bad_request_spec.rb +62 -0
- data/spec/lib/decidim/rest_full/core/definition_registry_add_resource_relationships_spec.rb +19 -0
- data/spec/lib/decidim/rest_full/core/gem_spec_paths_spec.rb +27 -0
- data/spec/lib/decidim/rest_full/core/http_cache/collection_fingerprint_spec.rb +59 -0
- data/spec/lib/decidim/rest_full/core/http_cache/fingerprint_contributor_registry_spec.rb +60 -0
- data/spec/lib/decidim/rest_full/core/http_cache/resource_show_fingerprint_spec.rb +33 -0
- data/spec/lib/decidim/rest_full/core/module_availability_spec.rb +130 -0
- data/spec/lib/decidim/rest_full/core/open_api_definition_paths_spec.rb +54 -0
- data/spec/lib/decidim/rest_full/core/optional_feature_gems_spec.rb +172 -0
- data/spec/lib/decidim/rest_full/core/roles/role_id_codec_spec.rb +62 -0
- data/spec/lib/decidim/rest_full/core/roles/roles_aggregator_spec.rb +53 -0
- data/spec/lib/decidim/rest_full/core/roles/roles_writer_spec.rb +38 -0
- data/spec/lib/decidim/rest_full/core/route_registry_spec.rb +90 -0
- data/spec/lib/decidim/rest_full/core/serializer_additions_registry_spec.rb +100 -0
- data/spec/lib/decidim/rest_full/core/settings_tab_spec.rb +15 -0
- data/spec/lib/decidim/rest_full/core/swagger_spec_paths_spec.rb +50 -0
- data/spec/lib/decidim/rest_full/core/webhook_dispatcher_proposal_published_spec.rb +63 -0
- data/spec/lib/decidim/rest_full/core/webhook_event_catalog_spec.rb +34 -0
- data/spec/lib/decidim/rest_full/routing_spec.rb +62 -0
- data/spec/lib/decidim/rest_full/test/apartment_spec.rb +17 -0
- data/spec/models/decidim/rest_full/api_job_spec.rb +51 -0
- data/spec/models/decidim/rest_full/application_mailer_override_spec.rb +60 -0
- data/spec/models/decidim/rest_full/core/has_extended_data_spec.rb +16 -0
- data/spec/models/decidim/rest_full/core/magic_token_spec.rb +68 -0
- data/spec/models/decidim/rest_full/core/webhook_registration_spec.rb +161 -0
- data/spec/models/decidim/rest_full/user_magic_token_spec.rb +51 -0
- data/spec/requests/decidim/api/rest_full/application_controller_introspect_spec.rb +85 -0
- data/spec/requests/decidim/api/rest_full/application_controller_ropc_spec.rb +299 -0
- data/spec/requests/decidim/api/rest_full/application_controller_token_spec.rb +57 -0
- data/spec/requests/decidim/api/rest_full/attachments/attachments_controller_direct_upload_spec.rb +39 -0
- data/spec/requests/decidim/api/rest_full/attachments/attachments_controller_index_spec.rb +41 -0
- data/spec/requests/decidim/api/rest_full/attachments/attachments_controller_show_spec.rb +34 -0
- data/spec/requests/decidim/api/rest_full/components/component_extended_data_controller_spec.rb +78 -0
- data/spec/requests/decidim/api/rest_full/components/components_controller_search_spec.rb +197 -0
- data/spec/requests/decidim/api/rest_full/components/components_controller_search_sql_spec.rb +48 -0
- data/spec/requests/decidim/api/rest_full/jobs/api_jobs_async_and_conditional_get_spec.rb +209 -0
- data/spec/requests/decidim/api/rest_full/jobs/jobs_controller_destroy_spec.rb +58 -0
- data/spec/requests/decidim/api/rest_full/jobs/jobs_controller_index_spec.rb +126 -0
- data/spec/requests/decidim/api/rest_full/jobs/jobs_controller_show_spec.rb +89 -0
- data/spec/requests/decidim/api/rest_full/module_availability_gate_spec.rb +77 -0
- data/spec/requests/decidim/api/rest_full/organizations/organization_extended_data_controller_index_spec.rb +88 -0
- data/spec/requests/decidim/api/rest_full/organizations/organization_extended_data_controller_update_spec.rb +194 -0
- data/spec/requests/decidim/api/rest_full/organizations/organizations_controller_index_spec.rb +57 -0
- data/spec/requests/decidim/api/rest_full/organizations/organizations_controller_show_spec.rb +66 -0
- data/spec/requests/decidim/api/rest_full/organizations/organizations_controller_update_spec.rb +120 -0
- data/spec/requests/decidim/api/rest_full/roles/roles_controller_create_spec.rb +230 -0
- data/spec/requests/decidim/api/rest_full/roles/roles_controller_destroy_spec.rb +52 -0
- data/spec/requests/decidim/api/rest_full/roles/roles_controller_index_spec.rb +127 -0
- data/spec/requests/decidim/api/rest_full/roles/roles_controller_show_spec.rb +215 -0
- data/spec/requests/decidim/api/rest_full/routes_boot_spec.rb +58 -0
- data/spec/requests/decidim/api/rest_full/scenarios/upsert_user_by_phone_and_set_locale_spec.rb +69 -0
- data/spec/requests/decidim/api/rest_full/spaces/space_extended_data_controller_spec.rb +78 -0
- data/spec/requests/decidim/api/rest_full/spaces/spaces_controller_index_spec.rb +167 -0
- data/spec/requests/decidim/api/rest_full/spaces/spaces_controller_search_spec.rb +280 -0
- data/spec/requests/decidim/api/rest_full/spaces/spaces_controller_show_spec.rb +98 -0
- data/spec/requests/decidim/api/rest_full/users/magic_links_controller_create_spec.rb +124 -0
- data/spec/requests/decidim/api/rest_full/users/magic_links_controller_show_spec.rb +84 -0
- data/spec/requests/decidim/api/rest_full/users/user_extended_data_controller_index_spec.rb +74 -0
- data/spec/requests/decidim/api/rest_full/users/user_extended_data_controller_update_spec.rb +192 -0
- data/spec/requests/decidim/api/rest_full/users/users_controller_index_spec.rb +182 -0
- data/spec/requests/decidim/api/rest_full/webhooks/webhook_events_controller_show_spec.rb +52 -0
- data/spec/requests/decidim/api/rest_full/webhooks/webhook_registrations_controller_create_spec.rb +95 -0
- data/spec/requests/decidim/api/rest_full/webhooks/webhook_registrations_controller_destroy_spec.rb +34 -0
- data/spec/requests/decidim/api/rest_full/webhooks/webhook_registrations_controller_index_spec.rb +43 -0
- data/spec/requests/decidim/api/rest_full/webhooks/webhook_registrations_controller_show_spec.rb +51 -0
- data/spec/requests/decidim/api/rest_full/webhooks/webhook_registrations_controller_update_spec.rb +57 -0
- data/spec/requests/decidim/rest_full/system/api_clients_controller_spec.rb +69 -0
- data/spec/serializers/decidim/api/rest_full/core/organization_webhook_serializer_spec.rb +18 -0
- data/spec/serializers/decidim/api/rest_full/core/space_webhook_serializer_spec.rb +44 -0
- data/spec/serializers/decidim/api/rest_full/core/user_webhook_serializer_spec.rb +19 -0
- data/spec/services/decidim/rest_full/core/api_system_operations_resource_extended_data_update_spec.rb +35 -0
- data/spec/services/decidim/rest_full/core/fire_webhook_spec.rb +59 -0
- data/spec/services/decidim/rest_full/core/participatory_process_step_activated_webhook_handler_spec.rb +57 -0
- metadata +482 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "swagger_helper"
|
|
4
|
+
RSpec.describe Decidim::Api::RestFull::Users::UserExtendedDataController do
|
|
5
|
+
path "/me/extended_data/sync" do
|
|
6
|
+
put "Update user extended data" do
|
|
7
|
+
tags "Users"
|
|
8
|
+
produces "application/json"
|
|
9
|
+
security [{ resourceOwnerFlowBearer: ["oauth"] }]
|
|
10
|
+
operationId "setUserExtendedData"
|
|
11
|
+
description <<~README
|
|
12
|
+
The extended_data feature allows you to update a hash with recursive merging. Use the body payload with these keys:
|
|
13
|
+
|
|
14
|
+
1. `data`: The value or hash you want to update.
|
|
15
|
+
2. `object_path`: The dot-style path to the key (e.g., access.this.key).
|
|
16
|
+
|
|
17
|
+
**Root path**<br />
|
|
18
|
+
To update data from root of the hash, use `object_path="."`.
|
|
19
|
+
|
|
20
|
+
Example:
|
|
21
|
+
```
|
|
22
|
+
body={"data": {"name": "Jane"}, "object_path": "personnal"}
|
|
23
|
+
```
|
|
24
|
+
This recursively merges data into the hash without removing existing keys.
|
|
25
|
+
|
|
26
|
+
**Merge some data**<br />
|
|
27
|
+
Initial hash:
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"personnal": {"birthday": "1989-05-18"}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
Patch payload:
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"data": {
|
|
37
|
+
"name": "Jane"
|
|
38
|
+
},
|
|
39
|
+
"object_path": "personnal"
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
Result:
|
|
43
|
+
```
|
|
44
|
+
{
|
|
45
|
+
"personnal": {"birthday": "1989-05-18", "name": "Jane"}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Create new Paths**<br />
|
|
50
|
+
Paths are created as needed.
|
|
51
|
+
Exemple:
|
|
52
|
+
```json
|
|
53
|
+
body = {"data": {"external_user_id": 12}, "object_path": "data-store.my-app.foo"}
|
|
54
|
+
```
|
|
55
|
+
Result:
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"personnal": {"birthday": "1989-05-18"},
|
|
59
|
+
"data-store": {"my-app": {"foo": {"external_user_id": 12}}}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
Alternatively:
|
|
63
|
+
```
|
|
64
|
+
body = {"data": 12, "object_path": "data-store.my-app.foo.external_user_id"}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Remove a key**<br />
|
|
68
|
+
Set a key to null or an empty value to remove it.
|
|
69
|
+
|
|
70
|
+
Example: Initial hash:
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"personnal": {"birthday": "1989-05-18", "name": "Jane"}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
Patch:
|
|
77
|
+
```json
|
|
78
|
+
body = {"data": {"birthday": ""}, "object_path": "personnal"}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Result:
|
|
82
|
+
```
|
|
83
|
+
{
|
|
84
|
+
"personnal": {"name": "Jane"}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Return Value**<br />
|
|
89
|
+
The update request returns the updated value at the specified path.
|
|
90
|
+
|
|
91
|
+
README
|
|
92
|
+
parameter name: :body, in: :body, required: true, schema: {
|
|
93
|
+
type: :object,
|
|
94
|
+
title: "User Extended Data Payload",
|
|
95
|
+
properties: {
|
|
96
|
+
data: { type: :object, title: "User Extended Data Data", description: "New value for the extended data at the given path" },
|
|
97
|
+
object_path: { type: :string, description: "object path, in dot style, like foo.bar. use '.' to update the whole user data" }
|
|
98
|
+
}, required: [:data]
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
describe_api_endpoint(
|
|
102
|
+
controller: Decidim::Api::RestFull::Users::UserExtendedDataController,
|
|
103
|
+
action: :update_sync,
|
|
104
|
+
security_types: [:impersonationFlow],
|
|
105
|
+
scopes: ["oauth"],
|
|
106
|
+
permissions: ["oauth.extended_data.update"]
|
|
107
|
+
) do
|
|
108
|
+
let(:body) { { data: { "foo" => "bar" }, object_path: "." } }
|
|
109
|
+
|
|
110
|
+
response "200", "Update extended data value" do
|
|
111
|
+
consumes "application/json"
|
|
112
|
+
produces "application/json"
|
|
113
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:user_extended_data)
|
|
114
|
+
|
|
115
|
+
context "with root path '.'" do
|
|
116
|
+
let(:user) { create(:user, locale: "fr", organization:, extended_data: { "foo" => { "bar" => "true" } }) }
|
|
117
|
+
|
|
118
|
+
run_test!(example_name: :ok) do |example|
|
|
119
|
+
data = JSON.parse(example.body)["data"]
|
|
120
|
+
expect(response).to have_http_status(:ok)
|
|
121
|
+
expect(data).to eq(body[:data])
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
context "with a path given" do
|
|
126
|
+
let(:user) { create(:user, locale: "fr", organization:, extended_data: { "personal" => { "birthday" => "1989-01-28" } }) }
|
|
127
|
+
let(:body) { { data: "1990-02-09", object_path: "personal.birthday" } }
|
|
128
|
+
|
|
129
|
+
run_test! do |example|
|
|
130
|
+
data = JSON.parse(example.body)["data"]
|
|
131
|
+
expect(response).to have_http_status(:ok)
|
|
132
|
+
expect(data).to include("1990-02-09")
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
context "with a path given and merging data" do
|
|
137
|
+
let(:user) { create(:user, locale: "fr", organization:, extended_data: { "personal" => { "birthday" => "1989-01-28" } }) }
|
|
138
|
+
let(:body) { { data: { "name" => "Jeanne" }, object_path: "personal" } }
|
|
139
|
+
|
|
140
|
+
run_test! do |example|
|
|
141
|
+
JSON.parse(example.body)["data"]
|
|
142
|
+
user.reload
|
|
143
|
+
expect(response).to have_http_status(:ok)
|
|
144
|
+
expect(user.extended_data["personal"]).to include({ "name" => "Jeanne", "birthday" => "1989-01-28" })
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
context "with a path given and unsetting data" do
|
|
149
|
+
let(:user) { create(:user, locale: "fr", organization:, extended_data: { "personal" => { "birthday" => "1989-01-28", "name" => "Jeanne" } }) }
|
|
150
|
+
let(:body) { { data: { "name" => nil }, object_path: "personal" } }
|
|
151
|
+
|
|
152
|
+
run_test! do |example|
|
|
153
|
+
JSON.parse(example.body)["data"]
|
|
154
|
+
user.reload
|
|
155
|
+
expect(response).to have_http_status(:ok)
|
|
156
|
+
expect(user.extended_data["personal"].keys).to eq(["birthday"])
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
context "when clearing the last key under a path" do
|
|
161
|
+
let(:user) { create(:user, locale: "fr", organization:, extended_data: { "learn" => { "cursor" => "abc" } }) }
|
|
162
|
+
let(:body) { { data: { "cursor" => nil }, object_path: "learn" } }
|
|
163
|
+
|
|
164
|
+
run_test! do |example|
|
|
165
|
+
data = JSON.parse(example.body)["data"]
|
|
166
|
+
user.reload
|
|
167
|
+
expect(response).to have_http_status(:ok)
|
|
168
|
+
expect(data).to eq({})
|
|
169
|
+
expect(user.extended_data).not_to have_key("learn")
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
context "with a path=unknown, upsert" do
|
|
174
|
+
let(:user) { create(:user, locale: "fr", organization:, extended_data: { "personal" => { "birthday" => "1989-01-28" } }) }
|
|
175
|
+
let(:body) { { data: { "whatever" => { "is" => { "stil" => "ok" } } }, object_path: "unknown" } }
|
|
176
|
+
|
|
177
|
+
run_test! do |example|
|
|
178
|
+
user.reload
|
|
179
|
+
data = JSON.parse(example.body)["data"]
|
|
180
|
+
expect(response).to have_http_status(:ok)
|
|
181
|
+
expect(data).to include(body[:data])
|
|
182
|
+
expect(user.extended_data).to eq({
|
|
183
|
+
"personal" => { "birthday" => "1989-01-28" },
|
|
184
|
+
"unknown" => { "whatever" => { "is" => { "stil" => "ok" } } }
|
|
185
|
+
})
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
end
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "swagger_helper"
|
|
4
|
+
RSpec.describe Decidim::Api::RestFull::Users::UsersController do
|
|
5
|
+
path "/users" do
|
|
6
|
+
get "List available Users" do
|
|
7
|
+
tags "Users"
|
|
8
|
+
produces "application/json"
|
|
9
|
+
operationId "listUsers"
|
|
10
|
+
description "List or search users of the organization"
|
|
11
|
+
it_behaves_like "paginated params"
|
|
12
|
+
it_behaves_like "filtered params", filter: "nickname", item_schema: { type: :string }, only: :string
|
|
13
|
+
it_behaves_like "filtered params", filter: "id", item_schema: { type: :integer }, only: :integer
|
|
14
|
+
parameter name: :"filter[extended_data_cont]",
|
|
15
|
+
schema: { type: :string },
|
|
16
|
+
in: :query,
|
|
17
|
+
required: false,
|
|
18
|
+
example: '"foo": "bar"',
|
|
19
|
+
description: 'Search on user extended_data. use the format: `"<key>":<space>"<value>"`'
|
|
20
|
+
|
|
21
|
+
describe_api_endpoint(
|
|
22
|
+
controller: Decidim::Api::RestFull::Users::UsersController,
|
|
23
|
+
action: :index,
|
|
24
|
+
security_types: [:credentialFlow],
|
|
25
|
+
scopes: ["oauth"],
|
|
26
|
+
permissions: ["oauth.read"]
|
|
27
|
+
) do
|
|
28
|
+
response "200", "Users listed" do
|
|
29
|
+
consumes "application/json"
|
|
30
|
+
produces "application/json"
|
|
31
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:user_index_response)
|
|
32
|
+
|
|
33
|
+
context "with no params" do
|
|
34
|
+
before do
|
|
35
|
+
create(:user, organization:)
|
|
36
|
+
create_list(:user, 5, organization:)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
run_test!(example_name: :ok)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
context "with per_page" do
|
|
43
|
+
let(:per_page) { 3 }
|
|
44
|
+
let(:page) { 1 }
|
|
45
|
+
|
|
46
|
+
before { create_list(:user, 5, organization:) }
|
|
47
|
+
|
|
48
|
+
run_test!(example_name: :ok_paginated) do |example|
|
|
49
|
+
data = JSON.parse(example.body)["data"]
|
|
50
|
+
expect(data.size).to eq(3)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
context "with locale" do
|
|
55
|
+
before do
|
|
56
|
+
create(:user, locale: "fr", organization:)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
run_test!(example_name: :user_fr) do |example|
|
|
60
|
+
data = JSON.parse(example.body)["data"]
|
|
61
|
+
expect(data.first["attributes"]["locale"]).to eq("fr")
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
context "without oauth.extended_data.read permission" do
|
|
66
|
+
context "and return empty extended_data" do
|
|
67
|
+
before do
|
|
68
|
+
create(:user, nickname: "specific-data", extended_data: { "key.path.is.awesome" => "bar" }, organization:)
|
|
69
|
+
create_list(:user, 5, organization:)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
run_test! do |example|
|
|
73
|
+
data = JSON.parse(example.body)["data"]
|
|
74
|
+
expect(data.reject { |d| d["attributes"]["extended_data"].empty? }).to be_empty
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
context "with oauth.extended_data.read permission" do
|
|
80
|
+
let(:api_client) do
|
|
81
|
+
api_client = create(:api_client, organization:, scopes: "oauth")
|
|
82
|
+
api_client.permissions = [
|
|
83
|
+
api_client.permissions.build(permission: "oauth.read"),
|
|
84
|
+
api_client.permissions.build(permission: "oauth.extended_data.read")
|
|
85
|
+
]
|
|
86
|
+
api_client.save!
|
|
87
|
+
api_client
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
context "with filter[extended_data_cont] results" do
|
|
91
|
+
before do
|
|
92
|
+
create(:user, nickname: "specific-data", extended_data: { "key" => { "is" => "awesome" } }, organization:)
|
|
93
|
+
create_list(:user, 5, organization:)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
let(:"filter[extended_data_cont]") do
|
|
97
|
+
'"key": {"is": "awesome"}'
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
run_test!(example_name: :filtered_by_extended_data) do |example|
|
|
101
|
+
data = JSON.parse(example.body)["data"]
|
|
102
|
+
expect(data.size).to eq(1)
|
|
103
|
+
expect(data.first["attributes"]["nickname"]).to eq("specific-data")
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
context "with filter[extended_data_cont], no results" do
|
|
108
|
+
before do
|
|
109
|
+
create(:user, nickname: "specific-data", extended_data: { foo: "404" }, organization:)
|
|
110
|
+
create_list(:user, 5, organization:)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
let(:"filter[extended_data_cont]") do
|
|
114
|
+
'"foo": "bar"'
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
run_test!(example_name: :filtered_by_extended_data) do |example|
|
|
118
|
+
data = JSON.parse(example.body)["data"]
|
|
119
|
+
expect(data.size).to eq(0)
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
context "with filter[id_in][] in a list of 5 ids" do
|
|
125
|
+
let(:user_list) { create_list(:user, 5, organization:) }
|
|
126
|
+
let(:"filter[id_in][]") { user_list.map(&:id) }
|
|
127
|
+
|
|
128
|
+
run_test!(example_name: :filtered_by_id_in) do |example|
|
|
129
|
+
data = JSON.parse(example.body)["data"]
|
|
130
|
+
expect(data.size).to eq(5)
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
context "with filter[nickname_eq]" do
|
|
135
|
+
before do
|
|
136
|
+
create(:user, nickname: "blue-panda-218", organization:)
|
|
137
|
+
create_list(:user, 5, organization:)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
let(:"filter[nickname_eq]") { "blue-panda-218" }
|
|
141
|
+
let(:page) { 1 }
|
|
142
|
+
let(:per_page) { 2 }
|
|
143
|
+
|
|
144
|
+
run_test!(example_name: :filtered_by_nickname) do |example|
|
|
145
|
+
data = JSON.parse(example.body)["data"]
|
|
146
|
+
expect(data.size).to eq(1)
|
|
147
|
+
expect(data.first["attributes"]["nickname"]).to eq("blue-panda-218")
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
it_behaves_like "paginated endpoint" do
|
|
152
|
+
let(:create_resource) { -> { create(:user, organization:) } }
|
|
153
|
+
let(:each_resource) { ->(_resource, _index) {} }
|
|
154
|
+
let(:resources) { Decidim::User.all }
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
response "403", "Forbidden" do
|
|
159
|
+
produces "application/json"
|
|
160
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:error_response)
|
|
161
|
+
context "with extended_data_cont" do
|
|
162
|
+
before do
|
|
163
|
+
create(:user, nickname: "specific-data", extended_data: { foo: "bar" }, organization:)
|
|
164
|
+
create_list(:user, 5, organization:)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
let(:"filter[extended_data_cont]") do
|
|
168
|
+
'"foo": "bar"'
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
run_test! do |_example|
|
|
172
|
+
expect(response).to have_http_status(:forbidden)
|
|
173
|
+
expect(response.body).to include("Forbidden")
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
it_behaves_like "unauthorized when no Bearer token"
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "swagger_helper"
|
|
4
|
+
|
|
5
|
+
RSpec.describe Decidim::Api::RestFull::Webhooks::WebhookEventsController do
|
|
6
|
+
path "/webhook_events/{event_type}" do
|
|
7
|
+
get "Show webhook event example payload" do
|
|
8
|
+
tags "Webhooks"
|
|
9
|
+
produces "application/json"
|
|
10
|
+
operationId "showWebhookEventExample"
|
|
11
|
+
description <<~README
|
|
12
|
+
Returns an example delivery envelope for the given event type, built by serializing a real
|
|
13
|
+
resource in the current organization (same serializers used for outbound delivery).
|
|
14
|
+
README
|
|
15
|
+
parameter name: :event_type, in: :path, type: :string, required: true,
|
|
16
|
+
description: "Event key (e.g. proposal_creation.succeeded)"
|
|
17
|
+
|
|
18
|
+
describe_api_endpoint(
|
|
19
|
+
controller: Decidim::Api::RestFull::Webhooks::WebhookEventsController,
|
|
20
|
+
action: :show,
|
|
21
|
+
security_types: [:credentialFlow],
|
|
22
|
+
scopes: ["webhooks"],
|
|
23
|
+
permissions: ["webhooks.read"]
|
|
24
|
+
) do
|
|
25
|
+
let(:event_type) { "proposal_creation.succeeded" }
|
|
26
|
+
let!(:participatory_process) { create(:participatory_process, :with_steps, organization:) }
|
|
27
|
+
let!(:component) { create(:proposal_component, participatory_space: participatory_process) }
|
|
28
|
+
let!(:proposal) { create(:proposal, :published, component:) }
|
|
29
|
+
|
|
30
|
+
response "200", "Example payload" do
|
|
31
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:webhook_delivery_envelope)
|
|
32
|
+
|
|
33
|
+
run_test!(example_name: :ok) do |example|
|
|
34
|
+
body = JSON.parse(example.body)
|
|
35
|
+
expect(body["type"]).to eq("proposal_creation.succeeded")
|
|
36
|
+
expect(body["data"]["type"]).to eq("proposal")
|
|
37
|
+
expect(body["data"]["id"]).to eq(proposal.id.to_s)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
response "404", "Unknown event" do
|
|
42
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:error_response)
|
|
43
|
+
let(:event_type) { "does.not.exist" }
|
|
44
|
+
|
|
45
|
+
run_test!(example_name: :not_found) do
|
|
46
|
+
expect(response).to have_http_status(:not_found)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
data/spec/requests/decidim/api/rest_full/webhooks/webhook_registrations_controller_create_spec.rb
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "swagger_helper"
|
|
4
|
+
|
|
5
|
+
RSpec.describe Decidim::Api::RestFull::Webhooks::WebhookRegistrationsController do
|
|
6
|
+
path "/webhook_registrations" do
|
|
7
|
+
post "Create webhook registration" do
|
|
8
|
+
tags "Webhooks"
|
|
9
|
+
produces "application/json"
|
|
10
|
+
consumes "application/json"
|
|
11
|
+
operationId "createWebhookRegistration"
|
|
12
|
+
description <<~README
|
|
13
|
+
Create a webhook registration for the current API client.
|
|
14
|
+
The signing secret is returned **only in this response** — store it to verify HMAC signatures.
|
|
15
|
+
Subscriptions must be event permissions already granted on the API client.
|
|
16
|
+
README
|
|
17
|
+
parameter name: :body, in: :body, required: true,
|
|
18
|
+
schema: { "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:webhook_registration_create_body) }
|
|
19
|
+
|
|
20
|
+
describe_api_endpoint(
|
|
21
|
+
controller: Decidim::Api::RestFull::Webhooks::WebhookRegistrationsController,
|
|
22
|
+
action: :create,
|
|
23
|
+
security_types: [:credentialFlow],
|
|
24
|
+
scopes: ["webhooks"],
|
|
25
|
+
permissions: ["webhooks.write"]
|
|
26
|
+
) do
|
|
27
|
+
let(:event_key) { "proposal_creation.succeeded" }
|
|
28
|
+
let(:body) do
|
|
29
|
+
{
|
|
30
|
+
data: {
|
|
31
|
+
attributes: {
|
|
32
|
+
url: "https://example.org/hooks/new",
|
|
33
|
+
subscriptions: [event_key]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
before do
|
|
40
|
+
api_client.permissions.create!(permission: event_key, is_event: true)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
response "201", "Registration created" do
|
|
44
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:webhook_registration_item_response)
|
|
45
|
+
|
|
46
|
+
run_test!(example_name: :ok) do |example|
|
|
47
|
+
data = JSON.parse(example.body)["data"]
|
|
48
|
+
expect(data["attributes"]["url"]).to eq("https://example.org/hooks/new")
|
|
49
|
+
expect(data["attributes"]["subscriptions"]).to eq([event_key])
|
|
50
|
+
expect(data["attributes"]["signing_secret"]).to be_present
|
|
51
|
+
expect(data["attributes"]["signing_secret"].length).to eq(64)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
response "201", "Registration created with http URL" do
|
|
56
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:webhook_registration_item_response)
|
|
57
|
+
let(:body) do
|
|
58
|
+
{
|
|
59
|
+
data: {
|
|
60
|
+
attributes: {
|
|
61
|
+
url: "http://internal.example/hooks/new",
|
|
62
|
+
subscriptions: [event_key]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
run_test!(example_name: :ok_http) do |example|
|
|
69
|
+
data = JSON.parse(example.body)["data"]
|
|
70
|
+
expect(data["attributes"]["url"]).to eq("http://internal.example/hooks/new")
|
|
71
|
+
expect(data["attributes"]["signing_secret"]).to be_present
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
response "400", "Invalid subscription" do
|
|
76
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:error_response)
|
|
77
|
+
let(:body) do
|
|
78
|
+
{
|
|
79
|
+
data: {
|
|
80
|
+
attributes: {
|
|
81
|
+
url: "https://example.org/hooks/bad",
|
|
82
|
+
subscriptions: ["not.an.event"]
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
run_test!(example_name: :bad_request) do
|
|
89
|
+
expect(response).to have_http_status(:bad_request)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
data/spec/requests/decidim/api/rest_full/webhooks/webhook_registrations_controller_destroy_spec.rb
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "swagger_helper"
|
|
4
|
+
|
|
5
|
+
RSpec.describe Decidim::Api::RestFull::Webhooks::WebhookRegistrationsController do
|
|
6
|
+
path "/webhook_registrations/{id}" do
|
|
7
|
+
delete "Delete webhook registration" do
|
|
8
|
+
tags "Webhooks"
|
|
9
|
+
produces "application/json"
|
|
10
|
+
operationId "deleteWebhookRegistration"
|
|
11
|
+
parameter name: :id, in: :path, type: :string, required: true
|
|
12
|
+
|
|
13
|
+
describe_api_endpoint(
|
|
14
|
+
controller: Decidim::Api::RestFull::Webhooks::WebhookRegistrationsController,
|
|
15
|
+
action: :destroy,
|
|
16
|
+
security_types: [:credentialFlow],
|
|
17
|
+
scopes: ["webhooks"],
|
|
18
|
+
permissions: ["webhooks.destroy"]
|
|
19
|
+
) do
|
|
20
|
+
let!(:webhook_registration) do
|
|
21
|
+
create(:webhook_registration, api_client:, url: "https://example.org/hooks/delete")
|
|
22
|
+
end
|
|
23
|
+
let(:id) { webhook_registration.id }
|
|
24
|
+
|
|
25
|
+
response "204", "Registration deleted" do
|
|
26
|
+
run_test!(example_name: :ok) do
|
|
27
|
+
expect(response).to have_http_status(:no_content)
|
|
28
|
+
expect(Decidim::RestFull::Core::WebhookRegistration.find_by(id: webhook_registration.id)).to be_nil
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
data/spec/requests/decidim/api/rest_full/webhooks/webhook_registrations_controller_index_spec.rb
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "swagger_helper"
|
|
4
|
+
|
|
5
|
+
RSpec.describe Decidim::Api::RestFull::Webhooks::WebhookRegistrationsController do
|
|
6
|
+
path "/webhook_registrations" do
|
|
7
|
+
get "List webhook registrations" do
|
|
8
|
+
tags "Webhooks"
|
|
9
|
+
produces "application/json"
|
|
10
|
+
operationId "listWebhookRegistrations"
|
|
11
|
+
description "List webhook registrations owned by the current API client."
|
|
12
|
+
it_behaves_like "paginated params"
|
|
13
|
+
|
|
14
|
+
describe_api_endpoint(
|
|
15
|
+
controller: Decidim::Api::RestFull::Webhooks::WebhookRegistrationsController,
|
|
16
|
+
action: :index,
|
|
17
|
+
security_types: [:credentialFlow],
|
|
18
|
+
scopes: ["webhooks"],
|
|
19
|
+
permissions: ["webhooks.read"]
|
|
20
|
+
) do
|
|
21
|
+
let!(:webhook_registration) do
|
|
22
|
+
create(:webhook_registration, api_client:, url: "https://example.org/hooks/mine")
|
|
23
|
+
end
|
|
24
|
+
let!(:other_client) { create(:api_client, organization:, scopes: ["webhooks"]) }
|
|
25
|
+
let!(:other_registration) do
|
|
26
|
+
create(:webhook_registration, api_client: other_client, url: "https://example.org/hooks/other")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
response "200", "Registrations listed" do
|
|
30
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:webhook_registration_index_response)
|
|
31
|
+
|
|
32
|
+
run_test!(example_name: :ok) do |example|
|
|
33
|
+
data = JSON.parse(example.body)["data"]
|
|
34
|
+
ids = data.map { |d| d["id"] }
|
|
35
|
+
expect(ids).to include(webhook_registration.id.to_s)
|
|
36
|
+
expect(ids).not_to include(other_registration.id.to_s)
|
|
37
|
+
expect(data.first["attributes"]).not_to have_key("signing_secret")
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
data/spec/requests/decidim/api/rest_full/webhooks/webhook_registrations_controller_show_spec.rb
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "swagger_helper"
|
|
4
|
+
|
|
5
|
+
RSpec.describe Decidim::Api::RestFull::Webhooks::WebhookRegistrationsController do
|
|
6
|
+
path "/webhook_registrations/{id}" do
|
|
7
|
+
get "Show webhook registration" do
|
|
8
|
+
tags "Webhooks"
|
|
9
|
+
produces "application/json"
|
|
10
|
+
operationId "showWebhookRegistration"
|
|
11
|
+
parameter name: :id, in: :path, type: :string, required: true
|
|
12
|
+
|
|
13
|
+
describe_api_endpoint(
|
|
14
|
+
controller: Decidim::Api::RestFull::Webhooks::WebhookRegistrationsController,
|
|
15
|
+
action: :show,
|
|
16
|
+
security_types: [:credentialFlow],
|
|
17
|
+
scopes: ["webhooks"],
|
|
18
|
+
permissions: ["webhooks.read"]
|
|
19
|
+
) do
|
|
20
|
+
let!(:webhook_registration) do
|
|
21
|
+
create(:webhook_registration, api_client:, url: "https://example.org/hooks/show")
|
|
22
|
+
end
|
|
23
|
+
let(:id) { webhook_registration.id }
|
|
24
|
+
|
|
25
|
+
response "200", "Registration found" do
|
|
26
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:webhook_registration_item_response)
|
|
27
|
+
|
|
28
|
+
run_test!(example_name: :ok) do |example|
|
|
29
|
+
data = JSON.parse(example.body)["data"]
|
|
30
|
+
expect(data["id"]).to eq(webhook_registration.id.to_s)
|
|
31
|
+
expect(data["attributes"]["url"]).to eq("https://example.org/hooks/show")
|
|
32
|
+
expect(data["attributes"]).not_to have_key("signing_secret")
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
response "404", "Not found for another API client" do
|
|
37
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:error_response)
|
|
38
|
+
let!(:other_client) { create(:api_client, organization:, scopes: ["webhooks"]) }
|
|
39
|
+
let!(:other_registration) do
|
|
40
|
+
create(:webhook_registration, api_client: other_client, url: "https://example.org/hooks/foreign")
|
|
41
|
+
end
|
|
42
|
+
let(:id) { other_registration.id }
|
|
43
|
+
|
|
44
|
+
run_test!(example_name: :not_found_other_client) do
|
|
45
|
+
expect(response).to have_http_status(:not_found)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|