Skip to content

Commit

Permalink
test(artifacts): extend testing of applicationsRegex
Browse files Browse the repository at this point in the history
to verify exact matches and use of regexes in both the "allow list" and "deny list" cases.
  • Loading branch information
dbyron-sf committed Mar 4, 2024
1 parent 6372617 commit efd5162
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,30 @@ void testApplicationsRegex(String application, String applicationsRegex, boolean
}

private static Stream<Arguments> applicationsRegexArgs() {
List<String> apps = List.of("app-one", "app-two", "app-three");
List<String> apps = List.of("app-one", "app-two", "app-three", "app-five.*");

// The artifact store is enabled only for exact matches (e.g. not partial
// matches) of applications in the list.
String allowRegex = "^(" + String.join("|", apps) + ")$";

// To test applicationsRegex as a "deny list", meaning that the artifact
// store is enabled for all apps except those in the list, use a negative
// lookahead (?!). See https://stackoverflow.com/a/406408/9572.
String denyRegex = "^((?!(" + String.join("|", apps) + ")).)*$";
// lookahead (?!). See https://stackoverflow.com/a/14147470/9572.
String denyRegex = "^(?!(" + String.join("|", apps) + ")$).*";

return Stream.of(
Arguments.of("any", null, true),
Arguments.of("app-one", allowRegex, true),
Arguments.of("app-four", allowRegex, false),
Arguments.of("one", allowRegex, false),
Arguments.of("app-one-more", allowRegex, false),
Arguments.of("app-five", allowRegex, true),
Arguments.of("app-five-more", allowRegex, true),
Arguments.of("app-one", denyRegex, false),
Arguments.of("app-four", denyRegex, true),
Arguments.of("one", denyRegex, true),
Arguments.of("any", null, true));
Arguments.of("app-one-more", denyRegex, true),
Arguments.of("app-five", denyRegex, false),
Arguments.of("app-five-more", denyRegex, false));
}
}

0 comments on commit efd5162

Please sign in to comment.