Use allowlist instead of whitelist

There is a config that we'd need to deprecate to completely remove the
use of whitelist, but this is not very helpful since the legacy config
will have to stay anyway. We remove references to whitelist and just
replace them with allowlist where possible.

Bug: Issue 13014
Change-Id: Id023e9fd1e1bfa4ee52a28bbb7ebf0e72cb0b262
diff --git a/src/main/java/com/googlesource/gerrit/plugins/uploadvalidator/ContentTypeValidator.java b/src/main/java/com/googlesource/gerrit/plugins/uploadvalidator/ContentTypeValidator.java
index 698d358..df1b633 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/uploadvalidator/ContentTypeValidator.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/uploadvalidator/ContentTypeValidator.java
@@ -63,27 +63,27 @@
                     "Pushes of commits that contain files with blocked content "
                         + "types will be rejected."));
         bind(ProjectConfigEntry.class)
-            .annotatedWith(Exports.named(KEY_BLOCKED_CONTENT_TYPE_WHITELIST))
+            .annotatedWith(Exports.named(KEY_BLOCKED_CONTENT_TYPE_ALLOWLIST))
             .toInstance(
                 new ProjectConfigEntry(
-                    "Blocked Content Type Whitelist",
+                    "Blocked Content Type Allowlist",
                     "false",
                     ProjectConfigEntryType.BOOLEAN,
                     null,
                     false,
                     "If this option is checked, the entered content types are "
-                        + "interpreted as a whitelist. Otherwise commits that "
+                        + "interpreted as an allowlist. Otherwise commits that "
                         + "contain one of these content types will be rejected."));
       }
     };
   }
 
   public static final String KEY_BLOCKED_CONTENT_TYPE = "blockedContentType";
-  public static final String KEY_BLOCKED_CONTENT_TYPE_WHITELIST = "blockedContentTypeWhitelist";
+  public static final String KEY_BLOCKED_CONTENT_TYPE_ALLOWLIST = "blockedContentTypeWhitelist";
 
   @VisibleForTesting
-  static boolean isWhitelist(PluginConfig cfg) {
-    return cfg.getBoolean(KEY_BLOCKED_CONTENT_TYPE_WHITELIST, false);
+  static boolean isAllowList(PluginConfig cfg) {
+    return cfg.getBoolean(KEY_BLOCKED_CONTENT_TYPE_ALLOWLIST, false);
   }
 
   @VisibleForTesting
@@ -135,7 +135,7 @@
                   receiveEvent.commit,
                   receiveEvent.revWalk,
                   getBlockedTypes(cfg),
-                  isWhitelist(cfg));
+                  isAllowList(cfg));
           if (!messages.isEmpty()) {
             throw new CommitValidationException("contains blocked content type", messages);
           }
@@ -149,7 +149,7 @@
 
   @VisibleForTesting
   List<CommitValidationMessage> performValidation(
-      Repository repo, RevCommit c, RevWalk revWalk, String[] blockedTypes, boolean whitelist)
+      Repository repo, RevCommit c, RevWalk revWalk, String[] blockedTypes, boolean allowList)
       throws IOException, ExecutionException {
     List<CommitValidationMessage> messages = new LinkedList<>();
     Map<String, ObjectId> content = CommitUtils.getChangedContent(repo, c, revWalk);
@@ -157,8 +157,8 @@
       ObjectLoader ol = repo.open(content.get(path));
       try (ObjectStream os = ol.openStream()) {
         String contentType = contentTypeUtil.getContentType(os, path);
-        if ((contentTypeUtil.matchesAny(contentType, blockedTypes) && !whitelist)
-            || (!contentTypeUtil.matchesAny(contentType, blockedTypes) && whitelist)) {
+        if ((contentTypeUtil.matchesAny(contentType, blockedTypes) && !allowList)
+            || (!contentTypeUtil.matchesAny(contentType, blockedTypes) && allowList)) {
           messages.add(
               new CommitValidationMessage(
                   "found blocked content type (" + contentType + ") in file: " + path, true));
diff --git a/src/test/java/com/googlesource/gerrit/plugins/uploadvalidator/ContentTypeValidatorTest.java b/src/test/java/com/googlesource/gerrit/plugins/uploadvalidator/ContentTypeValidatorTest.java
index 6477189..5ef6227 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/uploadvalidator/ContentTypeValidatorTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/uploadvalidator/ContentTypeValidatorTest.java
@@ -79,7 +79,7 @@
   }
 
   @Test
-  public void testWhitelist() throws Exception {
+  public void testAllowlist() throws Exception {
     String[] patterns = new String[] {"application/pdf", "application/xml"};
 
     try (RevWalk rw = new RevWalk(repo)) {
@@ -93,7 +93,7 @@
   @Test
   public void validatorBehaviorWhenConfigEmpty() {
     assertThat(ContentTypeValidator.isActive(EMPTY_PLUGIN_CONFIG)).isFalse();
-    assertThat(ContentTypeValidator.isWhitelist(EMPTY_PLUGIN_CONFIG)).isFalse();
+    assertThat(ContentTypeValidator.isAllowList(EMPTY_PLUGIN_CONFIG)).isFalse();
   }
 
   private RevCommit makeCommit(RevWalk rw) throws IOException, GitAPIException {