Skip to content

Commit

Permalink
Merge pull request #6011 from thc202/replacer/af/warn-del-all
Browse files Browse the repository at this point in the history
replacer: do not warn for `deleteAllRules`
  • Loading branch information
kingthorin authored Dec 16, 2024
2 parents 8ddfbde + 272b784 commit 29ddbc2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions addOns/replacer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## Unreleased
### Fixed
- Typo in automation job help.
- Address misleading warning `Unrecognised parameter` for `deleteAllRules` (Issue 8764).

### Changed
- Update minimum ZAP version to 2.16.0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ private ExtensionReplacer getExtReplacer() {
return extReplacer;
}

@Override
public boolean applyCustomParameter(String name, String value) {
if ("deleteAllRules".equals(name)) {
// Applied when the job is executed.
return true;
}

return super.applyCustomParameter(name, value);
}

@Override
public void verifyParameters(AutomationProgress progress) {
Map<?, ?> jobData = this.getJobData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void shouldVerifyWithNoData() {

@ParameterizedTest
@ValueSource(booleans = {true, false})
void shouldApplyParameterDeleteAllRules(boolean value) {
void shouldVerifyAndApplyParameterDeleteAllRules(boolean value) {
// Given
ReplacerJob job =
createReplacerJob(
Expand All @@ -113,6 +113,27 @@ void shouldApplyParameterDeleteAllRules(boolean value) {
assertThat(job.getData().getParameters().getDeleteAllRules(), is(equalTo(value)));
}

@Test
void shouldApplyParameters() {
// Given
ReplacerJob job =
createReplacerJob(
"""
parameters:
deleteAllRules: true
rules: []
""");
AutomationProgress progress = new AutomationProgress();

// When
job.applyParameters(progress);

// Then
assertThat(progress.hasErrors(), is(equalTo(false)));
assertThat(progress.hasWarnings(), is(equalTo(false)));
// Nothing else to check, they are applied at the same time as they are verified.
}

@Test
void shouldApplyValidMinRule() {
// Given
Expand Down

0 comments on commit 29ddbc2

Please sign in to comment.