@scality/data-browser-library 1.0.0-preview.13 → 1.0.0-preview.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/DataBrowserUI.d.ts +6 -14
- package/dist/components/DataBrowserUI.js +79 -55
- package/dist/components/Editor.d.ts +1 -1
- package/dist/components/Editor.js +3 -3
- package/dist/components/__tests__/BucketCreate.test.js +102 -102
- package/dist/components/__tests__/BucketDetails.test.js +122 -123
- package/dist/components/__tests__/BucketLifecycleFormPage.test.js +177 -177
- package/dist/components/__tests__/BucketLifecycleList.test.js +85 -85
- package/dist/components/__tests__/BucketList.test.js +175 -176
- package/dist/components/__tests__/BucketNotificationCreatePage.test.js +84 -84
- package/dist/components/__tests__/BucketOverview.test.js +257 -201
- package/dist/components/__tests__/BucketPolicyPage.test.js +62 -62
- package/dist/components/__tests__/BucketReplicationFormPage.test.js +542 -542
- package/dist/components/__tests__/BucketReplicationList.test.js +106 -106
- package/dist/components/__tests__/CreateFolderButton.test.js +56 -56
- package/dist/components/__tests__/DeleteBucketButton.test.js +62 -62
- package/dist/components/__tests__/DeleteBucketConfigRuleButton.test.js +47 -47
- package/dist/components/__tests__/DeleteObjectButton.test.js +63 -63
- package/dist/components/__tests__/EmptyBucketButton.test.js +56 -56
- package/dist/components/__tests__/MetadataSearch.test.js +65 -65
- package/dist/components/__tests__/ObjectList.test.js +252 -251
- package/dist/components/__tests__/UploadButton.test.js +45 -45
- package/dist/components/buckets/BucketCreate.d.ts +2 -2
- package/dist/components/buckets/BucketCreate.js +41 -41
- package/dist/components/buckets/BucketDetails.d.ts +2 -2
- package/dist/components/buckets/BucketDetails.js +48 -36
- package/dist/components/buckets/BucketLifecycleFormPage.js +161 -160
- package/dist/components/buckets/BucketLifecycleList.d.ts +2 -2
- package/dist/components/buckets/BucketLifecycleList.js +46 -46
- package/dist/components/buckets/BucketList.d.ts +2 -2
- package/dist/components/buckets/BucketList.js +28 -27
- package/dist/components/buckets/BucketLocation.js +3 -3
- package/dist/components/buckets/BucketOverview.d.ts +1 -1
- package/dist/components/buckets/BucketOverview.js +64 -65
- package/dist/components/buckets/BucketPage.js +19 -11
- package/dist/components/buckets/BucketPolicyButton.js +2 -2
- package/dist/components/buckets/BucketPolicyPage.js +27 -25
- package/dist/components/buckets/BucketReplicationFormPage.js +133 -132
- package/dist/components/buckets/BucketReplicationList.d.ts +2 -2
- package/dist/components/buckets/BucketReplicationList.js +41 -41
- package/dist/components/buckets/BucketVersioning.js +11 -11
- package/dist/components/buckets/DeleteBucketButton.js +5 -5
- package/dist/components/buckets/DeleteBucketConfigRuleButton.d.ts +2 -2
- package/dist/components/buckets/DeleteBucketConfigRuleButton.js +1 -1
- package/dist/components/buckets/EmptyBucketButton.js +19 -19
- package/dist/components/buckets/EmptyBucketSummary.d.ts +1 -1
- package/dist/components/buckets/EmptyBucketSummary.js +1 -1
- package/dist/components/buckets/EmptyBucketSummaryList.js +22 -22
- package/dist/components/buckets/__tests__/BucketVersioning.test.js +45 -45
- package/dist/components/buckets/notifications/BucketNotificationCreatePage.js +34 -33
- package/dist/components/buckets/notifications/EventsSection.js +144 -28
- package/dist/components/buckets/notifications/__tests__/events.test.d.ts +1 -0
- package/dist/components/buckets/notifications/__tests__/events.test.js +56 -0
- package/dist/components/buckets/notifications/events.d.ts +71 -7
- package/dist/components/buckets/notifications/events.js +98 -16
- package/dist/components/index.d.ts +24 -22
- package/dist/components/index.js +5 -3
- package/dist/components/layouts/ArrowNavigation.d.ts +1 -2
- package/dist/components/layouts/ArrowNavigation.js +3 -3
- package/dist/components/layouts/BrowserPageLayout.d.ts +2 -3
- package/dist/components/layouts/BrowserPageLayout.js +1 -1
- package/dist/components/objects/CreateFolderButton.d.ts +2 -2
- package/dist/components/objects/CreateFolderButton.js +9 -9
- package/dist/components/objects/DeleteObjectButton.d.ts +1 -1
- package/dist/components/objects/DeleteObjectButton.js +20 -20
- package/dist/components/objects/ObjectDetails/ObjectMetadata.d.ts +1 -1
- package/dist/components/objects/ObjectDetails/ObjectMetadata.js +56 -56
- package/dist/components/objects/ObjectDetails/ObjectSummary.d.ts +1 -1
- package/dist/components/objects/ObjectDetails/ObjectSummary.js +39 -39
- package/dist/components/objects/ObjectDetails/ObjectTags.d.ts +1 -1
- package/dist/components/objects/ObjectDetails/ObjectTags.js +25 -25
- package/dist/components/objects/ObjectDetails/__tests__/ObjectDetails.test.js +119 -119
- package/dist/components/objects/ObjectDetails/__tests__/ObjectSummary.test.js +211 -211
- package/dist/components/objects/ObjectDetails/index.d.ts +1 -1
- package/dist/components/objects/ObjectDetails/index.js +30 -30
- package/dist/components/objects/ObjectList.d.ts +5 -5
- package/dist/components/objects/ObjectList.js +113 -112
- package/dist/components/objects/ObjectLock/EditRetentionButton.js +3 -3
- package/dist/components/objects/ObjectLock/ObjectLockRetentionSettings.js +14 -14
- package/dist/components/objects/ObjectLock/ObjectLockSettings.d.ts +1 -1
- package/dist/components/objects/ObjectLock/ObjectLockSettings.js +29 -28
- package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.d.ts +1 -1
- package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.js +6 -6
- package/dist/components/objects/ObjectLock/__tests__/EditRetentionButton.test.js +50 -50
- package/dist/components/objects/ObjectLock/__tests__/ObjectLockSettings.test.js +77 -77
- package/dist/components/objects/ObjectPage.js +5 -4
- package/dist/components/objects/UploadButton.d.ts +3 -3
- package/dist/components/objects/UploadButton.js +5 -5
- package/dist/components/providers/DataBrowserProvider.d.ts +23 -12
- package/dist/components/providers/DataBrowserProvider.js +60 -38
- package/dist/components/providers/QueryProvider.d.ts +9 -0
- package/dist/components/providers/QueryProvider.js +22 -0
- package/dist/components/search/MetadataSearch.js +26 -25
- package/dist/components/search/SearchHints.js +1 -1
- package/dist/components/ui/ArrayFieldActions.js +4 -4
- package/dist/components/ui/ConfirmDeleteRuleModal.d.ts +1 -1
- package/dist/components/ui/ConfirmDeleteRuleModal.js +1 -1
- package/dist/components/ui/DeleteObjectModalContent.d.ts +1 -1
- package/dist/components/ui/DeleteObjectModalContent.js +12 -12
- package/dist/components/ui/FilterFormSection.d.ts +2 -2
- package/dist/components/ui/FilterFormSection.js +29 -29
- package/dist/components/ui/Search.elements.d.ts +1 -1
- package/dist/components/ui/Search.elements.js +7 -7
- package/dist/components/ui/Table.elements.js +5 -5
- package/dist/config/factory.d.ts +23 -10
- package/dist/config/factory.js +22 -7
- package/dist/config/types.d.ts +20 -3
- package/dist/contexts/DataBrowserUICustomizationContext.d.ts +2 -2
- package/dist/hooks/__tests__/useISVBucketDetection.test.js +42 -42
- package/dist/hooks/__tests__/useIsBucketEmpty.test.js +25 -25
- package/dist/hooks/bucketConfiguration.d.ts +1 -1
- package/dist/hooks/bucketConfiguration.js +48 -48
- package/dist/hooks/bucketOperations.d.ts +1 -1
- package/dist/hooks/bucketOperations.js +6 -6
- package/dist/hooks/factories/__tests__/useCreateS3FunctionMutationHook.test.js +78 -78
- package/dist/hooks/factories/__tests__/useCreateS3InfiniteQueryHook.test.js +78 -78
- package/dist/hooks/factories/__tests__/useCreateS3LoginHook.test.js +42 -42
- package/dist/hooks/factories/__tests__/useCreateS3MutationHook.test.js +61 -61
- package/dist/hooks/factories/__tests__/useCreateS3QueryHook.test.js +63 -63
- package/dist/hooks/factories/index.d.ts +4 -4
- package/dist/hooks/factories/useCreateS3InfiniteQueryHook.d.ts +2 -2
- package/dist/hooks/factories/useCreateS3InfiniteQueryHook.js +15 -12
- package/dist/hooks/factories/useCreateS3LoginHook.d.ts +2 -2
- package/dist/hooks/factories/useCreateS3MutationHook.d.ts +3 -3
- package/dist/hooks/factories/useCreateS3MutationHook.js +6 -1
- package/dist/hooks/factories/useCreateS3QueryHook.d.ts +2 -2
- package/dist/hooks/factories/useCreateS3QueryHook.js +8 -5
- package/dist/hooks/index.d.ts +16 -13
- package/dist/hooks/index.js +4 -1
- package/dist/hooks/loginOperations.d.ts +1 -1
- package/dist/hooks/loginOperations.js +1 -1
- package/dist/hooks/objectOperations.d.ts +2 -2
- package/dist/hooks/objectOperations.js +49 -49
- package/dist/hooks/presignedOperations.d.ts +2 -2
- package/dist/hooks/presignedOperations.js +3 -3
- package/dist/hooks/useBatchObjectLegalHold.js +7 -4
- package/dist/hooks/useDataBrowserNavigate.d.ts +28 -0
- package/dist/hooks/useDataBrowserNavigate.js +24 -0
- package/dist/hooks/useDeleteBucketConfigRule.d.ts +2 -2
- package/dist/hooks/useDeleteBucketConfigRule.js +4 -4
- package/dist/hooks/useEmptyBucket.js +10 -10
- package/dist/hooks/useFeatures.d.ts +7 -0
- package/dist/hooks/useFeatures.js +8 -0
- package/dist/hooks/useISVBucketDetection.js +5 -5
- package/dist/hooks/useIsBucketEmpty.js +4 -4
- package/dist/hooks/useLoginMutation.d.ts +1 -1
- package/dist/hooks/useLoginMutation.js +1 -1
- package/dist/hooks/useS3Client.d.ts +6 -0
- package/dist/hooks/useS3Client.js +3 -2
- package/dist/hooks/useS3ConfigSwitch.d.ts +11 -0
- package/dist/hooks/useS3ConfigSwitch.js +37 -0
- package/dist/hooks/useSupportedNotificationEvents.d.ts +6 -0
- package/dist/hooks/useSupportedNotificationEvents.js +8 -0
- package/dist/index.d.ts +6 -6
- package/dist/test/msw/handlers/deleteBucket.d.ts +1 -1
- package/dist/test/msw/handlers/deleteBucket.js +20 -10
- package/dist/test/msw/handlers/getBucketAcl.d.ts +1 -1
- package/dist/test/msw/handlers/getBucketAcl.js +29 -17
- package/dist/test/msw/handlers/getBucketLocation.d.ts +1 -1
- package/dist/test/msw/handlers/getBucketLocation.js +29 -15
- package/dist/test/msw/handlers/getBucketPolicy.d.ts +1 -1
- package/dist/test/msw/handlers/getBucketPolicy.js +52 -32
- package/dist/test/msw/handlers/headObject.d.ts +1 -1
- package/dist/test/msw/handlers/headObject.js +31 -13
- package/dist/test/msw/handlers/listBuckets.d.ts +1 -1
- package/dist/test/msw/handlers/listBuckets.js +5 -3
- package/dist/test/msw/handlers/listObjectVersions.d.ts +1 -1
- package/dist/test/msw/handlers/listObjectVersions.js +38 -26
- package/dist/test/msw/handlers/listObjects.d.ts +1 -1
- package/dist/test/msw/handlers/listObjects.js +35 -23
- package/dist/test/msw/handlers/objectLegalHold.d.ts +1 -1
- package/dist/test/msw/handlers/objectLegalHold.js +31 -16
- package/dist/test/msw/handlers/objectRetention.d.ts +1 -1
- package/dist/test/msw/handlers/objectRetention.js +31 -17
- package/dist/test/msw/handlers/putBucketAcl.d.ts +1 -1
- package/dist/test/msw/handlers/putBucketAcl.js +29 -14
- package/dist/test/msw/handlers/putObject.d.ts +1 -1
- package/dist/test/msw/handlers/putObject.js +27 -12
- package/dist/test/msw/handlers.d.ts +3 -3
- package/dist/test/msw/handlers.js +72 -49
- package/dist/test/msw/index.d.ts +2 -2
- package/dist/test/msw/server.d.ts +1 -1
- package/dist/test/msw/server.js +1 -1
- package/dist/test/msw/utils.js +2 -2
- package/dist/test/setup.d.ts +1 -1
- package/dist/test/setup.js +19 -19
- package/dist/test/testUtils.d.ts +9 -15
- package/dist/test/testUtils.js +73 -91
- package/dist/test/utils/errorHandling.test.js +119 -119
- package/dist/types/index.d.ts +6 -31
- package/dist/utils/__tests__/s3ConfigIdentifier.test.d.ts +1 -0
- package/dist/utils/__tests__/s3ConfigIdentifier.test.js +429 -0
- package/dist/utils/constants.js +8 -8
- package/dist/utils/deletion/index.d.ts +2 -2
- package/dist/utils/deletion/messages.d.ts +1 -1
- package/dist/utils/deletion/messages.js +4 -4
- package/dist/utils/errorHandling.d.ts +3 -3
- package/dist/utils/errorHandling.js +6 -6
- package/dist/utils/hooks.js +8 -8
- package/dist/utils/index.d.ts +5 -4
- package/dist/utils/index.js +2 -0
- package/dist/utils/proxyMiddleware.d.ts +1 -1
- package/dist/utils/proxyMiddleware.js +6 -11
- package/dist/utils/s3Client.d.ts +2 -2
- package/dist/utils/s3Client.js +1 -1
- package/dist/utils/s3ConfigIdentifier.d.ts +68 -0
- package/dist/utils/s3ConfigIdentifier.js +55 -0
- package/dist/utils/s3RuleUtils.d.ts +5 -5
- package/dist/utils/s3RuleUtils.js +17 -17
- package/package.json +2 -2
- package/dist/utils/useFeatures.d.ts +0 -1
- package/dist/utils/useFeatures.js +0 -7
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpResponse, http } from "msw";
|
|
2
2
|
import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
|
|
3
|
-
const getBucketAclHandler =
|
|
4
|
-
const { bucketName } =
|
|
5
|
-
const url = new URL(
|
|
6
|
-
if (!url.searchParams.has(
|
|
7
|
-
if (
|
|
8
|
-
if (bucketName.includes(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (bucketName.includes(
|
|
3
|
+
const getBucketAclHandler = http.get(`${getS3BaseUrl()}/:bucketName`, async ({ request, params })=>{
|
|
4
|
+
const { bucketName } = params;
|
|
5
|
+
const url = new URL(request.url);
|
|
6
|
+
if (!url.searchParams.has('acl')) return;
|
|
7
|
+
if ('string' == typeof bucketName) {
|
|
8
|
+
if (bucketName.includes('non-existent-bucket')) return HttpResponse.xml(createS3ErrorXml('NoSuchBucket', 'The specified bucket does not exist', bucketName), {
|
|
9
|
+
status: 404
|
|
10
|
+
});
|
|
11
|
+
if (bucketName.includes('access-denied-bucket')) return HttpResponse.xml(createS3ErrorXml('AccessDenied', 'Access Denied'), {
|
|
12
|
+
status: 403
|
|
13
|
+
});
|
|
14
|
+
if (bucketName.includes('network-error-bucket')) return HttpResponse.error();
|
|
15
|
+
if (bucketName.includes('private-bucket')) return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
12
16
|
<AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
13
17
|
<Owner>
|
|
14
18
|
<ID>owner-canonical-id-123</ID>
|
|
@@ -23,8 +27,10 @@ const getBucketAclHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req, res,
|
|
|
23
27
|
<Permission>FULL_CONTROL</Permission>
|
|
24
28
|
</Grant>
|
|
25
29
|
</AccessControlList>
|
|
26
|
-
</AccessControlPolicy
|
|
27
|
-
|
|
30
|
+
</AccessControlPolicy>`, {
|
|
31
|
+
status: 200
|
|
32
|
+
});
|
|
33
|
+
if (bucketName.includes('public-read-bucket')) return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
28
34
|
<AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
29
35
|
<Owner>
|
|
30
36
|
<ID>owner-canonical-id-123</ID>
|
|
@@ -45,8 +51,10 @@ const getBucketAclHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req, res,
|
|
|
45
51
|
<Permission>READ</Permission>
|
|
46
52
|
</Grant>
|
|
47
53
|
</AccessControlList>
|
|
48
|
-
</AccessControlPolicy
|
|
49
|
-
|
|
54
|
+
</AccessControlPolicy>`, {
|
|
55
|
+
status: 200
|
|
56
|
+
});
|
|
57
|
+
if (bucketName.includes('shared-bucket')) return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
50
58
|
<AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
51
59
|
<Owner>
|
|
52
60
|
<ID>owner-canonical-id-123</ID>
|
|
@@ -74,9 +82,11 @@ const getBucketAclHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req, res,
|
|
|
74
82
|
<Permission>READ</Permission>
|
|
75
83
|
</Grant>
|
|
76
84
|
</AccessControlList>
|
|
77
|
-
</AccessControlPolicy
|
|
85
|
+
</AccessControlPolicy>`, {
|
|
86
|
+
status: 200
|
|
87
|
+
});
|
|
78
88
|
}
|
|
79
|
-
return
|
|
89
|
+
return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
80
90
|
<AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
81
91
|
<Owner>
|
|
82
92
|
<ID>owner-canonical-id-123</ID>
|
|
@@ -91,6 +101,8 @@ const getBucketAclHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req, res,
|
|
|
91
101
|
<Permission>FULL_CONTROL</Permission>
|
|
92
102
|
</Grant>
|
|
93
103
|
</AccessControlList>
|
|
94
|
-
</AccessControlPolicy
|
|
104
|
+
</AccessControlPolicy>`, {
|
|
105
|
+
status: 200
|
|
106
|
+
});
|
|
95
107
|
});
|
|
96
108
|
export { getBucketAclHandler };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getBucketLocationHandler: import("msw").
|
|
1
|
+
export declare const getBucketLocationHandler: import("msw").HttpHandler;
|
|
@@ -1,23 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpResponse, http } from "msw";
|
|
2
2
|
import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
|
|
3
|
-
const getBucketLocationHandler =
|
|
4
|
-
const { bucketName } =
|
|
5
|
-
const url = new URL(
|
|
6
|
-
if (!url.searchParams.has(
|
|
7
|
-
if (
|
|
8
|
-
if (bucketName.includes(
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
const getBucketLocationHandler = http.get(`${getS3BaseUrl()}/:bucketName`, async ({ request, params })=>{
|
|
4
|
+
const { bucketName } = params;
|
|
5
|
+
const url = new URL(request.url);
|
|
6
|
+
if (!url.searchParams.has('location')) return;
|
|
7
|
+
if ('string' == typeof bucketName) {
|
|
8
|
+
if (bucketName.includes('non-existent-bucket')) return HttpResponse.xml(createS3ErrorXml('NoSuchBucket', 'The specified bucket does not exist', bucketName), {
|
|
9
|
+
status: 404
|
|
10
|
+
});
|
|
11
|
+
if (bucketName.includes('access-denied-bucket')) return HttpResponse.xml(createS3ErrorXml('AccessDenied', 'Access Denied'), {
|
|
12
|
+
status: 403
|
|
13
|
+
});
|
|
14
|
+
if (bucketName.includes('network-error-bucket')) return HttpResponse.error();
|
|
11
15
|
let locationConstraint = null;
|
|
12
|
-
if (bucketName.includes(
|
|
13
|
-
else if (bucketName.includes(
|
|
14
|
-
else if (bucketName.includes(
|
|
16
|
+
if (bucketName.includes('eu-west-1')) locationConstraint = 'eu-west-1';
|
|
17
|
+
else if (bucketName.includes('ap-southeast-1')) locationConstraint = 'ap-southeast-1';
|
|
18
|
+
else if (bucketName.includes('us-west-2')) locationConstraint = 'us-west-2';
|
|
15
19
|
const response = locationConstraint ? `<?xml version="1.0" encoding="UTF-8"?>
|
|
16
20
|
<LocationConstraint xmlns="http://s3.amazonaws.com/doc/2006-03-01/">${locationConstraint}</LocationConstraint>` : `<?xml version="1.0" encoding="UTF-8"?>
|
|
17
21
|
<LocationConstraint xmlns="http://s3.amazonaws.com/doc/2006-03-01/"></LocationConstraint>`;
|
|
18
|
-
return
|
|
22
|
+
return HttpResponse.xml(response, {
|
|
23
|
+
status: 200,
|
|
24
|
+
headers: {
|
|
25
|
+
'Content-Type': 'application/xml'
|
|
26
|
+
}
|
|
27
|
+
});
|
|
19
28
|
}
|
|
20
|
-
return
|
|
21
|
-
<LocationConstraint xmlns="http://s3.amazonaws.com/doc/2006-03-01/"></LocationConstraint
|
|
29
|
+
return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
30
|
+
<LocationConstraint xmlns="http://s3.amazonaws.com/doc/2006-03-01/"></LocationConstraint>`, {
|
|
31
|
+
status: 200,
|
|
32
|
+
headers: {
|
|
33
|
+
'Content-Type': 'application/xml'
|
|
34
|
+
}
|
|
35
|
+
});
|
|
22
36
|
});
|
|
23
37
|
export { getBucketLocationHandler };
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
* - "invalid-json-bucket" returns malformed JSON for testing
|
|
9
9
|
* - Other buckets return a default allow-all policy
|
|
10
10
|
*/
|
|
11
|
-
export declare const getBucketPolicyHandler: import("msw").
|
|
11
|
+
export declare const getBucketPolicyHandler: import("msw").HttpHandler;
|
|
@@ -1,65 +1,80 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpResponse, http } from "msw";
|
|
2
2
|
import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
|
|
3
|
-
const getBucketPolicyHandler =
|
|
4
|
-
const { bucketName } =
|
|
5
|
-
const url = new URL(
|
|
6
|
-
if (!url.searchParams.has(
|
|
7
|
-
if (
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
const getBucketPolicyHandler = http.get(`${getS3BaseUrl()}/:bucketName`, async ({ request, params })=>{
|
|
4
|
+
const { bucketName } = params;
|
|
5
|
+
const url = new URL(request.url);
|
|
6
|
+
if (!url.searchParams.has('policy')) return;
|
|
7
|
+
if ('no-policy-bucket' === bucketName) return HttpResponse.xml(createS3ErrorXml('NoSuchBucketPolicy', 'The bucket policy does not exist', bucketName), {
|
|
8
|
+
status: 404,
|
|
9
|
+
headers: {
|
|
10
|
+
'Content-Type': 'application/xml'
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
if ('access-denied-bucket' === bucketName) return HttpResponse.xml(createS3ErrorXml('AccessDenied', 'Access Denied', bucketName), {
|
|
14
|
+
status: 403,
|
|
15
|
+
headers: {
|
|
16
|
+
'Content-Type': 'application/xml'
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
if ('invalid-json-bucket' === bucketName) return HttpResponse.text('{"Version": "2012-10-17", "Statement": [invalid json}', {
|
|
20
|
+
status: 200,
|
|
21
|
+
headers: {
|
|
22
|
+
'Content-Type': 'application/json'
|
|
23
|
+
}
|
|
24
|
+
});
|
|
10
25
|
let policy;
|
|
11
|
-
policy =
|
|
12
|
-
Version:
|
|
26
|
+
policy = 'string' == typeof bucketName && bucketName.startsWith('policy-readonly-') ? {
|
|
27
|
+
Version: '2012-10-17',
|
|
13
28
|
Statement: [
|
|
14
29
|
{
|
|
15
|
-
Sid:
|
|
16
|
-
Effect:
|
|
17
|
-
Principal:
|
|
18
|
-
Action:
|
|
30
|
+
Sid: 'PublicReadGetObject',
|
|
31
|
+
Effect: 'Allow',
|
|
32
|
+
Principal: '*',
|
|
33
|
+
Action: 's3:GetObject',
|
|
19
34
|
Resource: `arn:aws:s3:::${bucketName}/*`
|
|
20
35
|
}
|
|
21
36
|
]
|
|
22
|
-
} :
|
|
23
|
-
Version:
|
|
37
|
+
} : 'string' == typeof bucketName && bucketName.startsWith('policy-complex-') ? {
|
|
38
|
+
Version: '2012-10-17',
|
|
24
39
|
Statement: [
|
|
25
40
|
{
|
|
26
|
-
Sid:
|
|
27
|
-
Effect:
|
|
41
|
+
Sid: 'AllowSpecificUser',
|
|
42
|
+
Effect: 'Allow',
|
|
28
43
|
Principal: {
|
|
29
|
-
AWS:
|
|
44
|
+
AWS: 'arn:aws:iam::123456789012:user/ExampleUser'
|
|
30
45
|
},
|
|
31
46
|
Action: [
|
|
32
|
-
|
|
33
|
-
|
|
47
|
+
's3:GetObject',
|
|
48
|
+
's3:PutObject'
|
|
34
49
|
],
|
|
35
50
|
Resource: `arn:aws:s3:::${bucketName}/*`
|
|
36
51
|
},
|
|
37
52
|
{
|
|
38
|
-
Sid:
|
|
39
|
-
Effect:
|
|
40
|
-
Principal:
|
|
41
|
-
Action:
|
|
53
|
+
Sid: 'DenyInsecureConnections',
|
|
54
|
+
Effect: 'Deny',
|
|
55
|
+
Principal: '*',
|
|
56
|
+
Action: 's3:*',
|
|
42
57
|
Resource: [
|
|
43
58
|
`arn:aws:s3:::${bucketName}`,
|
|
44
59
|
`arn:aws:s3:::${bucketName}/*`
|
|
45
60
|
],
|
|
46
61
|
Condition: {
|
|
47
62
|
Bool: {
|
|
48
|
-
|
|
63
|
+
'aws:SecureTransport': 'false'
|
|
49
64
|
}
|
|
50
65
|
}
|
|
51
66
|
}
|
|
52
67
|
]
|
|
53
68
|
} : {
|
|
54
|
-
Version:
|
|
69
|
+
Version: '2012-10-17',
|
|
55
70
|
Statement: [
|
|
56
71
|
{
|
|
57
|
-
Sid:
|
|
58
|
-
Effect:
|
|
72
|
+
Sid: 'DefaultStatement',
|
|
73
|
+
Effect: 'Allow',
|
|
59
74
|
Principal: {
|
|
60
|
-
AWS:
|
|
75
|
+
AWS: 'arn:aws:iam::123456789012:root'
|
|
61
76
|
},
|
|
62
|
-
Action:
|
|
77
|
+
Action: 's3:*',
|
|
63
78
|
Resource: [
|
|
64
79
|
`arn:aws:s3:::${bucketName}`,
|
|
65
80
|
`arn:aws:s3:::${bucketName}/*`
|
|
@@ -67,6 +82,11 @@ const getBucketPolicyHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req, r
|
|
|
67
82
|
}
|
|
68
83
|
]
|
|
69
84
|
};
|
|
70
|
-
return
|
|
85
|
+
return HttpResponse.json(policy, {
|
|
86
|
+
status: 200,
|
|
87
|
+
headers: {
|
|
88
|
+
'Content-Type': 'application/json'
|
|
89
|
+
}
|
|
90
|
+
});
|
|
71
91
|
});
|
|
72
92
|
export { getBucketPolicyHandler };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const headObjectHandler: import("msw").
|
|
1
|
+
export declare const headObjectHandler: import("msw").HttpHandler;
|
|
@@ -1,17 +1,35 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpResponse, http } from "msw";
|
|
2
2
|
import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
|
|
3
|
-
const headObjectHandler =
|
|
4
|
-
const { bucketName } =
|
|
5
|
-
const url = new URL(
|
|
6
|
-
const objectKey = url.pathname.substring(url.pathname.indexOf(
|
|
7
|
-
const versionId = url.searchParams.get(
|
|
8
|
-
if (
|
|
9
|
-
if (bucketName.includes(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (
|
|
13
|
-
|
|
3
|
+
const headObjectHandler = http.head(`${getS3BaseUrl()}/:bucketName/*`, async ({ request, params })=>{
|
|
4
|
+
const { bucketName } = params;
|
|
5
|
+
const url = new URL(request.url);
|
|
6
|
+
const objectKey = url.pathname.substring(url.pathname.indexOf('/', 1) + 1);
|
|
7
|
+
const versionId = url.searchParams.get('versionId');
|
|
8
|
+
if ('string' == typeof bucketName) {
|
|
9
|
+
if (bucketName.includes('non-existent-bucket')) return HttpResponse.xml(createS3ErrorXml('NoSuchBucket', 'The specified bucket does not exist', bucketName), {
|
|
10
|
+
status: 404
|
|
11
|
+
});
|
|
12
|
+
if (objectKey.includes('non-existent-object')) return HttpResponse.xml(createS3ErrorXml('NotFound', 'The specified key does not exist.', bucketName, objectKey), {
|
|
13
|
+
status: 404
|
|
14
|
+
});
|
|
15
|
+
if (bucketName.includes('restricted-bucket')) return HttpResponse.xml(createS3ErrorXml('AccessDenied', 'Access Denied'), {
|
|
16
|
+
status: 403
|
|
17
|
+
});
|
|
18
|
+
if (bucketName.includes('network-error-bucket')) return HttpResponse.error();
|
|
19
|
+
return new Response(null, {
|
|
20
|
+
status: 200,
|
|
21
|
+
headers: {
|
|
22
|
+
'x-amz-meta-custom-key': 'custom-value',
|
|
23
|
+
'Content-Length': '12345',
|
|
24
|
+
'Content-Type': 'application/octet-stream',
|
|
25
|
+
ETag: '"some-etag"',
|
|
26
|
+
'Last-Modified': new Date().toUTCString(),
|
|
27
|
+
'x-amz-version-id': versionId || 'some-version-id'
|
|
28
|
+
}
|
|
29
|
+
});
|
|
14
30
|
}
|
|
15
|
-
return
|
|
31
|
+
return HttpResponse.xml(createS3ErrorXml('InvalidArgument', 'Invalid request parameters'), {
|
|
32
|
+
status: 400
|
|
33
|
+
});
|
|
16
34
|
});
|
|
17
35
|
export { headObjectHandler };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const listBucketsHandler: import("msw").
|
|
1
|
+
export declare const listBucketsHandler: import("msw").HttpHandler;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpResponse, http } from "msw";
|
|
2
2
|
import { getS3BaseUrl } from "../utils.js";
|
|
3
|
-
const listBucketsHandler =
|
|
3
|
+
const listBucketsHandler = http.get(`${getS3BaseUrl()}/`, async ()=>HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
4
4
|
<ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
5
5
|
<Owner>
|
|
6
6
|
<ID>owner-id-123</ID>
|
|
@@ -20,5 +20,7 @@ const listBucketsHandler = rest.get(`${getS3BaseUrl()}/`, (_req, res, ctx)=>res(
|
|
|
20
20
|
<CreationDate>2023-10-10T17:50:00.000Z</CreationDate>
|
|
21
21
|
</Bucket>
|
|
22
22
|
</Buckets>
|
|
23
|
-
</ListAllMyBucketsResult
|
|
23
|
+
</ListAllMyBucketsResult>`, {
|
|
24
|
+
status: 200
|
|
25
|
+
}));
|
|
24
26
|
export { listBucketsHandler };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const listObjectVersionsHandler: import("msw").
|
|
1
|
+
export declare const listObjectVersionsHandler: import("msw").HttpHandler;
|
|
@@ -1,28 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpResponse, http } from "msw";
|
|
2
2
|
import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
|
|
3
|
-
const listObjectVersionsHandler =
|
|
4
|
-
const { bucketName } =
|
|
5
|
-
const url = new URL(
|
|
6
|
-
if (!url.searchParams.has(
|
|
7
|
-
const prefix = url.searchParams.get(
|
|
8
|
-
const delimiter = url.searchParams.get(
|
|
9
|
-
const maxKeys = parseInt(url.searchParams.get(
|
|
10
|
-
const keyMarker = url.searchParams.get(
|
|
11
|
-
if (
|
|
12
|
-
if (bucketName.includes(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (bucketName.includes(
|
|
3
|
+
const listObjectVersionsHandler = http.get(`${getS3BaseUrl()}/:bucketName`, async ({ request, params })=>{
|
|
4
|
+
const { bucketName } = params;
|
|
5
|
+
const url = new URL(request.url);
|
|
6
|
+
if (!url.searchParams.has('versions')) return;
|
|
7
|
+
const prefix = url.searchParams.get('prefix') || '';
|
|
8
|
+
const delimiter = url.searchParams.get('delimiter') || '';
|
|
9
|
+
const maxKeys = parseInt(url.searchParams.get('max-keys') || '1000', 10);
|
|
10
|
+
const keyMarker = url.searchParams.get('key-marker');
|
|
11
|
+
if ('string' == typeof bucketName) {
|
|
12
|
+
if (bucketName.includes('non-existent-bucket')) return HttpResponse.xml(createS3ErrorXml('NoSuchBucket', 'The specified bucket does not exist', bucketName), {
|
|
13
|
+
status: 404
|
|
14
|
+
});
|
|
15
|
+
if (bucketName.includes('access-denied-bucket')) return HttpResponse.xml(createS3ErrorXml('AccessDenied', 'Access Denied'), {
|
|
16
|
+
status: 403
|
|
17
|
+
});
|
|
18
|
+
if (bucketName.includes('network-error-bucket')) return HttpResponse.error();
|
|
19
|
+
if (bucketName.includes('empty-bucket')) return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
16
20
|
<ListVersionsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
17
21
|
<Name>${bucketName}</Name>
|
|
18
22
|
<Prefix>${prefix}</Prefix>
|
|
19
23
|
<Delimiter>${delimiter}</Delimiter>
|
|
20
24
|
<MaxKeys>${maxKeys}</MaxKeys>
|
|
21
25
|
<IsTruncated>false</IsTruncated>
|
|
22
|
-
</ListVersionsResult
|
|
26
|
+
</ListVersionsResult>`, {
|
|
27
|
+
status: 200
|
|
28
|
+
});
|
|
23
29
|
if (keyMarker) {
|
|
24
|
-
const pageKey = prefix &&
|
|
25
|
-
return
|
|
30
|
+
const pageKey = prefix && 'file.txt' !== prefix ? `${prefix.replace(/\/$/, '')}-v3.txt` : 'file-v3.txt';
|
|
31
|
+
return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
26
32
|
<ListVersionsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
27
33
|
<Name>${bucketName}</Name>
|
|
28
34
|
<Prefix>${prefix}</Prefix>
|
|
@@ -38,20 +44,22 @@ const listObjectVersionsHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req
|
|
|
38
44
|
<Size>1024</Size>
|
|
39
45
|
<StorageClass>STANDARD</StorageClass>
|
|
40
46
|
</Version>
|
|
41
|
-
</ListVersionsResult
|
|
47
|
+
</ListVersionsResult>`, {
|
|
48
|
+
status: 200
|
|
49
|
+
});
|
|
42
50
|
}
|
|
43
|
-
const hasMorePages = bucketName.includes(
|
|
44
|
-
const baseKey = prefix &&
|
|
45
|
-
const deletedKey = prefix &&
|
|
46
|
-
const nextKey = prefix &&
|
|
47
|
-
return
|
|
51
|
+
const hasMorePages = bucketName.includes('paginated-bucket');
|
|
52
|
+
const baseKey = prefix && 'file.txt' !== prefix ? prefix : 'file.txt';
|
|
53
|
+
const deletedKey = prefix && 'file.txt' !== prefix ? `${prefix.replace(/\/$/, '')}-deleted.txt` : 'deleted-file.txt';
|
|
54
|
+
const nextKey = prefix && 'file.txt' !== prefix ? `${prefix.replace(/\/$/, '')}-v2.txt` : 'file-v2.txt';
|
|
55
|
+
return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
48
56
|
<ListVersionsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
49
57
|
<Name>${bucketName}</Name>
|
|
50
58
|
<Prefix>${prefix}</Prefix>
|
|
51
59
|
<Delimiter>${delimiter}</Delimiter>
|
|
52
60
|
<MaxKeys>${maxKeys}</MaxKeys>
|
|
53
61
|
<IsTruncated>${hasMorePages}</IsTruncated>
|
|
54
|
-
${hasMorePages ? `<NextKeyMarker>${nextKey}</NextKeyMarker><NextVersionIdMarker>version-id-2</NextVersionIdMarker>` :
|
|
62
|
+
${hasMorePages ? `<NextKeyMarker>${nextKey}</NextKeyMarker><NextVersionIdMarker>version-id-2</NextVersionIdMarker>` : ''}
|
|
55
63
|
<Version>
|
|
56
64
|
<Key>${baseKey}</Key>
|
|
57
65
|
<VersionId>version-id-1</VersionId>
|
|
@@ -76,8 +84,12 @@ const listObjectVersionsHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req
|
|
|
76
84
|
<IsLatest>true</IsLatest>
|
|
77
85
|
<LastModified>2023-10-10T17:50:00.000Z</LastModified>
|
|
78
86
|
</DeleteMarker>
|
|
79
|
-
</ListVersionsResult
|
|
87
|
+
</ListVersionsResult>`, {
|
|
88
|
+
status: 200
|
|
89
|
+
});
|
|
80
90
|
}
|
|
81
|
-
return
|
|
91
|
+
return new Response(null, {
|
|
92
|
+
status: 200
|
|
93
|
+
});
|
|
82
94
|
});
|
|
83
95
|
export { listObjectVersionsHandler };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const listObjectsHandler: import("msw").
|
|
1
|
+
export declare const listObjectsHandler: import("msw").HttpHandler;
|
|
@@ -1,26 +1,32 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpResponse, http } from "msw";
|
|
2
2
|
import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
|
|
3
|
-
const listObjectsHandler =
|
|
4
|
-
const { bucketName } =
|
|
5
|
-
const url = new URL(
|
|
6
|
-
if (
|
|
7
|
-
const prefix = url.searchParams.get(
|
|
8
|
-
const delimiter = url.searchParams.get(
|
|
9
|
-
const maxKeys = parseInt(url.searchParams.get(
|
|
10
|
-
const continuationToken = url.searchParams.get(
|
|
11
|
-
if (
|
|
12
|
-
if (bucketName.includes(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (bucketName.includes(
|
|
3
|
+
const listObjectsHandler = http.get(`${getS3BaseUrl()}/:bucketName`, async ({ request, params })=>{
|
|
4
|
+
const { bucketName } = params;
|
|
5
|
+
const url = new URL(request.url);
|
|
6
|
+
if ('2' !== url.searchParams.get('list-type')) return;
|
|
7
|
+
const prefix = url.searchParams.get('prefix') || '';
|
|
8
|
+
const delimiter = url.searchParams.get('delimiter') || '';
|
|
9
|
+
const maxKeys = parseInt(url.searchParams.get('max-keys') || '1000', 10);
|
|
10
|
+
const continuationToken = url.searchParams.get('continuation-token');
|
|
11
|
+
if ('string' == typeof bucketName) {
|
|
12
|
+
if (bucketName.includes('non-existent-bucket')) return HttpResponse.xml(createS3ErrorXml('NoSuchBucket', 'The specified bucket does not exist', bucketName), {
|
|
13
|
+
status: 404
|
|
14
|
+
});
|
|
15
|
+
if (bucketName.includes('access-denied-bucket')) return HttpResponse.xml(createS3ErrorXml('AccessDenied', 'Access Denied'), {
|
|
16
|
+
status: 403
|
|
17
|
+
});
|
|
18
|
+
if (bucketName.includes('network-error-bucket')) return HttpResponse.error();
|
|
19
|
+
if (bucketName.includes('empty-bucket')) return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
16
20
|
<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
17
21
|
<Name>${bucketName}</Name>
|
|
18
22
|
<Prefix>${prefix}</Prefix>
|
|
19
23
|
<Delimiter>${delimiter}</Delimiter>
|
|
20
24
|
<MaxKeys>${maxKeys}</MaxKeys>
|
|
21
25
|
<IsTruncated>false</IsTruncated>
|
|
22
|
-
</ListBucketResult
|
|
23
|
-
|
|
26
|
+
</ListBucketResult>`, {
|
|
27
|
+
status: 200
|
|
28
|
+
});
|
|
29
|
+
if (continuationToken) return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
24
30
|
<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
25
31
|
<Name>${bucketName}</Name>
|
|
26
32
|
<Prefix>${prefix}</Prefix>
|
|
@@ -34,16 +40,18 @@ const listObjectsHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req, res,
|
|
|
34
40
|
<Size>2048</Size>
|
|
35
41
|
<StorageClass>STANDARD</StorageClass>
|
|
36
42
|
</Contents>
|
|
37
|
-
</ListBucketResult
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
</ListBucketResult>`, {
|
|
44
|
+
status: 200
|
|
45
|
+
});
|
|
46
|
+
const hasMorePages = bucketName.includes('paginated-bucket');
|
|
47
|
+
return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
40
48
|
<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
41
49
|
<Name>${bucketName}</Name>
|
|
42
50
|
<Prefix>${prefix}</Prefix>
|
|
43
51
|
<Delimiter>${delimiter}</Delimiter>
|
|
44
52
|
<MaxKeys>${maxKeys}</MaxKeys>
|
|
45
53
|
<IsTruncated>${hasMorePages}</IsTruncated>
|
|
46
|
-
${hasMorePages ?
|
|
54
|
+
${hasMorePages ? '<NextContinuationToken>token-123</NextContinuationToken>' : ''}
|
|
47
55
|
<Contents>
|
|
48
56
|
<Key>${prefix}file1.txt</Key>
|
|
49
57
|
<LastModified>2023-10-12T17:50:00.000Z</LastModified>
|
|
@@ -58,9 +66,13 @@ const listObjectsHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req, res,
|
|
|
58
66
|
<Size>512</Size>
|
|
59
67
|
<StorageClass>STANDARD</StorageClass>
|
|
60
68
|
</Contents>
|
|
61
|
-
${delimiter ? `<CommonPrefixes><Prefix>${prefix}folder1/</Prefix></CommonPrefixes>` :
|
|
62
|
-
</ListBucketResult
|
|
69
|
+
${delimiter ? `<CommonPrefixes><Prefix>${prefix}folder1/</Prefix></CommonPrefixes>` : ''}
|
|
70
|
+
</ListBucketResult>`, {
|
|
71
|
+
status: 200
|
|
72
|
+
});
|
|
63
73
|
}
|
|
64
|
-
return
|
|
74
|
+
return new Response(null, {
|
|
75
|
+
status: 200
|
|
76
|
+
});
|
|
65
77
|
});
|
|
66
78
|
export { listObjectsHandler };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getObjectLegalHoldHandler: import("msw").
|
|
1
|
+
export declare const getObjectLegalHoldHandler: import("msw").HttpHandler;
|
|
@@ -1,24 +1,39 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpResponse, http } from "msw";
|
|
2
2
|
import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
|
|
3
3
|
import { ObjectLockLegalHoldStatus } from "@aws-sdk/client-s3";
|
|
4
|
-
const getObjectLegalHoldHandler =
|
|
5
|
-
const { bucketName } =
|
|
6
|
-
const url = new URL(
|
|
7
|
-
const objectKey = url.pathname.substring(url.pathname.indexOf(
|
|
8
|
-
if (!url.searchParams.has(
|
|
9
|
-
if (
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (
|
|
14
|
-
|
|
4
|
+
const getObjectLegalHoldHandler = http.get(`${getS3BaseUrl()}/:bucketName/*`, async ({ request, params })=>{
|
|
5
|
+
const { bucketName } = params;
|
|
6
|
+
const url = new URL(request.url);
|
|
7
|
+
const objectKey = url.pathname.substring(url.pathname.indexOf('/', 1) + 1);
|
|
8
|
+
if (!url.searchParams.has('legal-hold')) return;
|
|
9
|
+
if ('string' == typeof bucketName) {
|
|
10
|
+
if ('no-such-bucket' === bucketName || 'non-existent-bucket' === bucketName) return HttpResponse.xml(createS3ErrorXml('NoSuchBucket', 'The specified bucket does not exist', bucketName), {
|
|
11
|
+
status: 404
|
|
12
|
+
});
|
|
13
|
+
if ('access-denied-bucket' === bucketName || 'restricted-bucket' === bucketName) return HttpResponse.xml(createS3ErrorXml('AccessDenied', 'Access Denied', bucketName, objectKey), {
|
|
14
|
+
status: 403
|
|
15
|
+
});
|
|
16
|
+
if ('network-error-bucket' === bucketName) return HttpResponse.error();
|
|
17
|
+
if ('non-existent-object.txt' === objectKey) return HttpResponse.xml(createS3ErrorXml('NoSuchKey', 'The specified key does not exist.', bucketName, objectKey), {
|
|
18
|
+
status: 404
|
|
19
|
+
});
|
|
20
|
+
if ('no-legal-hold-object.txt' === objectKey) return HttpResponse.xml(createS3ErrorXml('NoSuchObjectLockConfiguration', 'The specified object does not have a ObjectLock configuration', bucketName, objectKey), {
|
|
21
|
+
status: 404
|
|
22
|
+
});
|
|
15
23
|
let status = ObjectLockLegalHoldStatus.ON;
|
|
16
|
-
if (
|
|
17
|
-
return
|
|
24
|
+
if ('legal-hold-off-object.txt' === objectKey) status = ObjectLockLegalHoldStatus.OFF;
|
|
25
|
+
return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
18
26
|
<LegalHold xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
19
27
|
<Status>${status}</Status>
|
|
20
|
-
</LegalHold
|
|
28
|
+
</LegalHold>`, {
|
|
29
|
+
status: 200,
|
|
30
|
+
headers: {
|
|
31
|
+
'Content-Type': 'application/xml'
|
|
32
|
+
}
|
|
33
|
+
});
|
|
21
34
|
}
|
|
22
|
-
return
|
|
35
|
+
return HttpResponse.xml(createS3ErrorXml('InvalidArgument', 'Invalid request parameters'), {
|
|
36
|
+
status: 400
|
|
37
|
+
});
|
|
23
38
|
});
|
|
24
39
|
export { getObjectLegalHoldHandler };
|