GUACAMOLE-2302: Add test coverage for TokenFilter parameter token grammar#1231
Open
ciroiriarte wants to merge 1 commit into
Open
GUACAMOLE-2302: Add test coverage for TokenFilter parameter token grammar#1231ciroiriarte wants to merge 1 commit into
ciroiriarte wants to merge 1 commit into
Conversation
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.
Adds characterization tests for the parameter token grammar accepted by
TokenFilter.TokenFilterTestcovers basic substitution, escaping, and theLOWER/UPPERmodifiers. What isn't covered is the boundary of the grammar itself:[A-Za-z0-9_]*)default:and appends the value unchanged)That last point is load-bearing.
filterStrict()has a single caller in the tree —VaultUserContext.getTokens()— which resolves secret names fromvault-token-mapping.ymland treatsGuacamoleTokenUndefinedExceptionas a signal to skip that secret:So a change in which strings the token pattern matches can change whether a vault secret is retrieved at all, with only a debug-level log. These tests pin down the current behavior so that any future change to the pattern is evaluated against it rather than discovered later.
No production code is changed — this is test coverage only.
The tests also record two existing behaviors that are easy to alter unintentionally:
$${TOKEN}escaping, including in combination with modifiers${A}${B}) substitute only the first, because the pattern matches one character ahead of each token to detect escaping and that character is consumed by the preceding matchFor context, this came out of reviewing #1216, which proposes widening the token pattern. The tests are independent of that PR and apply to
mainas it stands.