diff --git a/modules/wikis/app/services/wikis/adapters/providers/xwiki/queries/concerns/xwiki_page_queries.rb b/modules/wikis/app/services/wikis/adapters/providers/xwiki/queries/concerns/xwiki_page_queries.rb new file mode 100644 index 00000000000..1719e3bbbfe --- /dev/null +++ b/modules/wikis/app/services/wikis/adapters/providers/xwiki/queries/concerns/xwiki_page_queries.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) the OpenProject GmbH +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2013 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See COPYRIGHT and LICENSE files for more details. +#++ + +module Wikis + module Adapters + module Providers + module XWiki + module Queries + module Concerns + module XWikiPageQueries + def canonical_page_info(identifier:, auth_strategy:) + Input::PageInfo.build(identifier:).bind do |input_data| + Internal::CanonicalPageInfo.new(model: provider).call(input_data:, auth_strategy:) + end + end + end + end + end + end + end + end +end diff --git a/modules/wikis/app/services/wikis/adapters/providers/xwiki/queries/referencing_pages.rb b/modules/wikis/app/services/wikis/adapters/providers/xwiki/queries/referencing_pages.rb index c55888cf1fe..ef6f2b535b7 100644 --- a/modules/wikis/app/services/wikis/adapters/providers/xwiki/queries/referencing_pages.rb +++ b/modules/wikis/app/services/wikis/adapters/providers/xwiki/queries/referencing_pages.rb @@ -34,23 +34,22 @@ module Wikis module XWiki module Queries class ReferencingPages < BaseQuery - def call(input_data:, **) - # TODO: use real API endpoints once available + include Concerns::XWikiQuery + include Concerns::XWikiPageQueries - title = [ - "What makes XWiki special?", - "API documentation", - "A brief introduction on configuring your own XWiki instance and connect it to OpenProject." - ] + MAXIMUM_RESULTS = 25 - results = [] - - if input_data.linkable.id % 2 == 0 - results << Success(Results::PageInfo.new(identifier: "1337", title: title.sample, href: "#", provider:)) - results << Success(Results::PageInfo.new(identifier: "1338", title: title.sample, href: "#", provider:)) + def call(input_data:, auth_strategy:) + authenticated(auth_strategy) do |http| + url = rest_url("openproject/links/workPackages/#{input_data.linkable.id}") + handle_response(http.get(url, params: { number: MAXIMUM_RESULTS })) do |data| + success( + fetch_json(data, "searchResults") + .uniq { |r| fetch_json(r, "id") } + .map { canonical_page_info(identifier: fetch_json(it, "id"), auth_strategy:) } + ) + end end - - success(results) end end end diff --git a/modules/wikis/app/services/wikis/adapters/providers/xwiki/queries/search_pages.rb b/modules/wikis/app/services/wikis/adapters/providers/xwiki/queries/search_pages.rb index e0f3c7b02e9..7dfeb1fd6f7 100644 --- a/modules/wikis/app/services/wikis/adapters/providers/xwiki/queries/search_pages.rb +++ b/modules/wikis/app/services/wikis/adapters/providers/xwiki/queries/search_pages.rb @@ -35,6 +35,7 @@ module Wikis module Queries class SearchPages < BaseQuery include Concerns::XWikiQuery + include Concerns::XWikiPageQueries # Limiting result size rather strictly, because each result will cause another HTTP call to XWiki, this does not # scale well. A stricter limit improves the worst case latency. @@ -64,12 +65,6 @@ module Wikis def escape_quotes(string) string.gsub("\\", "\\\\").gsub('"', '\"') end - - def canonical_page_info(identifier:, auth_strategy:) - Input::PageInfo.build(identifier:).bind do |input_data| - Internal::CanonicalPageInfo.new(model: provider).call(input_data:, auth_strategy:) - end - end end end end diff --git a/modules/wikis/app/services/wikis/adapters/providers/xwiki/queries/user.rb b/modules/wikis/app/services/wikis/adapters/providers/xwiki/queries/user.rb index a49fbb3296f..5a1bd0c4fe0 100644 --- a/modules/wikis/app/services/wikis/adapters/providers/xwiki/queries/user.rb +++ b/modules/wikis/app/services/wikis/adapters/providers/xwiki/queries/user.rb @@ -34,30 +34,29 @@ module Wikis module XWiki module Queries class User < BaseQuery + include Concerns::XWikiQuery + def call(auth_strategy:) - url = "#{provider.url.chomp('/')}/rest/wikis/xwiki/user" - Adapters::Authentication[auth_strategy].call do |http| - handle_response(http.get(url)) + authenticated(auth_strategy) do |http| + handle_response(http.get(rest_url("wikis/xwiki/user"))) end end private + # Overrides the concern's handle_response: User reads a response header, + # not a JSON body, so JSON parsing is not applicable here. def handle_response(response) return failure(code: :connection_error) if response.is_a?(HTTPX::ErrorResponse) case response in { status: 200..299 } - handle_success_response(response) + xwiki_user = response.headers["xwiki-user"] + xwiki_user.present? ? success(xwiki_user) : failure(code: :unauthorized) else failure(code: :request_failed) end end - - def handle_success_response(response) - xwiki_user = response.headers["xwiki-user"] - xwiki_user.present? ? success(xwiki_user) : failure(code: :unauthorized) - end end end end diff --git a/modules/wikis/spec/services/wikis/adapters/providers/xwiki/queries/referencing_pages_spec.rb b/modules/wikis/spec/services/wikis/adapters/providers/xwiki/queries/referencing_pages_spec.rb new file mode 100644 index 00000000000..d8ba1013b2a --- /dev/null +++ b/modules/wikis/spec/services/wikis/adapters/providers/xwiki/queries/referencing_pages_spec.rb @@ -0,0 +1,147 @@ +# frozen_string_literal: true + +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) the OpenProject GmbH +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2013 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See COPYRIGHT and LICENSE files for more details. +#++ + +require "spec_helper" +require_module_spec_helper + +RSpec.describe Wikis::Adapters::Providers::XWiki::Queries::ReferencingPages, :disable_ssrf_filter, :webmock do + include XWikiStubs + + it "is registered" do + expect(Wikis::Adapters::Registry.resolve("xwiki.queries.referencing_pages")).to eq(described_class) + end + + describe "input validation" do + it "rejects a linkable that is not a work package" do + expect(Wikis::Adapters::Input::ReferencingPages.build(linkable: create(:project))).to be_failure + end + end + + describe "#call" do + let(:user) { create(:user) } + let(:wiki_provider) do + create(:xwiki_provider, :with_connected_user, url: "https://xwiki.example.com/", connected_user: user) + end + let(:linkable) { create(:work_package) } + let(:auth_strategy) do + Wikis::Adapters::Input::AuthStrategy.build(key: :bearer_token, user:, provider: wiki_provider).value! + end + let(:input_data) { Wikis::Adapters::Input::ReferencingPages.build(linkable:).value! } + let(:query) { described_class.new(model: wiki_provider) } + + subject(:result) { query.call(input_data:, auth_strategy:) } + + context "when the same page appears multiple times in results" do + let(:duplicate_id) { "xwiki:Main.WebHome" } + let(:same_title_different_id) { "xwiki:Other.WebHome" } + + before do + stub_search( + [ + { "id" => duplicate_id, "title" => "Home" }, + { "id" => duplicate_id, "title" => "Home" }, + { "id" => same_title_different_id, "title" => "Home" } + ], + provider: wiki_provider, + linkable: + ) + stub_canonical_page_info(duplicate_id, + uid: "aaa111", + title: "Home", + href: "https://xwiki.example.com/bin/view/Main/", + provider: wiki_provider) + stub_canonical_page_info(same_title_different_id, + uid: "bbb222", + title: "Home", + href: "https://xwiki.example.com/bin/view/Other/", + provider: wiki_provider) + end + + it { is_expected.to be_success } + + it "deduplicates by page identifier, not by title" do + expect(result.value!.map { it.value!.identifier }).to contain_exactly("aaa111", "bbb222") + end + end + + context "when the search request fails" do + before do + stub_request(:get, search_endpoint(linkable, provider: wiki_provider)) + .to_return(status: 500, body: "Internal Server Error") + end + + it { is_expected.to be_failure.and have_attributes(failure: have_attributes(code: :request_failed)) } + end + + context "when no OAuth token exists for the user" do + let(:wiki_provider) { create(:xwiki_provider, :with_oauth_client, url: "https://xwiki.example.com/") } + + it { is_expected.to be_failure.and have_attributes(failure: have_attributes(code: :missing_token)) } + end + + context "when the search request returns unauthorized" do + before { stub_request(:get, search_endpoint(linkable, provider: wiki_provider)).to_return(status: 401, body: "") } + + it { is_expected.to be_failure.and have_attributes(failure: have_attributes(code: :unauthorized)) } + end + + context "when the search request times out" do + before { stub_request(:get, search_endpoint(linkable, provider: wiki_provider)).to_timeout } + + it { is_expected.to be_failure.and have_attributes(failure: have_attributes(code: :connection_error)) } + end + + context "with real XWiki responses", vcr: "xwiki/referencing_pages" do + let(:wiki_provider) { create(:xwiki_provider, :for_local_connection, connected_user: user) } + let(:linkable) { create(:work_package, id: 14) } + let(:auth_strategy) { wiki_provider.auth_strategy_for(user).value! } + + it "returns PageInfo for all linked pages" do + expect(result).to be_success + expect(result.value!.map { it.value!.to_h.except(:provider) }).to contain_exactly( + { identifier: "48944", title: "OpenProject integration", href: "https://xwiki.local/bin/view/test/" }, + { identifier: "42f2f", title: "Def New Page", href: "https://xwiki.local/bin/view/test/Def%20New%20Page/" }, + { identifier: "a3739", title: "Just a normal page", href: "https://xwiki.local/bin/view/Just%20a%20normal%20page/" } + ) + end + end + + context "with no linked pages in XWiki (VCR)", vcr: "xwiki/referencing_pages_empty" do + let(:wiki_provider) { create(:xwiki_provider, :for_local_connection, connected_user: user) } + let(:linkable) { create(:work_package, id: 21) } + let(:auth_strategy) { wiki_provider.auth_strategy_for(user).value! } + + it "returns an empty list" do + expect(result).to be_success + expect(result.value!).to eq([]) + end + end + end +end diff --git a/modules/wikis/spec/spec_helper.rb b/modules/wikis/spec/spec_helper.rb index d597b3f40aa..2210fd513b4 100644 --- a/modules/wikis/spec/spec_helper.rb +++ b/modules/wikis/spec/spec_helper.rb @@ -31,6 +31,8 @@ require "dry/core/container/stub" require "dry/monads" +Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each { |f| require f } + RSpec.configure do |config| config.include Dry::Monads[:result] diff --git a/modules/wikis/spec/support/xwiki_stubs.rb b/modules/wikis/spec/support/xwiki_stubs.rb new file mode 100644 index 00000000000..cf085732674 --- /dev/null +++ b/modules/wikis/spec/support/xwiki_stubs.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) the OpenProject GmbH +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2013 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See COPYRIGHT and LICENSE files for more details. +#++ + +module XWikiStubs + def search_endpoint(linkable, provider:, number: 25) + "#{provider.url}rest/openproject/links/workPackages/#{linkable.id}?number=#{number}" + end + + def stub_canonical_page_info(identifier, uid:, title:, href:, provider:, token: "user-bearer-token") + stub_request(:get, "#{provider.url}rest/openproject/documents") + .with(query: { "docRef" => identifier }, + headers: { "Authorization" => "Bearer #{token}" }) + .to_return(status: 200, + body: { "id" => uid, "title" => title, "xwikiAbsoluteUrl" => href }.to_json, + headers: { "Content-Type" => "application/json" }) + end + + def stub_search(search_results, provider:, linkable:, number: 25, token: "user-bearer-token") + stub_request(:get, search_endpoint(linkable, provider:, number:)) + .with(headers: { "Authorization" => "Bearer #{token}" }) + .to_return(status: 200, + body: { "searchResults" => search_results }.to_json, + headers: { "Content-Type" => "application/json" }) + end +end diff --git a/spec/support/fixtures/vcr_cassettes/xwiki/referencing_pages.yml b/spec/support/fixtures/vcr_cassettes/xwiki/referencing_pages.yml new file mode 100644 index 00000000000..13269461be0 --- /dev/null +++ b/spec/support/fixtures/vcr_cassettes/xwiki/referencing_pages.yml @@ -0,0 +1,193 @@ +--- +http_interactions: +- request: + method: get + uri: https://xwiki.local/rest/openproject/links/workPackages/14?number=25 + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - OpenProject 17.6.0 HTTPX Client + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Authorization: + - Bearer + response: + status: + code: 200 + message: OK + headers: + Content-Language: + - en + Content-Script-Type: + - text/javascript + Content-Type: + - application/json;charset=UTF-8 + Date: + - Wed, 10 Jun 2026 13:09:46 GMT + Set-Cookie: + - JSESSIONID=976A8D0872AE6EC68937149CE6F6191C; Path=/; HttpOnly + Xwiki-Form-Token: + - QVVZtN1gchKDZcFGGdo7Rg + Xwiki-User: + - xwiki:XWiki.admin + Xwiki-Version: + - 18.3.0 + Content-Length: + - '1892' + body: + encoding: UTF-8 + string: '{"links":[],"searchResults":[{"links":[{"href":"https://xwiki.local/rest/wikis/xwiki/spaces/test/pages/WebHome","rel":"http://www.xwiki.org/rel/page","type":null,"hrefLang":null}],"type":"page","id":"xwiki:test.WebHome","pageFullName":"test.WebHome","title":"OpenProject + integration","wiki":"xwiki","space":"test","pageName":"WebHome","modified":1780562303000,"author":"xwiki:XWiki.admin","authorName":null,"version":"5.1","language":null,"className":null,"objectNumber":null,"filename":null,"score":0.33462277,"object":null,"hierarchy":null},{"links":[{"href":"https://xwiki.local/rest/wikis/xwiki/spaces/test/spaces/Def%20New%20Page/pages/WebHome","rel":"http://www.xwiki.org/rel/page","type":null,"hrefLang":null}],"type":"page","id":"xwiki:test.Def + New Page.WebHome","pageFullName":"test.Def New Page.WebHome","title":"Def + New Page","wiki":"xwiki","space":"test.Def New Page","pageName":"WebHome","modified":1780583786000,"author":"xwiki:XWiki.admin","authorName":null,"version":"1.4","language":null,"className":null,"objectNumber":null,"filename":null,"score":0.33462277,"object":null,"hierarchy":null},{"links":[{"href":"https://xwiki.local/rest/wikis/xwiki/spaces/Just%20a%20normal%20page/pages/WebHome","rel":"http://www.xwiki.org/rel/page","type":null,"hrefLang":null}],"type":"page","id":"xwiki:Just + a normal page.WebHome","pageFullName":"Just a normal page.WebHome","title":"Just + a normal page","wiki":"xwiki","space":"Just a normal page","pageName":"WebHome","modified":1781077754000,"author":"xwiki:XWiki.admin","authorName":null,"version":"2.4","language":null,"className":null,"objectNumber":null,"filename":null,"score":0.33462277,"object":null,"hierarchy":null}],"template":"https://xwiki.local/rest/?q={solrquery}(&number={number})(&start={start})(&orderField={fieldname}(&order={asc|desc}))(&distinct=1)(&prettyNames={false|true})(&wikis={wikis})(&className={classname})"}' + recorded_at: Wed, 10 Jun 2026 13:09:46 GMT +- request: + method: get + uri: https://xwiki.local/rest/openproject/documents?docRef=xwiki:test.WebHome + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - OpenProject 17.6.0 HTTPX Client + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Content-Type: + - application/json + Authorization: + - Bearer + response: + status: + code: 200 + message: OK + headers: + Content-Language: + - en + Content-Script-Type: + - text/javascript + Content-Type: + - application/json;charset=UTF-8 + Date: + - Wed, 10 Jun 2026 13:09:46 GMT + Set-Cookie: + - JSESSIONID=213131400A5E972D47A5D58CA6592C66; Path=/; HttpOnly + Xwiki-Form-Token: + - QVVZtN1gchKDZcFGGdo7Rg + Xwiki-User: + - xwiki:XWiki.admin + Xwiki-Version: + - 18.3.0 + Content-Length: + - '2308' + body: + encoding: UTF-8 + string: '{"links":[{"href":"https://xwiki.local/rest/wikis/xwiki/spaces/test","rel":"http://www.xwiki.org/rel/space","type":null,"hrefLang":null},{"href":"https://xwiki.local/rest/wikis/xwiki/spaces/test/pages/WebHome","rel":"http://www.xwiki.org/rel/parent","type":null,"hrefLang":null},{"href":"https://xwiki.local/rest/wikis/xwiki/spaces/test/pages/WebHome/history","rel":"http://www.xwiki.org/rel/history","type":null,"hrefLang":null},{"href":"https://xwiki.local/rest/wikis/xwiki/spaces/test/pages/WebHome/children","rel":"http://www.xwiki.org/rel/children","type":null,"hrefLang":null},{"href":"https://xwiki.local/rest/wikis/xwiki/spaces/test/pages/WebHome/objects","rel":"http://www.xwiki.org/rel/objects","type":null,"hrefLang":null},{"href":"https://xwiki.local/rest/syntaxes","rel":"http://www.xwiki.org/rel/syntaxes","type":null,"hrefLang":null},{"href":"https://xwiki.local/rest/openproject/documents","rel":"self","type":null,"hrefLang":null},{"href":"https://xwiki.local/rest/wikis/xwiki/classes/test.WebHome","rel":"http://www.xwiki.org/rel/class","type":null,"hrefLang":null}],"id":"48944","fullName":"test.WebHome","wiki":"xwiki","space":"test","name":"WebHome","title":"OpenProject + integration","rawTitle":"OpenProject integration","parent":"Main.WebHome","parentId":"xwiki:Main.WebHome","version":"5.1","author":"XWiki.admin","authorName":null,"xwikiRelativeUrl":"https://xwiki.local/bin/view/test/","xwikiAbsoluteUrl":"https://xwiki.local/bin/view/test/","translations":{"links":[],"translations":[],"default":"en"},"syntax":"xwiki/2.1","language":"","majorVersion":5,"minorVersion":1,"hidden":false,"enforceRequiredRights":false,"created":1779288739000,"creator":"XWiki.admin","creatorName":null,"modified":1780562303000,"modifier":"XWiki.admin","modifierName":null,"originalMetadataAuthor":"xwiki:XWiki.admin","originalMetadataAuthorName":null,"comment":"","content":"{{openproject + instance=\"OpenProject\"/}}","clazz":null,"objects":null,"attachments":null,"hierarchy":{"items":[{"label":"xwiki","name":"xwiki","type":"wiki","url":"https://xwiki.local/bin/view/Main/"},{"label":"test","name":"test","type":"space","url":"https://xwiki.local/bin/view/test/"},{"label":"WebHome","name":"WebHome","type":"document","url":"https://xwiki.local/bin/view/test/"}]},"rights":[],"renderedContent":null}' + recorded_at: Wed, 10 Jun 2026 13:09:46 GMT +- request: + method: get + uri: https://xwiki.local/rest/openproject/documents?docRef=xwiki:test.Def%20New%20Page.WebHome + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - OpenProject 17.6.0 HTTPX Client + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Content-Type: + - application/json + Authorization: + - Bearer + response: + status: + code: 200 + message: OK + headers: + Content-Language: + - en + Content-Script-Type: + - text/javascript + Content-Type: + - application/json;charset=UTF-8 + Date: + - Wed, 10 Jun 2026 13:09:46 GMT + Set-Cookie: + - JSESSIONID=99DBB4EF48A0F8D8F2D058206A385953; Path=/; HttpOnly + Xwiki-Form-Token: + - QVVZtN1gchKDZcFGGdo7Rg + Xwiki-User: + - xwiki:XWiki.admin + Xwiki-Version: + - 18.3.0 + Content-Length: + - '2509' + body: + encoding: UTF-8 + string: '{"links":[{"href":"https://xwiki.local/rest/wikis/xwiki/spaces/test/spaces/Def%20New%20Page","rel":"http://www.xwiki.org/rel/space","type":null,"hrefLang":null},{"href":"https://xwiki.local/rest/wikis/xwiki/spaces/test/spaces/Def%20New%20Page/pages/WebHome","rel":"http://www.xwiki.org/rel/parent","type":null,"hrefLang":null},{"href":"https://xwiki.local/rest/wikis/xwiki/spaces/test/spaces/Def%20New%20Page/pages/WebHome/history","rel":"http://www.xwiki.org/rel/history","type":null,"hrefLang":null},{"href":"https://xwiki.local/rest/wikis/xwiki/spaces/test/spaces/Def%20New%20Page/pages/WebHome/objects","rel":"http://www.xwiki.org/rel/objects","type":null,"hrefLang":null},{"href":"https://xwiki.local/rest/syntaxes","rel":"http://www.xwiki.org/rel/syntaxes","type":null,"hrefLang":null},{"href":"https://xwiki.local/rest/openproject/documents","rel":"self","type":null,"hrefLang":null},{"href":"https://xwiki.local/rest/wikis/xwiki/classes/test.Def%20New%20Page.WebHome","rel":"http://www.xwiki.org/rel/class","type":null,"hrefLang":null}],"id":"42f2f","fullName":"test.Def + New Page.WebHome","wiki":"xwiki","space":"test.Def New Page","name":"WebHome","title":"Def + New Page","rawTitle":"Def New Page","parent":"test.WebHome","parentId":"xwiki:test.WebHome","version":"1.4","author":"XWiki.admin","authorName":null,"xwikiRelativeUrl":"https://xwiki.local/bin/view/test/Def%20New%20Page/","xwikiAbsoluteUrl":"https://xwiki.local/bin/view/test/Def%20New%20Page/","translations":{"links":[],"translations":[],"default":"en"},"syntax":"xwiki/2.1","language":"","majorVersion":1,"minorVersion":4,"hidden":false,"enforceRequiredRights":false,"created":1780583563000,"creator":"XWiki.admin","creatorName":null,"modified":1780583563000,"modifier":"XWiki.admin","modifierName":null,"originalMetadataAuthor":"xwiki:XWiki.admin","originalMetadataAuthorName":null,"comment":"Update + property ProjectManagement.Code.RelationClass[0].workItem","content":"{{openproject + instance=\"OpenProject\"/}}","clazz":null,"objects":null,"attachments":null,"hierarchy":{"items":[{"label":"xwiki","name":"xwiki","type":"wiki","url":"https://xwiki.local/bin/view/Main/"},{"label":"test","name":"test","type":"space","url":"https://xwiki.local/bin/view/test/"},{"label":"Def + New Page","name":"Def New Page","type":"space","url":"https://xwiki.local/bin/view/test/Def%20New%20Page/"},{"label":"WebHome","name":"WebHome","type":"document","url":"https://xwiki.local/bin/view/test/Def%20New%20Page/"}]},"rights":[],"renderedContent":null}' + recorded_at: Wed, 10 Jun 2026 13:09:46 GMT +- request: + method: get + uri: https://xwiki.local/rest/openproject/documents?docRef=xwiki:Just%20a%20normal%20page.WebHome + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - OpenProject 17.6.0 HTTPX Client + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Content-Type: + - application/json + Authorization: + - Bearer + response: + status: + code: 200 + message: OK + headers: + Content-Language: + - en + Content-Script-Type: + - text/javascript + Content-Type: + - application/json;charset=UTF-8 + Date: + - Wed, 10 Jun 2026 13:09:46 GMT + Set-Cookie: + - JSESSIONID=0A4B7316C9694C7744851A772202504B; Path=/; HttpOnly + Xwiki-Form-Token: + - QVVZtN1gchKDZcFGGdo7Rg + Xwiki-User: + - xwiki:XWiki.admin + Xwiki-Version: + - 18.3.0 + Content-Length: + - '2403' + body: + encoding: UTF-8 + string: '{"links":[{"href":"https://xwiki.local/rest/wikis/xwiki/spaces/Just%20a%20normal%20page","rel":"http://www.xwiki.org/rel/space","type":null,"hrefLang":null},{"href":"https://xwiki.local/rest/wikis/xwiki/spaces/Just%20a%20normal%20page/pages/WebHome","rel":"http://www.xwiki.org/rel/parent","type":null,"hrefLang":null},{"href":"https://xwiki.local/rest/wikis/xwiki/spaces/Just%20a%20normal%20page/pages/WebHome/history","rel":"http://www.xwiki.org/rel/history","type":null,"hrefLang":null},{"href":"https://xwiki.local/rest/wikis/xwiki/spaces/Just%20a%20normal%20page/pages/WebHome/objects","rel":"http://www.xwiki.org/rel/objects","type":null,"hrefLang":null},{"href":"https://xwiki.local/rest/syntaxes","rel":"http://www.xwiki.org/rel/syntaxes","type":null,"hrefLang":null},{"href":"https://xwiki.local/rest/openproject/documents","rel":"self","type":null,"hrefLang":null},{"href":"https://xwiki.local/rest/wikis/xwiki/classes/Just%20a%20normal%20page.WebHome","rel":"http://www.xwiki.org/rel/class","type":null,"hrefLang":null}],"id":"a3739","fullName":"Just + a normal page.WebHome","wiki":"xwiki","space":"Just a normal page","name":"WebHome","title":"Just + a normal page","rawTitle":"Just a normal page","parent":"Main.WebHome","parentId":"xwiki:Main.WebHome","version":"2.4","author":"XWiki.admin","authorName":null,"xwikiRelativeUrl":"https://xwiki.local/bin/view/Just%20a%20normal%20page/","xwikiAbsoluteUrl":"https://xwiki.local/bin/view/Just%20a%20normal%20page/","translations":{"links":[],"translations":[],"default":"en"},"syntax":"xwiki/2.1","language":"","majorVersion":2,"minorVersion":4,"hidden":false,"enforceRequiredRights":false,"created":1780583835000,"creator":"XWiki.admin","creatorName":null,"modified":1781015081000,"modifier":"XWiki.admin","modifierName":null,"originalMetadataAuthor":"xwiki:XWiki.admin","originalMetadataAuthorName":null,"comment":"Created + URL Shortener.","content":"{{openproject instance=\"OpenProject\"/}}","clazz":null,"objects":null,"attachments":null,"hierarchy":{"items":[{"label":"xwiki","name":"xwiki","type":"wiki","url":"https://xwiki.local/bin/view/Main/"},{"label":"Just + a normal page","name":"Just a normal page","type":"space","url":"https://xwiki.local/bin/view/Just%20a%20normal%20page/"},{"label":"WebHome","name":"WebHome","type":"document","url":"https://xwiki.local/bin/view/Just%20a%20normal%20page/"}]},"rights":[],"renderedContent":null}' + recorded_at: Wed, 10 Jun 2026 13:09:46 GMT +recorded_with: VCR 6.4.0 diff --git a/spec/support/fixtures/vcr_cassettes/xwiki/referencing_pages_empty.yml b/spec/support/fixtures/vcr_cassettes/xwiki/referencing_pages_empty.yml new file mode 100644 index 00000000000..738564cd8c3 --- /dev/null +++ b/spec/support/fixtures/vcr_cassettes/xwiki/referencing_pages_empty.yml @@ -0,0 +1,45 @@ +--- +http_interactions: +- request: + method: get + uri: https://xwiki.local/rest/openproject/links/workPackages/21?number=25 + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - OpenProject 17.6.0 HTTPX Client + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Authorization: + - Bearer + response: + status: + code: 200 + message: OK + headers: + Content-Language: + - en + Content-Script-Type: + - text/javascript + Content-Type: + - application/json;charset=UTF-8 + Date: + - Wed, 10 Jun 2026 13:35:49 GMT + Set-Cookie: + - JSESSIONID=438D0A8CA559253849D776554DCB7043; Path=/; HttpOnly + Xwiki-Form-Token: + - QVVZtN1gchKDZcFGGdo7Rg + Xwiki-User: + - xwiki:XWiki.admin + Xwiki-Version: + - 18.3.0 + Content-Length: + - '242' + body: + encoding: UTF-8 + string: '{"links":[],"searchResults":[],"template":"https://xwiki.local/rest/?q={solrquery}(&number={number})(&start={start})(&orderField={fieldname}(&order={asc|desc}))(&distinct=1)(&prettyNames={false|true})(&wikis={wikis})(&className={classname})"}' + recorded_at: Wed, 10 Jun 2026 13:35:49 GMT +recorded_with: VCR 6.4.0