Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita96cc11

Browse files
renovate[bot]github-actions[bot]danadajian
authored
chore(deps): update dependencies (#250)
* feat(deps): update dependencies* terraform-docs: automated action* migrate jest to bun test runner* format* terraform-docs: automated action* fix* fix deps* terraform-docs: automated action* fix prettier* fix only---------Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>Co-authored-by: danadajian <danadajian@gmail.com>
1 parentdbf68ed commita96cc11

File tree

11 files changed

+178
-66
lines changed

11 files changed

+178
-66
lines changed

‎.prettierignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
build/
22
node_modules/
3+
USAGE.md

‎.terraform-version‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.13.3
1+
1.13.4

‎CONTRIBUTING.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ where "my-new-feature" describes what you're working on.
2020

2121
###3. Add tests for any bug fixes or new functionality
2222

23-
All functions must be tested with a unit test. Please follow the existing convention of one exported function per file with a corresponding file to test it. Run tests using`yarn test`, or using the[Jest CLI](https://jestjs.io/docs/cli).
23+
All functions must be tested with a unit test. Please follow the existing convention of one exported function per file with a corresponding file to test it. Run tests using`bun test`.
2424

2525
There is also an integration test present in the[test workflow](./.github/workflows/test.yaml), which will actually run this Github Action using the code from this repository. This allows you to test your change to the Github Action right within the pull request you make.
2626

‎USAGE.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
| Name| Version|
55
|------|---------|
6-
| <aname="requirement_terraform"></a>[terraform](#requirement\_terraform)| 1.13.3|
6+
| <aname="requirement_terraform"></a>[terraform](#requirement\_terraform)| 1.13.4|
77

88
##Providers
99

‎bun.lock‎

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
{
2+
"lockfileVersion":1,
3+
"workspaces": {
4+
"": {
5+
"name":"github-webhook-proxy",
6+
"dependencies": {
7+
"axios":"1.13.1",
8+
"lodash.mapkeys":"4.6.0",
9+
"micromatch":"4.0.8",
10+
"zod":"4.1.12",
11+
},
12+
"devDependencies": {
13+
"@octokit/webhooks":"14.1.3",
14+
"@types/aws-lambda":"8.10.157",
15+
"@types/bun":"1.3.1",
16+
"@types/lodash.mapkeys":"4.6.9",
17+
"@types/micromatch":"4.0.10",
18+
"prettier":"3.6.2",
19+
"typescript":"5.9.3",
20+
},
21+
},
22+
},
23+
"packages": {
24+
"@octokit/openapi-types": ["@octokit/openapi-types@27.0.0","", {},"sha512-whrdktVs1h6gtR+09+QsNk2+FO+49j6ga1c55YZudfEG+oKJVvJLQi3zkOm5JjiUXAagWK2tI2kTGKJ2Ys7MGA=="],
25+
26+
"@octokit/openapi-webhooks-types": ["@octokit/openapi-webhooks-types@12.0.3","", {},"sha512-90MF5LVHjBedwoHyJsgmaFhEN1uzXyBDRLEBe7jlTYx/fEhPAk3P3DAJsfZwC54m8hAIryosJOL+UuZHB3K3yA=="],
27+
28+
"@octokit/request-error": ["@octokit/request-error@7.0.2","", {"dependencies": {"@octokit/types":"^16.0.0" } },"sha512-U8piOROoQQUyExw5c6dTkU3GKxts5/ERRThIauNL7yaRoeXW0q/5bgHWT7JfWBw1UyrbK8ERId2wVkcB32n0uQ=="],
29+
30+
"@octokit/types": ["@octokit/types@16.0.0","", {"dependencies": {"@octokit/openapi-types":"^27.0.0" } },"sha512-sKq+9r1Mm4efXW1FCk7hFSeJo4QKreL/tTbR0rz/qx/r1Oa2VV83LTA/H/MuCOX7uCIJmQVRKBcbmWoySjAnSg=="],
31+
32+
"@octokit/webhooks": ["@octokit/webhooks@14.1.3","", {"dependencies": {"@octokit/openapi-webhooks-types":"12.0.3","@octokit/request-error":"^7.0.0","@octokit/webhooks-methods":"^6.0.0" } },"sha512-gcK4FNaROM9NjA0mvyfXl0KPusk7a1BeA8ITlYEZVQCXF5gcETTd4yhAU0Kjzd8mXwYHppzJBWgdBVpIR9wUcQ=="],
33+
34+
"@octokit/webhooks-methods": ["@octokit/webhooks-methods@6.0.0","", {},"sha512-MFlzzoDJVw/GcbfzVC1RLR36QqkTLUf79vLVO3D+xn7r0QgxnFoLZgtrzxiQErAjFUOdH6fas2KeQJ1yr/qaXQ=="],
35+
36+
"@types/aws-lambda": ["@types/aws-lambda@8.10.157","", {},"sha512-ofjcRCO1N7tMZDSO11u5bFHPDfUFD3Q9YK9g4S4w8UDKuG3CNlw2lNK1sd3Itdo7JORygZmG4h9ZykS8dlXvMA=="],
37+
38+
"@types/braces": ["@types/braces@3.0.5","", {},"sha512-SQFof9H+LXeWNz8wDe7oN5zu7ket0qwMu5vZubW4GCJ8Kkeh6nBWUz87+KTz/G3Kqsrp0j/W253XJb3KMEeg3w=="],
39+
40+
"@types/bun": ["@types/bun@1.3.1","", {"dependencies": {"bun-types":"1.3.1" } },"sha512-4jNMk2/K9YJtfqwoAa28c8wK+T7nvJFOjxI4h/7sORWcypRNxBpr+TPNaCfVWq70tLCJsqoFwcf0oI0JU/fvMQ=="],
41+
42+
"@types/lodash": ["@types/lodash@4.17.20","", {},"sha512-H3MHACvFUEiujabxhaI/ImO6gUrd8oOurg7LQtS7mbwIXA/cUqWrvBsaeJ23aZEPk1TAYkurjfMbSELfoCXlGA=="],
43+
44+
"@types/lodash.mapkeys": ["@types/lodash.mapkeys@4.6.9","", {"dependencies": {"@types/lodash":"*" } },"sha512-6/ERBCabeDI656LsV+oopLjdnJ/x1PCAE6kkkssH8e4i0K7Pw307noxHCbUc6cAVfTo9vx0Z+k3QZwy1IrUZcA=="],
45+
46+
"@types/micromatch": ["@types/micromatch@4.0.10","", {"dependencies": {"@types/braces":"*" } },"sha512-5jOhFDElqr4DKTrTEbnW8DZ4Hz5LRUEmyrGpCMrD/NphYv3nUnaF08xmSLx1rGGnyEs/kFnhiw6dCgcDqMr5PQ=="],
47+
48+
"@types/node": ["@types/node@24.10.0","", {"dependencies": {"undici-types":"~7.16.0" } },"sha512-qzQZRBqkFsYyaSWXuEHc2WR9c0a0CXwiE5FWUvn7ZM+vdy1uZLfCunD38UzhuB7YN/J11ndbDBcTmOdxJo9Q7A=="],
49+
50+
"@types/react": ["@types/react@19.2.2","", {"dependencies": {"csstype":"^3.0.2" } },"sha512-6mDvHUFSjyT2B2yeNx2nUgMxh9LtOWvkhIU3uePn2I2oyNymUAX1NIsdgviM4CH+JSrp2D2hsMvJOkxY+0wNRA=="],
51+
52+
"asynckit": ["asynckit@0.4.0","", {},"sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="],
53+
54+
"axios": ["axios@1.13.1","", {"dependencies": {"follow-redirects":"^1.15.6","form-data":"^4.0.4","proxy-from-env":"^1.1.0" } },"sha512-hU4EGxxt+j7TQijx1oYdAjw4xuIp1wRQSsbMFwSthCWeBQur1eF+qJ5iQ5sN3Tw8YRzQNKb8jszgBdMDVqwJcw=="],
55+
56+
"braces": ["braces@3.0.3","", {"dependencies": {"fill-range":"^7.1.1" } },"sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA=="],
57+
58+
"bun-types": ["bun-types@1.3.1","", {"dependencies": {"@types/node":"*" },"peerDependencies": {"@types/react":"^19" } },"sha512-NMrcy7smratanWJ2mMXdpatalovtxVggkj11bScuWuiOoXTiKIu2eVS1/7qbyI/4yHedtsn175n4Sm4JcdHLXw=="],
59+
60+
"call-bind-apply-helpers": ["call-bind-apply-helpers@1.0.2","", {"dependencies": {"es-errors":"^1.3.0","function-bind":"^1.1.2" } },"sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ=="],
61+
62+
"combined-stream": ["combined-stream@1.0.8","", {"dependencies": {"delayed-stream":"~1.0.0" } },"sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg=="],
63+
64+
"csstype": ["csstype@3.1.3","", {},"sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="],
65+
66+
"delayed-stream": ["delayed-stream@1.0.0","", {},"sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ=="],
67+
68+
"dunder-proto": ["dunder-proto@1.0.1","", {"dependencies": {"call-bind-apply-helpers":"^1.0.1","es-errors":"^1.3.0","gopd":"^1.2.0" } },"sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A=="],
69+
70+
"es-define-property": ["es-define-property@1.0.1","", {},"sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g=="],
71+
72+
"es-errors": ["es-errors@1.3.0","", {},"sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw=="],
73+
74+
"es-object-atoms": ["es-object-atoms@1.1.1","", {"dependencies": {"es-errors":"^1.3.0" } },"sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA=="],
75+
76+
"es-set-tostringtag": ["es-set-tostringtag@2.1.0","", {"dependencies": {"es-errors":"^1.3.0","get-intrinsic":"^1.2.6","has-tostringtag":"^1.0.2","hasown":"^2.0.2" } },"sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA=="],
77+
78+
"fill-range": ["fill-range@7.1.1","", {"dependencies": {"to-regex-range":"^5.0.1" } },"sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg=="],
79+
80+
"follow-redirects": ["follow-redirects@1.15.11","", {},"sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ=="],
81+
82+
"form-data": ["form-data@4.0.4","", {"dependencies": {"asynckit":"^0.4.0","combined-stream":"^1.0.8","es-set-tostringtag":"^2.1.0","hasown":"^2.0.2","mime-types":"^2.1.12" } },"sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow=="],
83+
84+
"function-bind": ["function-bind@1.1.2","", {},"sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA=="],
85+
86+
"get-intrinsic": ["get-intrinsic@1.3.0","", {"dependencies": {"call-bind-apply-helpers":"^1.0.2","es-define-property":"^1.0.1","es-errors":"^1.3.0","es-object-atoms":"^1.1.1","function-bind":"^1.1.2","get-proto":"^1.0.1","gopd":"^1.2.0","has-symbols":"^1.1.0","hasown":"^2.0.2","math-intrinsics":"^1.1.0" } },"sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ=="],
87+
88+
"get-proto": ["get-proto@1.0.1","", {"dependencies": {"dunder-proto":"^1.0.1","es-object-atoms":"^1.0.0" } },"sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g=="],
89+
90+
"gopd": ["gopd@1.2.0","", {},"sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg=="],
91+
92+
"has-symbols": ["has-symbols@1.1.0","", {},"sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ=="],
93+
94+
"has-tostringtag": ["has-tostringtag@1.0.2","", {"dependencies": {"has-symbols":"^1.0.3" } },"sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw=="],
95+
96+
"hasown": ["hasown@2.0.2","", {"dependencies": {"function-bind":"^1.1.2" } },"sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ=="],
97+
98+
"is-number": ["is-number@7.0.0","", {},"sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng=="],
99+
100+
"lodash.mapkeys": ["lodash.mapkeys@4.6.0","", {},"sha512-0Al+hxpYvONWtg+ZqHpa/GaVzxuN3V7Xeo2p+bY06EaK/n+Y9R7nBePPN2o1LxmL0TWQSwP8LYZ008/hc9JzhA=="],
101+
102+
"math-intrinsics": ["math-intrinsics@1.1.0","", {},"sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g=="],
103+
104+
"micromatch": ["micromatch@4.0.8","", {"dependencies": {"braces":"^3.0.3","picomatch":"^2.3.1" } },"sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA=="],
105+
106+
"mime-db": ["mime-db@1.52.0","", {},"sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg=="],
107+
108+
"mime-types": ["mime-types@2.1.35","", {"dependencies": {"mime-db":"1.52.0" } },"sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw=="],
109+
110+
"picomatch": ["picomatch@2.3.1","", {},"sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="],
111+
112+
"prettier": ["prettier@3.6.2","", {"bin": {"prettier":"bin/prettier.cjs" } },"sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ=="],
113+
114+
"proxy-from-env": ["proxy-from-env@1.1.0","", {},"sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="],
115+
116+
"to-regex-range": ["to-regex-range@5.0.1","", {"dependencies": {"is-number":"^7.0.0" } },"sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ=="],
117+
118+
"typescript": ["typescript@5.9.3","", {"bin": {"tsc":"bin/tsc","tsserver":"bin/tsserver" } },"sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
119+
120+
"undici-types": ["undici-types@7.16.0","", {},"sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
121+
122+
"zod": ["zod@4.1.12","", {},"sha512-JInaHOamG8pt5+Ey8kGmdcAcg3OL9reK8ltczgHTAwNhMys/6ThXHityHxVV2p3fkw/c+MAvBHFVYHFZDmjMCQ=="],
123+
}
124+
}

‎bun.lockb‎

-175 KB
Binary file not shown.

‎lambda/proxy.test.ts‎

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,19 @@ limitations under the License.
1212
*/
1313

1414
import{handler}from"./proxy";
15-
importaxios,{AxiosRequestHeaders,AxiosResponse}from"axios";
15+
importtype{AxiosRequestHeaders,AxiosResponse}from"axios";
1616
import{readFileSync}from"fs";
1717
import{Agent}from"https";
18-
import{readFileFromLayer}from"./file-readers";
1918
import{APIGatewayProxyWithLambdaAuthorizerEvent}from"aws-lambda";
2019
import{VALID_PING_EVENT}from"../fixtures/valid-ping-payload";
2120
import{VALID_PUSH_PAYLOAD}from"../fixtures/valid-push-payload";
2221
import{VALID_PUSH_PAYLOAD_USER_REPO}from"../fixtures/valid-push-payload-user-repo";
22+
import{afterEach,beforeEach,describe,expect,it,mock}from"bun:test";
23+
2324
consturlencodedPayload=readFileSync(
2425
"fixtures/invalid-payload-urlencoded.txt",
2526
).toString();
2627

27-
jest.mock("axios");
28-
jest.mock("./file-readers");
2928
constaxiosResponse:AxiosResponse={
3029
status:200,
3130
data:{
@@ -39,7 +38,26 @@ const axiosResponse: AxiosResponse = {
3938
headers:{}asAxiosRequestHeaders,
4039
},
4140
};
42-
(axios.postasjest.Mock).mockResolvedValue(axiosResponse);
41+
constaxiosPostMock=mock(()=>axiosResponse);
42+
mock.module("axios",()=>({
43+
default:{
44+
post:axiosPostMock,
45+
},
46+
}));
47+
48+
constfileMap:Record<string,string>={
49+
"allowed-destination-hosts.json":JSON.stringify([
50+
"approved.host",
51+
"another.approved.host",
52+
"a.wildcard.*.host",
53+
]),
54+
};
55+
constreadFileFromLayerMock=mock((fileName:string)=>fileMap[fileName]);
56+
mock.module("./file-readers",()=>({
57+
readFileFromLayer:readFileFromLayerMock,
58+
getPublicCerts:mock(),
59+
}));
60+
4361
constexpectedResponseObject={
4462
statusCode:200,
4563
body:'{"some":"data"}',
@@ -66,23 +84,17 @@ const baseEvent: APIGatewayProxyWithLambdaAuthorizerEvent<any> = {
6684
requestContext:{}asany,
6785
resource:"",
6886
};
69-
constfileMap:Record<string,string>={
70-
"allowed-destination-hosts.json":JSON.stringify([
71-
"approved.host",
72-
"another.approved.host",
73-
"a.wildcard.*.host",
74-
]),
75-
};
76-
(readFileFromLayerasjest.Mock).mockImplementation(
77-
(fileName:string)=>fileMap[fileName],
78-
);
7987

8088
describe("proxy",()=>{
8189
beforeEach(()=>{
8290
process.env.ENTERPRISE_SLUG="some_enterprise";
8391
process.env.ENTERPRISE_MANAGED_USER_SUFFIX="";
8492
});
8593

94+
afterEach(()=>{
95+
mock.clearAllMocks();
96+
});
97+
8698
it("should reject a request with an invalid urlencoded payload",async()=>{
8799
constevent:APIGatewayProxyWithLambdaAuthorizerEvent<any>={
88100
...baseEvent,
@@ -94,7 +106,7 @@ describe("proxy", () => {
94106
};
95107
constresult=awaithandler(event);
96108
expect(result).toEqual({statusCode:403,body:"Access denied"});
97-
expect(axios.post).not.toHaveBeenCalled();
109+
expect(axiosPostMock).not.toHaveBeenCalled();
98110
});
99111

100112
it("should reject a request with an endpointId which is not an encoded URL",async()=>{
@@ -106,7 +118,7 @@ describe("proxy", () => {
106118
};
107119
constresult=awaithandler(event);
108120
expect(result).toEqual({statusCode:403,body:"Access denied"});
109-
expect(axios.post).not.toHaveBeenCalled();
121+
expect(axiosPostMock).not.toHaveBeenCalled();
110122
});
111123

112124
it("should allow a request from a managed user suffix when supplied",async()=>{
@@ -122,7 +134,7 @@ describe("proxy", () => {
122134
};
123135
constresult=awaithandler(event);
124136
expect(result).toEqual(expectedResponseObject);
125-
expect(axios.post).toHaveBeenCalled();
137+
expect(axiosPostMock).toHaveBeenCalled();
126138
});
127139

128140
it("should forward a request when header is Content-Type",async()=>{
@@ -142,7 +154,7 @@ describe("proxy", () => {
142154
};
143155
constresult=awaithandler(event);
144156
expect(result).toEqual(expectedResponseObject);
145-
expect(axios.post).toHaveBeenCalled();
157+
expect(axiosPostMock).toHaveBeenCalled();
146158
});
147159

148160
it("should not forward a request that does not come from an enterprise or managed user suffix",async()=>{
@@ -161,7 +173,7 @@ describe("proxy", () => {
161173
};
162174
constresult=awaithandler(event);
163175
expect(result).toEqual({statusCode:403,body:"Access denied"});
164-
expect(axios.post).not.toHaveBeenCalled();
176+
expect(axiosPostMock).not.toHaveBeenCalled();
165177
});
166178

167179
it("should not forward a request that does not have an approved host",async()=>{
@@ -175,7 +187,7 @@ describe("proxy", () => {
175187
};
176188
constresult=awaithandler(event);
177189
expect(result).toEqual({statusCode:403,body:"Access denied"});
178-
expect(axios.post).not.toHaveBeenCalled();
190+
expect(axiosPostMock).not.toHaveBeenCalled();
179191
});
180192

181193
it("should forward a request that has an approved host which matches a wildcard",async()=>{
@@ -201,7 +213,7 @@ describe("proxy", () => {
201213
},
202214
};
203215
constresult=awaithandler(event);
204-
expect(axios.post).toHaveBeenCalledWith(
216+
expect(axiosPostMock).toHaveBeenCalledWith(
205217
destinationUrl,
206218
stringifiedPayload,
207219
{
@@ -220,7 +232,7 @@ describe("proxy", () => {
220232
"ca.pem":"some ca",
221233
"cert.pem":"some cert",
222234
};
223-
(readFileFromLayerasjest.Mock).mockImplementation(
235+
readFileFromLayerMock.mockImplementation(
224236
(fileName:string)=>newFileMap[fileName],
225237
);
226238
constdestinationUrl="https://approved.host/github-webhook/";
@@ -232,7 +244,7 @@ describe("proxy", () => {
232244
},
233245
};
234246
constresult=awaithandler(event);
235-
expect(axios.post).toHaveBeenCalledWith(
247+
expect(axiosPostMock).toHaveBeenCalledWith(
236248
destinationUrl,
237249
stringifiedPayload,
238250
{
@@ -253,7 +265,7 @@ describe("proxy", () => {
253265
};
254266
constresult=awaithandler(event);
255267
expect(result).toEqual({statusCode:404,body:"Not found"});
256-
expect(axios.post).not.toHaveBeenCalled();
268+
expect(axiosPostMock).not.toHaveBeenCalled();
257269
});
258270

259271
it("should forward a ping event from a managed user suffix when supplied",async()=>{
@@ -269,7 +281,7 @@ describe("proxy", () => {
269281
};
270282
constresult=awaithandler(event);
271283
expect(result).toEqual(expectedResponseObject);
272-
expect(axios.post).toHaveBeenCalled();
284+
expect(axiosPostMock).toHaveBeenCalled();
273285
});
274286

275287
it("should return error response from axios",async()=>{
@@ -286,9 +298,7 @@ describe("proxy", () => {
286298
headers:{}asAxiosRequestHeaders,
287299
},
288300
};
289-
(axios.postasjest.Mock).mockRejectedValue({
290-
response:axiosErrorResponse,
291-
});
301+
axiosPostMock.mockImplementationOnce(()=>axiosErrorResponse);
292302

293303
process.env.ENTERPRISE_MANAGED_USER_SUFFIX="suffix";
294304
constdestinationUrl="https://approved.host/github-webhook/";
@@ -306,6 +316,6 @@ describe("proxy", () => {
306316
body:'{"some":"error"}',
307317
headers:{response:"headers"},
308318
});
309-
expect(axios.post).toHaveBeenCalled();
319+
expect(axiosPostMock).toHaveBeenCalled();
310320
});
311321
});

‎lambda/proxy.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { requestPayloadIsValid } from "./request-payload-is-valid";
1717
import{destinationHostIsAllowed}from"./destination-host-is-allowed";
1818
import{getHttpsAgent}from"./get-https-agent";
1919
import{parseRequestBody}from"./parse-request-body";
20-
import{EnterpriseProxyEvent}from"./types";
2120
import{urlIsValid}from"./url-is-valid";
2221
import{axiosErrorSchema}from"./schema";
2322

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp