diff --git a/core/src/main/resources/xsl/builder.xsl b/core/src/main/resources/xsl/builder.xsl index a7c4ef84..edc431f7 100644 --- a/core/src/main/resources/xsl/builder.xsl +++ b/core/src/main/resources/xsl/builder.xsl @@ -464,10 +464,12 @@ + - + URLXSD @@ -478,6 +480,9 @@ + + + diff --git a/core/src/test/scala/com/rackspace/com/papi/components/checker/ValidatorWADLSuite.scala b/core/src/test/scala/com/rackspace/com/papi/components/checker/ValidatorWADLSuite.scala index 915fa7f7..54915ea1 100644 --- a/core/src/test/scala/com/rackspace/com/papi/components/checker/ValidatorWADLSuite.scala +++ b/core/src/test/scala/com/rackspace/com/papi/components/checker/ValidatorWADLSuite.scala @@ -368,6 +368,39 @@ class ValidatorWADLSuite extends BaseValidatorSuite { assertResultFailed(validator_INT.validate(request("GET","/a/7/d"),response,chain), 404) } + // + // validator_FIXED allows a GET on /a/FOO/c. That is, the 2nd URI + // component may be the value FOO, but foo is described as a FIXED + // string. The validator is used in the following tests. + // + val validator_FIXED = Validator( + + + + + + + + + + + + + , assertConfig) + + test ("GET on /a/FOO/c should pass with validator_FOO") { + validator_FIXED.validate(request("GET","/a/FOO/c"), response, chain) + } + + test ("GET on /a/foo/c should fail on validator_FOO") { + assertResultFailed(validator_FIXED.validate(request("GET","/a/foo/c"), response, chain), 404) + } + + test ("GET on /a/bar/c should fail on validator_FOO") { + assertResultFailed(validator_FIXED.validate(request("GET","/a/bar/c"), response, chain), 404) + } + // // validator_RT allows: // diff --git a/core/src/test/scala/com/rackspace/com/papi/components/checker/wadl/WADLCheckerSpec.scala b/core/src/test/scala/com/rackspace/com/papi/components/checker/wadl/WADLCheckerSpec.scala index a2209c23..e5ceb00a 100644 --- a/core/src/test/scala/com/rackspace/com/papi/components/checker/wadl/WADLCheckerSpec.scala +++ b/core/src/test/scala/com/rackspace/com/papi/components/checker/wadl/WADLCheckerSpec.scala @@ -220,6 +220,56 @@ class WADLCheckerSpec extends BaseCheckerSpec with LogAssertions { assert (checker, URL("element2"), MethodFail) } + scenario("The WADL contains a / path deeper in the URI structure (with sub elements one of which is a fixed template param)") { + Given("a WADL that contains a / path deeper in the URI structure") + val inWADL = + + + + + + + + + + + + + + + + + + + + + + + + val checker = builder.build (inWADL, stdConfig) + Then("The checker should contain an URL node and element2") + assert (checker, "count(/chk:checker/chk:step[@type='URL']) = 2") + And ("The checker should contain two GET methods") + assert (checker, "count(/chk:checker/chk:step[@type='METHOD' and @match='GET']) = 2") + And ("The checker should contain a POST methods") + assert (checker, "count(/chk:checker/chk:step[@type='METHOD' and @match='POST']) = 1") + And ("The checker should NOT contian URL steps with a match == '/'") + assert (checker, "count(/chk:checker/chk:step[@type='URL' and @match='/']) = 0") + And ("The URL path should exist from Start to the element") + assert (checker, Start, URL("element"), Method("GET")) + And ("The URL path should exist from Start to the element2") + assert (checker, Start, URL("element"), URL("element2"), Method("POST")) + And ("The URL path should exist from START directly to GET method") + assert (checker, Start, Method("GET")) + And ("The Start state and each URL state should contain a path to MethodFail and URLFail") + assert (checker, Start, URLFail) + assert (checker, Start, MethodFail) + assert (checker, URL("element"), URLFail) + assert (checker, URL("element"), MethodFail) + assert (checker, URL("element2"), URLFail) + assert (checker, URL("element2"), MethodFail) + } scenario("The WADL contains a / path deeper in the URI structure (with sub elements and multiple nested '/')") { Given("a WADL that contains a / path deeper in the URI structure")