Skip to content

Commit

Permalink
NONE: remove FF (#2569)
Browse files Browse the repository at this point in the history
Co-authored-by: Gary Xue <[email protected]>
  • Loading branch information
bgvozdev and gxueatlassian authored Dec 4, 2023
1 parent 2d949a9 commit 9a45ea9
Show file tree
Hide file tree
Showing 12 changed files with 207 additions and 185 deletions.
2 changes: 0 additions & 2 deletions src/config/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export enum BooleanFlags {
export enum StringFlags {
BLOCKED_INSTALLATIONS = "blocked-installations",
LOG_LEVEL = "log-level",
HEADERS_TO_ENCRYPT = "headers-to-encrypt",
SEND_ALL = "send-all"
}

Expand All @@ -40,7 +39,6 @@ export enum NumberFlags {
PREEMPTIVE_RATE_LIMIT_THRESHOLD = "preemptive-rate-limit-threshold",
NUMBER_OF_BUILD_PAGES_TO_FETCH_IN_PARALLEL = "number-of-build-to-fetch-in-parallel",
BACKFILL_PAGE_SIZE = "backfill-page-size",
BACKFILL_MAX_SUBTASKS = "backfill-max-subtasks",
INSTALLATION_TOKEN_CACHE_MAX_SIZE = "installation-token-cache-max-size"
}

Expand Down
2 changes: 2 additions & 0 deletions src/sync/branch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ describe("sync/branches", () => {
.create();

githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);

});

Expand Down Expand Up @@ -293,6 +294,7 @@ describe("sync/branches", () => {
gitHubServerApp = builderResult.gitHubServerApp!;

gheUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
gheUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
});

const makeExpectedResponse = async (branchName: string) => {
Expand Down
7 changes: 7 additions & 0 deletions src/sync/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ describe("sync/builds", () => {
it("should sync builds to Jira when build message contains issue key", async () => {
const data: BackfillMessagePayload = { installationId: DatabaseStateCreator.GITHUB_INSTALLATION_ID, jiraHost };

githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);

Expand Down Expand Up @@ -137,6 +138,7 @@ describe("sync/builds", () => {
it("should not explode when returned payload doesn't have head_commit", async () => {
const data: BackfillMessagePayload = { installationId: DatabaseStateCreator.GITHUB_INSTALLATION_ID, jiraHost };

githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);

Expand Down Expand Up @@ -202,6 +204,7 @@ describe("sync/builds", () => {
expect.anything(),
expect.anything()
).mockResolvedValue(NUMBER_OF_PARALLEL_FETCHES);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);

const data: BackfillMessagePayload = { installationId: DatabaseStateCreator.GITHUB_INSTALLATION_ID, jiraHost };

Expand All @@ -224,6 +227,7 @@ describe("sync/builds", () => {

const data: BackfillMessagePayload = { installationId: DatabaseStateCreator.GITHUB_INSTALLATION_ID, jiraHost };

githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubNock
.get(`/repos/integrations/test-repo-name/actions/runs?per_page=20&page=6`)
Expand All @@ -236,6 +240,7 @@ describe("sync/builds", () => {
it("should sync multiple builds to Jira when they contain issue keys", async () => {
const data: BackfillMessagePayload = { installationId: DatabaseStateCreator.GITHUB_INSTALLATION_ID, jiraHost };

githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);

Expand Down Expand Up @@ -306,6 +311,7 @@ describe("sync/builds", () => {
it("should not call Jira if no issue keys are present", async () => {
const data: BackfillMessagePayload = { installationId: DatabaseStateCreator.GITHUB_INSTALLATION_ID, jiraHost };

githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);

Expand All @@ -329,6 +335,7 @@ describe("sync/builds", () => {
it("should not call Jira if no data is returned", async () => {
const data: BackfillMessagePayload = { installationId: DatabaseStateCreator.GITHUB_INSTALLATION_ID, jiraHost };

githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubNock
.get(`/repos/integrations/test-repo-name/actions/runs?per_page=20&page=21`)
Expand Down
9 changes: 9 additions & 0 deletions src/sync/code-scanning-alerts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe("sync/code-scanning-alerts", () => {
.get("/repos/integrations/test-repo-name/code-scanning/alerts?per_page=20&page=1&sort=created&direction=desc")
.reply(200, codeScanningAlerts);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
jiraNock
.post("/rest/security/1.0/bulk", expectedResponseCloudServer(subscription))
.reply(200);
Expand All @@ -73,6 +74,7 @@ describe("sync/code-scanning-alerts", () => {
.get("/repos/integrations/test-repo-name/code-scanning/alerts?per_page=20&page=1&sort=created&direction=desc")
.reply(200, []);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
// No Jira Nock

await expect(processInstallation(mockBackfillQueueSendMessage)(data, sentry, getLogger("test"))).toResolve();
Expand All @@ -86,6 +88,7 @@ describe("sync/code-scanning-alerts", () => {
.get("/repos/integrations/test-repo-name/code-scanning/alerts?per_page=20&page=1&sort=created&direction=desc")
.reply(403, { message: "Code scanning is not enabled for this repository" });
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
// No Jira Nock

await expect(processInstallation(mockBackfillQueueSendMessage)(data, sentry, getLogger("test"))).toResolve();
Expand All @@ -99,6 +102,7 @@ describe("sync/code-scanning-alerts", () => {
.get("/repos/integrations/test-repo-name/code-scanning/alerts?per_page=20&page=1&sort=created&direction=desc")
.reply(403, { message: "Advanced Security must be enabled for this repository to use code scanning" });
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
// No Jira Nock

await expect(processInstallation(mockBackfillQueueSendMessage)(data, sentry, getLogger("test"))).toResolve();
Expand All @@ -112,6 +116,7 @@ describe("sync/code-scanning-alerts", () => {
.get("/repos/integrations/test-repo-name/code-scanning/alerts?per_page=20&page=1&sort=created&direction=desc")
.reply(404, { message: "Ano analysis found" });
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
// No Jira Nock

await expect(processInstallation(mockBackfillQueueSendMessage)(data, sentry, getLogger("test"))).toResolve();
Expand All @@ -125,6 +130,7 @@ describe("sync/code-scanning-alerts", () => {
.get("/repos/integrations/test-repo-name/code-scanning/alerts?per_page=20&page=1&sort=created&direction=desc")
.reply(404);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
// No Jira Nock

await expect(processInstallation(mockBackfillQueueSendMessage)(data, sentry, getLogger("test"))).toResolve();
Expand All @@ -138,6 +144,7 @@ describe("sync/code-scanning-alerts", () => {
.get("/repos/integrations/test-repo-name/code-scanning/alerts?per_page=20&page=1&sort=created&direction=desc")
.reply(451);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
// No Jira Nock

await expect(processInstallation(mockBackfillQueueSendMessage)(data, sentry, getLogger("test"))).toResolve();
Expand Down Expand Up @@ -191,6 +198,7 @@ describe("sync/code-scanning-alerts", () => {
}
};
gheUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
gheUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
gheNock
.get("/api/v3/repos/integrations/test-repo-name/code-scanning/alerts?per_page=20&page=1&sort=created&direction=desc")
.reply(200, codeScanningAlerts);
Expand All @@ -216,6 +224,7 @@ describe("sync/code-scanning-alerts", () => {
}
};
gheUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
gheUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
gheNock
.get("/api/v3/repos/integrations/test-repo-name/code-scanning/alerts?per_page=20&page=1&sort=created&direction=desc")
.reply(200, []);
Expand Down
2 changes: 2 additions & 0 deletions src/sync/commits.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ describe("sync/commits", () => {
.create();

githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
});

const verifyMessageSent = async (data: BackfillMessagePayload, delaySec ?: number) => {
Expand Down Expand Up @@ -260,6 +261,7 @@ describe("sync/commits", () => {
gitHubServerApp = builderResult.gitHubServerApp!;

gheUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
gheUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
});

const makeExpectedJiraResponse = async (commits) => ({
Expand Down
10 changes: 9 additions & 1 deletion src/sync/dependabot-alerts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ describe("sync/dependabot-alerts", () => {
const data = { installationId: DatabaseStateCreator.GITHUB_INSTALLATION_ID, jiraHost };
nockDependabotAlertsRequest(dependabotAlerts);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
jiraNock
.post(
"/rest/security/1.0/bulk",
Expand All @@ -79,6 +80,7 @@ describe("sync/dependabot-alerts", () => {
"data": []
});
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
// No Jira Nock

await expect(processInstallation(mockBackfillQueueSendMessage)(data, sentry, getLogger("test"))).toResolve();
Expand All @@ -92,6 +94,7 @@ describe("sync/dependabot-alerts", () => {
.get("/repos/integrations/test-repo-name/dependabot/alerts?per_page=20&page=1&sort=created&direction=desc")
.reply(403, { message: "Dependabot alerts are disabled for this repository" });
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
// No Jira Nock

await expect(processInstallation(mockBackfillQueueSendMessage)(data, sentry, getLogger("test"))).toResolve();
Expand All @@ -105,6 +108,7 @@ describe("sync/dependabot-alerts", () => {
.get("/repos/integrations/test-repo-name/dependabot/alerts?per_page=20&page=1&sort=created&direction=desc")
.reply(403, { message: "Dependabot alerts are not available for archived repositories" });
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
// No Jira Nock

await expect(processInstallation(mockBackfillQueueSendMessage)(data, sentry, getLogger("test"))).toResolve();
Expand All @@ -118,6 +122,7 @@ describe("sync/dependabot-alerts", () => {
.get("/repos/integrations/test-repo-name/dependabot/alerts?per_page=20&page=1&sort=created&direction=desc")
.reply(404);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
// No Jira Nock

await expect(processInstallation(mockBackfillQueueSendMessage)(data, sentry, getLogger("test"))).toResolve();
Expand All @@ -131,6 +136,7 @@ describe("sync/dependabot-alerts", () => {
.get("/repos/integrations/test-repo-name/dependabot/alerts?per_page=20&page=1&sort=created&direction=desc")
.reply(451);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
// No Jira Nock

await expect(processInstallation(mockBackfillQueueSendMessage)(data, sentry, getLogger("test"))).toResolve();
Expand Down Expand Up @@ -188,6 +194,7 @@ describe("sync/dependabot-alerts", () => {
}
};
gheUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
gheUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
nockDependabotAlertsRequest(dependabotAlerts);
jiraNock
.post(
Expand Down Expand Up @@ -215,6 +222,7 @@ describe("sync/dependabot-alerts", () => {
}
};
gheUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
gheUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
nockDependabotAlertsRequest({
"data": []
});
Expand Down Expand Up @@ -357,4 +365,4 @@ const expectedResponseGHEServer = (subscription: Subscription) => ({
"workspaceId": subscription.id
},
"operationType": "BACKFILL"
});
});
5 changes: 5 additions & 0 deletions src/sync/deployment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ describe("sync/deployments", () => {
githubUserTokenNock(installationId);
githubUserTokenNock(installationId);
githubUserTokenNock(installationId);
githubUserTokenNock(installationId);

createGitHubNock(deploymentNodesFixture);
const lastEdges = deploymentNodesFixture.data.repository.deployments.edges;
Expand Down Expand Up @@ -458,6 +459,7 @@ describe("sync/deployments", () => {
githubUserTokenNock(installationId);
githubUserTokenNock(installationId);
githubUserTokenNock(installationId);
githubUserTokenNock(installationId);
githubNock.get(`/repos/test-repo-owner/test-repo-name/commits/${commitId}`)
.reply(200, {
commit: {
Expand Down Expand Up @@ -620,6 +622,7 @@ describe("sync/deployments", () => {
const lastEdges = deploymentNodesFixture.data.repository.deployments.edges;
createGitHubNock({ data: { repository: { deployments: { edges: [] } } } }, lastEdges[lastEdges.length -1].cursor);

githubUserTokenNock(installationId);
githubUserTokenNock(installationId);
githubNock.get(`/repos/test-repo-owner/test-repo-name/commits/51e16759cdac67b0d2a94e0674c9603b75a840f6`)
.reply(200, {
Expand Down Expand Up @@ -650,6 +653,7 @@ describe("sync/deployments", () => {
it("should not call Jira if no data is returned", async () => {
const data = { installationId, jiraHost };

githubUserTokenNock(installationId);
createGitHubNock({
data: {
repository: {
Expand Down Expand Up @@ -732,6 +736,7 @@ describe("sync/deployments", () => {
gheUserTokenNock(installationId);
gheUserTokenNock(installationId);
gheUserTokenNock(installationId);
gheUserTokenNock(installationId);

createGitHubServerNock(deploymentNodesFixture);
const lastEdges = deploymentNodesFixture.data.repository.deployments.edges;
Expand Down
Loading

0 comments on commit 9a45ea9

Please sign in to comment.