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,89 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "swagger_helper"
|
|
4
|
+
|
|
5
|
+
RSpec.describe Decidim::Api::RestFull::Jobs::JobsController do
|
|
6
|
+
path "/jobs/{id}" do
|
|
7
|
+
get "Poll API job" do
|
|
8
|
+
tags "Jobs"
|
|
9
|
+
produces "application/json"
|
|
10
|
+
operationId "getJob"
|
|
11
|
+
description <<~TXT.strip
|
|
12
|
+
Poll job status with the UUID from HTTP 202 responses. No Bearer header: capability is solely the opaque UUID scoped by request host / organization.
|
|
13
|
+
TXT
|
|
14
|
+
|
|
15
|
+
security []
|
|
16
|
+
|
|
17
|
+
parameter name: :id, in: :path, required: true, schema: {
|
|
18
|
+
type: :string,
|
|
19
|
+
format: :uuid,
|
|
20
|
+
description: "Job UUID (`job_id` from the asynchronous response body)"
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let!(:organization) { create(:organization, available_locales: ["en"]) }
|
|
24
|
+
let!(:user) { create(:user, organization:, locale: "en", confirmed_at: Time.zone.now) }
|
|
25
|
+
let!(:api_client) do
|
|
26
|
+
c = create(:api_client, organization:, scopes: ["proposals"])
|
|
27
|
+
c.permissions = [Decidim::RestFull::Core::Permission.new(permission: "proposals.draft")]
|
|
28
|
+
c.save!
|
|
29
|
+
c
|
|
30
|
+
end
|
|
31
|
+
let!(:bearer_token) do
|
|
32
|
+
create(:oauth_access_token, scopes: "proposals", resource_owner_id: user.id, application: api_client)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
before { host! organization.host }
|
|
36
|
+
|
|
37
|
+
response "200", "job state" do
|
|
38
|
+
consumes "application/json"
|
|
39
|
+
produces "application/json"
|
|
40
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:rest_full_api_job_detail)
|
|
41
|
+
|
|
42
|
+
context "when complete" do
|
|
43
|
+
let!(:job_row) do
|
|
44
|
+
Decidim::RestFull::ApiJob.compat_create!(
|
|
45
|
+
decidim_organization_id: organization.id,
|
|
46
|
+
doorkeeper_access_token_id: bearer_token.id,
|
|
47
|
+
oauth_application_id: api_client.id,
|
|
48
|
+
resource_owner_id: user.id,
|
|
49
|
+
command_key: "draft_proposals#create",
|
|
50
|
+
status: "completed",
|
|
51
|
+
payload: { "path" => {}, "data" => {} },
|
|
52
|
+
result: { "data" => { "ok" => true } }
|
|
53
|
+
)
|
|
54
|
+
end
|
|
55
|
+
let(:id) { job_row.id }
|
|
56
|
+
|
|
57
|
+
run_test!(example_name: :poll_completed) do
|
|
58
|
+
parsed = response.parsed_body
|
|
59
|
+
expect(parsed["status"]).to eq("completed")
|
|
60
|
+
expect(parsed["data"]).to eq({ "ok" => true })
|
|
61
|
+
expect(parsed.dig("links", "self", "href")).to end_with("/jobs/#{job_row.id}")
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
response "404", "Job not found" do
|
|
67
|
+
consumes "application/json"
|
|
68
|
+
produces "application/json"
|
|
69
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:error_response)
|
|
70
|
+
|
|
71
|
+
context "when id is not a UUID" do
|
|
72
|
+
let(:id) { "not-a-uuid" }
|
|
73
|
+
|
|
74
|
+
run_test!(example_name: :job_bad_id_shape) do
|
|
75
|
+
expect(response).to have_http_status(:not_found)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
context "when uuid unknown" do
|
|
80
|
+
let(:id) { SecureRandom.uuid }
|
|
81
|
+
|
|
82
|
+
run_test!(example_name: :job_unknown_uuid) do
|
|
83
|
+
expect(response).to have_http_status(:not_found)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
# rubocop:disable RSpec/DescribeClass -- request integration for ModuleAvailability gates
|
|
6
|
+
RSpec.describe "RestFull ModuleAvailability API gates" do
|
|
7
|
+
let(:organization) { create(:organization, host: "test.example.org") }
|
|
8
|
+
let(:api_client) { create(:api_client, organization:, scopes: %w(public blogs)) }
|
|
9
|
+
let(:user) { create(:user, :confirmed, organization:) }
|
|
10
|
+
let!(:token) do
|
|
11
|
+
create(:oauth_access_token, scopes: "public blogs", resource_owner_id: user.id, application: api_client)
|
|
12
|
+
end
|
|
13
|
+
let(:version) { Decidim::RestFull.major_minor_version }
|
|
14
|
+
let(:headers) { { "Authorization" => "Bearer #{token.token}", "Host" => organization.host } }
|
|
15
|
+
|
|
16
|
+
before do
|
|
17
|
+
host!(organization.host)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def stub_toggle(hash)
|
|
21
|
+
allow(Decidim::RestFull::Core::ModuleAvailability).to receive(:raw_config)
|
|
22
|
+
.and_return(hash.with_indifferent_access)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "returns 501 on core endpoints when master is off" do
|
|
26
|
+
stub_toggle(enabled: false)
|
|
27
|
+
get("/api/rest_full/v#{version}/organizations", headers:)
|
|
28
|
+
expect(response).to have_http_status(:not_implemented)
|
|
29
|
+
expect(response.parsed_body["error"]).to include("501")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "returns 501 on blogs endpoints when blogs is off" do
|
|
33
|
+
stub_toggle(enabled: true, blogs_enabled: false)
|
|
34
|
+
get("/api/rest_full/v#{version}/blogs", headers:)
|
|
35
|
+
expect(response).to have_http_status(:not_implemented)
|
|
36
|
+
expect(response.parsed_body["error"]).to include("501")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "allows core endpoints when only blogs is off" do
|
|
40
|
+
stub_toggle(enabled: true, blogs_enabled: false)
|
|
41
|
+
get("/api/rest_full/v#{version}/spaces/search", headers:)
|
|
42
|
+
# may be 200 or 403 depending on permissions; must not be 501
|
|
43
|
+
expect(response).not_to have_http_status(:not_implemented)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
context "when an Extension-registered feature gem is present" do
|
|
47
|
+
before do
|
|
48
|
+
skip "decidim-restfull-dummy not in bundle" unless Gem.loaded_specs.has_key?("decidim-restfull-dummy")
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
let(:api_client) { create(:api_client, organization:, scopes: %w(public dummy)) }
|
|
52
|
+
let!(:token) do
|
|
53
|
+
create(:oauth_access_token, scopes: "public dummy", resource_owner_id: user.id, application: api_client)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "registers controller paths and Toggle feature via Extension" do
|
|
57
|
+
expect(Decidim::RestFull::Core::ModuleAvailability.feature_gems[:dummy]).to eq("decidim-restfull-dummy")
|
|
58
|
+
expect(Decidim::RestFull::Core::ModuleAvailability.controller_path_features["dummies"]).to eq(:dummy)
|
|
59
|
+
expect(Decidim::RestFull::Core::ModuleAvailability.scope_features[:dummy]).to eq(:dummy)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "returns 501 when the registered feature Toggle is off" do
|
|
63
|
+
stub_toggle(enabled: true, dummy_enabled: false)
|
|
64
|
+
get("/api/rest_full/v#{version}/dummies", headers:)
|
|
65
|
+
expect(response).to have_http_status(:not_implemented)
|
|
66
|
+
expect(response.parsed_body["error"]).to include("501")
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it "returns 501 Not Implemented when a stub controller is hit (Toggle on)" do
|
|
70
|
+
stub_toggle(enabled: true, dummy_enabled: true)
|
|
71
|
+
get("/api/rest_full/v#{version}/dummies", headers:)
|
|
72
|
+
expect(response).to have_http_status(:not_implemented)
|
|
73
|
+
expect(response.parsed_body["error"]).to include("501")
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
# rubocop:enable RSpec/DescribeClass
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "swagger_helper"
|
|
4
|
+
RSpec.describe Decidim::Api::RestFull::Organizations::OrganizationExtendedDataController do
|
|
5
|
+
path "/organizations/{id}/extended_data" do
|
|
6
|
+
get "Organization extended data" do
|
|
7
|
+
tags "Organizations Extended Data"
|
|
8
|
+
produces "application/json"
|
|
9
|
+
operationId "getOrganizationExtendedData"
|
|
10
|
+
description "Fetch organization extended data"
|
|
11
|
+
parameter name: "object_path", in: :query, required: true, schema: { type: :string, description: "object path, in dot style, like foo.bar" }
|
|
12
|
+
parameter name: "id", in: :path, schema: { type: :integer, description: "Id of the organization" }
|
|
13
|
+
let(:organization) { create(:organization, available_locales: ["en"]) }
|
|
14
|
+
|
|
15
|
+
describe_api_endpoint(
|
|
16
|
+
controller: Decidim::Api::RestFull::Organizations::OrganizationExtendedDataController,
|
|
17
|
+
action: :index,
|
|
18
|
+
security_types: [:credentialFlow],
|
|
19
|
+
scopes: ["system"],
|
|
20
|
+
permissions: ["system.organizations.extended_data.read"]
|
|
21
|
+
) do
|
|
22
|
+
let!(:id) { organization.id }
|
|
23
|
+
let!(:object_path) { "custom.data" }
|
|
24
|
+
|
|
25
|
+
response "200", "Extended Data for a given object_path given" do
|
|
26
|
+
consumes "application/json"
|
|
27
|
+
produces "application/json"
|
|
28
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:organization_extended_data)
|
|
29
|
+
context "with extended_data={'foo' => {'bar' => 'true'}}, can access object_path=foo.bar" do
|
|
30
|
+
before do
|
|
31
|
+
organization.extended_data.update(data: { "foo" => { "bar" => "true" } })
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
let!(:object_path) { "foo.bar" }
|
|
35
|
+
|
|
36
|
+
run_test! do |example|
|
|
37
|
+
data = JSON.parse(example.body)["data"]
|
|
38
|
+
expect(response).to have_http_status(:ok)
|
|
39
|
+
expect(data).to eq("true")
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
context "with extended_data={'personal' => {'birthday' => '1989-01-28'}}, can access object_path=personal" do
|
|
44
|
+
before do
|
|
45
|
+
organization.extended_data.update(data: { "personal" => { "birthday" => "1989-01-28" } })
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
let!(:object_path) { "personal" }
|
|
49
|
+
|
|
50
|
+
run_test!(example_name: :ok) do |example|
|
|
51
|
+
data = JSON.parse(example.body)["data"]
|
|
52
|
+
expect(response).to have_http_status(:ok)
|
|
53
|
+
expect(data).to include({ "birthday" => "1989-01-28" })
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
context "with extended_data=<whatever object>, can access object_path=." do
|
|
58
|
+
before do
|
|
59
|
+
organization.extended_data.update(data: { "personal" => { "birthday" => "1989-01-28" } })
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
let!(:object_path) { "." }
|
|
63
|
+
|
|
64
|
+
run_test!(example_name: :ok) do |example|
|
|
65
|
+
data = JSON.parse(example.body)["data"]
|
|
66
|
+
expect(response).to have_http_status(:ok)
|
|
67
|
+
expect(data).to include({ "personal" => { "birthday" => "1989-01-28" } })
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
context "with a object_path=unknown returns empty data" do
|
|
72
|
+
before do
|
|
73
|
+
organization.extended_data.update(data: { "personal" => { "birthday" => "1989-01-28" } })
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
let!(:object_path) { "unknown" }
|
|
77
|
+
|
|
78
|
+
run_test!(example_name: :empty) do |example|
|
|
79
|
+
data = JSON.parse(example.body)["data"]
|
|
80
|
+
expect(response).to have_http_status(:ok)
|
|
81
|
+
expect(data).to eq({})
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "swagger_helper"
|
|
4
|
+
RSpec.describe Decidim::Api::RestFull::Organizations::OrganizationExtendedDataController do
|
|
5
|
+
path "/organizations/{id}/extended_data/sync" do
|
|
6
|
+
put "Update organization extended data" do
|
|
7
|
+
tags "Organizations Extended Data"
|
|
8
|
+
produces "application/json"
|
|
9
|
+
operationId "setOrganizationExtendedData"
|
|
10
|
+
description <<~README
|
|
11
|
+
The extended_data feature allows you to update a hash with recursive merging. Use the body payload with these keys:
|
|
12
|
+
|
|
13
|
+
1. `data`: The value or hash you want to update.
|
|
14
|
+
2. `object_path`: The dot-style path to the key (e.g., access.this.key).
|
|
15
|
+
|
|
16
|
+
**Root path**<br />
|
|
17
|
+
To update data from root of the hash, use `object_path="."`.
|
|
18
|
+
|
|
19
|
+
Example:
|
|
20
|
+
```
|
|
21
|
+
body={"data": {"name": "Jane"}, "object_path": "personnal"}
|
|
22
|
+
```
|
|
23
|
+
This recursively merges data into the hash without removing existing keys.
|
|
24
|
+
|
|
25
|
+
**Merge some data**<br />
|
|
26
|
+
Initial hash:
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"personnal": {"birthday": "1989-05-18"}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
Patch payload:
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"data": {
|
|
36
|
+
"name": "Jane"
|
|
37
|
+
},
|
|
38
|
+
"object_path": "personnal"
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
Result:
|
|
42
|
+
```
|
|
43
|
+
{
|
|
44
|
+
"personnal": {"birthday": "1989-05-18", "name": "Jane"}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Create new Paths**<br />
|
|
49
|
+
Paths are created as needed.
|
|
50
|
+
Exemple:
|
|
51
|
+
```json
|
|
52
|
+
body = {"data": {"external_user_id": 12}, "object_path": "data-store.my-app.foo"}
|
|
53
|
+
```
|
|
54
|
+
Result:
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"personnal": {"birthday": "1989-05-18"},
|
|
58
|
+
"data-store": {"my-app": {"foo": {"external_user_id": 12}}}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
Alternatively:
|
|
62
|
+
```
|
|
63
|
+
body = {"data": 12, "object_path": "data-store.my-app.foo.external_user_id"}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Remove a key**<br />
|
|
67
|
+
Set a key to null or an empty value to remove it.
|
|
68
|
+
|
|
69
|
+
Example: Initial hash:
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"personnal": {"birthday": "1989-05-18", "name": "Jane"}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
Patch:
|
|
76
|
+
```json
|
|
77
|
+
body = {"data": {"birthday": ""}, "object_path": "personnal"}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Result:
|
|
81
|
+
```
|
|
82
|
+
{
|
|
83
|
+
"personnal": {"name": "Jane"}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Return Value**<br />
|
|
88
|
+
The update request returns the updated value at the specified path.
|
|
89
|
+
|
|
90
|
+
README
|
|
91
|
+
parameter name: :body, in: :body, required: true, schema: {
|
|
92
|
+
type: :object,
|
|
93
|
+
title: "User Extended Data Payload",
|
|
94
|
+
properties: {
|
|
95
|
+
data: { type: :object, title: "User Extended Data Data", description: "New value for the extended data at the given path" },
|
|
96
|
+
object_path: { type: :string, description: "object path, in dot style, like foo.bar. use '.' to update the whole user data" }
|
|
97
|
+
}, required: [:data]
|
|
98
|
+
}
|
|
99
|
+
parameter name: "id", in: :path, schema: { type: :integer, description: "Id of the organization" }
|
|
100
|
+
describe_api_endpoint(
|
|
101
|
+
controller: Decidim::Api::RestFull::Organizations::OrganizationExtendedDataController,
|
|
102
|
+
action: :update_sync,
|
|
103
|
+
security_types: [:credentialFlow],
|
|
104
|
+
scopes: ["system"],
|
|
105
|
+
permissions: ["system.organizations.extended_data.update"]
|
|
106
|
+
) do
|
|
107
|
+
let(:body) { { data: { "foo" => "bar" }, object_path: "." } }
|
|
108
|
+
let(:organization) { create(:organization, available_locales: ["en"]) }
|
|
109
|
+
let(:id) { organization.id }
|
|
110
|
+
|
|
111
|
+
response "200", "Update extended data value" do
|
|
112
|
+
consumes "application/json"
|
|
113
|
+
produces "application/json"
|
|
114
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:organization_extended_data)
|
|
115
|
+
|
|
116
|
+
context "with root path '.'" do
|
|
117
|
+
before do
|
|
118
|
+
organization.extended_data.update(data: { "foo" => { "bar" => "true" } })
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
run_test!(example_name: :ok) do |example|
|
|
122
|
+
data = JSON.parse(example.body)["data"]
|
|
123
|
+
expect(response).to have_http_status(:ok)
|
|
124
|
+
expect(data).to eq(body[:data])
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
context "with a path given" do
|
|
129
|
+
before do
|
|
130
|
+
organization.extended_data.update(data: { "personal" => { "birthday" => "1989-01-28" } })
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
let(:body) { { data: "1990-02-09", object_path: "personal.birthday" } }
|
|
134
|
+
|
|
135
|
+
run_test! do |example|
|
|
136
|
+
data = JSON.parse(example.body)["data"]
|
|
137
|
+
expect(response).to have_http_status(:ok)
|
|
138
|
+
expect(data).to include("1990-02-09")
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
context "with a path given and merging data" do
|
|
143
|
+
before do
|
|
144
|
+
organization.extended_data.update(data: { "personal" => { "birthday" => "1989-01-28" } })
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
let(:body) { { data: { "name" => "Jeanne" }, object_path: "personal" } }
|
|
148
|
+
|
|
149
|
+
run_test! do |example|
|
|
150
|
+
JSON.parse(example.body)["data"]
|
|
151
|
+
organization.reload
|
|
152
|
+
expect(response).to have_http_status(:ok)
|
|
153
|
+
expect(organization.extended_data.data["personal"]).to include({ "name" => "Jeanne", "birthday" => "1989-01-28" })
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
context "with a path given and unsetting data" do
|
|
158
|
+
before do
|
|
159
|
+
organization.extended_data.update(data: { "personal" => { "birthday" => "1989-01-28", "name" => "Jeanne" } })
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
let(:body) { { data: { "name" => nil }, object_path: "personal" } }
|
|
163
|
+
|
|
164
|
+
run_test! do |example|
|
|
165
|
+
JSON.parse(example.body)["data"]
|
|
166
|
+
organization.reload
|
|
167
|
+
expect(response).to have_http_status(:ok)
|
|
168
|
+
expect(organization.extended_data.data["personal"].keys).to eq(["birthday"])
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
context "with a path=unknown, upsert" do
|
|
173
|
+
before do
|
|
174
|
+
organization.extended_data.update(data: { "personal" => { "birthday" => "1989-01-28" } })
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
let(:body) { { data: { "whatever" => { "is" => { "stil" => "ok" } } }, object_path: "unknown" } }
|
|
178
|
+
|
|
179
|
+
run_test! do |example|
|
|
180
|
+
organization.reload
|
|
181
|
+
data = JSON.parse(example.body)["data"]
|
|
182
|
+
expect(response).to have_http_status(:ok)
|
|
183
|
+
expect(data).to include(body[:data])
|
|
184
|
+
expect(organization.extended_data.data).to eq({
|
|
185
|
+
"personal" => { "birthday" => "1989-01-28" },
|
|
186
|
+
"unknown" => { "whatever" => { "is" => { "stil" => "ok" } } }
|
|
187
|
+
})
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "swagger_helper"
|
|
4
|
+
RSpec.describe Decidim::Api::RestFull::Organizations::OrganizationsController do
|
|
5
|
+
path "/organizations" do
|
|
6
|
+
get "Organizations" do
|
|
7
|
+
tags "Organizations"
|
|
8
|
+
produces "application/json"
|
|
9
|
+
operationId "listOrganizations"
|
|
10
|
+
description "List available organizations"
|
|
11
|
+
it_behaves_like "localized params"
|
|
12
|
+
it_behaves_like "paginated params"
|
|
13
|
+
|
|
14
|
+
describe_api_endpoint(
|
|
15
|
+
controller: Decidim::Api::RestFull::Organizations::OrganizationsController,
|
|
16
|
+
action: :index,
|
|
17
|
+
security_types: [:credentialFlow],
|
|
18
|
+
scopes: ["system"],
|
|
19
|
+
permissions: ["system.organizations.read"]
|
|
20
|
+
) do
|
|
21
|
+
it_behaves_like "localized endpoint"
|
|
22
|
+
|
|
23
|
+
response "200", "Organizations listed" do
|
|
24
|
+
consumes "application/json"
|
|
25
|
+
produces "application/json"
|
|
26
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:organization_index_response)
|
|
27
|
+
|
|
28
|
+
context "with locale[] filter translated results" do
|
|
29
|
+
let(:"locales[]") { %w(en fr) }
|
|
30
|
+
let(:page) { 1 }
|
|
31
|
+
let(:per_page) { 10 }
|
|
32
|
+
|
|
33
|
+
run_test!(example_name: :ok)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context "when another tenant exists", if: Gem.loaded_specs.has_key?("ros-apartment") do
|
|
37
|
+
let!(:other_organization) do
|
|
38
|
+
org = create(:organization, host: "org-b.example.org", available_locales: ["en"])
|
|
39
|
+
Apartment::Tenant.switch!(Decidim::Apartment::DistributionKey.for_host(organization.host).key)
|
|
40
|
+
org
|
|
41
|
+
end
|
|
42
|
+
let(:page) { 1 }
|
|
43
|
+
let(:per_page) { 10 }
|
|
44
|
+
|
|
45
|
+
run_test! do |example|
|
|
46
|
+
hosts = JSON.parse(example.body).fetch("data").map { |row| row.dig("attributes", "host") }
|
|
47
|
+
expect(hosts).to include(organization.host)
|
|
48
|
+
expect(hosts).not_to include(other_organization.host)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it_behaves_like "unauthorized when no Bearer token"
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "swagger_helper"
|
|
4
|
+
RSpec.describe Decidim::Api::RestFull::Organizations::OrganizationsController do
|
|
5
|
+
path "/organizations/{id}" do
|
|
6
|
+
get "Organization" do
|
|
7
|
+
tags "Organizations"
|
|
8
|
+
produces "application/json"
|
|
9
|
+
operationId "getOrganization"
|
|
10
|
+
description "Show organization"
|
|
11
|
+
it_behaves_like "localized params"
|
|
12
|
+
parameter name: :id, in: :path, type: :string, required: true, description: "The ID of the organization"
|
|
13
|
+
|
|
14
|
+
describe_api_endpoint(
|
|
15
|
+
controller: Decidim::Api::RestFull::Organizations::OrganizationsController,
|
|
16
|
+
action: :show,
|
|
17
|
+
security_types: [:credentialFlow],
|
|
18
|
+
scopes: ["system"],
|
|
19
|
+
permissions: ["system.organizations.read"]
|
|
20
|
+
) do
|
|
21
|
+
it_behaves_like "localized endpoint"
|
|
22
|
+
let(:organization) { create(:organization, available_locales: ["en"]) }
|
|
23
|
+
let(:id) { organization.id }
|
|
24
|
+
response "200", "Organization shown" do
|
|
25
|
+
consumes "application/json"
|
|
26
|
+
produces "application/json"
|
|
27
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:organization_item_response)
|
|
28
|
+
|
|
29
|
+
context "with locale[] filter translated results" do
|
|
30
|
+
let(:"locales[]") { %w(en fr) }
|
|
31
|
+
|
|
32
|
+
run_test!(example_name: :ok)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
response "404", "Organization Not Found" do
|
|
37
|
+
produces "application/json"
|
|
38
|
+
schema "$ref" => Decidim::RestFull::Core::DefinitionRegistry.reference(:error_response)
|
|
39
|
+
|
|
40
|
+
context "when id=bad_string" do
|
|
41
|
+
let(:id) { "bad_string" }
|
|
42
|
+
|
|
43
|
+
run_test!
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
context "when id=not_found" do
|
|
47
|
+
let(:id) { Decidim::Organization.last.id + 10 }
|
|
48
|
+
|
|
49
|
+
run_test!(example_name: :not_found)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
context "when id belongs to another tenant", if: Gem.loaded_specs.has_key?("ros-apartment") do
|
|
53
|
+
let!(:other_organization) do
|
|
54
|
+
org = create(:organization, id: 99_999, host: "org-b.example.org", available_locales: ["en"])
|
|
55
|
+
Apartment::Tenant.switch!(Decidim::Apartment::DistributionKey.for_host(organization.host).key)
|
|
56
|
+
org
|
|
57
|
+
end
|
|
58
|
+
let(:id) { other_organization.id }
|
|
59
|
+
|
|
60
|
+
run_test!
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|