Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ea31b06
chore: add coverage check to nyc script
jescalada Aug 10, 2025
62be927
test: main proxy file (preliminary tests)
jescalada Aug 11, 2025
c76efe7
chore: remove non-line coverage requirements
jescalada Aug 11, 2025
2abfdec
test: proxyPreparations function
jescalada Aug 11, 2025
1a7b8b9
test: fix proxyPreparations repo loading and add logging
jescalada Aug 11, 2025
f376bf6
chore: cleanup and fix linter issue
jescalada Aug 12, 2025
565bd9d
chore: add coverage and patch 80% targets to codecov.yml
jescalada Aug 12, 2025
8fea7c3
Merge branch 'main' into enforce-80-percent-coverage-ci
jescalada Aug 12, 2025
0240ea8
docs: add testing section to contributing.mdx
jescalada Aug 13, 2025
c9829cd
docs: add testing.mdx with unit testing section
jescalada Aug 13, 2025
52f8da1
docs: add more details to unit test section
jescalada Aug 13, 2025
ad97cd5
docs: add e2e testing with cypress section
jescalada Aug 13, 2025
f52ef08
docs: add fuzz testing section
jescalada Aug 13, 2025
16f78b7
docs: add development/testing to links
jescalada Aug 13, 2025
a838060
chore: remove logging
jescalada Aug 17, 2025
02715f0
Merge branch 'main' into enforce-80-percent-coverage-ci
jescalada Aug 20, 2025
73c5de0
test: refactor proxy tests
jescalada Aug 21, 2025
911ff7f
Merge branch 'main' into enforce-80-percent-coverage-ci
jescalada Aug 21, 2025
96eabcd
chore: add node v20 suggestions
jescalada Aug 21, 2025
9bcb91c
Merge branch 'enforce-80-percent-coverage-ci' of https://github.com/j…
jescalada Aug 21, 2025
0a1ed18
Update website/docs/development/testing.mdx
jescalada Aug 22, 2025
6f41113
docs: add cache reset details to testing.mdx
jescalada Aug 22, 2025
7498ddd
Merge branch 'main' into enforce-80-percent-coverage-ci
jescalada Aug 22, 2025
73e862e
docs: update 1.test.js with stubbing and proxyquire examples
jescalada Aug 30, 2025
e3e1521
Merge branch 'main' into enforce-80-percent-coverage-ci
jescalada Aug 30, 2025
8566f2a
chore: lint
jescalada Aug 30, 2025
8d2c69b
chore: format
jescalada Aug 30, 2025
a9f36ce
Merge branch 'main' into enforce-80-percent-coverage-ci
jescalada Sep 2, 2025
0ffb79c
Merge branch 'main' into enforce-80-percent-coverage-ci
kriswest Sep 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ customize for your environment, see the [project's documentation](https://git-pr
- [Quickstart](https://git-proxy.finos.org/docs/category/quickstart/)
- [Installation](https://git-proxy.finos.org/docs/installation)
- [Configuration](https://git-proxy.finos.org/docs/category/configuration)
- [Contributing](https://git-proxy.finos.org/docs/development/contributing)
- [Testing](https://git-proxy.finos.org/docs/development/testing)

## Contributing

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

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

🤝 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).
🌍 [Convert to your local time](https://www.timeanddate.com/worldclock)
🤝 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).
🌍 [Convert to your local time](https://www.timeanddate.com/worldclock)
📅 [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.
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ coverage:
status:
project:
default:
target: 80
informational: true
patch:
default:
target: 80
informational: true
4 changes: 1 addition & 3 deletions nyc.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const opts = {
branches: 80,
checkCoverage: true,
lines: 80,
functions: 80,
statements: 80,
};

console.log('nyc config: ', opts);
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@
"last 1 safari version"
]
},
"engines": {
"node": ">=20.19.2"
},
"lint-staged": {
"*.{js,jsx,ts,tsx,json,md,yml,yaml,css,scss}": [
"prettier --write"
Expand Down
87 changes: 80 additions & 7 deletions test/1.test.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,97 @@
// This test needs to run first
/*
Template test file. Demonstrates how to:
- Use chai-http to test the server
- Initialize the server
- Stub dependencies with sinon sandbox
- Reset stubs after each test
- Use proxyquire to replace modules
- Clear module cache after a test
*/

const chai = require('chai');
const chaiHttp = require('chai-http');
const sinon = require('sinon');
const proxyquire = require('proxyquire');

const service = require('../src/service');
const db = require('../src/db');

const expect = chai.expect;

chai.use(chaiHttp);
chai.should();

// Use this test as a template
describe('init', async () => {
const TEST_REPO = {
project: 'finos',
name: 'db-test-repo',
url: 'https://github.com/finos/db-test-repo.git',
};

describe('init', () => {
let app;
let sandbox;

// Runs before all tests
before(async function () {
app = await service.start(); // pass in proxy if testing config loading or administration of proxy routes
// Start the service (can also pass config if testing proxy routes)
app = await service.start();
});

// Runs before each test
beforeEach(function () {
// Create a sandbox for stubbing
sandbox = sinon.createSandbox();

// Example: stub a DB method
sandbox.stub(db, 'getRepo').resolves(TEST_REPO);
});

it('should not be logged in', async function () {
// Example test: check server is running
it('should return 401 if not logged in', async function () {
const res = await chai.request(app).get('/api/auth/profile');
expect(res).to.have.status(401);
});

// Example test: check db stub is working
it('should get the repo from stubbed db', async function () {
const repo = await db.getRepo('finos/db-test-repo');
expect(repo).to.deep.equal(TEST_REPO);
});

// Example test: use proxyquire to override the config module
it('should return an array of enabled auth methods when overridden', async function () {
const fsStub = {
readFileSync: sandbox.stub().returns(
JSON.stringify({
authentication: [
{ type: 'local', enabled: true },
{ type: 'ActiveDirectory', enabled: true },
{ type: 'openidconnect', enabled: true },
],
}),
),
};

const config = proxyquire('../src/config', {
fs: fsStub,
});
config.initUserConfig();
const authMethods = config.getAuthMethods();
expect(authMethods).to.have.lengthOf(3);
expect(authMethods[0].type).to.equal('local');
expect(authMethods[1].type).to.equal('ActiveDirectory');
expect(authMethods[2].type).to.equal('openidconnect');

// Clear config module cache so other tests don't use the stubbed config
delete require.cache[require.resolve('../src/config')];
});

res.should.have.status(401);
// Runs after each test
afterEach(function () {
// Restore all stubs in this sandbox
sandbox.restore();
});

// Runs after all tests
after(async function () {
await service.httpServer.close();
});
Expand Down
Loading
Loading