|
39 | 39 | import java.util.List; |
40 | 40 | import java.util.Locale; |
41 | 41 | import java.util.Map; |
| 42 | +import java.util.stream.Stream; |
42 | 43 | import org.junit.jupiter.api.BeforeAll; |
43 | 44 | import org.junit.jupiter.api.Test; |
| 45 | +import org.junit.jupiter.params.ParameterizedTest; |
| 46 | +import org.junit.jupiter.params.provider.MethodSource; |
44 | 47 | import org.mockito.quality.Strictness; |
45 | 48 | import org.parosproxy.paros.Constant; |
46 | 49 | import org.parosproxy.paros.control.Control; |
| 50 | +import org.parosproxy.paros.core.scanner.Plugin.AlertThreshold; |
| 51 | +import org.parosproxy.paros.core.scanner.Plugin.AttackStrength; |
47 | 52 | import org.parosproxy.paros.extension.ExtensionLoader; |
48 | 53 | import org.parosproxy.paros.model.Model; |
49 | 54 | import org.zaproxy.addon.automation.AutomationEnvironment; |
@@ -409,6 +414,47 @@ void shouldReturnFileFromRelativePathWithVars() { |
409 | 414 | assertFilePath(f, "/full/path/dir/relative/path/to/file"); |
410 | 415 | } |
411 | 416 |
|
| 417 | + static Stream<Locale> locales() { |
| 418 | + return Stream.of( |
| 419 | + Locale.ROOT, Locale.ENGLISH, new Locale.Builder().setLanguage("TR").build()); |
| 420 | + } |
| 421 | + |
| 422 | + @ParameterizedTest |
| 423 | + @MethodSource("locales") |
| 424 | + void shouldParseAttackStrengthInDifferentLocales(Locale locale) { |
| 425 | + Locale defaultLocale = Locale.getDefault(); |
| 426 | + try { |
| 427 | + // Given |
| 428 | + Locale.setDefault(locale); |
| 429 | + AutomationProgress progress = mock(AutomationProgress.class); |
| 430 | + // When |
| 431 | + AttackStrength attackStrength = JobUtils.parseAttackStrength("medium", "job", progress); |
| 432 | + // Then |
| 433 | + assertThat(attackStrength, is(equalTo(AttackStrength.MEDIUM))); |
| 434 | + verifyNoInteractions(progress); |
| 435 | + } finally { |
| 436 | + Locale.setDefault(defaultLocale); |
| 437 | + } |
| 438 | + } |
| 439 | + |
| 440 | + @ParameterizedTest |
| 441 | + @MethodSource("locales") |
| 442 | + void shouldParseAlertThresholdInDifferentLocales(Locale locale) { |
| 443 | + Locale defaultLocale = Locale.getDefault(); |
| 444 | + try { |
| 445 | + // Given |
| 446 | + Locale.setDefault(locale); |
| 447 | + AutomationProgress progress = mock(AutomationProgress.class); |
| 448 | + // When |
| 449 | + AlertThreshold alertThreshold = JobUtils.parseAlertThreshold("medium", "job", progress); |
| 450 | + // Then |
| 451 | + assertThat(alertThreshold, is(equalTo(AlertThreshold.MEDIUM))); |
| 452 | + verifyNoInteractions(progress); |
| 453 | + } finally { |
| 454 | + Locale.setDefault(defaultLocale); |
| 455 | + } |
| 456 | + } |
| 457 | + |
412 | 458 | private static void assertFilePath(File file, String path) { |
413 | 459 | assertThat( |
414 | 460 | file.toPath().normalize().toAbsolutePath(), is(Paths.get(path).toAbsolutePath())); |
|
0 commit comments