Repository navigation
fix(test): generated test callers apply entity access - #2148
Merged
Merged
Conversation
A test calling a microflow with Apply entity access = Yes failed CE0114 at build and MDL-SEC22 at check: the endpoint test microflows, the legacy MxTest.TestRunner and the MxTest.Check_* wrappers were written without the setting. They now apply it, as RegisterEndpoint already did (#1654); CE0114 has one direction, so an applying caller may call both. An applying flow may not read $latestError/Message (CE0150), so the runner's verdict and @throws handlers pass $latestError to a generated non-applying helper, MxTest.Test_ErrorMessage, each into its own variable. It carries the generated prefix, so every discovery and cleanup path removes it; the legacy cleanup drops it explicitly, and a build error in it is attributed to mxcli. A test whose own handler reads $latestError/... keeps a non-applying caller, so it builds as before. Tests run in a system context, so nothing changes at run time. Measured on 11.12.1 at security Off and Production; end to end with --local, --legacy-runner and a pre-existing MxTest module. Closes #2100. Refs mendixlabs#1805. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QiMsnXa9crge2qnSk9S7Zn
…-entity-access # Conflicts: # CHANGELOG.md
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 #2100 (upstream mendixlabs#1805).
Problem
A
.test.mdltest that calls a microflow with Apply entity access = Yes failed at build with CE0114, and at check with MDL-SEC22. The same happened for an applying@setupmicroflow. Three generators wrote their callers without the setting:writeTestFlow);--legacy-runner'sMxTest.TestRunner;MxTest.Check_*wrappers thatmxcli checkand the editor use.The issue names two of them; the legacy runner is the third. The only workaround was to weaken the production microflow.
Setting it on the callers alone exposes the second error the issue reports, CE0150. An applying flow may not read
$latestError/Message, and the runner's verdict and@throwshandlers read it.Measured (mx check, 11.12.1, security Off and Production)
$latestError/Message$latestErrorto a non-applying helperTests run under
Core.createSystemContext, which entity access does not restrict, so nothing changes at run time.Change
MxTest.RegisterEndpointalready did for [up#1645]mxcli test --local: the generatedMxTest.RegisterEndpointdoes not apply entity access, so a project whose after-startup microflow does cannot be tested (CE0114) #1654. The check wrapper keeps the annotation on its existing line, so no body line moves.MxTest.Test_ErrorMessage(RaisedError = $latestError), a generated helper that does not apply entity access, into its own$MxTestErrorMessage[_suite]_n.attachOnErrornow numbers the handlers. The handlers are built in a structured way, not by rewriting text.Test_prefix means every existing discovery and cleanup path removes it, while no test ID (test_N) can produce its name;$latestError/…(outside strings and comments) keeps a non-applying caller, so it builds as it does today. Under the legacy runner this applies per suite, since all tests share one microflow. The docs give the fix for a test that needs both.Verification
caller_entity_access_test.go. Generated MDL is parsed to the AST and checked for:$latestError/Messagedirectly, they fail on CE0150.--local --db-type hsqldb):@setupincluded, was an ERROR with CE0114, and check reported MDL-SEC22.@throwswith a matching message, bare@throwsand an applying@setupall PASS. An unexpected error FAILs withexception during execution: Amount must be positive. A wrong@throwsFAILs withexpected an error containing 'something else', actual: Amount must be positive. A test whose own handler reads$latestError/MessagePASSes. Check passes.MxTestmodule: only the user's own microflow remains after cleanup.--legacy-runner: builds and runs. As before this change, an unexpected error ends that runner.mdl-examples/bug-tests/test-runner-2100-*was run exactly as its header documents.make ci-localpasses.Docs:
running-tests.mdand the test-microflows skill. Also a CHANGELOG entry and a finding record.Generated by Claude Code