test: assert admin metadata GET decrypts on first request#13645
Merged
shreemaan-abhishek merged 2 commits intoJul 6, 2026
Merged
Conversation
Follow-up test coverage for apache#12624. The existing plugin-metadata3.t covered the nil-init state and the 404 crash, but used example-plugin, which has no encrypt_fields, so it never asserted the primary behavior: that the first successful GET of an encrypted metadata field returns plaintext rather than ciphertext. Add a case using azure-functions.master_apikey (a real encrypt_fields metadata) that resets plugin.enable_data_encryption to nil to simulate a fresh worker, then asserts the GET returns the decrypted value while etcd still holds the ciphertext. Also scope local_conf/err as locals in TEST 1 to avoid leaking globals.
There was a problem hiding this comment.
Pull request overview
Adds regression coverage for encrypted plugin metadata to ensure the Admin API returns decrypted plaintext on the first successful GET, even when apisix.plugin.enable_data_encryption hasn’t been lazily initialized yet (fresh-worker simulation). This strengthens confidence in the behavior restored by #12624 and reduces the chance of ciphertext leaking through the Admin API.
Changes:
- Scope
local_conf/erras locals in TEST 1 to avoid leaking globals between tests. - Add a new test using
azure-functions.master_apikey(anencrypt_fieldsmetadata) to assert:- etcd stores ciphertext
- Admin GET returns plaintext even when
plugin.enable_data_encryptionis reset tonil
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+257
to
+258
| local res = assert(etcd.get('/plugin_metadata/azure-functions')) | ||
| ngx.say("etcd encrypted: ", tostring(res.body.node.value.master_apikey ~= "foo")) |
Contributor
Author
There was a problem hiding this comment.
Good catch. Tightened in 0c6d9c4 to require a non-empty string that differs from the plaintext, so a missing/empty stored value no longer reads as "encrypted".
Tighten the etcd-side check so it can't false-positive when the stored value is missing or empty: require a non-empty string that differs from the plaintext.
AlinsRan
approved these changes
Jul 3, 2026
membphis
approved these changes
Jul 3, 2026
nic-6443
approved these changes
Jul 6, 2026
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.
Description
Follow-up test coverage for #12624.
The existing
t/admin/plugin-metadata3.tcovers theplugin.enable_data_encryptionnil-init state and the 404-GET crash, but it usesexample-plugin, which has noencrypt_fields. So it never asserts the primary behavior the fix restored: that the first successful GET of an encrypted metadata field returns plaintext, not ciphertext.This PR adds a case using
azure-functions.master_apikey(a realencrypt_fieldsmetadata):plugin.enable_data_encryption = nilto simulate a fresh worker where the flag has not been lazily initialized yet.plugin.enable_gde()forces initialization on the GET path.Without #12624 this case returns ciphertext; with it, plaintext.
Also scopes
local_conf/erras locals in TEST 1 (they were previously assigned as globals).Checklist