Skip to content

Commit d7cc4d7

Browse files
authored
Merge branch 'main' into config
2 parents 868aa13 + b5c0b2d commit d7cc4d7

13 files changed

Lines changed: 758 additions & 23 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
npm run test-coverage-ci --workspaces --if-present
5858
5959
- name: Upload test coverage report
60-
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
60+
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
6161
with:
6262
files: ./coverage/lcov.info
6363
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060

6161
# Initializes the CodeQL tools for scanning.
6262
- name: Initialize CodeQL
63-
uses: github/codeql-action/init@df559355d593797519d70b90fc8edd5db049e7a2 # v3
63+
uses: github/codeql-action/init@f1f6e5f6af878fb37288ce1c627459e94dbf7d01 # v3
6464
with:
6565
languages: ${{ matrix.language }}
6666
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -73,7 +73,7 @@ jobs:
7373
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
7474
# If this step fails, then you should remove it and run the build manually (see below)
7575
- name: Autobuild
76-
uses: github/codeql-action/autobuild@df559355d593797519d70b90fc8edd5db049e7a2 # v3
76+
uses: github/codeql-action/autobuild@f1f6e5f6af878fb37288ce1c627459e94dbf7d01 # v3
7777

7878
# ℹ️ Command-line programs to run using the OS shell.
7979
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -86,6 +86,6 @@ jobs:
8686
# ./location_of_script_within_repo/buildscript.sh
8787

8888
- name: Perform CodeQL Analysis
89-
uses: github/codeql-action/analyze@df559355d593797519d70b90fc8edd5db049e7a2 # v3
89+
uses: github/codeql-action/analyze@f1f6e5f6af878fb37288ce1c627459e94dbf7d01 # v3
9090
with:
9191
category: '/language:${{matrix.language}}'

.github/workflows/dependency-review.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: 'Checkout Repository'
1818
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
1919
- name: Dependency Review
20-
uses: actions/dependency-review-action@da24556b548a50705dd671f47852072ea4c105d9 # v4
20+
uses: actions/dependency-review-action@595b5aeba73380359d98a5e087f648dbb0edce1b # v4
2121
with:
2222
comment-summary-in-pr: always
2323
fail-on-severity: high

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,6 @@ jobs:
7272

7373
# Upload the results to GitHub's code scanning dashboard.
7474
- name: 'Upload to code-scanning'
75-
uses: github/codeql-action/upload-sarif@df559355d593797519d70b90fc8edd5db049e7a2 # v3.29.9
75+
uses: github/codeql-action/upload-sarif@f1f6e5f6af878fb37288ce1c627459e94dbf7d01 # v3.30.1
7676
with:
7777
sarif_file: results.sarif

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ customize for your environment, see the [project's documentation](https://git-pr
9191
- [Quickstart](https://git-proxy.finos.org/docs/category/quickstart/)
9292
- [Installation](https://git-proxy.finos.org/docs/installation)
9393
- [Configuration](https://git-proxy.finos.org/docs/category/configuration)
94+
- [Contributing](https://git-proxy.finos.org/docs/development/contributing)
95+
- [Testing](https://git-proxy.finos.org/docs/development/testing)
9496

9597
## Contributing
9698

@@ -116,6 +118,6 @@ If you can't access Slack, you can also [subscribe to our mailing list](mailto:g
116118

117119
Otherwise, if you have a deeper query or require more support, please [raise an issue](https://github.com/finos/git-proxy/issues) 🧵
118120

119-
🤝 Join our [fortnightly Zoom meeting](https://zoom-lfx.platform.linuxfoundation.org/meeting/95849833904?password=99413314-d03a-4b1c-b682-1ede2c399595) on Monday, 4PM BST (odd week numbers).
120-
🌍 [Convert to your local time](https://www.timeanddate.com/worldclock)
121+
🤝 Join our [fortnightly Zoom meeting](https://zoom-lfx.platform.linuxfoundation.org/meeting/95849833904?password=99413314-d03a-4b1c-b682-1ede2c399595) on Monday, 4PM BST (odd week numbers).
122+
🌍 [Convert to your local time](https://www.timeanddate.com/worldclock)
121123
📅 [Click here](https://calendar.google.com/calendar/event?action=TEMPLATE&tmeid=MTRvbzM0NG01dWNvNGc4OGJjNWphM2ZtaTZfMjAyNTA2MDJUMTUwMDAwWiBzYW0uaG9sbWVzQGNvbnRyb2wtcGxhbmUuaW8&tmsrc=sam.holmes%40control-plane.io&scp=ALL) for the recurring Google Calendar meeting invite. Alternatively, send an e-mail to [help@finos.org](https://zoom-lfx.platform.linuxfoundation.org/meeting/95849833904?password=99413314-d03a-4b1c-b682-1ede2c399595#:~:text=Need-,an,-invite%3F) to get a calendar invitation.

codecov.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ coverage:
22
status:
33
project:
44
default:
5+
target: 80
56
informational: true
67
patch:
78
default:
9+
target: 80
810
informational: true

nyc.config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
const opts = {
2-
branches: 80,
2+
checkCoverage: true,
33
lines: 80,
4-
functions: 80,
5-
statements: 80,
64
};
75

86
console.log('nyc config: ', opts);

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@
152152
"last 1 safari version"
153153
]
154154
},
155+
"engines": {
156+
"node": ">=20.19.2"
157+
},
155158
"lint-staged": {
156159
"*.{js,jsx,ts,tsx,json,md,yml,yaml,css,scss}": [
157160
"prettier --write"

test/1.test.js

Lines changed: 80 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,97 @@
1-
// This test needs to run first
1+
/*
2+
Template test file. Demonstrates how to:
3+
- Use chai-http to test the server
4+
- Initialize the server
5+
- Stub dependencies with sinon sandbox
6+
- Reset stubs after each test
7+
- Use proxyquire to replace modules
8+
- Clear module cache after a test
9+
*/
10+
211
const chai = require('chai');
312
const chaiHttp = require('chai-http');
13+
const sinon = require('sinon');
14+
const proxyquire = require('proxyquire');
15+
416
const service = require('../src/service');
17+
const db = require('../src/db');
18+
19+
const expect = chai.expect;
520

621
chai.use(chaiHttp);
7-
chai.should();
822

9-
// Use this test as a template
10-
describe('init', async () => {
23+
const TEST_REPO = {
24+
project: 'finos',
25+
name: 'db-test-repo',
26+
url: 'https://github.com/finos/db-test-repo.git',
27+
};
28+
29+
describe('init', () => {
1130
let app;
31+
let sandbox;
32+
33+
// Runs before all tests
1234
before(async function () {
13-
app = await service.start(); // pass in proxy if testing config loading or administration of proxy routes
35+
// Start the service (can also pass config if testing proxy routes)
36+
app = await service.start();
37+
});
38+
39+
// Runs before each test
40+
beforeEach(function () {
41+
// Create a sandbox for stubbing
42+
sandbox = sinon.createSandbox();
43+
44+
// Example: stub a DB method
45+
sandbox.stub(db, 'getRepo').resolves(TEST_REPO);
1446
});
1547

16-
it('should not be logged in', async function () {
48+
// Example test: check server is running
49+
it('should return 401 if not logged in', async function () {
1750
const res = await chai.request(app).get('/api/auth/profile');
51+
expect(res).to.have.status(401);
52+
});
53+
54+
// Example test: check db stub is working
55+
it('should get the repo from stubbed db', async function () {
56+
const repo = await db.getRepo('finos/db-test-repo');
57+
expect(repo).to.deep.equal(TEST_REPO);
58+
});
59+
60+
// Example test: use proxyquire to override the config module
61+
it('should return an array of enabled auth methods when overridden', async function () {
62+
const fsStub = {
63+
readFileSync: sandbox.stub().returns(
64+
JSON.stringify({
65+
authentication: [
66+
{ type: 'local', enabled: true },
67+
{ type: 'ActiveDirectory', enabled: true },
68+
{ type: 'openidconnect', enabled: true },
69+
],
70+
}),
71+
),
72+
};
73+
74+
const config = proxyquire('../src/config', {
75+
fs: fsStub,
76+
});
77+
config.initUserConfig();
78+
const authMethods = config.getAuthMethods();
79+
expect(authMethods).to.have.lengthOf(3);
80+
expect(authMethods[0].type).to.equal('local');
81+
expect(authMethods[1].type).to.equal('ActiveDirectory');
82+
expect(authMethods[2].type).to.equal('openidconnect');
83+
84+
// Clear config module cache so other tests don't use the stubbed config
85+
delete require.cache[require.resolve('../src/config')];
86+
});
1887

19-
res.should.have.status(401);
88+
// Runs after each test
89+
afterEach(function () {
90+
// Restore all stubs in this sandbox
91+
sandbox.restore();
2092
});
2193

94+
// Runs after all tests
2295
after(async function () {
2396
await service.httpServer.close();
2497
});

0 commit comments

Comments
 (0)