Skip to content

Commit

Permalink
update echo test file and add new integration test for variable renaming
Browse files Browse the repository at this point in the history
during script execution
  • Loading branch information
Daniel Nüst committed Apr 23, 2014
1 parent 08d0d32 commit a1ea55e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
20 changes: 18 additions & 2 deletions 52n-wps-webapp/src/main/webapp/R/scripts/test_echo.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

# wps.in: id = inputVariable, type = string, title = input variable, minOccurs = 1, maxOccurs = 1;

outputVariable <- inputVariable
# wps.off;
inputVariable <- "The quick brown fox jumps over the lazy dog"
# wps.on;

#wps.out: id = outputVariable, type = string, title = returning input variable;
# test that the renaming measures do not affect the script
quitter <- inputVariable

uuunlinkkk <- quitter
evaluator <- uuunlinkkk
qevalq <- evaluator
systemo <- qevalq
setwdsetwdsetwd <- systemo

outputVariable <- setwdsetwdsetwd

#wps.out: id = outputVariable, type = string, title = returning input variable;

# wps.off;
outputVariable
24 changes: 20 additions & 4 deletions 52n-wps-webapp/src/test/java/org/n52/wps/test/Wps4rIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Random;
import java.util.UUID;

import javax.xml.parsers.ParserConfigurationException;

Expand Down Expand Up @@ -294,7 +295,7 @@ public void exceptionsOnIllegalInputs() throws XmlException, IOException {
// "<-", "a<-q", // result in WPS parsing error
"="};

URL resource = Wps4rIT.class.getResource("/R/ExecuteTestInjection.xml");
URL resource = Wps4rIT.class.getResource("/R/ExecuteTestEcho.xml");
XmlObject xmlPayload = XmlObject.Factory.parse(resource);

for (String cmd : illegalCommands) {
Expand All @@ -314,7 +315,7 @@ public void exceptionsOnIllegalInputs() throws XmlException, IOException {
public void syntaxErrorOnIllegalInputs() throws XmlException, IOException {
String[] illegalCommands = new String[] {"\"\";quit(\"no\");", "setwd('/root/')", "setwd(\"c:/\")"};

URL resource = Wps4rIT.class.getResource("/R/ExecuteTestInjection.xml");
URL resource = Wps4rIT.class.getResource("/R/ExecuteTestEcho.xml");
XmlObject xmlPayload = XmlObject.Factory.parse(resource);

for (String cmd : illegalCommands) {
Expand All @@ -335,12 +336,12 @@ public void replacementsOnIllegalInputs() throws XmlException, IOException {
// "system('format hardisk')",
"quit(\\\"no\\\");inputVariable;"};

URL resource = Wps4rIT.class.getResource("/R/ExecuteTestInjection.xml");
URL resource = Wps4rIT.class.getResource("/R/ExecuteTestEcho.xml");
XmlObject xmlPayload = XmlObject.Factory.parse(resource);

for (String cmd : illegalCommands) {
String payload = xmlPayload.toString();
payload = payload.replace("@@@cmd@@@", cmd);
payload = payload.replace("@@@data@@@", cmd);

String response = PostClient.sendRequest(wpsUrl, payload);

Expand All @@ -349,4 +350,19 @@ public void replacementsOnIllegalInputs() throws XmlException, IOException {
}
}

@Test
public void renamingDoesNotAffectScript() throws XmlException, IOException {
URL resource = Wps4rIT.class.getResource("/R/ExecuteTestEcho.xml");
XmlObject xmlPayload = XmlObject.Factory.parse(resource);

String data = UUID.randomUUID().toString();
String payload = xmlPayload.toString();
payload = payload.replace("@@@data@@@", data);

String response = PostClient.sendRequest(wpsUrl, payload);

assertThat("Response is not an exception", response, not(containsString("ExceptionReport")));
assertThat("Response contains an echo of '" + data + "'", response, containsString(data));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<wps:Input>
<ows:Identifier>inputVariable</ows:Identifier>
<wps:Data>
<wps:LiteralData>@@@cmd@@@</wps:LiteralData>
<wps:LiteralData>@@@data@@@</wps:LiteralData>
</wps:Data>
</wps:Input>
</wps:DataInputs>
Expand Down

0 comments on commit a1ea55e

Please sign in to comment.