*/
private String personalAccessToken;
+ /**
+ * Application client Id of the GitHub instance. Max size is 40.
+ * This column will only be fed when alm is GitHub.
+ * It will be null when the ALM is Azure DevOps or Bitbucket.
+ */
+ private String clientId;
+ /**
+ * Application client secret of the GitHub instance. Max size is 80.
+ * This column will only be fed when alm is GitHub.
+ * It will be null when the ALM is Azure DevOps or Bitbucket.
+ */
+ private String clientSecret;
+
private long updatedAt;
private long createdAt;
return this;
}
+ @CheckForNull
+ public String getClientId() {
+ return clientId;
+ }
+
+ public AlmSettingDto setClientId(@Nullable String clientId) {
+ this.clientId = clientId;
+ return this;
+ }
+
+ @CheckForNull
+ public String getClientSecret() {
+ return clientSecret;
+ }
+
+ public AlmSettingDto setClientSecret(@Nullable String clientSecret) {
+ this.clientSecret = clientSecret;
+ return this;
+ }
+
long getUpdatedAt() {
return updatedAt;
}
a.app_id as "appId",
a.private_key as "privateKey",
a.pat as "personalAccessToken",
+ a.client_id as "clientId",
+ a.client_secret as "clientSecret",
a.created_at as "createdAt",
a.updated_at as "updatedAt"
</sql>
app_id,
private_key,
pat,
+ client_id,
+ client_secret,
created_at,
updated_at
)
#{dto.appId, jdbcType=VARCHAR},
#{dto.privateKey, jdbcType=VARCHAR},
#{dto.personalAccessToken, jdbcType=VARCHAR},
+ #{dto.clientId, jdbcType=VARCHAR},
+ #{dto.clientSecret, jdbcType=VARCHAR},
#{dto.createdAt, jdbcType=BIGINT},
#{dto.updatedAt, jdbcType=BIGINT}
)
app_id = #{dto.appId, jdbcType=VARCHAR},
private_key = #{dto.privateKey, jdbcType=VARCHAR},
pat = #{dto.personalAccessToken, jdbcType=VARCHAR},
+ client_id = #{dto.clientId, jdbcType=VARCHAR},
+ client_secret = #{dto.clientSecret, jdbcType=VARCHAR},
updated_at = #{dto.updatedAt, jdbcType=BIGINT}
</set>
<where>
"PRIVATE_KEY" VARCHAR(2000),
"PAT" VARCHAR(2000),
"UPDATED_AT" BIGINT NOT NULL,
- "CREATED_AT" BIGINT NOT NULL
+ "CREATED_AT" BIGINT NOT NULL,
+ "CLIENT_ID" VARCHAR(80),
+ "CLIENT_SECRET" VARCHAR(80)
);
ALTER TABLE "ALM_SETTINGS" ADD CONSTRAINT "PK_ALM_SETTINGS" PRIMARY KEY("UUID");
CREATE UNIQUE INDEX "UNIQ_ALM_SETTINGS" ON "ALM_SETTINGS"("KEE");
import org.sonar.server.platform.db.migration.version.v84.activerules.MakeActiveRulesUuidColumnNotNullable;
import org.sonar.server.platform.db.migration.version.v84.activerules.PopulateActiveRuleParametersActiveRuleUuid;
import org.sonar.server.platform.db.migration.version.v84.activerules.PopulateActiveRulesUuid;
+import org.sonar.server.platform.db.migration.version.v84.alm.AddClientIdAndClientSecretColumns;
import org.sonar.server.platform.db.migration.version.v84.ceactivity.AddPrimaryKeyOnUuidColumnOfCeActivityTable;
import org.sonar.server.platform.db.migration.version.v84.ceactivity.DropIdColumnOfCeActivityTable;
import org.sonar.server.platform.db.migration.version.v84.ceactivity.DropPrimaryKeyOnIdColumnOfCeActivityTable;
.add(3804, "Populate 'need_issue_sync' of 'project_branches'", PopulateProjectBranchesNeedIssueSync.class)
.add(3805, "Make 'need_issue_sync' of 'project_branches' not null", MakeProjectBranchesNeedIssueSyncNonNull.class)
- .add(3806, "Drop local webhooks", DropLocalWebhooks.class)
+ .add(3806, "Drop local webhooks", DropLocalWebhooks.class)
+
+ // Migration of ALM_SETTINGS table
+ .add(3807, "Add columns 'CLIENT_ID' and 'CLIENT_SECRET' to 'ALM_SETTINGS' table", AddClientIdAndClientSecretColumns.class)
;
}
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v84.alm;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder;
+
+public class AddClientIdAndClientSecretColumns extends DdlChange {
+
+ public AddClientIdAndClientSecretColumns(Database db) {
+ super(db);
+ }
+
+ @Override
+ public void execute(Context context) throws SQLException {
+ context.execute(new AddColumnsBuilder(getDialect(), "alm_settings")
+ .addColumn(newVarcharColumnDefBuilder()
+ .setColumnName("client_id")
+ .setIsNullable(true)
+ .setDefaultValue(null)
+ .setLimit(80)
+ .build())
+ .addColumn(newVarcharColumnDefBuilder()
+ .setColumnName("client_secret")
+ .setIsNullable(true)
+ .setDefaultValue(null)
+ .setLimit(80)
+ .build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v84.alm;
+
+import java.sql.SQLException;
+import java.sql.Types;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.MigrationStep;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+public class AddClientIdAndClientSecretColumnsTest {
+ @Rule
+ public CoreDbTester db = CoreDbTester.createForSchema(AddClientIdAndClientSecretColumnsTest.class, "schema.sql");
+
+ private MigrationStep underTest = new AddClientIdAndClientSecretColumns(db.database());
+
+ @Test
+ public void execute() throws SQLException {
+ underTest.execute();
+
+ db.assertColumnDefinition("alm_settings", "client_id", Types.VARCHAR, 80, true);
+ db.assertColumnDefinition("alm_settings", "client_secret", Types.VARCHAR, 80, true);
+ }
+
+ @Test
+ public void migration_is_not_re_entrant() throws SQLException {
+ underTest.execute();
+
+ assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ }
+}
--- /dev/null
+CREATE TABLE "ALM_SETTINGS"(
+ "UUID" VARCHAR(40) NOT NULL,
+ "ALM_ID" VARCHAR(40) NOT NULL,
+ "KEE" VARCHAR(200) NOT NULL,
+ "URL" VARCHAR(2000),
+ "APP_ID" VARCHAR(80),
+ "PRIVATE_KEY" VARCHAR(2000),
+ "PAT" VARCHAR(2000),
+ "UPDATED_AT" BIGINT NOT NULL,
+ "CREATED_AT" BIGINT NOT NULL
+);
+ALTER TABLE "ALM_SETTINGS" ADD CONSTRAINT "PK_ALM_SETTINGS" PRIMARY KEY("UUID");
+CREATE UNIQUE INDEX "UNIQ_ALM_SETTINGS" ON "ALM_SETTINGS"("KEE");
optional string key = 1;
optional string name = 2;
}
+
+// WS api/alm_integrations/get_github_client_id
+message GithubClientIdWsResponse {
+ optional string clientId = 1;
+}