Skip to content

Commit 8decdea

Browse files
committed
Merge remote-tracking branch 'origin/main' into jwt-claims-role-mapping
2 parents 5bdcd69 + 3718943 commit 8decdea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+3457
-1427
lines changed

.eslintrc.json

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"parser": "@babel/eslint-parser",
2+
"parser": "@typescript-eslint/parser",
33
"env": {
44
"node": true,
55
"browser": true,
@@ -9,13 +9,23 @@
99
},
1010
"extends": [
1111
"eslint:recommended",
12+
"plugin:@typescript-eslint/recommended",
1213
"plugin:react/recommended",
1314
"google",
1415
"prettier",
1516
"plugin:json/recommended"
1617
],
17-
"overrides": [],
18+
"overrides": [
19+
{
20+
"files": ["test/**/*.js", "**/*.json"],
21+
"parser": "espree",
22+
"rules": {
23+
"@typescript-eslint/no-unused-expressions": "off"
24+
}
25+
}
26+
],
1827
"parserOptions": {
28+
"project": "./tsconfig.json",
1929
"requireConfigFile": false,
2030
"ecmaVersion": 12,
2131
"sourceType": "module",
@@ -27,11 +37,15 @@
2737
"presets": ["@babel/preset-react"]
2838
}
2939
},
30-
"plugins": ["react", "prettier"],
40+
"plugins": ["@typescript-eslint", "react", "prettier"],
3141
"rules": {
3242
"react/prop-types": "off",
3343
"require-jsdoc": "off",
34-
"no-async-promise-executor": "off"
44+
"no-async-promise-executor": "off",
45+
"@typescript-eslint/no-explicit-any": "warn", // temporary until TS refactor is complete
46+
"@typescript-eslint/no-unused-vars": "off", // temporary until TS refactor is complete
47+
"@typescript-eslint/no-require-imports": "off", // prevents error on old "require" imports
48+
"@typescript-eslint/no-unused-expressions": "off" // prevents error on test "expect" expressions
3549
},
3650
"settings": {
3751
"react": {

.github/workflows/unused-dependencies.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: 'Unused Dependencies'
22
on: [pull_request]
33

4-
permissions:
5-
contents: read
4+
permissions:
5+
contents: read
66

77
jobs:
88
unused-dependecies:
@@ -20,11 +20,10 @@ jobs:
2020
with:
2121
node-version: '18.x'
2222
- name: 'Run depcheck'
23-
run: |
24-
npx depcheck --skip-missing --ignores="@babel/*,@commitlint/*,eslint,eslint-*,husky,mocha,concurrently,nyc,prettier"
23+
run: |
24+
npx depcheck --skip-missing --ignores="tsx,@babel/*,@commitlint/*,eslint,eslint-*,husky,mocha,ts-mocha,ts-node,concurrently,nyc,prettier,typescript,tsconfig-paths,vite-tsconfig-paths"
2525
echo $?
2626
if [[ $? == 1 ]]; then
2727
echo "Unused dependencies or devDependencies found"
2828
exit 1
2929
fi
30-

config.schema.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@
8585
"items": {
8686
"$ref": "#/definitions/authentication"
8787
}
88+
},
89+
"tls": {
90+
"description": "TLS configuration for secure connections",
91+
"type": "object",
92+
"properties": {
93+
"enabled": { "type": "boolean" },
94+
"key": { "type": "string" },
95+
"cert": { "type": "string" }
96+
},
97+
"required": ["enabled", "key", "cert"]
8898
}
8999
},
90100
"definitions": {

cypress/e2e/autoApproved.cy.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import moment from 'moment';
2+
3+
describe('Auto-Approved Push Test', () => {
4+
beforeEach(() => {
5+
cy.intercept('GET', '/api/v1/push/123', {
6+
statusCode: 200,
7+
body: {
8+
steps: [
9+
{
10+
stepName: 'diff',
11+
content: '',
12+
},
13+
],
14+
error: false,
15+
allowPush: true,
16+
authorised: true,
17+
canceled: false,
18+
rejected: false,
19+
autoApproved: true,
20+
autoRejected: false,
21+
commitFrom: 'commitFrom',
22+
commitTo: 'commitTo',
23+
branch: 'refs/heads/main',
24+
user: 'testUser',
25+
id: 'commitFrom__commitTo',
26+
type: 'push',
27+
method: 'POST',
28+
timestamp: 1696161600000,
29+
project: 'testUser',
30+
repoName: 'test.git',
31+
url: 'https://github.com/testUser/test.git',
32+
repo: 'testUser/test.git',
33+
commitData: [
34+
{
35+
tree: '1234',
36+
parent: '12345',
37+
},
38+
],
39+
attestation: {
40+
timestamp: '2023-10-01T12:00:00Z',
41+
autoApproved: true,
42+
},
43+
},
44+
}).as('getPush');
45+
});
46+
47+
it('should display auto-approved message and verify tooltip contains the expected timestamp', () => {
48+
cy.visit('/admin/push/123');
49+
50+
cy.wait('@getPush');
51+
52+
cy.contains('Auto-approved by system').should('be.visible');
53+
54+
cy.get('svg.MuiSvgIcon-root')
55+
.filter((_, el) => getComputedStyle(el).fill === 'rgb(0, 128, 0)')
56+
.invoke('attr', 'style')
57+
.should('include', 'cursor: default')
58+
.and('include', 'opacity: 0.5');
59+
60+
const expectedTooltipTimestamp = moment('2023-10-01T12:00:00Z')
61+
.local()
62+
.format('dddd, MMMM Do YYYY, h:mm:ss a');
63+
64+
cy.get('kbd')
65+
.trigger('mouseover')
66+
.then(() => {
67+
cy.get('.MuiTooltip-tooltip').should('contain', expectedTooltipTimestamp);
68+
});
69+
70+
cy.contains('approved this contribution').should('not.exist');
71+
});
72+
});

index.js

Lines changed: 0 additions & 48 deletions
This file was deleted.

index.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env tsx
2+
/* eslint-disable max-len */
3+
import yargs from 'yargs';
4+
import { hideBin } from 'yargs/helpers';
5+
import * as fs from 'fs';
6+
import { configFile, setConfigFile, validate } from './src/config/file';
7+
import proxy from './src/proxy';
8+
import service from './src/service';
9+
10+
const argv = yargs(hideBin(process.argv))
11+
.usage('Usage: $0 [options]')
12+
.options({
13+
validate: {
14+
description:
15+
'Check the proxy.config.json file in the current working directory for validation errors.',
16+
required: false,
17+
alias: 'v',
18+
type: 'boolean',
19+
},
20+
config: {
21+
description: 'Path to custom git-proxy configuration file.',
22+
default: 'proxy.config.json',
23+
required: false,
24+
alias: 'c',
25+
type: 'string',
26+
},
27+
})
28+
.strict()
29+
.parseSync();
30+
31+
setConfigFile(argv.c as string || "");
32+
33+
if (argv.v) {
34+
if (!fs.existsSync(configFile)) {
35+
console.error(
36+
`Config file ${configFile} doesn't exist, nothing to validate! Did you forget -c/--config?`,
37+
);
38+
process.exit(1);
39+
}
40+
41+
validate();
42+
console.log(`${configFile} is valid`);
43+
process.exit(0);
44+
}
45+
46+
validate();
47+
48+
proxy.start();
49+
service.start();
50+
51+
export { proxy, service };

0 commit comments

Comments
 (0)