Skip to content

Commit 0b98de3

Browse files
committed
test: ✅ fix test due to ssl issue of the target test bucket
1 parent 7dbacf6 commit 0b98de3

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/lib/bucket/info.test.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ describe("bucket info", () => {
77
});
88

99
it("should be able to detect ListBucket permission", async () => {
10-
expect(
11-
await hasListBucketPermission("flaws.cloud.s3.amazonaws.com")
12-
).toEqual({
10+
expect(await hasListBucketPermission("aneta.s3.amazonaws.com")).toEqual({
1311
ListBucket: true,
1412
});
1513

@@ -19,13 +17,11 @@ describe("bucket info", () => {
1917
});
2018

2119
it("should be able to extract bucket information", async () => {
22-
const bucketInfo = await getBucketInfo("flaws.cloud.s3.amazonaws.com");
23-
console.log("bucketInfo", bucketInfo);
20+
const bucketInfo = await getBucketInfo("aneta.s3.amazonaws.com");
2421
expect(bucketInfo).toMatchObject({
2522
public: true,
26-
hostname: "flaws.cloud.s3.amazonaws.com",
27-
owner: undefined,
28-
owned: true,
23+
hostname: "aneta.s3.amazonaws.com",
24+
owner: "c7f6e5706fc415058cb9f4d41107a24191a94f1b79dbce9cd9a516925d718c1d",
2925
permissions: { ListBucket: true },
3026
});
3127
expect(typeof bucketInfo.date).toBe("number");

src/lib/bucket/info.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import axios from "axios";
22
import { IBucket, IPermissions } from "@/@types";
33
import { CheerioAPI, load } from "cheerio";
4+
import { Agent } from "https";
45

56
/**
67
* Get all possible information about a bucket
@@ -11,7 +12,9 @@ export const getBucketInfo = async (
1112
): Promise<Omit<IBucket, "initiator">> => {
1213
const [listBucketReq, aclReq] = await Promise.allSettled([
1314
hasListBucketPermission(bucketName),
14-
axios.get(`https://${bucketName}/?acl`),
15+
axios.get(`https://${bucketName}/?acl`, {
16+
httpsAgent: new Agent({ rejectUnauthorized: false }),
17+
}),
1518
]);
1619
const listBucket =
1720
listBucketReq.status === "fulfilled" ? listBucketReq.value : {};
@@ -51,7 +54,9 @@ export async function hasListBucketPermission(
5154
): Promise<{ ListBucket?: boolean }> {
5255
const url = `https://${bucketName}`;
5356
try {
54-
const response = await axios.get(url);
57+
const response = await axios.get(url, {
58+
httpsAgent: new Agent({ rejectUnauthorized: false }),
59+
});
5560
const $ = load(response.data);
5661
const hasListBucket = $("ListBucketResult");
5762
return hasListBucket.length > 0 ? { ListBucket: true } : {};

0 commit comments

Comments
 (0)