Feature/dpav 3018 - Discover and Product View - #73
Merged
Merged
Conversation
- Deleted `ProductService`, `ProductServiceImpl`, and associated test classes (`ProductServiceImplTest`, `ProductRepositoryTest`). - Updated `ProductControllerTest` to use `ProductDiscoveryService` for discovery scenarios. - Cleaned up redundant methods and DTOs, reducing unnecessary maintenance overhead. - Updated `Product` entity to include a description field for more detailed search and discovery.
…andling - Migrated `ProductDiscoveryServiceImpl` to a modular design, introducing search planning, criteria validation, repository execution, and assembly components. - Enhanced policy enforcement with delegated searches through the `ProductQueryPlanner` and enriched output via the `DiscoveredProductAssembler`. - Updated OPA fallback and dispatch rules for more descriptive policy denials with specific refusal reasons. - Improved policy documentation to reflect updated request handling, configuration options, and contract-based search execution flows.
…andling - Migrated `ProductDiscoveryServiceImpl` to a modular design, introducing search planning, criteria validation, repository execution, and assembly components. - Enhanced policy enforcement with delegated searches through the `ProductQueryPlanner` and enriched output via the `DiscoveredProductAssembler`. - Updated OPA fallback and dispatch rules for more descriptive policy denials with specific refusal reasons. - Improved policy documentation to reflect updated request handling, configuration options, and contract-based search execution flows.
…andling - Migrated `ProductDiscoveryServiceImpl` to a modular design, introducing search planning, criteria validation, repository execution, and assembly components. - Enhanced policy enforcement with delegated searches through the `ProductQueryPlanner` and enriched output via the `DiscoveredProductAssembler`. - Updated OPA fallback and dispatch rules for more descriptive policy denials with specific refusal reasons. - Improved policy documentation to reflect updated request handling, configuration options, and contract-based search execution flows.
- Introduced test specification documentation for API manual testing, including objectives, preconditions, test data, and edge cases. - Updated OPA policy documentation and sample stories to clarify product `view` and `discover` rules. - Detailed the unification of the discovery and view rules to ensure consistent policy behavior and prevent rule divergence. - Revised product attribute definitions, population risk tags, and coverage jurisdiction logic with new data samples and validation information.
- Introduced test specification documentation for API manual testing, including objectives, preconditions, test data, and edge cases. - Updated OPA policy documentation and sample stories to clarify product `view` and `discover` rules. - Detailed the unification of the discovery and view rules to ensure consistent policy behavior and prevent rule divergence. - Revised product attribute definitions, population risk tags, and coverage jurisdiction logic with new data samples and validation information.
Contributor
✅ OSS Checks PassedAll tracked OSS checks passed in this run.
Results from commit 24ec620, view the full job summary ♻️ This comment has been updated with latest results. |
…arity - Extracted column selection logic in `ProductSearchQueryBuilder` into a dedicated method for improved readability and reusability. - Refactored test assertions for better readability by introducing intermediate variables for views and comparisons. - Clarified SQL concatenation handling in `ProductDiscoveryRepository` to address injection risk review notes. - Enhanced `ProductSearchCriteriaFactory` by separating filter and sort key extraction into modular private methods for better maintainability. - Updated relevant unit tests to align with new method structures and improve test comprehension.
…arity - Extracted column selection logic in `ProductSearchQueryBuilder` into a dedicated method for improved readability and reusability. - Refactored test assertions for better readability by introducing intermediate variables for views and comparisons. - Clarified SQL concatenation handling in `ProductDiscoveryRepository` to address injection risk review notes. - Enhanced `ProductSearchCriteriaFactory` by separating filter and sort key extraction into modular private methods for better maintainability. - Updated relevant unit tests to align with new method structures and improve test comprehension.
…d reuse - Moved static SQL query strings in `ProductDiscoveryRepository` to centralized fields for reuse and improved maintainability. - Updated query methods to use new query fields, reducing redundancy and enhancing readability. - Refined generic handling and improved method signatures in `ProductQueryPlanner` for better type safety and modularity. - Adjusted JavaDoc comments and formatting for consistency in `ProductSearchCriteriaFactory`.
|
jenniferbrown94
approved these changes
Sep 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Sensitive Credential Checks
Motivation and Context
Jira: DPAV-3018
Product discovery previously filtered in Java and returned a shape that could not be acted on: a
discovered product carried no id, so it could not be passed to any other endpoint, and there was no
way to retrieve a single product at all.
Two problems had to be solved together.
Discovery had to become policy-driven rather than code-driven. Entitlement logic (clearance
comparisons, purpose checks, attribute names) lived in Java, so changing who may see what meant a
release. The policy decision now returns a search contract, which the service compiles into one
parameterised SQL statement. Nothing a caller may not see is selected, paging counts are exact, and
one decision serves the whole search.
A single-product endpoint had to not become a hole in that filtering. If view applied weaker
rules than discovery, any caller holding the role could read the whole catalogue one id at a time,
including products discovery deliberately withholds. View is therefore implemented as discovery
constrained to one product: same caller gates, same row filter, same masking, from one shared
definition rather than two implementations that happen to agree.
Description
Discovery rebuilt as a contract-driven search pipeline.
ProductDiscoveryServiceImplis splitinto focused components:
ProductQueryPlanner(turns the decision into a contract),ProductSearchCriteriaFactory(validates caller criteria against it),SqlPredicateCompilerandProductSearchQueryBuilder(compile the contract and criteria into SQL),ProductDiscoveryRepository(executes), and
DiscoveredProductAssembler(builds the response).ProductField,ProductBlock,ProductProjection,DiscoverySchemaandDiscoveryObligationssupport them.New Product View endpoint.
GET /api/v1/product/{productId}, roleproduct_view, policyproduct/view. AddedProductViewServiceandProductViewServiceImpl; the id becomes one morecondition AND-ed onto the policy row filter. A product the row filter excludes returns
404, thesame answer as a product that does not exist, so an id cannot be used to probe what exists.
One shared policy contract.
ProductPolicyContractDetailsis a new base type returned by boththe discover and view rules, and
lib/product_access.regois the single definition both Rego rulesreturn.
view_test.regoasserts the two decisions are equal for every sample organisation, so thetwo endpoints cannot drift apart unnoticed.
Filter model. New
FilterNodepredicate tree withComparisonOperator,Combinator,FilterScopeandFilterTarget, shared by the policy row filter and caller-supplied filters.Attribute names are always bound parameters, never interpolated.
Dead code removed.
ProductService,ProductServiceImpland their tests are deleted, along withthe
ProductRepositoryquery methods they used.ProductControllerTestnow exercises the discoveryand view services directly.
Database. Three schema migrations (product
descriptioncolumn, thepolicy_attribute_live_valueview, discovery join indexes) and three local sample migrations(product descriptions, sensitive organisation attribute flags, and the 17-product discovery
dataset).
Error handling. New
InvalidSearchCriteriaExceptionwith handling inGlobalExceptionHandler,so a malformed search is a
400with a message naming the problem rather than a500.Identity.
docker/keycloak/tofu/clients.tfadds theproduct_discovery,product_subscribeandproduct_viewclient roles.Documentation.
POLICY_ENFORCEMENT.md,AUTHENTICATION_REQUIREMENTS.mdandDATABASE_SCHEMA.mdupdated; newDISCOVERY_TEST_SCENARIOS.md(guided tour over the sample data)and
docs/tests/products/(a test requirement specification per API, which is what the testing teamchecks against);
policy_sample_stories.mdand the OPA readme reworked.97 files changed, 15,268 insertions, 1,826 deletions, across 5 commits.
How Has This Been Tested?
Automated. Every check below was run against a clean checkout of this branch head, so the
results describe exactly what is committed here and nothing from a local working tree:
./mvnw test./mvnw spotless:checkopa test /popa check --strict /popa fmt --diff /pTest coverage added by this branch includes
ProductViewServiceImplTest,ProductQueryPlannerTest,SqlPredicateCompilerTest,ProductSearchQueryBuilderTest,ProductSearchContractTest,ProductSearchCriteriaFactoryTest,DiscoveredProductAssemblerTest,ProductViewPolicyDecisionDetailsTestandFilterNodeSerializationTest, alongside substantiallyexpanded
ProductDiscoveryServiceImplTestandProductControllerTest.Two cross-checks are asserted at build time rather than by inspection:
discover_test.regoasserts the row filter and the per-candidate decision agree for every sampleorganisation and every sample product, catching any divergence between the SQL and the Rego.
view_test.regoasserts view's whole decision equals discovery's, so "discoverable but notviewable" and the reverse are both impossible.
Manual verification follows
docs/DISCOVERY_TEST_SCENARIOS.mdagainst the local stack (Keycloak,Postgres, OPA). Note that the policy decision point fails closed: with OPA stopped, every
policy-enforced endpoint returns
403, which is expected rather than a defect.Not covered by the automated suite: the six Flyway migrations. The repo runs no Testcontainers
and Flyway is disabled in
src/test/resources/application.yml, so the migrations are exercised onlyby running the application against a local database.
Screenshots (if appropriate):
n/a, API-only change.
Checklist:
Reviewer notes
an identical message from a rebase, so the squashed message is worth writing by hand.
lib/product_access.rego: it is the one definition bothproduct rules return, so it is where the caller gates, row filter and masking actually live.
docs/tests/products/, which the testing team checks against,so those files are part of the change rather than a follow-up.