Skip to content

Commit 3a02bb4

Browse files
committed
Verify Zest scripts can be parsed
Create the Zest scripts to verify they can be properly parsed. Close #114 - Verify Zest scripts Signed-off-by: thc202 <[email protected]>
1 parent dae463e commit 3a02bb4

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@ dependencies {
4848
testImplementation("org.junit.jupiter:junit-jupiter-params:$jupiterVersion")
4949
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$jupiterVersion")
5050

51+
testImplementation("commons-io:commons-io:2.6")
5152
testImplementation("org.assertj:assertj-core:3.11.0")
5253
testImplementation("org.apache.commons:commons-lang3:3.8")
5354

5455
// The following versions should match the ones of the add-ons.
5556
testImplementation("org.codehaus.groovy:groovy-all:2.4.14")
5657
testImplementation("org.jruby:jruby-complete:1.7.4")
58+
testImplementation("org.mozilla:zest:0.14.0")
5759
testImplementation("org.python:jython-standalone:2.7.1")
5860
}
5961

src/test/java/org/zaproxy/VerifyScripts.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.io.File;
2525
import java.io.IOException;
2626
import java.io.Reader;
27+
import java.io.UncheckedIOException;
2728
import java.nio.charset.StandardCharsets;
2829
import java.nio.file.FileVisitResult;
2930
import java.nio.file.Files;
@@ -42,6 +43,7 @@
4243
import javax.script.Compilable;
4344
import javax.script.ScriptEngineManager;
4445
import javax.script.ScriptException;
46+
import org.apache.commons.io.IOUtils;
4547
import org.apache.commons.lang3.SystemUtils;
4648
import org.apache.commons.lang3.mutable.MutableInt;
4749
import org.codehaus.groovy.jsr223.GroovyScriptEngineFactory;
@@ -51,6 +53,8 @@
5153
import org.junit.jupiter.params.ParameterizedTest;
5254
import org.junit.jupiter.params.provider.Arguments;
5355
import org.junit.jupiter.params.provider.MethodSource;
56+
import org.mozilla.zest.core.v1.ZestJSON;
57+
import org.mozilla.zest.core.v1.ZestScript;
5458
import org.python.core.Options;
5559
import org.python.jsr223.PyScriptEngineFactory;
5660

@@ -116,9 +120,16 @@ private static Stream<Arguments> scriptsRuby() {
116120
}
117121

118122
private static Stream<Arguments> scriptsZest() {
119-
// Just collect the files for now (Issue 114).
120-
getFilesWithExtension(".zst");
121-
return Stream.empty();
123+
return testData(
124+
".zst",
125+
reader -> {
126+
try {
127+
assertThat(ZestJSON.fromString(IOUtils.toString(reader)))
128+
.isInstanceOf(ZestScript.class);
129+
} catch (IOException e) {
130+
throw new UncheckedIOException(e);
131+
}
132+
});
122133
}
123134

124135
private static Stream<Arguments> testData(String extension, Compilable engine) {

0 commit comments

Comments
 (0)