-
Notifications
You must be signed in to change notification settings - Fork 4
fix: test container setup with SigningKey
#64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: test container setup with SigningKey
#64
Conversation
Locally (MacBook M1) the `EsdbClient` testsuite currently fails for me with: > 1) Thenativeweb\Eventsourcingdb\Tests\CloudEventSignatureTest::testVerifiesTheSignature > RuntimeException: Failed to get mapped port ‘’ for container > > 2) Thenativeweb\Eventsourcingdb\Tests\CloudEventSignatureTest::testThrowsAnErrorIfTheSignatureVerificationFails > RuntimeException: Failed to get mapped port ‘’ for container > > 3) Thenativeweb\Eventsourcingdb\Tests\CloudEventSignatureTest::testThrowsAnErrorIfTheHashVerificationFails > RuntimeException: Failed to get mapped port ‘’ for container With this change, tests are green again.
|
Not sure why the CI fails, but apparently this needs some more work.. FYI: Without this change, the docker container logs
even though the following test script seems to yield valid results: $signingKey = new SigningKey();
$container = (new GenericContainer('alpine'))
->withCommand(['tail', '-f', '/dev/null'])
->withCopyContentToContainer([[
'content' => $signingKey->privateKeyPem,
'target' => '/etc/esdb/signing-key.pem',
]])
->start();
$output = $container->exec(['cat', '/etc/esdb/signing-key.pem']);
$container->stop();
var_dump($signingKey->privateKeyPem);
var_dump($output);=> (not sure where the leading "w" comes from though) |
|
I could not let this go and jumped into the rabbit hole: The leading "w" in the test above comes from a bug in the StartedGenericContainer::sanitizeOutput() implementation – but this only affects the debug script above and is unrelated. The actual issue seems to be a "timing problem": at the time of running the command, the private key is not yet available on the container, i.e. it fails with manually works |
The previous version called withCommand() twice which caused issues. This version: - Builds the complete command array first (including signing-key params) - Calls withCommand() only once - Adds the mount after the command is set This maintains the fix from the original PR (using withMount instead of withCopyContentToContainer) while avoiding the double command issue. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
b97d34d to
25c67ae
Compare
Changes: - Use current directory (getcwd()) instead of sys_get_temp_dir() for better CI compatibility with Docker mounts - Add cleanup of temp file in stop() method to avoid leaving files behind - Store temp file path in private property for cleanup The mount approach works better than copy methods because the file must be available when the container starts (not after). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Restore the originally intended path /etc/esdb/signing-key.pem instead of /tmp/signing-key.pem. Both work, but /etc/esdb matches the original design and is more semantically correct. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Locally (MacBook M1) the
EsdbClienttestsuite currently fails for me with:With this change, tests are green again.