Skip to content

Sync: BioPortal v6.8.0 release #18

Draft
alexskr wants to merge 255 commits into
ontoportal:masterfrom
ncbo:master
Draft

Sync: BioPortal v6.8.0 release #18
alexskr wants to merge 255 commits into
ontoportal:masterfrom
ncbo:master

Conversation

@alexskr

@alexskr alexskr commented Nov 21, 2025

Copy link
Copy Markdown
Contributor

mdorf and others added 30 commits September 16, 2025 20:41
Feature: Ontology Admin Endpoints for Logs and Submission Management
…ests

Replace non-idiomatic assertions with Minitest equivalents:
- assert(x == y) -> assert_equal
- .eql?() -> assert_equal
- assert !x.empty? -> assert_operator x.length, :>, 0
- submissions.all? -> submissions.each for better error messages

Extract repeated contact validation into helper method to reduce duplication.

Fix intermittent test failures by sorting array keys before comparison to handle non-deterministic ordering.
refs #197
- Replace class variables (@@) with class instance variables using accessors
- Add attr_accessor definitions for shared test state
- Modernize assertions to Minitest style (assert_equal, assert_includes, assert_nil)
- Improve code formatting and readability
…dition

- Replace random .sample(3) with deterministic .first(3)
- Use dynamic assertion for keep_ids count instead of hardcoded value
- Capture process_id before use for clarity
- Simplify polling loop condition to check only for 'done' or 'errors'
- Clean up assertion message formatting for consistency
…n/deletion

- Replace `assert 201, ...` with `assert_equal 201, ...` to properly compare response status.
- Add GET checks after slice creation to confirm the new slice exists.
- Remove redundant manual reset of LinkedData.settings.enable_security.
- Update DELETE test to expect 204 (No Content) instead of 201.
- Add GET checks after deletion to verify the slice was actually removed.
- Add explicit flunk when status_payload contains 'errors'
  to prevent false positives from incomplete or invalid responses
- Ensure test fails immediately on backend error instead of silently skipping assertions
Restore LinkedData.settings.enable_slices to its original value after tests.
…com:ncbo/ontologies_api into refactor/tests-stability-and-minitest-style
… user helpers

This change refactors `TestOntologySubmissionsController` to eliminate
suite-level globals and class-variable state in favor of per-test setup
and shared helpers:

- Replace `before_suite` + `@@acronym`/`@@name`/`@@file_params` with
  per-test `setup` that generates a unique ontology acronym and creates
  an ontology administered by a shared test user.
- Introduce a suite-local `USERNAME = "test_user"` and use
  `ensure_user(USERNAME)` to guarantee the user exists without races.
- Normalize assertion style:
  - Use `assert_equal(expected, actual, message)` with parentheses
  - Remove `msg=` pseudo-named args
  - Add `.sort` where appropriate when comparing unordered keys
- Replace direct references to `@@acronym`/`@@name` with instance vars
  (`@acronym`, `@name`).

New helper methods (in the base test class) used by this suite:
- `create_user(username, email:, password:)` — always creates a user
- `ensure_user(username, email:, password:)` — idempotently finds or creates
- `delete_user(username)` — removes a user if present

Notes:
- `delete_ontologies_and_submissions` now runs in `setup` to guarantee
  a clean slate per test. `after_all` also cleans up the shared user via
  `delete_user(USERNAME)`. If the extra cleanup proves redundant, we can
  drop `before_all`/`after_all` and keep only the per-test cleanup.
…st-style

Refactor/tests stability and minitest style
Feature/user admin endpoints - fix unit tests and stability after merging feature branch
Develop -> Master merge, release v6.8.0
mdorf added 12 commits June 9, 2026 15:15
The prefLabelExact/synonymExact fields now use the string_ci_exact
field type (case-insensitive exact match + binary scoring via
omitTermFreqAndPositions). The schema assertions still expected the
old string_ci literal, failing CI on develop after the type change
merged. Case-insensitivity is preserved, so the functional check is
unchanged.
Fix: malformed Solr query in Annotator (#233)
Fix: restore production access log output
@alexskr
alexskr marked this pull request as draft June 18, 2026 16:58
alexskr and others added 17 commits June 22, 2026 10:04
Trailing-slash canonicalization was implemented in init.rb by registering
a companion "#{pattern}/" 301-redirect route for every route. That route
ran in the route-dispatch phase, so it sat behind every before filter and
doubled the route table, and it hardcoded 301 for all verbs (which can
downgrade the method and drop POST/PUT/PATCH bodies).

Replace it with Rack::TrailingSlashRedirect, used as the innermost
middleware so it runs before Sinatra routing and filters. It strips the
trailing slash and redirects (301 for GET/HEAD, 308 for other verbs to
preserve method and body), preserving the forwarded scheme
(X-Forwarded-Proto), the query string, and percent-encoded path segments.
The guard `error 403, "Access denied" unless current_user && current_user.admin?`
was copy-pasted across slices (4x) and annotator (2x), with a nil-guard-less
variant in users. Extract a single admin_only! helper next to current_user
and call it from all seven sites.
Data-driven test asserting every reachable admin_only!-guarded endpoint (slices create/update/delete, user delete, annotator dictionary/cache) returns 403 for an authenticated non-admin.
Adds test/middleware/test_trailing_slash_redirect.rb driven directly via
Rack::MockRequest (no app boot / backend) covering: the verb split (301 for
GET/HEAD, 308 for POST/PUT/PATCH/DELETE), HEAD redirect with an empty body,
root and non-trailing-slash pass-through, and Location building (query string,
percent-encoded segments, X-Forwarded-Proto scheme selection).

Also fixes the middleware to return an empty body for HEAD redirects (a HEAD
response must not carry a body).
The redirect Location is built from X-Forwarded-Proto, but an outer
Rack::Cache keys entries on path + query only. Without no-store a 301/308
generated for an https client could be cached and replayed to a plain-http
client (or vice versa), reintroducing the scheme-downgrade from issue
#217. Redirects are cheap, so keeping them out of the
shared cache costs nothing.
Settings like enable_security live on global singletons, so a suite that
flips one (or errors after flipping it) leaked the value into later tests.

Add a with_settings block helper that restores prior values even when the
block raises, plus per-test (before_setup/after_teardown) and per-suite
(before_all/after_all) snapshot/restore nets in the test base class. Suites
can now set what they need and never restore. Drop the ad-hoc
enable_security/disable_security/reset_security class helpers and convert
callers.
after_all ran after_suite before restoring the per-suite settings snapshot.
Suites that enable a setting in before_suite (e.g. test_rack_attack sets
enable_security) and do privileged cleanup in after_suite (deleting users)
then ran that teardown with the setting still active -> WriteAccessDeniedError.
Because after_suite raised, restore_settings never ran, so enable_security
leaked into every later suite (data-setup WriteAccessDenied, 401s on public
routes). Restore first so teardown runs with settings rolled back and a raising
after_suite cannot leak.
…leware

The Rack SPEC requires both env keys to always be present (possibly
empty, never nil), so the nil checks were unreachable. Add tests pinning
the boundary cases: empty PATH_INFO passes through untouched, and an
empty query string appends no '?' to the Location.
Controller/routing cleanup: trailing-slash middleware, admin_only! helper, test settings isolation
Fixes staging term search failing with RSolr 400 'undefined field:
ontologyRank'. The deployed ontologies_linked_data (24c5a6d0) still
queried the legacy :term_search_core1 collection, which has no
ontologyRank field, while ontologies_api boosts on sum(ontologyRank,1).

Advances locked git revisions to current branch tips:
  ontologies_linked_data develop  -> a8a8dfbd (uses :term_search alias +
                                     defines/populates ontologyRank)
  goo                    development -> c0c1ec7
  ncbo_cron              develop  -> 5e3768b9

goo/sparql-client track 'development'; the rest track 'develop'.
Guards the staging incident where a stale ontologies_linked_data (no
ontologyRank field) was bundled with an api that boosts term search on
sum(ontologyRank,1), making every /search fail with Solr 400
'undefined field: ontologyRank'.

Each repo's own suite stays green on this (ld tests its schema generator;
api's boost test bundles a matching ld), so the cross-repo version skew is
invisible to both. This infra-free contract test binds the query-layer
boost field to the *bundled* linked-data schema, so api CI fails whenever
the resolved ontologies_linked_data omits the field.
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.

3 participants