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,299 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# spec/integration/oauth_scopes_spec.rb
|
|
4
|
+
require "swagger_helper"
|
|
5
|
+
def uniq_nickname
|
|
6
|
+
final_nickname = nickname = "decidimuser"
|
|
7
|
+
i = 0
|
|
8
|
+
while Decidim::User.find_by(nickname: final_nickname)
|
|
9
|
+
i += 1
|
|
10
|
+
final_nickname = "#{nickname}_#{i}"
|
|
11
|
+
end
|
|
12
|
+
final_nickname
|
|
13
|
+
end
|
|
14
|
+
RSpec.describe Decidim::Api::RestFull::ApplicationController do
|
|
15
|
+
let!(:organization) { create(:organization, available_locales: ["en"]) }
|
|
16
|
+
let!(:user) { create(:user, organization:, password: "decidim123456789!", password_confirmation: "decidim123456789!") }
|
|
17
|
+
let!(:api_client) do
|
|
18
|
+
api_client = create(:api_client, organization:, scopes: %w(oauth public))
|
|
19
|
+
api_client.permissions = [
|
|
20
|
+
api_client.permissions.build(permission: "oauth.impersonate"),
|
|
21
|
+
api_client.permissions.build(permission: "oauth.login")
|
|
22
|
+
]
|
|
23
|
+
api_client.save!
|
|
24
|
+
api_client.reload
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
before do
|
|
28
|
+
host! organization.host
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
path "/oauth/token" do
|
|
32
|
+
post "Request an OAuth token (ROPC)" do
|
|
33
|
+
tags "OAuth"
|
|
34
|
+
consumes "application/json"
|
|
35
|
+
produces "application/json"
|
|
36
|
+
security([])
|
|
37
|
+
operationId "createToken"
|
|
38
|
+
description "Create an OAuth token for the given scopes (password or client_credentials grant)."
|
|
39
|
+
|
|
40
|
+
parameter name: :body, in: :body, required: true, schema: { "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:oauth_grant_param) }
|
|
41
|
+
|
|
42
|
+
response "400", "Bad Request when grant_type is invalid" do
|
|
43
|
+
produces "application/json"
|
|
44
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:error_response)
|
|
45
|
+
let(:body) do
|
|
46
|
+
{
|
|
47
|
+
grant_type: "invalid_grant",
|
|
48
|
+
client_id: api_client.client_id,
|
|
49
|
+
client_secret: api_client.client_secret,
|
|
50
|
+
scope: "public"
|
|
51
|
+
}
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
run_test!(example_name: :invalid_grant_type) do |response|
|
|
55
|
+
# RFC 6749 suggests 400; Doorkeeper may return 400 or 401
|
|
56
|
+
expect(response.status).to satisfy("be 400 or 401") { |code| [400, 401].include?(code) }
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
response "200", "Token returned" do
|
|
61
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:oauth_token_response)
|
|
62
|
+
context "when user does not exists" do
|
|
63
|
+
context "with meta.register_on_missing=true" do
|
|
64
|
+
let(:nickname) { uniq_nickname }
|
|
65
|
+
let(:body) do
|
|
66
|
+
{
|
|
67
|
+
grant_type: "password",
|
|
68
|
+
auth_type: "impersonate",
|
|
69
|
+
username: nickname,
|
|
70
|
+
client_id: api_client.client_id,
|
|
71
|
+
client_secret: api_client.client_secret,
|
|
72
|
+
meta: {
|
|
73
|
+
register_on_missing: true
|
|
74
|
+
},
|
|
75
|
+
scope: "public"
|
|
76
|
+
}
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
run_test! do |_example|
|
|
80
|
+
expect(Decidim::User.find_by(nickname:)).to be_truthy
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
context "with meta.register_on_missing=true and meta.email=an_email" do
|
|
85
|
+
let(:nickname) { uniq_nickname }
|
|
86
|
+
let(:email) do
|
|
87
|
+
"test#{Devise.friendly_token.first(10).downcase}@example.org"
|
|
88
|
+
end
|
|
89
|
+
let(:body) do
|
|
90
|
+
{
|
|
91
|
+
grant_type: "password",
|
|
92
|
+
auth_type: "impersonate",
|
|
93
|
+
username: nickname,
|
|
94
|
+
client_id: api_client.client_id,
|
|
95
|
+
client_secret: api_client.client_secret,
|
|
96
|
+
meta: {
|
|
97
|
+
register_on_missing: true,
|
|
98
|
+
email:
|
|
99
|
+
},
|
|
100
|
+
scope: "public"
|
|
101
|
+
}
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
run_test! do |_example|
|
|
105
|
+
created_user = Decidim::User.find_by(nickname:)
|
|
106
|
+
expect(created_user).to be_truthy
|
|
107
|
+
expect(created_user.email).to eq(email)
|
|
108
|
+
expect(created_user.extended_data).to eq({})
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
context "with meta.register_on_missing=true and meta.name='My Name'" do
|
|
113
|
+
let(:nickname) { uniq_nickname }
|
|
114
|
+
|
|
115
|
+
let(:body) do
|
|
116
|
+
{
|
|
117
|
+
grant_type: "password",
|
|
118
|
+
auth_type: "impersonate",
|
|
119
|
+
username: nickname,
|
|
120
|
+
client_id: api_client.client_id,
|
|
121
|
+
client_secret: api_client.client_secret,
|
|
122
|
+
meta: {
|
|
123
|
+
register_on_missing: true,
|
|
124
|
+
name: "My Name"
|
|
125
|
+
},
|
|
126
|
+
scope: "public"
|
|
127
|
+
}
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
run_test! do |_example|
|
|
131
|
+
created_user = Decidim::User.find_by(nickname:)
|
|
132
|
+
expect(created_user).to be_truthy
|
|
133
|
+
expect(created_user.name).to eq("My Name")
|
|
134
|
+
expect(created_user.extended_data).to eq({})
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
context "when user does exists" do
|
|
140
|
+
context "with auth_type=impersonate" do
|
|
141
|
+
let(:body) do
|
|
142
|
+
{
|
|
143
|
+
grant_type: "password",
|
|
144
|
+
auth_type: "impersonate",
|
|
145
|
+
username: user.nickname,
|
|
146
|
+
client_id: api_client.client_id,
|
|
147
|
+
client_secret: api_client.client_secret,
|
|
148
|
+
scope: "public"
|
|
149
|
+
}
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
run_test!(example_name: :ok_ropc_impersonate) do |response|
|
|
153
|
+
json_response = JSON.parse(response.body)
|
|
154
|
+
expect(json_response["access_token"]).to be_present
|
|
155
|
+
expect(
|
|
156
|
+
Doorkeeper::AccessToken.find_by(token: json_response["access_token"]).scopes
|
|
157
|
+
).to include("public")
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
context "with auth_type=login" do
|
|
162
|
+
let(:proposal_api_client) do
|
|
163
|
+
api_client = create(:api_client, organization:, scopes: "proposals public")
|
|
164
|
+
api_client.permissions = [
|
|
165
|
+
api_client.permissions.build(permission: "oauth.login")
|
|
166
|
+
]
|
|
167
|
+
api_client.save!
|
|
168
|
+
api_client
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
let(:body) do
|
|
172
|
+
{
|
|
173
|
+
grant_type: "password",
|
|
174
|
+
auth_type: "login",
|
|
175
|
+
password: "decidim123456789!",
|
|
176
|
+
username: user.nickname,
|
|
177
|
+
client_id: proposal_api_client.client_id,
|
|
178
|
+
client_secret: proposal_api_client.client_secret,
|
|
179
|
+
scope: "public proposals"
|
|
180
|
+
}
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
run_test!(example_name: :ok_ropc_login) do |response|
|
|
184
|
+
json_response = JSON.parse(response.body)
|
|
185
|
+
expect(json_response["access_token"]).to be_present
|
|
186
|
+
expect(
|
|
187
|
+
Doorkeeper::AccessToken.find_by(token: json_response["access_token"]).scopes
|
|
188
|
+
).to include("proposals")
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
response "400", "Bad Request" do
|
|
195
|
+
produces "application/json"
|
|
196
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:error_response)
|
|
197
|
+
|
|
198
|
+
context "when user does not exists" do
|
|
199
|
+
context "with meta.register_on_missing=false" do
|
|
200
|
+
let(:nickname) { uniq_nickname }
|
|
201
|
+
let(:body) do
|
|
202
|
+
{
|
|
203
|
+
grant_type: "password",
|
|
204
|
+
auth_type: "impersonate",
|
|
205
|
+
username: nickname,
|
|
206
|
+
client_id: api_client.client_id,
|
|
207
|
+
client_secret: api_client.client_secret,
|
|
208
|
+
meta: {
|
|
209
|
+
register_on_missing: false
|
|
210
|
+
},
|
|
211
|
+
scope: "public"
|
|
212
|
+
}
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
run_test!(example_name: :user_not_found) do |_example|
|
|
216
|
+
expect(Decidim::User.find_by(nickname:)).to be_nil
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
context "with meta.register_on_missing=true and invalid username" do
|
|
221
|
+
let(:nickname) { uniq_nickname }
|
|
222
|
+
let(:body) do
|
|
223
|
+
{
|
|
224
|
+
grant_type: "password",
|
|
225
|
+
auth_type: "impersonate",
|
|
226
|
+
username: nickname,
|
|
227
|
+
client_id: api_client.client_id,
|
|
228
|
+
client_secret: api_client.client_secret,
|
|
229
|
+
meta: {
|
|
230
|
+
register_on_missing: false
|
|
231
|
+
},
|
|
232
|
+
scope: "public"
|
|
233
|
+
}
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
run_test!(example_name: :invalid_username_on_register) do |_example|
|
|
237
|
+
expect(Decidim::User.find_by(nickname:)).to be_nil
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
context "with client_id from another organization" do
|
|
243
|
+
let(:organization_b) { create(:organization, available_locales: ["en"]) }
|
|
244
|
+
let(:foreign_api_client) { create(:api_client, organization: organization_b, scopes: %w(oauth public)) }
|
|
245
|
+
let(:body) do
|
|
246
|
+
{
|
|
247
|
+
grant_type: "password",
|
|
248
|
+
username: user.nickname,
|
|
249
|
+
auth_type: "impersonate",
|
|
250
|
+
client_id: foreign_api_client.client_id,
|
|
251
|
+
client_secret: foreign_api_client.client_secret,
|
|
252
|
+
scope: "public"
|
|
253
|
+
}
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
before do
|
|
257
|
+
host! organization.host
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
run_test!(example_name: :bad_request)
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
context "with impersonate username from an another tenant" do
|
|
264
|
+
let(:other_tenant) { create(:organization, available_locales: ["en"]) }
|
|
265
|
+
let(:body) do
|
|
266
|
+
{
|
|
267
|
+
grant_type: "password",
|
|
268
|
+
username: user.nickname,
|
|
269
|
+
auth_type: "impersonate",
|
|
270
|
+
client_id: api_client.client_id,
|
|
271
|
+
client_secret: api_client.client_secret,
|
|
272
|
+
scope: "public"
|
|
273
|
+
}
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
before { host! other_tenant.host }
|
|
277
|
+
|
|
278
|
+
run_test!
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
context "with scope=system and password grant" do
|
|
282
|
+
let(:system_api_client) { create(:api_client, organization:, scopes: "system") }
|
|
283
|
+
let(:body) do
|
|
284
|
+
{
|
|
285
|
+
grant_type: "password",
|
|
286
|
+
username: user.nickname,
|
|
287
|
+
auth_type: "impersonate",
|
|
288
|
+
client_id: system_api_client.client_id,
|
|
289
|
+
client_secret: system_api_client.client_secret,
|
|
290
|
+
scope: "system"
|
|
291
|
+
}
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
run_test!
|
|
295
|
+
end
|
|
296
|
+
end
|
|
297
|
+
end
|
|
298
|
+
end
|
|
299
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# spec/integration/oauth_scopes_spec.rb
|
|
4
|
+
require "swagger_helper"
|
|
5
|
+
RSpec.describe Decidim::Api::RestFull::ApplicationController do
|
|
6
|
+
let!(:organization) { create(:organization, available_locales: ["en"]) }
|
|
7
|
+
let!(:user) { create(:user, organization:, password: "decidim123456789!", password_confirmation: "decidim123456789!") }
|
|
8
|
+
let!(:api_client) { create(:api_client, organization:, scopes: "oauth") }
|
|
9
|
+
let!(:permissions) do
|
|
10
|
+
api_client.permissions = [
|
|
11
|
+
api_client.permissions.build(permission: "oauth.impersonate"),
|
|
12
|
+
api_client.permissions.build(permission: "oauth.login")
|
|
13
|
+
]
|
|
14
|
+
api_client.save!
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
before do
|
|
18
|
+
host! api_client.organization.host
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
path "/oauth/token" do
|
|
22
|
+
post "Request a OAuth token through Client Credentials" do
|
|
23
|
+
tags "OAuth"
|
|
24
|
+
consumes "application/json"
|
|
25
|
+
produces "application/json"
|
|
26
|
+
security([])
|
|
27
|
+
operationId "createToken"
|
|
28
|
+
description "Create a oauth token for the given scopes"
|
|
29
|
+
|
|
30
|
+
parameter name: :body, in: :body, required: true, schema: { "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:oauth_grant_param) }
|
|
31
|
+
|
|
32
|
+
response "200", "Token returned" do
|
|
33
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:oauth_token_response)
|
|
34
|
+
context "with client_credentials grant" do
|
|
35
|
+
let(:system_api_client) { create(:api_client, organization:, scopes: "system") }
|
|
36
|
+
let(:body) do
|
|
37
|
+
{
|
|
38
|
+
grant_type: "client_credentials",
|
|
39
|
+
auth_type: "impersonate",
|
|
40
|
+
client_id: system_api_client.client_id,
|
|
41
|
+
client_secret: system_api_client.client_secret,
|
|
42
|
+
scope: "system"
|
|
43
|
+
}
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
run_test! do |response|
|
|
47
|
+
json_response = JSON.parse(response.body)
|
|
48
|
+
expect(json_response["access_token"]).to be_present
|
|
49
|
+
expect(
|
|
50
|
+
Doorkeeper::AccessToken.find_by(token: json_response["access_token"]).scopes
|
|
51
|
+
).to include("system")
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
data/spec/requests/decidim/api/rest_full/attachments/attachments_controller_direct_upload_spec.rb
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "swagger_helper"
|
|
4
|
+
|
|
5
|
+
RSpec.describe Decidim::Api::RestFull::Attachments::AttachmentsController do
|
|
6
|
+
path "/attachments/direct_upload" do
|
|
7
|
+
post "Stage file for direct upload" do
|
|
8
|
+
tags "Attachments"
|
|
9
|
+
consumes "application/json"
|
|
10
|
+
produces "application/json"
|
|
11
|
+
operationId "attachmentsDirectUpload"
|
|
12
|
+
parameter name: :filename, in: :query, type: :string, required: true
|
|
13
|
+
parameter name: :byte_size, in: :query, type: :integer, required: true
|
|
14
|
+
parameter name: :checksum, in: :query, type: :string, required: true
|
|
15
|
+
parameter name: :content_type, in: :query, type: :string, required: false
|
|
16
|
+
|
|
17
|
+
describe_api_endpoint(
|
|
18
|
+
controller: Decidim::Api::RestFull::Attachments::AttachmentsController,
|
|
19
|
+
action: :direct_upload,
|
|
20
|
+
security_types: [:credentialFlow],
|
|
21
|
+
scopes: ["attachments"],
|
|
22
|
+
permissions: ["attachments.write"]
|
|
23
|
+
) do
|
|
24
|
+
let(:filename) { "hello.pdf" }
|
|
25
|
+
let(:byte_size) { 12_345 }
|
|
26
|
+
let(:checksum) { Base64.strict_encode64(Digest::MD5.digest("x" * byte_size)) }
|
|
27
|
+
let(:content_type) { "application/pdf" }
|
|
28
|
+
|
|
29
|
+
response "201", "Direct upload prepared" do
|
|
30
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:attachment_direct_upload_response)
|
|
31
|
+
run_test!(example_name: :ok) do |example|
|
|
32
|
+
body = JSON.parse(example.body)
|
|
33
|
+
expect(body["signed_id"]).to be_present
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "swagger_helper"
|
|
4
|
+
|
|
5
|
+
RSpec.describe Decidim::Api::RestFull::Attachments::AttachmentsController do
|
|
6
|
+
path "/attachments" do
|
|
7
|
+
get "List attachments" do
|
|
8
|
+
tags "Attachments"
|
|
9
|
+
produces "application/json"
|
|
10
|
+
operationId "listAttachments"
|
|
11
|
+
it_behaves_like "paginated params"
|
|
12
|
+
it_behaves_like "filtered params", filter: "attached_to_type", item_schema: { type: :string }, only: :string
|
|
13
|
+
it_behaves_like "filtered params", filter: "attached_to_id", item_schema: { type: :integer }, only: :integer
|
|
14
|
+
|
|
15
|
+
describe_api_endpoint(
|
|
16
|
+
controller: Decidim::Api::RestFull::Attachments::AttachmentsController,
|
|
17
|
+
action: :index,
|
|
18
|
+
security_types: [:credentialFlow],
|
|
19
|
+
scopes: ["attachments"],
|
|
20
|
+
permissions: ["attachments.read"]
|
|
21
|
+
) do
|
|
22
|
+
let!(:organization) { create(:organization, available_locales: ["en"]) }
|
|
23
|
+
let!(:participatory_process) { create(:participatory_process, :with_steps, organization:) }
|
|
24
|
+
let!(:component) { create(:component, participatory_space: participatory_process, manifest_name: "proposals", published_at: Time.zone.now) }
|
|
25
|
+
let!(:proposal) { create(:proposal, component:) }
|
|
26
|
+
let!(:attachment) { create(:attachment, :with_pdf, attached_to: proposal) }
|
|
27
|
+
|
|
28
|
+
response "200", "Attachments listed" do
|
|
29
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:attachment_index_response)
|
|
30
|
+
|
|
31
|
+
let(:filter) { { attached_to_type: "Decidim::Proposals::Proposal", attached_to_id: proposal.id } }
|
|
32
|
+
|
|
33
|
+
run_test!(example_name: :ok) do |example|
|
|
34
|
+
data = JSON.parse(example.body)["data"]
|
|
35
|
+
expect(data.map { |d| d["id"] }).to include(attachment.id.to_s)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "swagger_helper"
|
|
4
|
+
|
|
5
|
+
RSpec.describe Decidim::Api::RestFull::Attachments::AttachmentsController do
|
|
6
|
+
path "/attachments/{id}" do
|
|
7
|
+
get "Show attachment" do
|
|
8
|
+
tags "Attachments"
|
|
9
|
+
produces "application/json"
|
|
10
|
+
operationId "showAttachment"
|
|
11
|
+
parameter name: :id, in: :path, type: :string, required: true
|
|
12
|
+
|
|
13
|
+
describe_api_endpoint(
|
|
14
|
+
controller: Decidim::Api::RestFull::Attachments::AttachmentsController,
|
|
15
|
+
action: :show,
|
|
16
|
+
security_types: [:credentialFlow],
|
|
17
|
+
scopes: ["attachments"],
|
|
18
|
+
permissions: ["attachments.read"]
|
|
19
|
+
) do
|
|
20
|
+
let!(:organization) { create(:organization, available_locales: ["en"]) }
|
|
21
|
+
let!(:participatory_process) { create(:participatory_process, :with_steps, organization:) }
|
|
22
|
+
let!(:component) { create(:component, participatory_space: participatory_process, manifest_name: "proposals", published_at: Time.zone.now) }
|
|
23
|
+
let!(:proposal) { create(:proposal, component:) }
|
|
24
|
+
let!(:attachment) { create(:attachment, :with_pdf, attached_to: proposal) }
|
|
25
|
+
let(:id) { attachment.id }
|
|
26
|
+
|
|
27
|
+
response "200", "Attachment found" do
|
|
28
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:attachment_item_response)
|
|
29
|
+
run_test!(example_name: :ok)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
data/spec/requests/decidim/api/rest_full/components/component_extended_data_controller_spec.rb
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "swagger_helper"
|
|
4
|
+
|
|
5
|
+
RSpec.describe Decidim::Api::RestFull::Components::ComponentExtendedDataController do
|
|
6
|
+
path "/components/{id}/extended_data" do
|
|
7
|
+
get "Component extended data" do
|
|
8
|
+
tags "Components"
|
|
9
|
+
produces "application/json"
|
|
10
|
+
operationId "getComponentExtendedData"
|
|
11
|
+
description "See [Extended data](#{Decidim::RestFull.config.docs_url}/integrator/extended-data)."
|
|
12
|
+
parameter name: "object_path", in: :query, required: true, schema: { type: :string }
|
|
13
|
+
parameter name: "id", in: :path, schema: { type: :string }
|
|
14
|
+
|
|
15
|
+
describe_api_endpoint(
|
|
16
|
+
controller: Decidim::Api::RestFull::Components::ComponentExtendedDataController,
|
|
17
|
+
action: :index,
|
|
18
|
+
security_types: [:credentialFlow],
|
|
19
|
+
scopes: ["public"],
|
|
20
|
+
permissions: ["public.component.read", "public.component.extended_data.read"]
|
|
21
|
+
) do
|
|
22
|
+
let!(:participatory_process) { create(:participatory_process, :with_steps, organization:) }
|
|
23
|
+
let!(:component) { create(:component, participatory_space: participatory_process, published_at: Time.zone.now) }
|
|
24
|
+
let(:id) { component.id }
|
|
25
|
+
let(:object_path) { "." }
|
|
26
|
+
|
|
27
|
+
response "200", "Extended data" do
|
|
28
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:resource_extended_data)
|
|
29
|
+
|
|
30
|
+
before { component.extended_data.update!(data: { "a" => 1 }) }
|
|
31
|
+
|
|
32
|
+
run_test!(example_name: :ok) do |example|
|
|
33
|
+
expect(JSON.parse(example.body)["data"]).to include("a" => 1)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
path "/components/{id}/extended_data/sync" do
|
|
41
|
+
put "Set component extended data (sync)" do
|
|
42
|
+
tags "Components"
|
|
43
|
+
consumes "application/json"
|
|
44
|
+
produces "application/json"
|
|
45
|
+
operationId "setComponentExtendedData"
|
|
46
|
+
description "See [Extended data](#{Decidim::RestFull.config.docs_url}/integrator/extended-data)."
|
|
47
|
+
parameter name: "object_path", in: :query, required: true, schema: { type: :string }
|
|
48
|
+
parameter name: "id", in: :path, schema: { type: :string }
|
|
49
|
+
parameter name: :body, in: :body, required: true, schema: {
|
|
50
|
+
type: :object,
|
|
51
|
+
properties: { data: { type: :object, additionalProperties: true } },
|
|
52
|
+
required: [:data]
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
describe_api_endpoint(
|
|
56
|
+
controller: Decidim::Api::RestFull::Components::ComponentExtendedDataController,
|
|
57
|
+
action: :update_sync,
|
|
58
|
+
security_types: [:credentialFlow],
|
|
59
|
+
scopes: ["public"],
|
|
60
|
+
permissions: ["public.component.read", "public.component.extended_data.update"]
|
|
61
|
+
) do
|
|
62
|
+
let!(:participatory_process) { create(:participatory_process, :with_steps, organization:) }
|
|
63
|
+
let!(:component) { create(:component, participatory_space: participatory_process, published_at: Time.zone.now) }
|
|
64
|
+
let(:id) { component.id }
|
|
65
|
+
let(:object_path) { "." }
|
|
66
|
+
let(:body) { { data: { "k" => "v" } } }
|
|
67
|
+
|
|
68
|
+
response "200", "Updated" do
|
|
69
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:resource_extended_data)
|
|
70
|
+
|
|
71
|
+
run_test!(example_name: :ok) do |_example|
|
|
72
|
+
expect(component.reload.extended_data_hash).to include("k" => "v")
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|