Skip to content

Add HTTP shared-tenancy broker variant for tests. - #1245

Open
floitsch wants to merge 3 commits into
floitsch/build-artemis-service.s-new.090from
floitsch/build-artemis-service.s-new.091
Open

Add HTTP shared-tenancy broker variant for tests.#1245
floitsch wants to merge 3 commits into
floitsch/build-artemis-service.s-new.090from
floitsch/build-artemis-service.s-new.091

Conversation

@floitsch

@floitsch floitsch commented May 23, 2026

Copy link
Copy Markdown
Member

Adds a shared-tenancy HTTP broker path and exercises the auth-side device creation now owned by brokers.\n\nCLI:\n- BrokerCliHttpShared overrides notify-created to send hardware-id and organization-id alongside device-id and state.\n- The BrokerCli factory selects the shared HTTP variant when the server config uses shared tenancy; dedicated HTTP configs keep the existing path.\n\nShared config:\n- ServerConfig.with is a single clone method with optional host, scope, and tenancy overrides.\n- Both Supabase and HTTP configs preserve fields that are not overridden.\n\nHTTP test broker:\n- Stores auth-side device records when notify-created carries the shared-tenancy fields.\n- Validates hardware-id and organization-id as a pair.\n- Performs duplicate and payload validation before mutating broker or auth-side state.\n- Exposes auth-record lookup and insertion to the test backdoor.\n\nTests:\n- Adds http-toit-shared to the broker test matrix.\n- Removes the stale Supabase auth-device pre-seeding, so notify-created is responsible for creating the record under test.\n- Verifies the broker-created hardware-id record contains both the expected alias and organization-id for shared HTTP and shared Supabase.\n- Keeps the Artemis Supabase resource lock while shared broker tests inspect auth-side records.

floitsch added 3 commits May 23, 2026 19:05
Mirrors the BrokerCliSupabase shared-tenancy path so the HTTP test
broker can exercise the cross-table auth-side write that production
shared-tenancy deployments rely on.

CLI:
- BrokerCliHttpShared (subclass of BrokerCliHttp) overrides
  notify-created to send _hardware_id and _organization_id alongside
  _device_id/_state on the wire.
- BrokerCli factory dispatches HTTP + TENANCY-SHARED to the shared
  variant; other HTTP configs keep the dedicated path.

Shared config:
- ServerConfigHttp gains a 'with --tenancy/string' clone, matching the
  Supabase variant.

HTTP test broker server:
- Stores auth-side device records in auth-devices_ when notify-created
  carries the extra fields. Rejects duplicate hardware-ids.
- Exposes get-auth-device + insert-auth-device for the backdoor.

Tests:
- with-broker recognizes 'http-toit-shared'; with-http-broker takes an
  optional --tenancy to opt into shared mode.
- ToitHttpBackdoor carries the scoped ServerConfigHttp and mirrors the
  shared-tenancy auth-side insert in its create-device backdoor.
- broker-test.toit asserts auth-side records are populated when running
  under http-toit-shared.
- CMakeLists.txt adds --http-toit-shared-broker to BROKER_FLAGS so all
  BROKER tests exercise the shared HTTP variant.
Replace the three separate 'with --host', 'with --scope', 'with --tenancy'
overloads (per subclass) with a single 'with' that takes all updatable
fields as optional. Non-null params override 'this.field', null params
inherit it. Matches the FleetFile.with pattern already used elsewhere in
the codebase.
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