Skip to content

Commit

Permalink
Inject appropriate context path into expected http responses
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-tchad committed Jan 22, 2024
1 parent a801a81 commit d0a6b54
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 46 deletions.
78 changes: 39 additions & 39 deletions data/api/http-api.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<ApiTests xmlns="http://labkey.org/query/xml">
<test name="recorded test case 1" type="post">
<url>
<![CDATA[query/HTTPApiVerifyProject/insertRows.api?schemaName=lists&query.queryName=Test%20List]]></url>
<![CDATA[HTTPApiVerifyProject/query-insertRows.api?schemaName=lists&query.queryName=Test%20List]]></url>
<formData>{ "schemaName": "lists",
"queryName": "Test List",
"command": "insert",
Expand Down Expand Up @@ -31,7 +31,7 @@

<test name="recorded test case 2" type="get">
<url>
<![CDATA[query/HTTPApiVerifyProject/selectRows.api?schemaName=lists&query.queryName=Test%20List]]></url>
<![CDATA[HTTPApiVerifyProject/query-selectRows.api?schemaName=lists&query.queryName=Test%20List]]></url>
<response><![CDATA[{"schemaName":"lists",
"queryName":"Test List",
"formatVersion":8.3,
Expand Down Expand Up @@ -134,35 +134,35 @@
"rows":[{
"Good": 10,
"Like": "Zany",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Blue",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Blue",
"Month": "2000-01-01 00:00:00.000",
"Color": "Blue"
},
{
"Good": 9,
"Like": "Robust",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Green",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Green",
"Month": "2000-04-04 00:00:00.000",
"Color": "Green"
},
{
"Good": 4,
"Like": "Magenta",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Purple",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Purple",
"Month": "2000-01-01 00:00:00.000",
"Color": "Purple"
},
{
"Good": 8,
"Like": "Mellow",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Red",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Red",
"Month": "2000-03-03 00:00:00.000",
"Color": "Red"
},
{
"Good": 7,
"Like": "Light",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Yellow",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Yellow",
"Month": "2000-02-02 00:00:00.000",
"Color": "Yellow"
}],
Expand All @@ -171,7 +171,7 @@

<test name="recorded test case 3" type="post">
<url>
<![CDATA[query/HTTPApiVerifyProject/insertRows.api?schemaName=lists&query.queryName=Test%20List]]></url>
<![CDATA[HTTPApiVerifyProject/query-insertRows.api?schemaName=lists&query.queryName=Test%20List]]></url>
<formData>{ "schemaName": "lists",
"queryName": "Test List",
"command": "insert",
Expand Down Expand Up @@ -225,7 +225,7 @@

<test name="recorded test case 4" type="get">
<url>
<![CDATA[query/HTTPApiVerifyProject/selectRows.api?schemaName=lists&query.queryName=Test%20List]]></url>
<![CDATA[HTTPApiVerifyProject/query-selectRows.api?schemaName=lists&query.queryName=Test%20List]]></url>
<response><![CDATA[{"schemaName":"lists",
"queryName":"Test List",
"formatVersion":8.3,
Expand Down Expand Up @@ -304,56 +304,56 @@
"rows":[{
"Good": 10,
"Like": "Zany",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Blue",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Blue",
"Month": "2000-01-01 00:00:00.000",
"Color": "Blue"
},
{
"Good": 1,
"Like": "Red",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Fuscia",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Fuscia",
"Month": "2000-03-01 00:00:00.000",
"Color": "Fuscia"
},
{
"Good": 2,
"Like": "Black",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Gray",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Gray",
"Month": "2000-04-01 00:00:00.000",
"Color": "Gray"
},
{
"Good": 9,
"Like": "Robust",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Green",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Green",
"Month": "2000-04-04 00:00:00.000",
"Color": "Green"
},
{
"Good": 7,
"Like": "Rose",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Pink",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Pink",
"Month": "2000-02-01 00:00:00.000",
"Color": "Pink"
},
{
"Good": 4,
"Like": "Magenta",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Purple",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Purple",
"Month": "2000-01-01 00:00:00.000",
"Color": "Purple"
},
{
"Good": 8,
"Like": "Mellow",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Red",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Red",
"Month": "2000-03-03 00:00:00.000",
"Color": "Red"
},
{
"Good": 7,
"Like": "Light",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Yellow",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Yellow",
"Month": "2000-02-02 00:00:00.000",
"Color": "Yellow"
}],
Expand All @@ -362,7 +362,7 @@

<test name="recorded test case 5" type="post">
<url>
<![CDATA[query/HTTPApiVerifyProject/updateRows.api?schemaName=lists&query.queryName=Test%20List]]></url>
<![CDATA[HTTPApiVerifyProject/query-updateRows.api?schemaName=lists&query.queryName=Test%20List]]></url>
<formData>{ "schemaName": "lists",
"queryName": "Test List",
"command": "insert",
Expand Down Expand Up @@ -402,7 +402,7 @@

<test name="recorded test case 6" type="get">
<url>
<![CDATA[query/HTTPApiVerifyProject/selectRows.api?schemaName=lists&query.queryName=Test%20List]]></url>
<![CDATA[HTTPApiVerifyProject/query-selectRows.api?schemaName=lists&query.queryName=Test%20List]]></url>
<response><![CDATA[{"schemaName":"lists",
"queryName":"Test List",
"formatVersion":8.3,
Expand Down Expand Up @@ -481,56 +481,56 @@
"rows":[{
"Good": 10,
"Like": "Zany",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Blue",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Blue",
"Month": "2000-01-01 00:00:00.000",
"Color": "Blue"
},
{
"Good": 1,
"Like": "Crimson",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Fuscia",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Fuscia",
"Month": "2000-03-01 00:00:00.000",
"Color": "Fuscia"
},
{
"Good": 2,
"Like": "Black",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Gray",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Gray",
"Month": "2000-04-01 00:00:00.000",
"Color": "Gray"
},
{
"Good": 2,
"Like": "Jungle Green",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Green",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Green",
"Month": "2000-01-11 00:00:00.000",
"Color": "Green"
},
{
"Good": 7,
"Like": "Rose",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Pink",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Pink",
"Month": "2000-02-01 00:00:00.000",
"Color": "Pink"
},
{
"Good": 4,
"Like": "Magenta",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Purple",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Purple",
"Month": "2000-01-01 00:00:00.000",
"Color": "Purple"
},
{
"Good": 8,
"Like": "Mellow",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Red",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Red",
"Month": "2000-03-03 00:00:00.000",
"Color": "Red"
},
{
"Good": 7,
"Like": "Light",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Yellow",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Yellow",
"Month": "2000-02-02 00:00:00.000",
"Color": "Yellow"
}],
Expand All @@ -539,7 +539,7 @@

<test name="recorded test case 7" type="post">
<url>
<![CDATA[query/HTTPApiVerifyProject/deleteRows.api?schemaName=lists&query.queryName=Test%20List]]></url>
<![CDATA[HTTPApiVerifyProject/query-deleteRows.api?schemaName=lists&query.queryName=Test%20List]]></url>
<formData>{ "schemaName": "lists",
"queryName": "Test List",
"command": "delete",
Expand Down Expand Up @@ -568,7 +568,7 @@

<test name="recorded test case 8" type="get">
<url>
<![CDATA[query/HTTPApiVerifyProject/selectRows.api?schemaName=lists&query.queryName=Test%20List]]></url>
<![CDATA[HTTPApiVerifyProject/query-selectRows.api?schemaName=lists&query.queryName=Test%20List]]></url>
<response><![CDATA[{"schemaName":"lists",
"queryName":"Test List",
"formatVersion":8.3,
Expand Down Expand Up @@ -647,35 +647,35 @@
"rows":[{
"Good": 1,
"Like": "Crimson",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Fuscia",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Fuscia",
"Month": "2000-03-01 00:00:00.000",
"Color": "Fuscia"
},
{
"Good": 2,
"Like": "Black",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Gray",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Gray",
"Month": "2000-04-01 00:00:00.000",
"Color": "Gray"
},
{
"Good": 4,
"Like": "Magenta",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Purple",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Purple",
"Month": "2000-01-01 00:00:00.000",
"Color": "Purple"
},
{
"Good": 8,
"Like": "Mellow",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Red",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Red",
"Month": "2000-03-03 00:00:00.000",
"Color": "Red"
},
{
"Good": 7,
"Like": "Light",
"_labkeyurl_Like": "/labkey/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Yellow",
"_labkeyurl_Like": "%contextPath%/list/HTTPApiVerifyProject/details.view?listId=64&amp;pk=Yellow",
"Month": "2000-02-02 00:00:00.000",
"Color": "Yellow"
}],
Expand All @@ -684,7 +684,7 @@

<test name="apiVersion=17.1, includeMetadata=false, includeUpdateColumn=true" type="post">
<url>
<![CDATA[query/HTTPApiVerifyProject/selectRows.api]]></url>
<![CDATA[HTTPApiVerifyProject/query-selectRows.api]]></url>
<formData>{
"schemaName": "lists",
"queryName": "Test List",
Expand All @@ -704,7 +704,7 @@
"value" : "2000-04-01 00:00:00.000"
},
"Like" : {
"url" : "/labkey/HTTPApiVerifyProject/list-details.view?name=Test%20List&pk=Gray",
"url" : "%contextPath%/HTTPApiVerifyProject/list-details.view?name=Test%20List&pk=Gray",
"value" : "Black"
},
"Color" : {
Expand All @@ -716,7 +716,7 @@
},
"links" : {
"edit" : {
"href" : "/labkey/HTTPApiVerifyProject/query-updateQueryRow.view?schemaName=lists&query.queryName=Test%20List&Color=Gray",
"href" : "%contextPath%/HTTPApiVerifyProject/query-updateQueryRow.view?schemaName=lists&query.queryName=Test%20List&Color=Gray",
"title" : "edit"
}
}
Expand All @@ -727,7 +727,7 @@

<test name="apiVersion=17.1, includeMetadata=false, columns=*, includeUpdateColumn=true" type="post">
<url>
<![CDATA[query/HTTPApiVerifyProject/selectRows.api]]></url>
<![CDATA[HTTPApiVerifyProject/query-selectRows.api]]></url>
<formData>{
"schemaName": "lists",
"queryName": "Test List",
Expand All @@ -753,7 +753,7 @@
},
"links" : {
"edit" : {
"href" : "/labkey/HTTPApiVerifyProject/query-updateQueryRow.view?schemaName=lists&query.queryName=Test%20List&Color=Gray",
"href" : "%contextPath%/HTTPApiVerifyProject/query-updateQueryRow.view?schemaName=lists&query.queryName=Test%20List&Color=Gray",
"title" : "edit"
}
}
Expand Down
6 changes: 3 additions & 3 deletions data/api/security-api.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<ApiTests xmlns="http://labkey.org/query/xml">

<test name="get group permissions" type="get">
<url>security/Security%20API%20Test%20Project/getGroupPerms.view?</url>
<url>Security%20API%20Test%20Project/security-getGroupPerms.view?</url>
<response>
{"container":
{
Expand Down Expand Up @@ -135,7 +135,7 @@
</test>

<test name="groups for current user" type="get">
<url>security/Security%20Api%20Test%20Project/getGroupsForCurrentUser.view?</url>
<url>Security%20Api%20Test%20Project/security-getGroupsForCurrentUser.view?</url>
<response>
{"groups": [
{
Expand All @@ -162,7 +162,7 @@
</test>

<test name="ensure login" type="get">
<url>security/Security%20Api%20Test%20Project/ensureLogin.view?</url>
<url>Security%20Api%20Test%20Project/security-ensureLogin.view?</url>
<response>
{"currentUser":
{
Expand Down
2 changes: 1 addition & 1 deletion data/api/study-api.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
label: 'Non Controller',
}
</formData>
<url>participant-group/StudyVerifyProject/My%20Study/deleteParticipantCategory.view?</url>
<url>StudyVerifyProject/My%20Study/participant-group-deleteParticipantCategory.view?</url>
<response>{"success": true}</response>
</test>
</ApiTests>
Expand Down
4 changes: 2 additions & 2 deletions data/api/timechart-api.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<ApiTests xmlns="http://labkey.org/query/xml">
<test name="recorded test case" type="get">
<url>visualization/TimeChartTest%20Project%E2%98%83~%21%40%24%26%28%29_%2B%7B%7D-%3D%5B%5D%2C.%23%C3%A4%C3%B6%C3%BC%C3%85/Demo%20Study/getVisualizationTypes.view?</url>
<url>TimeChartTest%20Project%E2%98%83~%21%40%24%26%28%29_%2B%7B%7D-%3D%5B%5D%2C.%23%C3%A4%C3%B6%C3%BC%C3%85/Demo%20Study/visualization-getVisualizationTypes.view?</url>
<response>{
"types": [
{
Expand Down Expand Up @@ -34,7 +34,7 @@
}</response>
</test>
<test name="recorded test case" type="get">
<url>visualization/TimeChartTest%20Project%E2%98%83~%21%40%24%26%28%29_%2B%7B%7D-%3D%5B%5D%2C.%23%C3%A4%C3%B6%C3%BC%C3%85/Demo%20Visit%20Study/getVisualizationTypes.view?</url>
<url>TimeChartTest%20Project%E2%98%83~%21%40%24%26%28%29_%2B%7B%7D-%3D%5B%5D%2C.%23%C3%A4%C3%B6%C3%BC%C3%85/Demo%20Visit%20Study/visualization-getVisualizationTypes.view?</url>
<response>{
"types": [
{
Expand Down
3 changes: 2 additions & 1 deletion src/org/labkey/test/util/APITestHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ private static ApiTestCase parseTestCase(TestCaseType element, boolean strictTyp

String response = element.getResponse();
if (response != null)
testCase.setResponse(StringUtils.trim(response));
testCase.setResponse(StringUtils.trim(response)
.replaceAll("%contextPath%", WebTestHelper.getContextPath()));

String formData = element.getFormData();
if (formData != null)
Expand Down

0 comments on commit d0a6b54

Please sign in to comment.