Skip to content

v1.6.55 Expand Core API backend test coverage baseline - #231

Open
roncodes wants to merge 377 commits into
mainfrom
dev-v1.6.55
Open

v1.6.55 Expand Core API backend test coverage baseline#231
roncodes wants to merge 377 commits into
mainfrom
dev-v1.6.55

Conversation

@roncodes

@roncodes roncodes commented Jul 18, 2026

Copy link
Copy Markdown
Member

Summary

This PR completes the Core API backend full-coverage campaign on dev-v1.6.55.

Latest verified coverage baseline:

  • Line coverage: 100.00% (19,872/19,872 statements)
  • Method coverage: 100.00% (2,569/2,569 methods)
  • Fully covered class coverage: 100.00% (393/393 classes)
  • Touched class coverage: 100.00% (393/393 classes executed at least once)

The generated Clover report includes classes=393 but omits the coveredclasses metric, so the coverage summary derives fully covered class coverage from per-class statement metrics and separately reports touched classes.

Coverage Work

  • Expanded controller and API contract coverage across auth, user, company, IAM metrics/search, settings, reports, templates, files, notifications, comments, channels, onboard, lookup, schedules, middleware, and webhook paths.
  • Expanded reporting coverage for query validation, conversion, exporting, error handling, schema registration, computed columns, and execution failure contracts.
  • Expanded service and support coverage for scheduling, template rendering, file resolution, SMS routing/providers, two-factor auth, telemetry, socket cluster, SQL dumping, API model cache, notification registry, data purging, and utility helpers.
  • Expanded model and trait coverage for user/company membership behavior, scheduling models, chat models, settings, templates, reports, API model/controller behavior, custom fields, policies, lifecycle traits, internal ids, and API credential tracking.
  • Added focused console command coverage for database creation, permissions, purge, backup trimming, recovery, migrate sandbox, and sync sandbox behavior.
  • Added narrow coverage ignores only for defensive or unreachable framework/runtime fallback paths after validating the runtime contract.

Class Coverage Fix

  • Fixed the class coverage summary issue where Clover omitted coveredclasses, which previously caused class coverage to appear as 0.00%.
  • The summary now reports:
    • fully covered class coverage, derived from per-class statement metrics
    • touched class coverage, showing whether each class executed at least once

Validation

  • PATH=/Users/ron/.asdf/shims:$PATH /usr/local/bin/composer lint
  • git diff --check
  • git diff --cached --check
  • XDEBUG_MODE=coverage /Users/ron/.asdf/shims/php /usr/local/bin/composer coverage:baseline
  • /Users/ron/.asdf/shims/php scripts/coverage-summary.php coverage/clover.xml

Full coverage run result:

  • 1,326 tests passed
  • 9,638 assertions
  • 25 deprecated notices
  • 6 warnings

Raw Clover uncovered-statement scan result:

  • No uncovered statements.

@roncodes roncodes changed the title v1.6.55 Improve backend test coverage v1.6.55 Expand Core API backend test coverage baseline Jul 18, 2026
roncodes and others added 25 commits July 26, 2026 11:01
- ReportQueryConverter: enforce registered join tables, validate every
  raw-interpolated join identifier and user select/group alias, and scope
  joined tenant tables to the active company inside the JOIN ON clause
  (closes execution-path identifier injection + cross-tenant join exposure).
- SecurityBehavioralTest: real cross-tenant IDOR tests (Policy/Notification
  delete, File download, Company transfer/leave guards); drop matching
  source-text-grep tests from SecurityFindingsTest.
- RequestValidationBehaviorTest: PublicWebhookUrl SSRF edge cases + request
  rule-set security invariants.
- Backfill ParsePhone (extension, non-string) and DataPurger (disableForeignKeys
  off, deep-pass partial-failure rollback) edge cases; add getenv mail-from
  regression test.
- Remove unreachable dead delete guards in HasApiModelBehavior (2 coverage
  ignores dropped).
- Fix stale inviteUser comment (assignCompany already issues the invite).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Rewrite the obfuscated `$userEnabled ? !$userEnabled : ...` (which always
evaluated to false when 2FA was enabled) as the equivalent, explicit
`$userEnabled ? false : ($systemEnforced || $companyEnforced)` with a comment.
Behavior is unchanged: an already-enrolled user is not re-prompted to enroll,
otherwise enrollment is enforced when the system or company mandates it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a behavioral test asserting that a valid personal access token whose owner's
email/phone does not match the claimed `identity` is ignored (falls through to
password auth, returns 401 invalid_credentials, issues no token) rather than being
honored — the token-swap attack the login guard is meant to prevent.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add behavioral tests for the SMS-2FA security contracts that run before the
Auth::login guard path:
- invalid code is rejected;
- the SMS_AUTH_BYPASS_CODE is refused in production;
- the bypass code is accepted only outside production (falls through to the user lookup);
- a consumed OTP is deleted from Redis and cannot be replayed.

Adds a get() accessor to the harness Redis fake.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a Codecov upload step to the backend CI using codecov-action@v5 with
the organization CODECOV_TOKEN, and a coverage badge to the README.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

roncodes and others added 4 commits July 27, 2026 14:25
Add a minimal 'auth' guard fake so controller calls to the Auth facade work
without a real auth manager, and use it to cover the previously-unreachable
guarded paths:
- authenticateSmsCode success: a valid OTP for a matching user logs in, consumes
  the OTP, and issues a Sanctum token.
- ApiCredential::roll: unauthenticated requests are rejected, and rolling another
  company's credential is refused (cross-tenant IDOR) with the key left unchanged.

Replaces the ApiCredential source-text grep in SecurityFindingsTest with the
behavioral roll tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a behavioral test for the sign-up endpoint (reusing the auth-support fixture):
a valid payload registers the owner + organization via Auth::register, assigns the
owner to the company, and returns a Sanctum access token. Removes the
@codeCoverageIgnore from signUp now that it is exercised end-to-end.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Str::domain() read $host[count($host) - 2], which throws "Undefined
array key -1" for single-label hosts such as "localhost" (e.g.
Str::domain(env('CONSOLE_HOST')) in Utils.php). This broke fleetbase:seed
on any localhost install.

Parse the host, drop empty labels, and return the host as-is when it has
fewer than two labels instead of indexing past the start of the array.
Add localhost coverage to the expansion contract test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add illuminate/validation (+ illuminate/translation) as dev dependencies so the
real Laravel validator can be exercised instead of stubs:
- RequestValidationBehaviorTest now runs each request's rules() through a real
  Validator and asserts valid input passes / invalid input is actually rejected
  (forgot-password, invite-user, update-password, webhook-endpoint), alongside the
  PublicWebhookUrl SSRF unit tests.
- Fix stub-dependent tests now that the real Illuminate\Validation classes exist:
  give validator fakes a getTranslator() (ValidationException::summarize needs it),
  and update expected Rule::unique() strings to the engine's quoted format.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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