Skip to content

Commit 6822912

Browse files
authored
Merge pull request #6926 from thc202/automation/set-output-state-always
automation: set default std output always
2 parents 500dfd0 + 2a6b3e3 commit 6822912

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

addOns/automation/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
77
### Changed
88
- Make the "pass" output of Monitor Tests consistent with the "fail" output.
99

10+
### Fixed
11+
- Restore default standard output on absent `env` `parameters`.
12+
1013
## [0.56.0] - 2025-11-07
1114
### Added
1215
- Command line -autocheck option which checks if the specified yaml plan has the right format.

addOns/automation/src/main/java/org/zaproxy/addon/automation/AutomationEnvironment.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ void readData(Map<?, ?> envData) {
104104
Constant.messages.getString("automation.env.name"),
105105
null,
106106
progress);
107-
this.progress.setOutputToStdout(
108-
this.getData().getParameters().getProgressToStdout());
109107
break;
110108
case "proxy":
111109
LinkedHashMap<?, ?> proxy = (LinkedHashMap<?, ?>) entry.getValue();
@@ -163,6 +161,9 @@ void readData(Map<?, ?> envData) {
163161
"automation.error.env.unknown", entry.getKey()));
164162
}
165163
}
164+
165+
progress.setOutputToStdout(getData().getParameters().getProgressToStdout());
166+
166167
if (this.contexts.isEmpty()) {
167168
progress.error(Constant.messages.getString("automation.error.env.nocontexts", envData));
168169
}

addOns/automation/src/test/java/org/zaproxy/addon/automation/AutomationEnvironmentUnitTest.java

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,35 @@ void shouldSetResolvedExcludeRegexes() {
578578
.addExcludeFromContextRegex("https://www.prefix.envVarValue.example.com.*");
579579
}
580580

581+
@Test
582+
void shouldHaveDefaultParams() {
583+
// Given
584+
String contextStr =
585+
"""
586+
env:
587+
contexts:
588+
- name: context 1
589+
urls:
590+
- https://www.example.com
591+
""";
592+
Yaml yaml = new Yaml();
593+
LinkedHashMap<?, ?> data =
594+
yaml.load(new ByteArrayInputStream(contextStr.getBytes(StandardCharsets.UTF_8)));
595+
LinkedHashMap<?, ?> contextData = (LinkedHashMap<?, ?>) data.get("env");
596+
AutomationProgress progress = new AutomationProgress();
597+
598+
// When
599+
AutomationEnvironment ae = new AutomationEnvironment(contextData, progress);
600+
601+
// Then
602+
assertThat(progress.hasErrors(), is(equalTo(false)));
603+
assertThat(progress.hasWarnings(), is(equalTo(false)));
604+
assertThat(progress.isOutputToStdout(), is(equalTo(true)));
605+
assertThat(ae.isFailOnError(), is(equalTo(true)));
606+
assertThat(ae.isFailOnWarning(), is(equalTo(false)));
607+
assertThat(ae.isContinueOnFailure(), is(equalTo(false)));
608+
}
609+
581610
@Test
582611
void shouldSetValidParams() {
583612
// Given
@@ -590,7 +619,8 @@ void shouldSetValidParams() {
590619
+ " parameters:\n"
591620
+ " failOnError: false\n"
592621
+ " failOnWarning: true\n"
593-
+ " progressToStdout: true\n";
622+
+ " progressToStdout: false\n"
623+
+ " continueOnFailure: true";
594624
Yaml yaml = new Yaml();
595625
LinkedHashMap<?, ?> data =
596626
yaml.load(new ByteArrayInputStream(contextStr.getBytes(StandardCharsets.UTF_8)));
@@ -605,8 +635,10 @@ void shouldSetValidParams() {
605635
assertThat(progress.getErrors().size(), is(equalTo(0)));
606636
assertThat(progress.hasWarnings(), is(equalTo(false)));
607637
assertThat(progress.getWarnings().size(), is(equalTo(0)));
638+
assertThat(progress.isOutputToStdout(), is(equalTo(false)));
608639
assertThat(ae.isFailOnError(), is(equalTo(false)));
609640
assertThat(ae.isFailOnWarning(), is(equalTo(true)));
641+
assertThat(ae.isContinueOnFailure(), is(equalTo(true)));
610642
assertThat(ae.isTimeToQuit(), is(equalTo(false)));
611643
}
612644

0 commit comments

Comments
 (0)