Fix exception during Gerrit init on authType

When initializing Gerrit, do not fail when processing
the selection of the authType: even if only HTTP and OAUTH are
valid with the GitHub plugin, it is incorrect to fail with
an IllegalArgumentException.

Use instead the EnumSet of the AuthType allowed values
to specify the only valid values with GitHub authentication.

Change-Id: I3abcd821cfa33550c1d5102f2f91cfa25fe3f2d1
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/InitGitHub.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/InitGitHub.java
index 6e5975d..4fdb9bb 100644
--- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/InitGitHub.java
+++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/InitGitHub.java
@@ -14,12 +14,14 @@
 package com.googlesource.gerrit.plugins.github;
 
 import com.google.common.base.Strings;
+import com.google.gerrit.extensions.client.AuthType;
 import com.google.gerrit.pgm.init.api.ConsoleUI;
 import com.google.gerrit.pgm.init.api.InitStep;
 import com.google.gerrit.pgm.init.api.InitUtil;
 import com.google.gerrit.pgm.init.api.Section;
 import com.google.inject.Inject;
 import java.net.URISyntaxException;
+import java.util.EnumSet;
 
 public class InitGitHub implements InitStep {
   private static final String GITHUB_URL = "https://github.com";
@@ -33,14 +35,6 @@
   private final Section github;
   private final Section gerrit;
 
-  public enum OAuthType {
-    /* Legacy Gerrit/HTTP authentication for GitHub through HTTP Header enrichment */
-    HTTP,
-
-    /* New native Gerrit/OAuth authentication provider */
-    OAUTH
-  }
-
   @Inject
   InitGitHub(final ConsoleUI ui, final Section.Factory sections) {
     this.ui = ui;
@@ -74,8 +68,8 @@
     github.string("GitHub Client ID", "clientId", null);
     github.passwordForKey("GitHub Client Secret", "clientSecret");
 
-    OAuthType authType = auth.select("Gerrit OAuth implementation", "type", OAuthType.HTTP);
-    if (authType.equals(OAuthType.HTTP)) {
+    AuthType authType = auth.select("Gerrit OAuth implementation", "type", AuthType.HTTP, EnumSet.of(AuthType.HTTP, AuthType.OAUTH));
+    if (authType.equals(AuthType.HTTP)) {
       auth.string("HTTP Authentication Header", "httpHeader", "GITHUB_USER");
       httpd.set("filterClass", "com.googlesource.gerrit.plugins.github.oauth.OAuthFilter");
       authSetDefault("httpExternalIdHeader", "GITHUB_OAUTH_TOKEN");