Skip to content

Migrate Azure Key Vault acceptance tests off live Azure to a Testcontainers emulator - #1

Closed
usmansaleem wants to merge 2 commits into
masterfrom
use_azure_simulator
Closed

Migrate Azure Key Vault acceptance tests off live Azure to a Testcontainers emulator#1
usmansaleem wants to merge 2 commits into
masterfrom
use_azure_simulator

Conversation

@usmansaleem

@usmansaleem usmansaleem commented Aug 26, 2026

Copy link
Copy Markdown
Owner

PR Description

Migrates all Azure Key Vault acceptance tests off live Azure onto a local Testcontainers-managed emulator (ghcr.io/usmansaleem/azure-keyvault-emulator:v2.3.4), so they run with zero external Azure credentials.

  • Adds AzureKeyVaultEmulator, a Testcontainers DSL class that starts a shared emulator container, generates a self-signed TLS cert, and seeds the exact BLS/SECP fixtures previously documented for manual import into real Azure.
  • AzureKeyVaultAcceptanceTest, BlsSigningAcceptanceTest.ableToSignUsingAzure, SecpSigningAcceptanceTest.signDataWithKeyInAzure, and KeyIdentifiersAcceptanceTest.azureKeysReturnAppropriatePublicKey now all run against the emulator.
  • Threads a new AzureKeyVaultParameters.getEndpointOverride() through the config chain (CLI option, YAML metadata, DefaultAzureKeyVaultParameters, AzureConfig), mirroring the existing AWS endpoint-override pattern, so AzureKeyVault can target the emulator instead of *.vault.azure.net, use a fixed emulator bearer token, and disable Azure SDK challenge-resource verification.
  • CI no longer needs any AZURE_* secrets; removed from ci_main.yml and the README's manual-setup instructions.

Fixes discovered only by actually running the emulator end-to-end:

  • Pin 127.0.0.1 instead of localhost for the container URL (Docker Desktop for Mac IPv6 quirk).
  • Make the generated PKCS12 cert world-readable (the container runs as a non-root user).
  • Always set explicit enabled=true on seeded secrets (the Azure Secrets SDK NPEs on the emulator's default omission of that attribute).
  • Pin the resolved key version for the raw-REST sign call instead of the empty "latest" placeholder (the emulator 405s on the double-slash "latest" URL convention that real Azure tolerates).

Also fixed the root-cause blocker upstream in usmansaleem/azure-keyvault-emulator: its ES256K Sign/Verify operations were re-hashing an already-computed digest before signing (ECDsa.SignData instead of SignHash), producing signatures that don't verify against real Azure Key Vault's documented Sign semantics. Fixed, tested, and released as v2.3.4 (which also now builds natively for both amd64 and arm64). SecpSigningAcceptanceTest.signDataWithKeyInAzure is verified working end-to-end against the real published image.

Fixed Issue(s)

Documentation

  • I thought about documentation and added the doc-change-required label to this PR if updates are required.

Changelog

  • I thought about adding a changelog entry, and added one if I deemed necessary.

Testing

  • I thought about testing these changes in a realistic/non-local environment.

- Wire the custom acceptanceTest task to the test source set explicitly for Gradle 9.
- Update Besu from 26.5.0 to 26.8.0.
- Replace removed PoW miner CLI options with a single-validator QBFT test network.
- Verify insufficient-funds transactions are not mined and leave balances unchanged under Besu 26.8 transaction-pool behavior.
…ainers emulator

Adds an AzureKeyVaultEmulator Testcontainers DSL class (ghcr.io/usmansaleem/azure-keyvault-emulator:v2.3.4)
that starts a shared emulator container, generates a self-signed TLS cert, and seeds the exact
BLS/SECP fixtures previously documented for manual import into real Azure. AzureKeyVaultAcceptanceTest,
BlsSigningAcceptanceTest.ableToSignUsingAzure, SecpSigningAcceptanceTest.signDataWithKeyInAzure, and
KeyIdentifiersAcceptanceTest.azureKeysReturnAppropriatePublicKey now run against the emulator with zero
external Azure credentials. CI no longer needs any AZURE_* secrets.

Threads a new AzureKeyVaultParameters.getEndpointOverride() through the config chain (CLI option, YAML
metadata, DefaultAzureKeyVaultParameters, AzureConfig), mirroring the existing AWS endpoint-override
pattern, so AzureKeyVault can target the emulator instead of *.vault.azure.net, use a fixed emulator
bearer token, and disable Azure SDK challenge-resource verification.

Fixes found only by actually running the emulator end-to-end (see individual commits/diffs for detail):
- pin linux/amd64 platform for Testcontainers (fixed upstream in v2.3.4, which now ships native arm64
  too, so this pin has since been removed again)
- pin 127.0.0.1 instead of localhost for the container URL (Docker Desktop for Mac IPv6 quirk)
- make the generated PKCS12 cert world-readable (container runs as non-root)
- always set explicit enabled=true on seeded secrets (Secrets SDK NPEs on the emulator's default omission)
- pin the resolved key version for the raw-REST sign call instead of the empty "latest" placeholder

Also fixes the actual root-cause blocker upstream in usmansaleem/azure-keyvault-emulator: its ES256K
Sign/Verify operations were re-hashing an already-computed digest before signing (via ECDsa.SignData
instead of SignHash), producing signatures that don't verify against real Azure Key Vault's documented
Sign semantics. Fixed and released as v2.3.4; SecpSigningAcceptanceTest.signDataWithKeyInAzure is
verified working end-to-end against the real published image.
@usmansaleem

Copy link
Copy Markdown
Owner Author

Opened against upstream instead: Consensys-Incorporated#1222

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