Skip to content

Commit 840ece8

Browse files
committed
Fix end2end test
1 parent c1a8116 commit 840ece8

File tree

2 files changed

+5
-32
lines changed

2 files changed

+5
-32
lines changed

end2end/server/src/handlers/updateLists.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ module.exports = function updateIPLists(req, res) {
6565

6666
if (
6767
req.body.userAgentDetails &&
68-
typeof req.body.userAgentDetails === "string"
68+
Array.isArray(req.body.userAgentDetails)
6969
) {
7070
updateUserAgentDetails(req.app, req.body.userAgentDetails);
7171
}

end2end/tests/hono-xml-monitored-lists.test.js

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,11 @@ t.beforeEach(async () => {
2323
body: JSON.stringify({
2424
blockedIPAddresses: [],
2525
monitoredIPAddresses: ["1.3.2.0/24", "e98c:a7ba:2329:8c69::/64"],
26-
monitoredUserAgents: "suspicious-bot|monitored-crawler|GPTBot",
26+
monitoredUserAgents: "monitored-bot",
2727
userAgentDetails: [
2828
{
29-
key: "suspicious-bot",
30-
pattern: "suspicious-bot",
31-
},
32-
{
33-
key: "monitored-crawler",
34-
pattern: "monitored-crawler",
35-
},
36-
{
37-
key: "gpt-bot",
38-
pattern: "GPTBot",
29+
key: "monitored-bot",
30+
pattern: "monitored-bot",
3931
},
4032
],
4133
}),
@@ -144,30 +136,11 @@ t.test("it does not block monitored user agents", (t) => {
144136
// Test monitored user agent
145137
const resp1 = await fetch("http://127.0.0.1:4006/", {
146138
headers: {
147-
"User-Agent": "suspicious-bot",
139+
"User-Agent": "monitored-bot",
148140
},
149141
signal: AbortSignal.timeout(5000),
150142
});
151143
t.same(resp1.status, 200);
152-
153-
// Test monitored GPT bot
154-
const resp2 = await fetch("http://127.0.0.1:4006/", {
155-
headers: {
156-
"User-Agent":
157-
"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko); compatible; GPTBot/1.1; +https://openai.com/gptbot",
158-
},
159-
signal: AbortSignal.timeout(5000),
160-
});
161-
t.same(resp2.status, 200);
162-
163-
// Test monitored crawler
164-
const resp3 = await fetch("http://127.0.0.1:4006/", {
165-
headers: {
166-
"User-Agent": "monitored-crawler/1.0",
167-
},
168-
signal: AbortSignal.timeout(5000),
169-
});
170-
t.same(resp3.status, 200);
171144
})
172145
.catch((error) => {
173146
t.fail(error);

0 commit comments

Comments
 (0)