Skip to content

Extend sample test coverage with App2App and catalog tests - #118

Open
NiklasHerrmann21 wants to merge 3 commits into
mainfrom
extend-sample-test-coverage
Open

NiklasHerrmann21 wants to merge 3 commits into
mainfrom
extend-sample-test-coverage

Conversation

@NiklasHerrmann21

Copy link
Copy Markdown
Contributor

Overview

Extends the test coverage of the samples with scenarios that were not covered before. No production code changes — tests only.

Changes

ams-javalin-shopping + ams-spring-boot-shopping — App2App technical user flow

The App2App technical user flow (API mappers in App2AppAuthorizationConfiguration / AuthHandler) was not exercised by any test. The checked-in TechnicalUser.json fixture is actually a negative case: its ias_apis (ReadProducts, ReadInvoices) are not mapped by the samples' API mappers, so a request with it is denied.

Adds to both samples:

  • a new TechnicalUser_GetProducts.json fixture (ias_apis=["GetProducts"], which the API mapper maps to the internal GetProducts policy that USEs ReadProducts)
  • GET /products with the mapped technical user -> 200
  • GET /products with the unmapped TechnicalUser.json fixture -> 403

ams-cap-bookshop — catalog + anonymous access

  • CatalogService reads are public (no @requires) — previously untested
  • the @After(READ) discount handler is applied to service-level reads (books with stock > 200 get the " (discounted)" suffix)
  • the submitOrder action (previously zero coverage) decreases the stock and returns the new stock
  • AdminService is denied for unauthenticated requests (requires ManageAuthors or ManageBooks)

Verification

All module test suites run green locally:

  • ams-javalin-shopping: 28 tests
  • ams-spring-boot-shopping: 14 tests
  • ams-cap-bookshop: 14 + 21 tests (default + customization executions)

Note: building ams-cap-bookshop locally requires Maven >= 3.9.14 (per cds-maven-plugin 5.1.1); CI is unaffected.

Cover the previously untested App2App technical user flow: a technical
user whose ias_apis is mapped to the internal GetProducts policy can read
the products, while a technical user with unmapped APIs is denied. The new
TechnicalUser_GetProducts.json fixture complements the existing
TechnicalUser.json fixture (whose APIs are intentionally unmapped).
Cover the previously untested App2App technical user flow: a technical
user whose ias_apis is mapped to the internal GetProducts policy can read
the products, while a technical user with unmapped APIs is denied. The new
TechnicalUser_GetProducts.json fixture complements the existing
TechnicalUser.json fixture (whose APIs are intentionally unmapped).
Cover the previously untested parts of the CAP bookshop: catalog reads
are public (CatalogService has no @requires), the @after(READ) discount
handler is applied to service reads, the submitOrder action decreases the
stock and returns the new stock, and AdminService is denied for
unauthenticated requests.
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