refactor: consolidate duplicated helpers, types, and test fixtures #212

Merged
David merged 2 commits from feat/pms-199-consolidate-duplicated-helpers into main 2026-06-14 00:01:13 +02:00
Owner

Replace copy-pasted helpers with single shared functions, standardize divergent type patterns, fix stale naming/URL drift, and consolidate duplicated test fixtures. No behavior change beyond consolidation.

Types crate (mokosh-types): extract a compute_sla_status free fn shared by Ticket::sla_status and the tickets service row mapping; move default_true() to one pub(crate) location and reference it as crate::default_true; switch ContactStatus to the Option-returning from_str pattern its peers use; drop the unused ModuleConfig/UpdateModuleConfigRequest; make JwtClaims.role a UserRole (its snake_case serde keeps wire compat); give time-entry DTOs BillingStatus/ApprovalStatus enums instead of bare String.

Auth HTTP (mokosh-auth-http): add handlers::shared holding TokenBundle, DEFAULT_FIRST_PARTY_SCOPE, looks_like_email, token_hash_prefix, and one require_admin guard; rewire auth/tenants/invites/signup/password_reset/audit/feedback/users handlers onto it.

Auth storage (mokosh-auth-storage): extract a retry_serializable helper in conv.rs and route all nine SERIALIZABLE retry sites through it; use the shared ip_to_inet in trusted_device.

Other: parse directly to GrantType in the OIDC token endpoint (drop the local TokenGrant); add AeadError::Encrypt and use it in encrypt(); include [::1] in is_local_issuer; use { workspace = true } for argon2/rand_core in mokosh-auth-crypto; use the RequireManager extractor for list_users; set the Forgejo repository URL; update stale mokosh-clients references to mokosh-apps.

Tests: move seed_company and a dec() Decimal parser into tests/common/mod.rs; add the rust_decimal dev-dep (and the sqlx rust_decimal feature) and bind Decimal in seed_time_entry instead of format!() SQL; use common::DEFAULT_TENANT_ID in notifications_backfill; extend common::seed_user with a tenant_id arg and drop auth.rs's insert_user_in_tenant.

#PMS-199

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

Replace copy-pasted helpers with single shared functions, standardize divergent type patterns, fix stale naming/URL drift, and consolidate duplicated test fixtures. No behavior change beyond consolidation. Types crate (mokosh-types): extract a `compute_sla_status` free fn shared by `Ticket::sla_status` and the tickets service row mapping; move `default_true()` to one `pub(crate)` location and reference it as `crate::default_true`; switch `ContactStatus` to the Option-returning `from_str` pattern its peers use; drop the unused `ModuleConfig`/`UpdateModuleConfigRequest`; make `JwtClaims.role` a `UserRole` (its snake_case serde keeps wire compat); give time-entry DTOs `BillingStatus`/`ApprovalStatus` enums instead of bare `String`. Auth HTTP (mokosh-auth-http): add `handlers::shared` holding `TokenBundle`, `DEFAULT_FIRST_PARTY_SCOPE`, `looks_like_email`, `token_hash_prefix`, and one `require_admin` guard; rewire auth/tenants/invites/signup/password_reset/audit/feedback/users handlers onto it. Auth storage (mokosh-auth-storage): extract a `retry_serializable` helper in conv.rs and route all nine SERIALIZABLE retry sites through it; use the shared `ip_to_inet` in trusted_device. Other: parse directly to `GrantType` in the OIDC token endpoint (drop the local `TokenGrant`); add `AeadError::Encrypt` and use it in `encrypt()`; include `[::1]` in `is_local_issuer`; use `{ workspace = true }` for argon2/rand_core in mokosh-auth-crypto; use the `RequireManager` extractor for `list_users`; set the Forgejo repository URL; update stale `mokosh-clients` references to `mokosh-apps`. Tests: move `seed_company` and a `dec()` Decimal parser into `tests/common/mod.rs`; add the `rust_decimal` dev-dep (and the sqlx `rust_decimal` feature) and bind `Decimal` in `seed_time_entry` instead of `format!()` SQL; use `common::DEFAULT_TENANT_ID` in notifications_backfill; extend `common::seed_user` with a `tenant_id` arg and drop auth.rs's `insert_user_in_tenant`. #PMS-199 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
refactor: consolidate duplicated helpers, types, and test fixtures
Some checks failed
E2E / Playwright against staging (pull_request) Successful in 40s
Check / fmt + clippy + compile + tests (pull_request) Failing after 3m44s
5f7c728c26
Replace copy-pasted helpers with single shared functions, standardize divergent type patterns, fix stale naming/URL drift, and consolidate duplicated test fixtures. No behavior change beyond consolidation.

Types crate (mokosh-types): extract a `compute_sla_status` free fn shared by `Ticket::sla_status` and the tickets service row mapping; move `default_true()` to one `pub(crate)` location and reference it as `crate::default_true`; switch `ContactStatus` to the Option-returning `from_str` pattern its peers use; drop the unused `ModuleConfig`/`UpdateModuleConfigRequest`; make `JwtClaims.role` a `UserRole` (its snake_case serde keeps wire compat); give time-entry DTOs `BillingStatus`/`ApprovalStatus` enums instead of bare `String`.

Auth HTTP (mokosh-auth-http): add `handlers::shared` holding `TokenBundle`, `DEFAULT_FIRST_PARTY_SCOPE`, `looks_like_email`, `token_hash_prefix`, and one `require_admin` guard; rewire auth/tenants/invites/signup/password_reset/audit/feedback/users handlers onto it.

Auth storage (mokosh-auth-storage): extract a `retry_serializable` helper in conv.rs and route all nine SERIALIZABLE retry sites through it; use the shared `ip_to_inet` in trusted_device.

Other: parse directly to `GrantType` in the OIDC token endpoint (drop the local `TokenGrant`); add `AeadError::Encrypt` and use it in `encrypt()`; include `[::1]` in `is_local_issuer`; use `{ workspace = true }` for argon2/rand_core in mokosh-auth-crypto; use the `RequireManager` extractor for `list_users`; set the Forgejo repository URL; update stale `mokosh-clients` references to `mokosh-apps`.

Tests: move `seed_company` and a `dec()` Decimal parser into `tests/common/mod.rs`; add the `rust_decimal` dev-dep (and the sqlx `rust_decimal` feature) and bind `Decimal` in `seed_time_entry` instead of `format!()` SQL; use `common::DEFAULT_TENANT_ID` in notifications_backfill; extend `common::seed_user` with a `tenant_id` arg and drop auth.rs's `insert_user_in_tenant`.

#PMS-199

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Merge origin/main into feat/pms-199-consolidate-duplicated-helpers
Some checks failed
E2E / Playwright against staging (pull_request) Failing after 1m0s
Check / fmt + clippy + compile + tests (pull_request) Successful in 3m6s
Create release / Create release from merged PR (pull_request) Has been skipped
c00cae20c8
#PMS-199
David merged commit bad33e08b8 into main 2026-06-14 00:01:13 +02:00
David deleted branch feat/pms-199-consolidate-duplicated-helpers 2026-06-14 00:01:13 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-server!212
No description provided.