fix(core): Imposter.uri() reports the admin host, not the host the imposter is bound to - #246
Merged
Merged
Conversation
The engine binds an imposter on its own host, defaulting to 0.0.0.0 (IPv4 only), whatever interface the admin API uses. uri() always reported the admin host, so an imposter bound elsewhere, or a default imposter behind an IPv6 admin host, was not reachable at its uri(). On an engine the SDK runs itself (spawn, embedded) a concrete imposter host now wins: create reads it from the posted definition, and lookups read the replayable list, the only shape that carries it. A connected engine keeps its resolver, since there the host is an address on another machine; so does any wildcard host. Closes #243
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #243
The engine binds an imposter on its own
host, defaulting to0.0.0.0(IPv4 only), whatever interface the admin API uses (crates/rift-mock-core/src/imposter/manager.rs:836).Imposter.uri()always reported the admin host. So an imposter bound elsewhere was unreachable at itsuri(), and so was a default imposter behind an IPv6 admin host. Found by #232's live IT.Changes
RiftImplrecords whether the SDK runs the engine itself:spawnedandembeddeddo,connectdoesn't. testcontainers goes throughconnect, so it keeps its gateway resolver.hostResolvercan't be set on spawn or embedded anyway: both build theirConnectOptionsinternally.createreads it from the JSON the SDK posted. The engine's create response doesn't echo it.imposter(port)andimposters()on a local engine read the replayable list. The engine's single-imposter GET never includeshost, and neither does the non-replayable list. This was caught in review. The cost is one replayable list per lookup on a local engine. A connected engine is unchanged.ImposterImpl.uri()usesHostAuthority.httpUri(host, port)for a concrete host. Any spelling of the wildcard (0.0.0.0,::,[::],0:0:0:0:0:0:0:0) falls back to the resolver, as does an absent host.Imposter.uri()states the rule. It also says to setImposterSpec.host("::1")when the admin host is IPv6, since a host-less imposter is IPv4-only.Tests
ImposterUriHostTest(4):::1,[::1],localhost);RemoteTransportCoverageTest: a connected engine keeps its resolver whatever host the imposter names.Ipv6HostIT, new case on a default spawned engine (admin127.0.0.1) with an imposter on::1:uri(),imposter(port).uri()andimposters().get(0).uri()all report[::1], and a GET succeeds.127.0.0.1../mvnw verifypasses on all modules.🤖 Generated with Claude Code