Remove gerrit[AuthBaseUrl|Password] from config Gerrit data is accessed over the direct GerritApi calls therefore neither URL nor user password are required. Remove them from the `Configuration` and documentation. Bug: Issue 336577745 Change-Id: Ie377db71a0689adab7f70cacb7f02ae498fbc205
diff --git a/README.md b/README.md index 91574ee..f63ab97 100644 --- a/README.md +++ b/README.md
@@ -30,15 +30,11 @@ `[plugin "chatgpt-code-review-gerrit-plugin"]`: - `gptToken`: OpenAI GPT token. -- `gerritAuthBaseUrl`: The URL of your Gerrit instance, similar to `https://gerrit.local.team`. - - **NOTE**: Do not append "/a" authentication sub-path to the Gerrit URL. - `gerritUserName`: Gerrit username of ChatGPT user. -- `gerritPassword`: Gerrit password of ChatGPT user. - `globalEnable`: Default value is false. The plugin will only review specified repositories. If set to true, the plugin will by default review all pull requests. - For enhanced security, consider storing sensitive information like gptToken and gerritPassword in a secure location + For enhanced security, consider storing sensitive information like gptToken in a secure location or file. Detailed instructions on how to do this will be provided later in this document. 4. **Verify:** After restarting Gerrit, you can see the following information in Gerrit's logs: @@ -84,7 +80,6 @@ [plugin "chatgpt-code-review-gerrit-plugin"] # Required parameters gptToken = {gptToken} - gerritAuthBaseUrl = {gerritAuthBaseUrl} ... # Optional parameters @@ -95,13 +90,12 @@ #### Secure Configuration -It is highly recommended to store sensitive information such as `gptToken` and `gerritPassword` in the `secure.config` +It is highly recommended to store sensitive information such as `gptToken` in the `secure.config` file. Please edit the file at $gerrit_site/etc/`secure.config` and include the following details: ``` [plugin "chatgpt-code-review-gerrit-plugin"] gptToken = {gptToken} - gerritPassword = {gerritPassword} ``` If you wish to encrypt the information within the `secure.config` file, you can refer @@ -115,7 +109,6 @@ [plugin "chatgpt-code-review-gerrit-plugin"] # Required parameters gerritUserName = {gerritUserName} - gerritAuthBaseUrl = {gerritAuthBaseUrl} ... # Optional parameters @@ -127,7 +120,7 @@ #### Secure Configuration Please ensure **strict control over the access permissions of `refs/meta/config`** since sensitive information such as -`gptToken` and `gerritPassword` is configured in the `project.config` file within `refs/meta/config`. +`gptToken` is configured in the `project.config` file within `refs/meta/config`. ### Optional Parameters
diff --git a/gerrit.config b/gerrit.config index cf859cc..80787ac 100644 --- a/gerrit.config +++ b/gerrit.config
@@ -2,7 +2,5 @@ gptToken = <CHATGPT_API_TOKEN> gptModel = gpt-4 gptStreamOutput = false - gerritAuthBaseUrl = <CANONICAL_WEB_URL> gerritUserName = <GERRIT_USER_NAME> - gerritPassword = <GERRIT_PASSWORD> globalEnable = true
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/config/Configuration.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/config/Configuration.java index d5c189c..7da35e4 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/config/Configuration.java +++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/config/Configuration.java
@@ -94,8 +94,6 @@ public static final String KEY_GERRIT_USERNAME = "gerritUserName"; private static final String KEY_GPT_TOKEN = "gptToken"; - private static final String KEY_GERRIT_AUTH_BASE_URL = "gerritAuthBaseUrl"; - private static final String KEY_GERRIT_PASSWORD = "gerritPassword"; private static final String KEY_GPT_DOMAIN = "gptDomain"; private static final String KEY_GPT_MODEL = "gptModel"; private static final String KEY_STREAM_OUTPUT = "gptStreamOutput"; @@ -155,18 +153,10 @@ return getValidatedOrThrow(KEY_GPT_TOKEN); } - public String getGerritAuthBaseUrl() { - return getValidatedOrThrow(KEY_GERRIT_AUTH_BASE_URL); - } - public String getGerritUserName() { return getValidatedOrThrow(KEY_GERRIT_USERNAME); } - public String getGerritPassword() { - return getValidatedOrThrow(KEY_GERRIT_PASSWORD); - } - public String getGptDomain() { return getString(KEY_GPT_DOMAIN, OPENAI_DOMAIN); }
diff --git a/src/test/java/com/googlesource/gerrit/plugins/chatgpt/integration/CodeReviewPluginIT.java b/src/test/java/com/googlesource/gerrit/plugins/chatgpt/integration/CodeReviewPluginIT.java index 5485443..fa33a2d 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/chatgpt/integration/CodeReviewPluginIT.java +++ b/src/test/java/com/googlesource/gerrit/plugins/chatgpt/integration/CodeReviewPluginIT.java
@@ -52,9 +52,7 @@ @Test public void getPatchSet() throws Exception { - when(config.getGerritAuthBaseUrl()).thenReturn("Your Gerrit URL"); when(config.getGerritUserName()).thenReturn("Your Gerrit username"); - when(config.getGerritPassword()).thenReturn("Your Gerrit password"); String patchSet = gerritClient.getPatchSet("${changeId}"); log.info("patchSet: {}", patchSet); @@ -63,9 +61,7 @@ @Test public void setReview() throws Exception { - when(config.getGerritAuthBaseUrl()).thenReturn("Your Gerrit URL"); when(config.getGerritUserName()).thenReturn("Your Gerrit username"); - when(config.getGerritPassword()).thenReturn("Your Gerrit password"); List<ReviewBatch> reviewBatches = new ArrayList<>(); reviewBatches.add(new ReviewBatch());