Repository navigation
test: reach 100% test coverage - #184
Conversation
Cover the remaining lines and branches of the config package with tests of behaviour, and remove code that no request can reach: - User: the builder sets all group sets, so the null checks are gone; equals and hashCode use Objects; the unused no-arg constructor is gone. Tests cover the account flags, groups, toString and equality. - ServiceClientTokenServices: no status check after jose4j's Get, which throws for any status but 200; no second check of the verifier under the lock (a request that raced another one's build builds it again). Tests cover nested JWTs, a discovery document without jwks_uri, a blank client claim, [::1], concurrent builds and refreshes, and the refusal reasons. - TraceInterceptorConfiguration: the pointcuts are expressions instead of empty @pointcut methods; tests check which wrapper calls are traced (never createSecret) and the trace of Kubernetes errors. - GroupNamesSecurityExtractor: one path per claim shape. - CustomErrorHandler: Spring MVC always passes ServletWebRequests. - Tests for the Swagger UI's grant types and scopes, and for an admin group named like the managers of a team. Refs #179 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cover the remaining lines and branches of the k8s package: - TesKubernetesConverter: a task that can't be serialized now fails the creation instead of creating a job without the task's JSON, which could be neither run nor read; gzipping has no unreachable catch. - KubernetesObjectsSupplier reads taskmaster.json once, at startup, instead of on every task (no unreachable IOException per task). - KubernetesClientWrapper: minimumRamGb reads the LimitRanges directly. - Constants classes get private constructors. - Tests for errors of every Kubernetes call, LimitRanges without a minimum, jobs without labels, the executors' security context from the ConfigMap, the FTP and executor Secret settings, and the task data classes. Refs #179 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cover the remaining lines and branches of the tes and trs packages: the minimum memory of tasks, exhausted name collision retries, pod logs that Kubernetes doesn't return, TRS errors and empty responses, the reload of service-info.yaml, and the view parameter. Remove the check for the FULL view, which is the only one left at that point, and the getRequest override of ServiceInfoApiController, which only the generated default methods use. Refs #179 Co-Authored-By: Claude Opus 5.5 <[email protected]>
./mvnw verify now fails below 100% of the lines or branches of the unit and integration tests together, and Codecov's project and patch targets are 100%. The JaCoCo exclusion of the models pointed to a package that no longer exists (uk/ac/ebi/tsc/tesk/model), so the generated code was measured; it now excludes exactly the files that openapi-generator generates (src/main/java/.openapi-generator/FILES, also excluded from Spotless and Checkstyle) and TeskApplication, with the reasons. The developer docs say how to read the merged report. Closes #179 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review findings: a request that found no verifier just before another one finished building it fetched the keys again, and was refused if that fetch failed. It now uses the verifier built meanwhile, as before; a test makes that race deterministic. The tests of concurrent fetches wait 3 seconds instead of 1 for the slow responses, so that a stalled runner doesn't fail them. Refs #179 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov got the unit and integration reports separately; JaCoCo XML has no branch identities, so a line whose branches the two suites cover in part each would stay partial for Codecov while the JaCoCo check, on the merged data, passes. The build now writes a report of the merged data (target/site/jacoco-merged), and CI sends only that one. Refs #179 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Round 2 review: clearer comments on the merged report in pom.xml and ci.yml; the race test names the fields it reaches by reflection and fails clearly if the verifier field is renamed. Refs #179 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideData structuresMake User group collections non-null by construction and simplify its equality and hashing around that invariant.
APIRemove the controller’s redundant request accessor while preserving its service-info endpoint.
ImplementationSimplify MVC exception handling to use the servlet request Spring supplies, and add consistent validation and status responses.
Replace named tracing pointcuts with explicit expressions and retain Kubernetes response bodies in traces of Kubernetes exceptions.
Normalize group claims by handling null as no groups and reducing claim-shape conversion to a single path per shape.
Avoid redundant verifier fetches after acquiring the build lock and rely on jose4j’s status handling for discovery responses.
Load the taskmaster template once when constructing the supplier, then build each job from the cached JSON.
Fail task conversion on JSON or gzip I/O errors instead of creating a job without usable task data.
Inline LimitRange listing in minimum-memory calculation and define zero as the fallback when Kubernetes refuses the request.
Read executor pod logs for the remaining full-view path without replacing the compatibility empty stdout when Kubernetes returns no log.
Prevent instantiation of the constants-only classes.
ConfigurationConfigure CI to upload the merged JaCoCo report so Codecov evaluates the same combined test data as the build.
Exclude only the listed generated OpenAPI classes and application entry point, enforce complete merged line and branch coverage, and produce a merged report.
DocumentationDocument the merged coverage requirement, exclusions, local report locations, and keeping generated-code exclusions synchronized.
TestsAdd behavioral coverage for TRS failure, missing images, and non-success responses.
Cover servlet error responses and validation messages, trace pointcut matching and exception logging, and security-claim edge cases.
Exercise service-client configuration failures, nested tokens, discovery edge cases, verifier and JWKS concurrency, and refusal-reason reporting.
Test User account flags, group behavior, string representation, equality, and hash-code consistency.
Verify Swagger OAuth grant selection and scope parsing.
Cover creator-label behavior without metadata maps and executor security-context lookup defaults and missing data.
Test FTP and executor-secret enablement, conversion failures, group fallback, executor logs, and task input views.
Cover single-task listing, output-filer jobs outside the current task list, and executor ordering and missing pods.
Exercise LimitRange minima, jobs without labels, and Kubernetes error conversion across wrapper calls.
Update the controller test for its simplified constructor and verify task-view parsing, service-info reload behavior, and task-creation edge cases.
Other changesFiles not grouped.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #184 +/- ##
============================================
+ Coverage 77.61% 100.00% +22.38%
============================================
Files 74 51 -23
Lines 3489 2262 -1227
Branches 416 254 -162
============================================
- Hits 2708 2262 -446
+ Misses 621 0 -621
+ Partials 160 0 -160 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Linked issuesChecked at commit a5a274a #179 test: reach 100% test coverage · 4 of 5 met · 1 to check by hand
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/main/java/uk/ac/ebi/tsc/tesk/config/security/GroupNamesSecurityExtractor.java" line_range="48" />
<code_context>
}
- return StringUtils.collectionToCommaDelimitedString(authorities);
+ // a single group, e.g. a string of comma-separated names
+ return String.valueOf(object);
}
}
</code_context>
<issue_to_address>
**Null group claim becomes an authority**
When the user-info map contains the configured groups claim with a null value, `asAuthorities` turns the null claim into the literal string `"null"`; `extractAuthorities` then creates a `GrantedAuthority` with that name, and `ElixirPrincipalExtractor` stores it as a group instead of treating the claim as empty.
Handle null explicitly so it produces no authorities (or apply the intended missing-claim default).
</issue_to_address>
### Comment 2
<location path="src/main/java/uk/ac/ebi/tsc/tesk/config/security/User.java" line_range="75" />
<code_context>
*/
private Set<String> teskManagedGroups;
- public User() {}
-
public String getName() {
</code_context>
<issue_to_address>
**Downstream user construction breaks**
When an external consumer instantiates `User` with its former public no-argument constructor, downstream code that calls `new User()` no longer compiles because the public no-argument constructor was removed and the remaining constructor is package-private.
Retain the public no-argument constructor if `User` is intended to remain constructible by external callers, or make the breaking API change explicit.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 2 findings to address first, and the changes affect JWT verification concurrency and how group claims are normalized into authorities, which determine whether requests are authenticated and which group-scoped tasks a user can access. If that handling is wrong, task access could be granted or denied; reverting restores the old logic but cannot undo any access or data exposure that already occurred.
Blocking findings: src/main/java/uk/ac/ebi/tsc/tesk/config/security/GroupNamesSecurityExtractor.java:48, src/main/java/uk/ac/ebi/tsc/tesk/config/security/User.java:75
A groups claim with a null value turned into an authority named "null". It now yields no authorities. Found by Sourcery on #184; the old code behaved the same way. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in #161, #174, #175, #176, #178, #181, #183 and #184. The conflict in docs/upgrading.md is resolved by merging both lists under "To 1.3.0": the upgrade order for filer labels and Java 21 come first, and the TES 1.1 fields item no longer says that ignore_error: true is refused. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Lists the changes merged into dev since the notes were written: Java 21 (#161), ignore_error (#174), the resource server (#175), output file logs (#176), the Kubernetes client (#178), Dependabot labels (#181), the executor job selector (#183) and full test coverage (#184). Adds a Breaking changes section, as in the 1.2.0 notes, and sets date-released to the planned tag date, 2026-11-16. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Brings the unit and integration tests together to 100% of the lines and branches, and makes the build and Codecov enforce it.
Why Codecov showed ~74%: the JaCoCo exclusion of the models pointed to
uk/ac/ebi/tsc/tesk/model, a package that no longer exists, so all generated models were measured. The exclusions now list exactly the files that openapi-generator generates (src/main/java/.openapi-generator/FILES, the list Spotless and Checkstyle already exclude) plusTeskApplication(itsmainonly starts Spring Boot, which@SpringBootTestdoes too). The reasons are inpom.xmlanddocs/development.md.Tests (behaviour, not just execution), among others:
KubernetesExceptions; LimitRanges without a minimum; jobs without labelsjwks_uri, blank client claim,[::1], concurrent builds and refreshes of the keys, refusal reasonscreateSecret, which carries credentials), and the trace of Kubernetes errorsUseraccount flags, groups,toStringand equality; an admin group named like the managers of a teamservice-info.yamlreload and invalid filesCode removed or simplified instead of tested (unreachable):
ServiceClientTokenServices: the status check after jose4j'sGet(it throws for any status but 200); the re-check of the verifier under the lock is kept and now has a deterministic testUser: null checks of group sets (the builder always sets them), the unused no-arg constructor;equals/hashCodeviaObjectsTraceInterceptorConfiguration: empty@Pointcutmethods replaced by expressionsCustomErrorHandler: the non-servlet branch (Spring MVC always passesServletWebRequests)TesServiceImpl: the always-trueFULLcheck;ServiceInfoApiController.getRequest(only the generated default methods use it)GroupNamesSecurityExtractor: identical if/else branches;KubernetesClientWrapper.listLimitsinlined; private constructors for constants classesKubernetesObjectsSupplierreadstaskmaster.jsononce at startup instead of on every taskOne intended behaviour change: if a task can't be serialized to JSON,
TesKubernetesConverternow fails the creation (500) instead of logging and creating a job without the task's JSON, which could be neither run nor read back. Jackson doesn't fail on TES models in practice.Enforcement:
./mvnw verifyfails below 100% lines or branches (JaCoCocheckon the merged data);codecov.ymlsets project and patch targets to 100%. CI now sends Codecov one report of the merged data (target/site/jacoco-merged/jacoco.xml) instead of the unit and integration reports separately: JaCoCo XML has no branch identities, so Codecov couldn't combine a line's branches covered in part by each suite, and would disagree with the check.docs/development.mdhas a new "Test coverage" section (what is measured, the exclusions, how to see the merged report locally) and a note to keep the exclusions in sync when regenerating the stub.Verification
./mvnw clean verify(Java 21): 18547 unit tests, 114 integration tests, all pass (after merging dev with fix: select only executor jobs for a single task #183); "All coverage checks have been met"; merged reporttarget/site/jacoco-merged/jacoco.xml: 2260/2260 lines, 797/797 branches./mvnw spotless:check checkstyle:check(Java 8, as the Lint job): passmkdocs build --strict: passDeclined review findings
From the reviewer subagents (round 1; round 2 below):
unchecked/IoSupplierhelper by inline handling: kept; one helper for both checked call sites (Jackson and gzip) is what lets the gzip path, which can't fail on aByteArrayOutputStream, share the tested failure path. The behaviour change is stated above.failingRefresh_isThrottledis timing-dependent (300 ms interval, 400 ms sleep): a test that predates this PR and isn't changed here; it hasn't flaked in CI so far.FILES: the stub-generation docs now say to update the exclusions of Spotless, Checkstyle and JaCoCo together; a test reading the pom is more machinery than a list that changes with a new TES version.TesServiceImplrelies on the early returns for MINIMAL and BASIC (observation; the comment says so).Userserialization shape: the resource server is stateless and never deserializesUser.CustomErrorHandlercasts toServletWebRequest: Spring MVC always passes one (comment in the code).buildLockby reflection, which JEP 500 restricts in Java versions after 21: the project is on Java 21 (pom, Dockerfile, CI); when it moves on, make the lock injectable through a package-private constructor.From Sourcery:
User's public no-arg constructor breaks external callers: declined; tesk-api is an application, nothing constructsUserexcept through its builder, and the builder is what guarantees non-null group sets.Open questions
None.
Closes #179
🤖 Generated with Claude Code