Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/eb 4517 base uri #4957

Draft
wants to merge 13 commits into
base: develop
Choose a base branch
from

Conversation

alanpaxton
Copy link
Collaborator

Thank you for your contribution to eXist-db!

To help the community judge your pull request (PR), please include the following:

Your PR will be tested using GitHub Actions against a number of operating systems and environments. The build status is visible in the PR.

To detect errors in your PR before submitting it, please run eXist's full test suite on your own system via mvn -V clean verify.


Description:

Reference:

Type of tests:

eXist-db#4517
static-base-uri is wrong or non-existent in several cases.
We need to set it in the global context.
First failing unit tests for “execute script” via RESTServer,
and for ?_query parameter via RESTServer
Needed for running jetty in the extensions project, in order to test RESTXQ.

[test] webapp config
The RESTXQ integration test now _runs_ correctly against ExistWebserver and invokes RESTXQ functions when the appropriate http endpoints are invoked. The tests _fail_, but this is expected.

It remains to make the tests _pass_ by repairing the `static-base-uri()` function to properly take account of the query context.
We had added this test at the start, but RESTXQ-based unit testing ncan only work in the exist-restxq module, and we have a UT for static-base-uri() there now which does what was intended by this test.
Construct a base URI for the RESTXQ function which prefixes the location of the xquery with the xmldb:exist:// “scheme”
Share mechanism to calculate static base URI from the above change for RESTXQ. Pull it out into a little library class.
Move all the base URI testing into single place in extension unit tests, RESTXQ parts will only run there. Rename to BaseURITest as that is really all there is in it now.
@alanpaxton alanpaxton marked this pull request as draft June 12, 2023 07:42
All the base-uri tests get run in the exist-restxq extensions tests, so no point in the initial refactor of the core RESTServiceTest
Remove a do-nothing test.

Current (not yet complete) set of tests now passing, pending further discussion of the correct base-uri “scheme” to return. Works for the following cases:

Implemented:
1. GET _query parameter
2. PUT a script and execute with RESTServer
3. POST an extended query
4. RESTXQ resource invoked
Pending:
5. An XQuery is executed from the filesystem directly via the XQueryServlet
Make base URI work/consistent over multiple eXist database APIs

- Base URI is defined in XQueryServlet
    - Uses the `file:` URI of the XQuery file executed by the servlet
    - previous checkins defined base URI for RESTXQ and RESTServer as the URI of the "resource" in the database

- URI resolution in the presence of the xmldb:exist: pseudo-URI (for database resources) is implemented/improved
    - `AnyURI.resolveURI()` is defined/implemented to support this
    - FunResolveURI (implementation of XQuery fn:resolve-uri()) makes use of `AnyURI.resolveURI()`

- With `xmldb:exist:` appearing as a base URI, URI resolution needs to deal with `xmldb:exist:`
    - This previously "resolved" to the relative URI, i.e. resolution was effectively a no-op

Tests
-----
fnResolveURI.xqm tests `fn:resolve-uri()` as a set of XQuery unit tests

RESTXQ extensions `BaseURITest.java` tests API requests to `fn:base-uri()` and `fn:resolve-uri()`
    - It centralises all the possible API-level call methods to eXist, testing these methods using each API
    - It covers RESTXQ, RESTServer and XQueryServlet
    - It configures the internal `ExistWebServer` to run all the servlets, using `controller-config.xml` and `web.xml`
    - It has to be placed in the extension module because it uses RESTXQ, which is not part of the eXist core
Need to squash into this change when base-uri is implemented appropriately for XML-RPC.

There may be 2 cases again here; the usual
(1) executing some code directly
(2) running a file through this mechanism
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant