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,190 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module RestFull
|
|
5
|
+
module Test
|
|
6
|
+
module OnApiEndpointMethods
|
|
7
|
+
def on_security(flow_type)
|
|
8
|
+
raise "Security type is nil" if Decidim::RestFull::Test::GlobalContext.security_type.nil?
|
|
9
|
+
|
|
10
|
+
yield if Decidim::RestFull::Test::GlobalContext.security_type == flow_type
|
|
11
|
+
nil
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def describe_api_endpoint(options = {}, &)
|
|
15
|
+
rest_full_validate_options!(options)
|
|
16
|
+
scopes = options[:scopes].map(&:to_s)
|
|
17
|
+
security_types = options[:security_types]
|
|
18
|
+
is_protected = options.fetch(:is_protected, true)
|
|
19
|
+
|
|
20
|
+
# Bearer auth is documented via OpenAPI securitySchemes (credentialFlowBearer / resourceOwnerFlowBearer).
|
|
21
|
+
# RSwag request specs still need an explicit Authorization header parameter so
|
|
22
|
+
# let(:Authorization) is wired into the Rack request (securitySchemes alone do not).
|
|
23
|
+
|
|
24
|
+
# Prepare host for the request
|
|
25
|
+
rest_full_setup_api_context!(options)
|
|
26
|
+
|
|
27
|
+
security_types.each do |security_type_item|
|
|
28
|
+
Decidim::RestFull::Test::GlobalContext.security_type = security_type_item
|
|
29
|
+
|
|
30
|
+
rest_full_validate_security_type!(security_type_item)
|
|
31
|
+
context "when #{security_type_item}" do
|
|
32
|
+
let(:security_type) { security_type_item }
|
|
33
|
+
let(:Authorization) { "Bearer #{bearer_token.token}" }
|
|
34
|
+
|
|
35
|
+
parameter name: :Authorization, in: :header, schema: { type: :string }, required: false,
|
|
36
|
+
description: "Bearer access token (see security schemes)"
|
|
37
|
+
|
|
38
|
+
before do
|
|
39
|
+
Decidim::RestFull::Test::GlobalContext.security_type = security_type_item
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Prepare security for the request (api_client and bearer_token)
|
|
43
|
+
rest_full_setup_credential_flow!(scopes, is_protected) if security_type_item == :credentialFlow
|
|
44
|
+
rest_full_setup_resource_owner_flow!(scopes, is_protected) if security_type_item == :impersonationFlow
|
|
45
|
+
|
|
46
|
+
rest_full_handle_forbidden(security_type_item, options) if is_protected
|
|
47
|
+
rest_full_handle_500_error(options)
|
|
48
|
+
instance_eval(&)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
def rest_full_validate_options!(options)
|
|
56
|
+
[:controller, :action, :scopes, :security_types].each do |key|
|
|
57
|
+
raise ArgumentError, "Missing option `#{key}`" unless options[key]
|
|
58
|
+
end
|
|
59
|
+
scopes = options[:scopes]
|
|
60
|
+
raise ArgumentError, "scopes option must be an array" unless scopes.is_a?(Array)
|
|
61
|
+
|
|
62
|
+
permissions = options[:permissions]
|
|
63
|
+
raise ArgumentError, "permissions option must be an array" unless permissions.is_a?(Array)
|
|
64
|
+
|
|
65
|
+
security_types = options[:security_types]
|
|
66
|
+
raise ArgumentError, "security_types option must be an array" unless security_types.is_a?(Array)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def rest_full_setup_api_context!(options)
|
|
70
|
+
scopes = options[:scopes].map(&:to_s)
|
|
71
|
+
permissions = options[:permissions].map(&:to_s)
|
|
72
|
+
|
|
73
|
+
let!(:organization) { create(:organization, available_locales: ["en"]) }
|
|
74
|
+
before do
|
|
75
|
+
host! organization.host
|
|
76
|
+
https!
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
let(:api_client) do
|
|
80
|
+
api_client = create(:api_client, organization:, scopes:)
|
|
81
|
+
api_client.permissions = permissions.map do |permission|
|
|
82
|
+
api_client.permissions.build(permission:)
|
|
83
|
+
end
|
|
84
|
+
api_client.save!
|
|
85
|
+
api_client
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def rest_full_validate_security_type!(security_type)
|
|
90
|
+
security_type_options = [:credentialFlow, :impersonationFlow]
|
|
91
|
+
unless security_type_options.include?(security_type)
|
|
92
|
+
suggestions = DidYouMean::SpellChecker.new(dictionary: security_type_options).correct(security_type)
|
|
93
|
+
message = "Invalid security type `#{security_type}`. Must be one of: #{security_type_options.join(", ")}"
|
|
94
|
+
message += ". Did you mean: #{suggestions.map { |s| "`#{s}`" }.join(", ")} ?" if suggestions.any?
|
|
95
|
+
raise ArgumentError, message
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def rest_full_bearer_credential_flow!(scopes)
|
|
100
|
+
let!(:bearer_token) { create(:oauth_access_token, scopes: scopes.join(" "), resource_owner_id: nil, application: api_client) }
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def rest_full_bearer_resource_owner_flow!(scopes)
|
|
104
|
+
let(:user) { create(:user, locale: "fr", organization:, confirmed_at: Time.zone.now) }
|
|
105
|
+
let!(:bearer_token) { create(:oauth_access_token, scopes: scopes.join(" "), resource_owner_id: user.id, application: api_client) }
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def rest_full_setup_credential_flow!(scopes, is_protected)
|
|
109
|
+
rest_full_bearer_credential_flow!(scopes)
|
|
110
|
+
security is_protected ? [{ credentialFlowBearer: scopes }] : []
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def rest_full_setup_resource_owner_flow!(scopes, is_protected)
|
|
114
|
+
rest_full_bearer_resource_owner_flow!(scopes)
|
|
115
|
+
security is_protected ? [{ resourceOwnerFlowBearer: scopes }] : []
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def rest_full_handle_forbidden_scopes(security_type, options)
|
|
119
|
+
scopes = options[:scopes].map(&:to_s)
|
|
120
|
+
available_scopes = %w(public oauth blogs proposals users roles)
|
|
121
|
+
response "403", "Forbidden" do
|
|
122
|
+
produces "application/json"
|
|
123
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:error_response)
|
|
124
|
+
scopes.each do |scope|
|
|
125
|
+
wrong_scope = available_scopes.find { |s| scopes.exclude?(s) && s != scope }
|
|
126
|
+
context "with invalid `#{wrong_scope}` scope" do
|
|
127
|
+
rest_full_bearer_resource_owner_flow!([wrong_scope]) if security_type == :impersonationFlow
|
|
128
|
+
rest_full_bearer_credential_flow!([wrong_scope]) if security_type == :credentialFlow
|
|
129
|
+
run_test!(example_name: :"forbidden_#{security_type}") do |_example|
|
|
130
|
+
expect(response).to have_http_status(:forbidden)
|
|
131
|
+
expect(response.body).to include("Forbidden")
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def rest_full_handle_forbidden_permissions(security_type, options)
|
|
139
|
+
scopes = options[:scopes].map(&:to_s)
|
|
140
|
+
permissions = options[:permissions].map(&:to_s)
|
|
141
|
+
|
|
142
|
+
response "403", "Forbidden" do
|
|
143
|
+
produces "application/json"
|
|
144
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:error_response)
|
|
145
|
+
permissions.each do |permission|
|
|
146
|
+
context "without #{permission} permission" do
|
|
147
|
+
let(:api_client) { create(:api_client, organization:, scopes:) }
|
|
148
|
+
|
|
149
|
+
rest_full_bearer_resource_owner_flow!(scopes) if security_type == :impersonationFlow
|
|
150
|
+
rest_full_bearer_credential_flow!(scopes) if security_type == :credentialFlow
|
|
151
|
+
run_test! do |_example|
|
|
152
|
+
expect(response).to have_http_status(:forbidden)
|
|
153
|
+
expect(response.body).to include("Forbidden")
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def rest_full_handle_forbidden(security_type, options)
|
|
161
|
+
rest_full_handle_forbidden_scopes(security_type, options)
|
|
162
|
+
rest_full_handle_forbidden_permissions(security_type, options)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def rest_full_handle_500_error(options)
|
|
166
|
+
action = options[:action]
|
|
167
|
+
controller = options[:controller]
|
|
168
|
+
|
|
169
|
+
response "500", "Internal Server Error" do
|
|
170
|
+
consumes "application/json"
|
|
171
|
+
produces "application/json"
|
|
172
|
+
|
|
173
|
+
before do
|
|
174
|
+
controller_instance = controller.new
|
|
175
|
+
allow(controller_instance).to receive(action).and_raise(StandardError.new("Intentional error for testing"))
|
|
176
|
+
allow(controller).to receive(:new).and_return(controller_instance)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:error_response)
|
|
180
|
+
|
|
181
|
+
run_test! do |response|
|
|
182
|
+
expect(response.status).to eq(500)
|
|
183
|
+
expect(response.body).to include("Internal Server Error")
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module RestFull
|
|
5
|
+
module Test
|
|
6
|
+
# Optional Swagger/OpenAPI +tags+ entries contributed by +decidim-restfull-*+ gems when their
|
|
7
|
+
# +test_definitions+ load (mirrors the registry pattern used in +Decidim.component_registry+).
|
|
8
|
+
module OpenApiTagRegistry
|
|
9
|
+
class << self
|
|
10
|
+
def register_tag(tag_hash)
|
|
11
|
+
tag_definitions.append(tag_hash)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def tag_definitions
|
|
15
|
+
@tag_definitions ||= []
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def clear!
|
|
19
|
+
@tag_definitions = []
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module RestFull
|
|
5
|
+
module Test
|
|
6
|
+
def self.openapi_specs
|
|
7
|
+
{
|
|
8
|
+
"v1/swagger.json" => {
|
|
9
|
+
openapi: "3.0.1",
|
|
10
|
+
info: {
|
|
11
|
+
title: "API V1",
|
|
12
|
+
version: "v#{Decidim::RestFull.major_minor_version}",
|
|
13
|
+
description: <<~README
|
|
14
|
+
A RestFull API for Decidim, to be able to CRUD resources from Decidim.#{" "}
|
|
15
|
+
_current version: #{Decidim::RestFull.version}_
|
|
16
|
+
|
|
17
|
+
## Authentication
|
|
18
|
+
[Get a token](#{Decidim::RestFull.config.docs_url}/category/authentication) from our `/oauth/token` routes,
|
|
19
|
+
following OAuth specs on Credential Flows or Resource Owner Password Credentials Flow.
|
|
20
|
+
|
|
21
|
+
### Permissions
|
|
22
|
+
A permission system is attached to the created OAuth application, that is designed in two levels:
|
|
23
|
+
|
|
24
|
+
- **scope**: a broad permission to access a collection of endpoints
|
|
25
|
+
- **abilities**: a fine grained permission system that allow actions.
|
|
26
|
+
|
|
27
|
+
The scopes and abilities are manageable in your System Admin Panel.
|
|
28
|
+
|
|
29
|
+
### Multi-tenant **Organizations**
|
|
30
|
+
One deployment hosts many **Organizations** (tenants by **`host`**).
|
|
31
|
+
- The **`system` scope** endpoints apply in the context of the resolved organization
|
|
32
|
+
- The request **`host`** selects which **Organization** you target.
|
|
33
|
+
For example, `example.org/oauth/token` and `foobar.org/oauth/token` obtain tokens for those organizations' OAuth applications.
|
|
34
|
+
|
|
35
|
+
### Integrators
|
|
36
|
+
Start with the [Integrator quickstart](#{Decidim::RestFull.config.docs_url}/integrator/quickstart) (host → API client → token → first API call).
|
|
37
|
+
|
|
38
|
+
TypeScript client: [#{Decidim::RestFull.config.docs_url}/integrator/typescript-sdk](#{Decidim::RestFull.config.docs_url}/integrator/typescript-sdk) (`@octree/decidim-sdk`).
|
|
39
|
+
|
|
40
|
+
**Extended data** (client metadata on organizations, components, spaces, proposals, meetings): [#{Decidim::RestFull.config.docs_url}/integrator/extended-data](#{Decidim::RestFull.config.docs_url}/integrator/extended-data).
|
|
41
|
+
|
|
42
|
+
Outbound **webhook** events are listed under the **Webhooks** tag.
|
|
43
|
+
Manage registrations via `/webhook_registrations` (or System admin) and fetch example
|
|
44
|
+
payloads from `GET /webhook_events/{event_type}`.
|
|
45
|
+
README
|
|
46
|
+
},
|
|
47
|
+
servers: [
|
|
48
|
+
{
|
|
49
|
+
url: "https://{defaultHost}/api/rest_full/v#{Decidim::RestFull.major_minor_version}",
|
|
50
|
+
variables: {
|
|
51
|
+
defaultHost: {
|
|
52
|
+
default: "www.example.org"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
url: "http://localhost:{port}/api/rest_full/v#{Decidim::RestFull.major_minor_version}",
|
|
58
|
+
variables: {
|
|
59
|
+
port: {
|
|
60
|
+
default: "3000"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
tags: [
|
|
66
|
+
Definitions::Tags::OAUTH,
|
|
67
|
+
Definitions::Tags::ORGANIZATIONS,
|
|
68
|
+
Definitions::Tags::ORGANIZATION_EXTENDED_DATA,
|
|
69
|
+
Definitions::Tags::SPACE,
|
|
70
|
+
Definitions::Tags::COMPONENT,
|
|
71
|
+
Definitions::Tags::USER,
|
|
72
|
+
*Decidim::RestFull::Test::OpenApiTagRegistry.tag_definitions,
|
|
73
|
+
Definitions::Tags::JOBS,
|
|
74
|
+
Definitions::Tags::ROLES,
|
|
75
|
+
Definitions::Tags::WEBHOOKS
|
|
76
|
+
],
|
|
77
|
+
components: {
|
|
78
|
+
securitySchemes: {
|
|
79
|
+
credentialFlowBearer: {
|
|
80
|
+
type: :http,
|
|
81
|
+
scheme: :bearer,
|
|
82
|
+
bearerFormat: :JWT,
|
|
83
|
+
description: <<~README
|
|
84
|
+
Authorization via service-to-service credentials flow.
|
|
85
|
+
Use this for machine clients.
|
|
86
|
+
[Learn more here](#{Decidim::RestFull.config.docs_url}/user_documentation/auth/client-credential-flow)
|
|
87
|
+
README
|
|
88
|
+
},
|
|
89
|
+
resourceOwnerFlowBearer: {
|
|
90
|
+
type: :http,
|
|
91
|
+
scheme: :bearer,
|
|
92
|
+
bearerFormat: :JWT,
|
|
93
|
+
description: <<~README
|
|
94
|
+
Authorization via resource owner flow.
|
|
95
|
+
Use this for user-based authentication
|
|
96
|
+
[Learn more here](#{Decidim::RestFull.config.docs_url}/user_documentation/auth/user-credentials-flow)
|
|
97
|
+
README
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
schemas: Decidim::RestFull::Core::DefinitionRegistry.as_json
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.shared_examples "a model with HasExtendedData" do
|
|
4
|
+
it "includes HasExtendedData" do
|
|
5
|
+
expect(subject.class.ancestors).to include(Decidim::RestFull::Core::HasExtendedData)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it "has_one extended_data association" do
|
|
9
|
+
expect(subject).to respond_to(:extended_data)
|
|
10
|
+
expect(subject.class.reflect_on_association(:extended_data).macro).to eq(:has_one)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "exposes extended_data_hash" do
|
|
14
|
+
expect(subject.extended_data_hash).to eq({})
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "ensures an extended_data row after create" do
|
|
18
|
+
expect(subject.extended_data).to be_present
|
|
19
|
+
expect(subject.extended_data.data).to eq({})
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "stores data on the polymorphic related row" do
|
|
23
|
+
subject.extended_data.update!(data: { "foo" => "bar" })
|
|
24
|
+
expect(subject.reload.extended_data_hash).to eq("foo" => "bar")
|
|
25
|
+
expect(subject.extended_data.resource).to eq(subject)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "touches the parent resource on extended_data update" do
|
|
29
|
+
previous = subject.reload.updated_at
|
|
30
|
+
travel 1.second do
|
|
31
|
+
subject.extended_data.update!(data: { "touch" => "1" })
|
|
32
|
+
end
|
|
33
|
+
expect(subject.reload.updated_at).to be > previous
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "quotes resource_type in the extended_data ransacker SQL" do
|
|
37
|
+
sql = subject.class.ransack(extended_data_cont: "probe").result.to_sql
|
|
38
|
+
expect(sql).to include(ActiveRecord::Base.connection.quote(subject.class.name))
|
|
39
|
+
expect(sql).to match(/data::text/i)
|
|
40
|
+
end
|
|
41
|
+
end
|