Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed issue apiman-1227 related to a trailing / being left out in the…
… gateway
- Loading branch information
1 parent
f694919
commit 5d8c60a
Showing
9 changed files
with
180 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
60 changes: 60 additions & 0 deletions
60
common/util/src/test/java/io/apiman/common/util/ApimanPathUtilsTest.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2016 JBoss Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.apiman.common.util; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import io.apiman.common.util.ApimanPathUtils.ApiRequestPathInfo; | ||
|
||
public class ApimanPathUtilsTest { | ||
|
||
@Test | ||
public void testParseApiRequestPath() { | ||
ApiRequestPathInfo path = ApimanPathUtils.parseApiRequestPath(null, "application/json", "/OrgId/ApiId/VER/path/to/thing"); | ||
Assert.assertEquals("OrgId", path.orgId); | ||
Assert.assertEquals("ApiId", path.apiId); | ||
Assert.assertEquals("VER", path.apiVersion); | ||
Assert.assertEquals("/path/to/thing", path.resource); | ||
|
||
path = ApimanPathUtils.parseApiRequestPath(null, "application/json", "/OrgId/ApiId/VER"); | ||
Assert.assertEquals("OrgId", path.orgId); | ||
Assert.assertEquals("ApiId", path.apiId); | ||
Assert.assertEquals("VER", path.apiVersion); | ||
Assert.assertEquals(null, path.resource); | ||
|
||
path = ApimanPathUtils.parseApiRequestPath(null, "application/json", "/OrgId/ApiId/VER/"); | ||
Assert.assertEquals("OrgId", path.orgId); | ||
Assert.assertEquals("ApiId", path.apiId); | ||
Assert.assertEquals("VER", path.apiVersion); | ||
Assert.assertEquals("/", path.resource); | ||
|
||
path = ApimanPathUtils.parseApiRequestPath("VER", "application/json", "/OrgId/ApiId/path/to/thing"); | ||
Assert.assertEquals("OrgId", path.orgId); | ||
Assert.assertEquals("ApiId", path.apiId); | ||
Assert.assertEquals("VER", path.apiVersion); | ||
Assert.assertEquals("/path/to/thing", path.resource); | ||
|
||
path = ApimanPathUtils.parseApiRequestPath("VER", "application/json", "/OrgId/ApiId"); | ||
Assert.assertEquals("OrgId", path.orgId); | ||
Assert.assertEquals("ApiId", path.apiId); | ||
Assert.assertEquals("VER", path.apiVersion); | ||
Assert.assertEquals(null, path.resource); | ||
|
||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
gateway/test/src/test/java/io/apiman/gateway/test/SimpleEcho1227Test.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2014 JBoss Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.apiman.gateway.test; | ||
|
||
import io.apiman.gateway.test.junit.GatewayRestTestPlan; | ||
import io.apiman.gateway.test.junit.GatewayRestTester; | ||
|
||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* Make sure the gateway and test echo server are working. | ||
* | ||
* @author eric.wittmann@redhat.com | ||
*/ | ||
@RunWith(GatewayRestTester.class) | ||
@GatewayRestTestPlan("test-plans/simple/simple-echo-1227-testPlan.xml") | ||
public class SimpleEcho1227Test { | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
...y/test/src/test/resources/test-plan-data/simple/simple-echo-1227/001-publish-api.resttest
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
PUT /apis admin/admin | ||
Content-Type: application/json | ||
|
||
{ | ||
"organizationId" : "SimpleEcho1227Test", | ||
"apiId" : "echo", | ||
"version" : "1.0", | ||
"publicAPI" : true, | ||
"endpointType" : "REST", | ||
"endpoint" : "${apiman-gateway-test.endpoints.echo}/endpoint/with-trailing-slash/", | ||
"apiPolicies" : [ ] | ||
} | ||
---- | ||
204 |
14 changes: 14 additions & 0 deletions
14
gateway/test/src/test/resources/test-plan-data/simple/simple-echo-1227/002-echo.resttest
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
GET /SimpleEcho1227Test/echo/1.0/ admin/admin | ||
Accept: application/json | ||
|
||
---- | ||
200 | ||
Content-Type: application/json | ||
|
||
{ | ||
"method" : "GET", | ||
"resource" : "/endpoint/with-trailing-slash/", | ||
"uri" : "/endpoint/with-trailing-slash/", | ||
"headers" : { | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
gateway/test/src/test/resources/test-plan-data/simple/simple-echo-1227/003-echo-2.resttest
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
GET /SimpleEcho1227Test/echo/1.0 admin/admin | ||
Accept: application/json | ||
|
||
---- | ||
200 | ||
Content-Type: application/json | ||
|
||
{ | ||
"method" : "GET", | ||
"resource" : "/endpoint/with-trailing-slash", | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
EricWittmann
Author
Member
|
||
"uri" : "/endpoint/with-trailing-slash", | ||
"headers" : { | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
gateway/test/src/test/resources/test-plan-data/simple/simple-echo-1227/004-echo-3.resttest
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
GET /SimpleEcho1227Test/echo/1.0/some/resource admin/admin | ||
Accept: application/json | ||
|
||
---- | ||
200 | ||
Content-Type: application/json | ||
|
||
{ | ||
"method" : "GET", | ||
"resource" : "/endpoint/with-trailing-slash/some/resource", | ||
"uri" : "/endpoint/with-trailing-slash/some/resource", | ||
"headers" : { | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
gateway/test/src/test/resources/test-plan-data/simple/simple-echo-1227/005-echo-4.resttest
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
GET /SimpleEcho1227Test/echo/1.0/some/resource/ admin/admin | ||
Accept: application/json | ||
|
||
---- | ||
200 | ||
Content-Type: application/json | ||
|
||
{ | ||
"method" : "GET", | ||
"resource" : "/endpoint/with-trailing-slash/some/resource/", | ||
"uri" : "/endpoint/with-trailing-slash/some/resource/", | ||
"headers" : { | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
gateway/test/src/test/resources/test-plans/simple/simple-echo-1227-testPlan.xml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<testPlan xmlns="urn:io.apiman.test:2014:02:testPlan"> | ||
|
||
<!-- Reproducer for APIMAN-1227 --> | ||
|
||
<testGroup name="setup" endpoint="api"> | ||
<test name="Publish Api">test-plan-data/simple/simple-echo-1227/001-publish-api.resttest</test> | ||
</testGroup> | ||
|
||
<testGroup name="test"> | ||
<test name="Echo 1">test-plan-data/simple/simple-echo-1227/002-echo.resttest</test> | ||
<test name="Echo 2">test-plan-data/simple/simple-echo-1227/003-echo-2.resttest</test> | ||
<test name="Echo 3">test-plan-data/simple/simple-echo-1227/004-echo-3.resttest</test> | ||
<test name="Echo 4">test-plan-data/simple/simple-echo-1227/005-echo-4.resttest</test> | ||
</testGroup> | ||
</testPlan> |
@EricWittmann Hmm, is this right? As I understand it - we should be using registered API endpoint plus whatever is on the API call path after the
/SimpleEcho1227Test/echo/1.0
bit?So, registered endpoint is:
${apiman-gateway-test.endpoints.echo}/endpoint/with-trailing-slash/
Invoked path is:
""
(empty string)Which would be
"/endpoint/with-trailing-slash/" + "" = /endpoint/with-trailing-slash/
Am I misunderstanding?