Skip to content

Commit 1835aba

Browse files
authored
Merge branch 'main' into drop-jwk-to-pem
2 parents 6e45775 + 9f24d3f commit 1835aba

File tree

4 files changed

+112
-35
lines changed

4 files changed

+112
-35
lines changed

.github/workflows/dependency-review.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ jobs:
2121
with:
2222
comment-summary-in-pr: always
2323
fail-on-severity: high
24-
allow-licenses: MIT, MIT-0, Apache-2.0, BSD-3-Clause, BSD-3-Clause-Clear, ISC, BSD-2-Clause, Unlicense, CC0-1.0, 0BSD, X11, MPL-2.0, MPL-1.0, MPL-1.1, MPL-2.0, OFL-1.1, Zlib
24+
allow-licenses: MIT, MIT-0, Apache-2.0, BSD-3-Clause, BSD-3-Clause-Clear, ISC, BSD-2-Clause, Unlicense, CC0-1.0, 0BSD, X11, MPL-2.0, MPL-1.0, MPL-1.1, MPL-2.0, OFL-1.1, Zlib, BlueOak-1.0.0
2525
fail-on-scopes: development, runtime
2626
allow-dependencies-licenses: 'pkg:npm/caniuse-lite'

package-lock.json

Lines changed: 82 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/proxy/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default class Proxy {
5151
const allowedList: Repo[] = await getRepos();
5252

5353
defaultAuthorisedRepoList.forEach(async (x) => {
54-
const found = allowedList.find((y) => y.project === x.project && x.name === y.name);
54+
const found = allowedList.find((y) => y.url === x.url);
5555
if (!found) {
5656
const repo = await createRepo(x);
5757
await addUserCanPush(repo._id!, 'admin');

test/testProxyRoute.test.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,23 @@ import Proxy from '../src/proxy';
1818
const TEST_DEFAULT_REPO = {
1919
url: 'https://github.com/finos/git-proxy.git',
2020
name: 'git-proxy',
21-
project: 'finos/git-proxy',
21+
project: 'finos',
2222
host: 'github.com',
2323
proxyUrlPrefix: '/github.com/finos/git-proxy.git',
2424
};
2525

2626
const TEST_GITLAB_REPO = {
2727
url: 'https://gitlab.com/gitlab-community/meta.git',
2828
name: 'gitlab',
29-
project: 'gitlab-community/meta',
29+
project: 'gitlab-community',
3030
host: 'gitlab.com',
3131
proxyUrlPrefix: '/gitlab.com/gitlab-community/meta.git',
3232
};
3333

3434
const TEST_UNKNOWN_REPO = {
3535
url: 'https://github.com/finos/fdc3.git',
3636
name: 'fdc3',
37-
project: 'finos/fdc3',
37+
project: 'finos',
3838
host: 'github.com',
3939
proxyUrlPrefix: '/github.com/finos/fdc3.git',
4040
fallbackUrlPrefix: '/finos/fdc3.git',
@@ -559,4 +559,29 @@ describe('proxy express application', async () => {
559559
res2.should.have.status(200);
560560
expect(res2.text).to.contain('Rejecting repo');
561561
}).timeout(5000);
562+
563+
it('should create the default repo if it does not exist', async function () {
564+
// Remove the default repo from the db and check it no longer exists
565+
await cleanupRepo(TEST_DEFAULT_REPO.url);
566+
567+
const repo = await db.getRepoByUrl(TEST_DEFAULT_REPO.url);
568+
expect(repo).to.be.null;
569+
570+
// Restart the proxy
571+
await proxy.stop();
572+
await proxy.start();
573+
574+
// Check that the default repo was created in the db
575+
const repo2 = await db.getRepoByUrl(TEST_DEFAULT_REPO.url);
576+
expect(repo2).to.not.be.null;
577+
578+
// Check that the default repo isn't duplicated on subsequent restarts
579+
await proxy.stop();
580+
await proxy.start();
581+
582+
const allRepos = await db.getRepos();
583+
const matchingRepos = allRepos.filter((r) => r.url === TEST_DEFAULT_REPO.url);
584+
585+
expect(matchingRepos).to.have.length(1);
586+
});
562587
});

0 commit comments

Comments
 (0)