Skip to content

Commit 9fe4145

Browse files
authored
Merge branch 'main' into 1299-awsCredentialProviders-c
2 parents d832465 + f31592b commit 9fe4145

File tree

6 files changed

+14
-19
lines changed

6 files changed

+14
-19
lines changed

src/db/file/pushes.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ import { PushQuery } from '../types';
66

77
const COMPACTION_INTERVAL = 1000 * 60 * 60 * 24; // once per day
88

9-
// these don't get coverage in tests as they have already been run once before the test
10-
/* istanbul ignore if */
11-
129
// export for testing purposes
1310
export let db: Datastore;
1411
if (process.env.NODE_ENV === 'test') {

test/processors/checkEmptyBranch.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
22
import { Action } from '../../src/proxy/actions';
3+
import { EMPTY_COMMIT_HASH } from '../../src/proxy/processors/constants';
34

45
vi.mock('simple-git');
56
vi.mock('fs');
@@ -55,7 +56,7 @@ describe('checkEmptyBranch', () => {
5556
action = new Action('1234567890', 'push', 'POST', 1234567890, 'test/repo');
5657
action.proxyGitPath = '/tmp/gitproxy';
5758
action.repoName = 'test-repo';
58-
action.commitFrom = '0000000000000000000000000000000000000000';
59+
action.commitFrom = EMPTY_COMMIT_HASH;
5960
action.commitTo = 'abcdef1234567890abcdef1234567890abcdef12';
6061
action.commitData = [];
6162
});

test/processors/getDiff.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import fc from 'fast-check';
66
import { Action } from '../../src/proxy/actions';
77
import { exec } from '../../src/proxy/processors/push-action/getDiff';
88
import { CommitData } from '../../src/proxy/processors/types';
9+
import { EMPTY_COMMIT_HASH } from '../../src/proxy/processors/constants';
910

1011
describe('getDiff', () => {
1112
let tempDir: string;
@@ -40,7 +41,7 @@ describe('getDiff', () => {
4041
action.repoName = 'temp-test-repo';
4142
action.commitFrom = 'HEAD~1';
4243
action.commitTo = 'HEAD';
43-
action.commitData = [{ parent: '0000000000000000000000000000000000000000' } as CommitData];
44+
action.commitData = [{ parent: EMPTY_COMMIT_HASH } as CommitData];
4445

4546
const result = await exec({}, action);
4647

@@ -55,7 +56,7 @@ describe('getDiff', () => {
5556
action.repoName = 'temp-test-repo';
5657
action.commitFrom = 'HEAD~1';
5758
action.commitTo = 'HEAD';
58-
action.commitData = [{ parent: '0000000000000000000000000000000000000000' } as CommitData];
59+
action.commitData = [{ parent: EMPTY_COMMIT_HASH } as CommitData];
5960

6061
const result = await exec({}, action);
6162

@@ -106,7 +107,7 @@ describe('getDiff', () => {
106107

107108
action.proxyGitPath = path.dirname(tempDir);
108109
action.repoName = path.basename(tempDir);
109-
action.commitFrom = '0000000000000000000000000000000000000000';
110+
action.commitFrom = EMPTY_COMMIT_HASH;
110111
action.commitTo = headCommit;
111112
action.commitData = [{ parent: parentCommit } as CommitData];
112113

@@ -156,9 +157,7 @@ describe('getDiff', () => {
156157
action.repoName = 'temp-test-repo';
157158
action.commitFrom = from;
158159
action.commitTo = to;
159-
action.commitData = [
160-
{ parent: '0000000000000000000000000000000000000000' } as CommitData,
161-
];
160+
action.commitData = [{ parent: EMPTY_COMMIT_HASH } as CommitData];
162161

163162
const result = await exec({}, action);
164163

test/proxy.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,6 @@ describe.skip('Proxy Module TLS Certificate Loading', () => {
102102
close: vi.fn(),
103103
} as any);
104104

105-
process.env.NODE_ENV = 'test';
106-
process.env.GIT_PROXY_HTTPS_SERVER_PORT = '8443';
107-
108105
const ProxyClass = (await import('../src/proxy/index')).Proxy;
109106
proxyModule = new ProxyClass();
110107
});

test/testDb.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Repo, User } from '../src/db/types';
44
import { Action } from '../src/proxy/actions/Action';
55
import { Step } from '../src/proxy/actions/Step';
66
import { AuthorisedRepo } from '../src/config/generated/config';
7+
import { EMPTY_COMMIT_HASH } from '../src/proxy/processors/constants';
78

89
const TEST_REPO = {
910
project: 'finos',
@@ -37,7 +38,7 @@ const TEST_PUSH = {
3738
autoApproved: false,
3839
autoRejected: false,
3940
commitData: [],
40-
id: '0000000000000000000000000000000000000000__1744380874110',
41+
id: `${EMPTY_COMMIT_HASH}__1744380874110`,
4142
type: 'push',
4243
method: 'get',
4344
timestamp: 1744380903338,
@@ -49,7 +50,7 @@ const TEST_PUSH = {
4950
userEmail: '[email protected]',
5051
lastStep: null,
5152
blockedMessage:
52-
'\n\n\nGitProxy has received your push:\n\nhttp://localhost:8080/requests/0000000000000000000000000000000000000000__1744380874110\n\n\n',
53+
'\n\n\nGitProxy has received your push:\n\nhttp://localhost:8080/requests/${EMPTY_COMMIT_HASH}__1744380874110\n\n\n',
5354
_id: 'GIMEz8tU2KScZiTz',
5455
attestation: null,
5556
};

test/testPush.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as db from '../src/db';
44
import { Service } from '../src/service';
55
import { Proxy } from '../src/proxy';
66
import { Express } from 'express';
7+
import { EMPTY_COMMIT_HASH } from '../src/proxy/processors/constants';
78

89
// dummy repo
910
const TEST_ORG = 'finos';
@@ -32,7 +33,7 @@ const TEST_PUSH = {
3233
autoApproved: false,
3334
autoRejected: false,
3435
commitData: [],
35-
id: '0000000000000000000000000000000000000000__1744380874110',
36+
id: `${EMPTY_COMMIT_HASH}__1744380874110`,
3637
type: 'push',
3738
method: 'get',
3839
timestamp: 1744380903338,
@@ -44,7 +45,7 @@ const TEST_PUSH = {
4445
userEmail: TEST_EMAIL_2,
4546
lastStep: null,
4647
blockedMessage:
47-
'\n\n\nGitProxy has received your push:\n\nhttp://localhost:8080/requests/0000000000000000000000000000000000000000__1744380874110\n\n\n',
48+
'\n\n\nGitProxy has received your push:\n\nhttp://localhost:8080/requests/${EMPTY_COMMIT_HASH}__1744380874110\n\n\n',
4849
_id: 'GIMEz8tU2KScZiTz',
4950
attestation: null,
5051
};
@@ -128,8 +129,7 @@ describe('Push API', () => {
128129

129130
it('should get 404 for unknown push', async () => {
130131
await loginAsApprover();
131-
const commitId =
132-
'0000000000000000000000000000000000000000__79b4d8953cbc324bcc1eb53d6412ff89666c241f';
132+
const commitId = `${EMPTY_COMMIT_HASH}__79b4d8953cbc324bcc1eb53d6412ff89666c241f`;
133133
const res = await request(app).get(`/api/v1/push/${commitId}`).set('Cookie', `${cookie}`);
134134
expect(res.status).toBe(404);
135135
});

0 commit comments

Comments
 (0)