Fix TeamCity integration

This commit is contained in:
Tuan Dang
2023-09-22 12:06:42 +01:00
parent 48f7bd146f
commit c623f572b7
5 changed files with 14 additions and 9 deletions

View File

@@ -713,11 +713,12 @@ export const getIntegrationAuthNorthflankSecretGroups = async (req: Request, res
*/
export const getIntegrationAuthTeamCityBuildConfigs = async (req: Request, res: Response) => {
const {
params: { integrationAuthId, appId }
params: { integrationAuthId },
query: { appId }
} = await validateRequest(reqValidator.GetIntegrationAuthTeamCityBuildConfigsV1, req);
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
const { integrationAuth } = await getIntegrationAuthAccessHelper({
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
integrationAuthId: new ObjectId(integrationAuthId)
});
@@ -749,13 +750,13 @@ export const getIntegrationAuthTeamCityBuildConfigs = async (req: Request, res:
const {
data: { buildType }
} = await standardRequest.get<GetTeamCityBuildConfigsRes>(
`${req.integrationAuth.url}/app/rest/buildTypes`,
`${integrationAuth.url}/app/rest/buildTypes`,
{
params: {
locator: `project:${appId}`
},
headers: {
Authorization: `Bearer ${req.accessToken}`,
Authorization: `Bearer ${accessToken}`,
Accept: "application/json"
}
}

View File

@@ -160,7 +160,7 @@ export const getIntegrationAuthAccessHelper = async ({
let accessId;
let accessToken;
const integrationAuth = await IntegrationAuth.findById(integrationAuthId).select(
"workspace integration +accessCiphertext +accessIV +accessTag +accessExpiresAt +refreshCiphertext +refreshIV +refreshTag +accessIdCiphertext +accessIdIV +accessIdTag metadata teamId"
"workspace integration +accessCiphertext +accessIV +accessTag +accessExpiresAt +refreshCiphertext +refreshIV +refreshTag +accessIdCiphertext +accessIdIV +accessIdTag metadata teamId url"
);
if (!integrationAuth)

View File

@@ -153,9 +153,11 @@ export const DeleteIntegrationAuthV1 = z.object({
});
export const GetIntegrationAuthTeamCityBuildConfigsV1 = z.object({
params:z.object({
appId:z.string().trim(),
params: z.object({
integrationAuthId:z.string().trim()
}),
query: z.object({
appId:z.string().trim()
})
})

View File

@@ -197,6 +197,8 @@ const fetchIntegrationAuthTeamCityBuildConfigs = async ({
integrationAuthId: string;
appId: string;
}) => {
if (appId === "") return [];
const {
data: { buildConfigs }
} = await apiRequest.get<{ buildConfigs: TeamCityBuildConfig[] }>(

View File

@@ -49,7 +49,7 @@ export default function TeamCityCreateIntegrationPage() {
integrationAuthId: (integrationAuthId as string) ?? "",
appId: targetAppId
});
useEffect(() => {
if (workspace) {
setSelectedSourceEnvironment(workspace.environments[0].slug);