-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
1,240 additions
and
692 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,6 @@ jobs: | |
run: npm i | ||
|
||
- name: Code Linting | ||
run: npm run lint | ||
run: | | ||
npm run lint | ||
npm run lint --workspaces |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "@finos/git-proxy-cli", | ||
"version": "1.0.0", | ||
"description": "Command line interface tool for FINOS Git Proxy.", | ||
"bin": "./index.js", | ||
"main": "index.js", | ||
"dependencies": { | ||
"axios": "^1.6.0", | ||
"yargs": "^17.7.2", | ||
"@finos/git-proxy": "file:../.." | ||
}, | ||
"devDependencies": { | ||
"@jsdevtools/chai-exec": "^2.1.1" | ||
}, | ||
"scripts": { | ||
"lint": "eslint --fix . --ext .js,.jsx", | ||
"test": "mocha --exit" | ||
}, | ||
"author": "Miklos Sagi", | ||
"license": "Apache-2.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Import the dependencies for testing | ||
const chaiExec = require("@jsdevtools/chai-exec"); | ||
const chai = require('chai'); | ||
const service = require('../../../src/service'); | ||
const util = require("util") | ||
|
||
chai.use(chaiExec); | ||
const expect = chai.expect; | ||
|
||
chaiExec.defaults = { | ||
options: { | ||
timeout: 10000 // fail test case if server hangs | ||
} | ||
}; | ||
|
||
describe('test git-proxy-cli', async () => { | ||
let app; | ||
|
||
before(async function () { | ||
// app = await service.start(); | ||
// console.log(""); | ||
}); | ||
|
||
describe('test git-proxy-cli :: login', async function () { | ||
it('login shoud fail with invalid credentials', async function () { | ||
let username = "unkn0wn" | ||
let password = "p4ssw0rd" | ||
let cli = chaiExec(`npx -- @finos/git-proxy-cli login --username ${username} --password ${password}`); | ||
expect(cli).to.exit.with.code(2); | ||
}); | ||
it('login shoud be successful with valid (default) admin credentials', async function () { | ||
let username = "admin" | ||
let password = "admin" | ||
let cli = chaiExec(`npx -- @finos/git-proxy-cli login --username ${username} --password ${password}`); | ||
expect(cli).to.exit.with.code(0); | ||
}); | ||
}); | ||
|
||
describe('test git-proxy-cli :: approve commit', async function () { | ||
it('attempt to approve non-existing commit should return exit code 3', async function () { | ||
let commitId = | ||
'0000000000000000000000000000000000000000__79b4d8953cbc324bcc1eb53d6412ff89666c241f'; // eslint-disable-line max-len | ||
cli = chaiExec(`npx -- @finos/git-proxy-cli approve --commitId ${commitId}`); | ||
expect(cli).to.exit.with.code(3); | ||
}); | ||
}); | ||
|
||
describe('test git-proxy-cli :: logout', async function () { | ||
it('attempt to log out should be successful', async function () { | ||
cli = chaiExec(`npx -- @finos/git-proxy-cli logout`); | ||
expect(cli).to.exit.with.code(0); | ||
}); | ||
}); | ||
after(async function () { | ||
// await service.httpServer.close(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Import the dependencies for testing | ||
const chai = require('chai'); | ||
const chaiHttp = require('chai-http'); | ||
const db = require('../src/db'); | ||
const service = require('../src/service'); | ||
|
||
chai.use(chaiHttp); | ||
chai.should(); | ||
const expect = chai.expect; | ||
|
||
describe('auth', async () => { | ||
let app; | ||
let cookie; | ||
|
||
before(async function () { | ||
app = await service.start(); | ||
await db.deleteUser('login-test-user'); | ||
|
||
const res = await chai.request(app).post('/auth/login').send({ | ||
username: 'admin', | ||
password: 'admin', | ||
}); | ||
|
||
expect(res).to.have.cookie('connect.sid'); | ||
res.should.have.status(200); | ||
|
||
// Get the connect cooie | ||
res.headers['set-cookie'].forEach((x) => { | ||
if (x.startsWith('connect')) { | ||
cookie = x.split(';')[0]; | ||
} | ||
}); | ||
}); | ||
|
||
describe('test push API', async function () { | ||
it('should get 404 for unknown push', async function () { | ||
const commitId = | ||
'0000000000000000000000000000000000000000__79b4d8953cbc324bcc1eb53d6412ff89666c241f'; // eslint-disable-line max-len | ||
const res = await chai | ||
.request(app) | ||
.get(`/api/v1/push/${commitId}`) | ||
.set('Cookie', `${cookie}`); | ||
res.should.have.status(404); | ||
}); | ||
}); | ||
|
||
after(async function () { | ||
const res = await chai | ||
.request(app) | ||
.post('/auth/logout') | ||
.set('Cookie', `${cookie}`); | ||
res.should.have.status(200); | ||
|
||
await service.httpServer.close(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters