Fix McpTestScreen rendering by implementing missing webappName property in WebFacadeStub
Showing
4 changed files
with
18 additions
and
11 deletions
| ... | @@ -14,14 +14,9 @@ | ... | @@ -14,14 +14,9 @@ |
| 14 | <set field="userId" from="ec.user?.userId ?: 'ANONYMOUS'"/> | 14 | <set field="userId" from="ec.user?.userId ?: 'ANONYMOUS'"/> |
| 15 | <set field="sessionId" from="ec.web?.sessionId ?: 'NO_SESSION'"/> | 15 | <set field="sessionId" from="ec.web?.sessionId ?: 'NO_SESSION'"/> |
| 16 | 16 | ||
| 17 | <!-- Test different data access patterns --> | ||
| 18 | <entity-find entity-name="moqui.basic.Enumeration" list="enumerations" limit="5"/> | ||
| 19 | <entity-find entity-name="McpSession" list="mcpSessions" limit="5"> | ||
| 20 | <econdition field-name="userId" from="userId"/> | ||
| 21 | </entity-find> | ||
| 22 | |||
| 23 | <!-- Test service calls --> | 17 | <!-- Test service calls --> |
| 24 | <service-call name="org.moqui.impl.SystemServices.ping" out-map="pingResult"/> | 18 | <service-call name="McpServices.mcp#Ping" out-map="pingContext"/> |
| 19 | <set field="pingResult" from="pingContext?.result"/> | ||
| 25 | 20 | ||
| 26 | <!-- Test permissions --> | 21 | <!-- Test permissions --> |
| 27 | <set field="hasAdminAccess" from="ec.user?.hasPermission('MCP_ADMIN')"/> | 22 | <set field="hasAdminAccess" from="ec.user?.hasPermission('MCP_ADMIN')"/> |
| ... | @@ -30,7 +25,7 @@ | ... | @@ -30,7 +25,7 @@ |
| 30 | 25 | ||
| 31 | <!-- Test context data --> | 26 | <!-- Test context data --> |
| 32 | <set field="renderMode" from="sri.renderMode ?: 'unknown'"/> | 27 | <set field="renderMode" from="sri.renderMode ?: 'unknown'"/> |
| 33 | <set field="screenPath" from="sri.screenPath ?: 'unknown'"/> | 28 | <set field="screenPath" from="sri.getActiveScreenPath()?.join('/') ?: 'unknown'"/> |
| 34 | <set field="webappName" from="ec.web?.webappName ?: 'unknown'"/> | 29 | <set field="webappName" from="ec.web?.webappName ?: 'unknown'"/> |
| 35 | <set field="locale" from="ec.user?.locale ?: 'en_US'"/> | 30 | <set field="locale" from="ec.user?.locale ?: 'en_US'"/> |
| 36 | </actions> | 31 | </actions> |
| ... | @@ -81,9 +76,7 @@ | ... | @@ -81,9 +76,7 @@ |
| 81 | <container style="test-section"> | 76 | <container style="test-section"> |
| 82 | <label text="Data Access Tests" type="h2"/> | 77 | <label text="Data Access Tests" type="h2"/> |
| 83 | <container style="data-section"> | 78 | <container style="data-section"> |
| 84 | <label text="System Ping Result: ${pingResult?.message ?: 'No response'}" type="p"/> | 79 | <label text="System Ping Result: ${pingResult?.status ?: 'No response'}" type="p"/> |
| 85 | <label text="Enumerations Found: ${enumerations?.size() ?: 0}" type="p"/> | ||
| 86 | <label text="MCP Sessions Found: ${mcpSessions?.size() ?: 0}" type="p"/> | ||
| 87 | </container> | 80 | </container> |
| 88 | </container> | 81 | </container> |
| 89 | 82 | ... | ... |
| ... | @@ -1457,6 +1457,7 @@ def startTime = System.currentTimeMillis() | ... | @@ -1457,6 +1457,7 @@ def startTime = System.currentTimeMillis() |
| 1457 | def screenTest = new org.moqui.mcp.CustomScreenTestImpl(ec.ecfi) | 1457 | def screenTest = new org.moqui.mcp.CustomScreenTestImpl(ec.ecfi) |
| 1458 | .rootScreen(rootScreen) | 1458 | .rootScreen(rootScreen) |
| 1459 | .renderMode(renderMode ? renderMode : "html") | 1459 | .renderMode(renderMode ? renderMode : "html") |
| 1460 | .auth(ec.user.username) // Propagate current user to the test renderer | ||
| 1460 | 1461 | ||
| 1461 | ec.logger.info("MCP Screen Execution: ScreenTest object created: ${screenTest?.getClass()?.getSimpleName()}") | 1462 | ec.logger.info("MCP Screen Execution: ScreenTest object created: ${screenTest?.getClass()?.getSimpleName()}") |
| 1462 | 1463 | ... | ... |
| ... | @@ -55,6 +55,7 @@ class CustomScreenTestImpl implements McpScreenTest { | ... | @@ -55,6 +55,7 @@ class CustomScreenTestImpl implements McpScreenTest { |
| 55 | protected String servletContextPath = null | 55 | protected String servletContextPath = null |
| 56 | protected String webappName = null | 56 | protected String webappName = null |
| 57 | protected boolean skipJsonSerialize = false | 57 | protected boolean skipJsonSerialize = false |
| 58 | protected String authUsername = null | ||
| 58 | protected static final String hostname = "localhost" | 59 | protected static final String hostname = "localhost" |
| 59 | 60 | ||
| 60 | long renderCount = 0, errorCount = 0, totalChars = 0, startTime = System.currentTimeMillis() | 61 | long renderCount = 0, errorCount = 0, totalChars = 0, startTime = System.currentTimeMillis() |
| ... | @@ -116,6 +117,8 @@ class CustomScreenTestImpl implements McpScreenTest { | ... | @@ -116,6 +117,8 @@ class CustomScreenTestImpl implements McpScreenTest { |
| 116 | @Override McpScreenTest baseLinkUrl(String baseLinkUrl) { this.baseLinkUrl = baseLinkUrl; return this } | 117 | @Override McpScreenTest baseLinkUrl(String baseLinkUrl) { this.baseLinkUrl = baseLinkUrl; return this } |
| 117 | @Override McpScreenTest servletContextPath(String scp) { this.servletContextPath = scp; return this } | 118 | @Override McpScreenTest servletContextPath(String scp) { this.servletContextPath = scp; return this } |
| 118 | @Override McpScreenTest skipJsonSerialize(boolean skip) { this.skipJsonSerialize = skip; return this } | 119 | @Override McpScreenTest skipJsonSerialize(boolean skip) { this.skipJsonSerialize = skip; return this } |
| 120 | |||
| 121 | McpScreenTest auth(String username) { this.authUsername = username; return this } | ||
| 119 | 122 | ||
| 120 | @Override | 123 | @Override |
| 121 | McpScreenTest webappName(String wan) { | 124 | McpScreenTest webappName(String wan) { |
| ... | @@ -213,6 +216,8 @@ class CustomScreenTestImpl implements McpScreenTest { | ... | @@ -213,6 +216,8 @@ class CustomScreenTestImpl implements McpScreenTest { |
| 213 | ExecutionContextFactoryImpl ecfi = sti.ecfi | 216 | ExecutionContextFactoryImpl ecfi = sti.ecfi |
| 214 | ExecutionContextImpl localEci = ecfi.getEci() | 217 | ExecutionContextImpl localEci = ecfi.getEci() |
| 215 | String username = localEci.userFacade.getUsername() | 218 | String username = localEci.userFacade.getUsername() |
| 219 | if (!username && sti.authUsername) username = sti.authUsername | ||
| 220 | |||
| 216 | org.apache.shiro.subject.Subject loginSubject = localEci.userFacade.getCurrentSubject() | 221 | org.apache.shiro.subject.Subject loginSubject = localEci.userFacade.getCurrentSubject() |
| 217 | boolean authzDisabled = localEci.artifactExecutionFacade.getAuthzDisabled() | 222 | boolean authzDisabled = localEci.artifactExecutionFacade.getAuthzDisabled() |
| 218 | CustomScreenTestRenderImpl stri = this | 223 | CustomScreenTestRenderImpl stri = this | ... | ... |
| ... | @@ -125,6 +125,12 @@ class WebFacadeStub implements WebFacade { | ... | @@ -125,6 +125,12 @@ class WebFacadeStub implements WebFacade { |
| 125 | return withPort ? "localhost:8080" : "localhost" | 125 | return withPort ? "localhost:8080" : "localhost" |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | String getWebappName() { | ||
| 129 | // Return a default webappName since this is a stub implementation | ||
| 130 | // In real Moqui, this would come from the webapp configuration | ||
| 131 | return "mcp" | ||
| 132 | } | ||
| 133 | |||
| 128 | @Override | 134 | @Override |
| 129 | String getPathInfo() { | 135 | String getPathInfo() { |
| 130 | if (logger.isDebugEnabled()) { | 136 | if (logger.isDebugEnabled()) { |
| ... | @@ -176,6 +182,8 @@ class WebFacadeStub implements WebFacade { | ... | @@ -176,6 +182,8 @@ class WebFacadeStub implements WebFacade { |
| 176 | 182 | ||
| 177 | @Override | 183 | @Override |
| 178 | String getSessionToken() { return "test-token" } | 184 | String getSessionToken() { return "test-token" } |
| 185 | |||
| 186 | String getSessionId() { return httpSession?.getId() } | ||
| 179 | 187 | ||
| 180 | @Override | 188 | @Override |
| 181 | ServletContext getServletContext() { | 189 | ServletContext getServletContext() { | ... | ... |
-
Please register or sign in to post a comment