|
1 | | -///* |
2 | | -// * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
3 | | -// * SPDX-License-Identifier: Apache-2.0 |
4 | | -// */ |
5 | | -//package aws.sdk.kotlin.e2etest |
6 | | -// |
7 | | -//import aws.sdk.kotlin.e2etest.S3TestUtils.createMultiRegionAccessPoint |
8 | | -//import aws.sdk.kotlin.e2etest.S3TestUtils.deleteBucketAndAllContents |
9 | | -//import aws.sdk.kotlin.e2etest.S3TestUtils.deleteMultiRegionAccessPoint |
10 | | -//import aws.sdk.kotlin.e2etest.S3TestUtils.getAccountId |
11 | | -//import aws.sdk.kotlin.e2etest.S3TestUtils.getBucketWithPrefix |
12 | | -//import aws.sdk.kotlin.e2etest.S3TestUtils.getMultiRegionAccessPointArn |
13 | | -//import aws.sdk.kotlin.e2etest.S3TestUtils.multiRegionAccessPointWasCreated |
14 | | -//import aws.sdk.kotlin.services.s3.S3Client |
15 | | -//import aws.sdk.kotlin.services.s3.deleteObject |
16 | | -//import aws.sdk.kotlin.services.s3.putObject |
17 | | -//import aws.sdk.kotlin.services.s3.withConfig |
18 | | -//import aws.sdk.kotlin.services.s3control.S3ControlClient |
19 | | -//import aws.smithy.kotlin.runtime.auth.awssigning.UnsupportedSigningAlgorithmException |
20 | | -//import aws.smithy.kotlin.runtime.auth.awssigning.crt.CrtAwsSigner |
21 | | -//import aws.smithy.kotlin.runtime.http.auth.SigV4AsymmetricAuthScheme |
22 | | -//import kotlinx.coroutines.runBlocking |
23 | | -//import org.junit.jupiter.api.AfterAll |
24 | | -//import org.junit.jupiter.api.BeforeAll |
25 | | -//import org.junit.jupiter.api.TestInstance |
26 | | -//import kotlin.test.Test |
27 | | -//import kotlin.test.assertEquals |
28 | | -//import kotlin.test.assertFailsWith |
29 | | -// |
30 | | -//private const val MRAP_BUCKET_PREFIX = "s3-mrap-test-bucket-" |
31 | | -// |
32 | | -//@TestInstance(TestInstance.Lifecycle.PER_CLASS) |
33 | | -//class MutliRegionAccessPointTest { |
34 | | -// private val s3West = S3Client { region = "us-west-2" } |
35 | | -// private val s3East = s3West.withConfig { region = "us-east-2" } |
36 | | -// private val s3SigV4a = s3West.withConfig { authSchemes = listOf(SigV4AsymmetricAuthScheme(CrtAwsSigner)) } |
37 | | -// private val s3Control = S3ControlClient { region = "us-west-2" } |
38 | | -// |
39 | | -// private val multiRegionAccessPoint = "aws-sdk-for-kotlin-test-multi-region-access-point" |
40 | | -// private val objectKey = "test.txt" |
41 | | -// |
42 | | -// private lateinit var accountId: String |
43 | | -// private lateinit var multiRegionAccessPointArn: String |
44 | | -// private lateinit var usWestBucket: String |
45 | | -// private lateinit var usEastBucket: String |
46 | | -// |
47 | | -// @BeforeAll |
48 | | -// private fun setUp(): Unit = runBlocking { |
49 | | -// accountId = getAccountId() |
50 | | -// usWestBucket = getBucketWithPrefix(s3West, MRAP_BUCKET_PREFIX, "us-west-2", accountId) |
51 | | -// usEastBucket = getBucketWithPrefix(s3East, MRAP_BUCKET_PREFIX, "us-east-2", accountId) |
52 | | -// |
53 | | -// createMultiRegionAccessPoint( |
54 | | -// s3Control, |
55 | | -// multiRegionAccessPoint, |
56 | | -// usWestBucket, |
57 | | -// usEastBucket, |
58 | | -// accountId, |
59 | | -// ) |
60 | | -// |
61 | | -// multiRegionAccessPointArn = |
62 | | -// getMultiRegionAccessPointArn( |
63 | | -// s3Control, |
64 | | -// multiRegionAccessPoint, |
65 | | -// accountId, |
66 | | -// ) |
67 | | -// } |
68 | | -// |
69 | | -// @AfterAll |
70 | | -// private fun cleanUp(): Unit = runBlocking { |
71 | | -// if (multiRegionAccessPointWasCreated(s3Control, multiRegionAccessPoint, accountId)) { |
72 | | -// deleteMultiRegionAccessPoint(s3Control, multiRegionAccessPoint, accountId) |
73 | | -// } |
74 | | -// |
75 | | -// deleteBucketAndAllContents(s3West, usWestBucket) |
76 | | -// deleteBucketAndAllContents(s3East, usEastBucket) |
77 | | -// |
78 | | -// s3West.close() |
79 | | -// s3East.close() |
80 | | -// s3SigV4a.close() |
81 | | -// s3Control.close() |
82 | | -// } |
83 | | -// |
84 | | -// @Test |
85 | | -// fun testMultiRegionAccessPointOperation(): Unit = runBlocking { |
86 | | -// s3SigV4a.putObject { |
87 | | -// bucket = multiRegionAccessPointArn |
88 | | -// key = objectKey |
89 | | -// } |
90 | | -// |
91 | | -// s3SigV4a.deleteObject { |
92 | | -// bucket = multiRegionAccessPointArn |
93 | | -// key = objectKey |
94 | | -// } |
95 | | -// } |
96 | | -// |
97 | | -// @Test |
98 | | -// fun testUnsupportedSigningAlgorithm(): Unit = runBlocking { |
99 | | -// val ex = assertFailsWith<UnsupportedSigningAlgorithmException> { |
100 | | -// s3West.putObject { |
101 | | -// bucket = multiRegionAccessPointArn |
102 | | -// key = objectKey |
103 | | -// } |
104 | | -// } |
105 | | -// |
106 | | -// assertEquals( |
107 | | -// ex.message, |
108 | | -// "SIGV4A support is not yet implemented for the default signer. For more information on how to enable it with the CRT signer, please refer to: https://a.co/3sf8533", |
109 | | -// ) |
110 | | -// } |
111 | | -//} |
| 1 | +/* |
| 2 | + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | +package aws.sdk.kotlin.e2etest |
| 6 | + |
| 7 | +import aws.sdk.kotlin.e2etest.S3TestUtils.createMultiRegionAccessPoint |
| 8 | +import aws.sdk.kotlin.e2etest.S3TestUtils.deleteBucketAndAllContents |
| 9 | +import aws.sdk.kotlin.e2etest.S3TestUtils.deleteMultiRegionAccessPoint |
| 10 | +import aws.sdk.kotlin.e2etest.S3TestUtils.getAccountId |
| 11 | +import aws.sdk.kotlin.e2etest.S3TestUtils.getBucketWithPrefix |
| 12 | +import aws.sdk.kotlin.e2etest.S3TestUtils.getMultiRegionAccessPointArn |
| 13 | +import aws.sdk.kotlin.e2etest.S3TestUtils.multiRegionAccessPointWasCreated |
| 14 | +import aws.sdk.kotlin.services.s3.S3Client |
| 15 | +import aws.sdk.kotlin.services.s3.deleteObject |
| 16 | +import aws.sdk.kotlin.services.s3.putObject |
| 17 | +import aws.sdk.kotlin.services.s3.withConfig |
| 18 | +import aws.sdk.kotlin.services.s3control.S3ControlClient |
| 19 | +import aws.smithy.kotlin.runtime.auth.awssigning.UnsupportedSigningAlgorithmException |
| 20 | +import aws.smithy.kotlin.runtime.auth.awssigning.crt.CrtAwsSigner |
| 21 | +import aws.smithy.kotlin.runtime.http.auth.SigV4AsymmetricAuthScheme |
| 22 | +import kotlinx.coroutines.runBlocking |
| 23 | +import org.junit.jupiter.api.AfterAll |
| 24 | +import org.junit.jupiter.api.BeforeAll |
| 25 | +import org.junit.jupiter.api.TestInstance |
| 26 | +import kotlin.test.Test |
| 27 | +import kotlin.test.assertEquals |
| 28 | +import kotlin.test.assertFailsWith |
| 29 | + |
| 30 | +private const val MRAP_BUCKET_PREFIX = "s3-mrap-test-bucket-" |
| 31 | + |
| 32 | +@TestInstance(TestInstance.Lifecycle.PER_CLASS) |
| 33 | +class MutliRegionAccessPointTest { |
| 34 | + private val s3West = S3Client { region = "us-west-2" } |
| 35 | + private val s3East = s3West.withConfig { region = "us-east-2" } |
| 36 | + private val s3SigV4a = s3West.withConfig { authSchemes = listOf(SigV4AsymmetricAuthScheme(CrtAwsSigner)) } |
| 37 | + private val s3Control = S3ControlClient { region = "us-west-2" } |
| 38 | + |
| 39 | + private val multiRegionAccessPoint = "aws-sdk-for-kotlin-test-multi-region-access-point" |
| 40 | + private val objectKey = "test.txt" |
| 41 | + |
| 42 | + private lateinit var accountId: String |
| 43 | + private lateinit var multiRegionAccessPointArn: String |
| 44 | + private lateinit var usWestBucket: String |
| 45 | + private lateinit var usEastBucket: String |
| 46 | + |
| 47 | + @BeforeAll |
| 48 | + private fun setUp(): Unit = runBlocking { |
| 49 | + accountId = getAccountId() |
| 50 | + usWestBucket = getBucketWithPrefix(s3West, MRAP_BUCKET_PREFIX, "us-west-2", accountId) |
| 51 | + usEastBucket = getBucketWithPrefix(s3East, MRAP_BUCKET_PREFIX, "us-east-2", accountId) |
| 52 | + |
| 53 | + createMultiRegionAccessPoint( |
| 54 | + s3Control, |
| 55 | + multiRegionAccessPoint, |
| 56 | + usWestBucket, |
| 57 | + usEastBucket, |
| 58 | + accountId, |
| 59 | + ) |
| 60 | + |
| 61 | + multiRegionAccessPointArn = |
| 62 | + getMultiRegionAccessPointArn( |
| 63 | + s3Control, |
| 64 | + multiRegionAccessPoint, |
| 65 | + accountId, |
| 66 | + ) |
| 67 | + } |
| 68 | + |
| 69 | + @AfterAll |
| 70 | + private fun cleanUp(): Unit = runBlocking { |
| 71 | + if (multiRegionAccessPointWasCreated(s3Control, multiRegionAccessPoint, accountId)) { |
| 72 | + deleteMultiRegionAccessPoint(s3Control, multiRegionAccessPoint, accountId) |
| 73 | + } |
| 74 | + |
| 75 | + deleteBucketAndAllContents(s3West, usWestBucket) |
| 76 | + deleteBucketAndAllContents(s3East, usEastBucket) |
| 77 | + |
| 78 | + s3West.close() |
| 79 | + s3East.close() |
| 80 | + s3SigV4a.close() |
| 81 | + s3Control.close() |
| 82 | + } |
| 83 | + |
| 84 | + @Test |
| 85 | + fun testMultiRegionAccessPointOperation(): Unit = runBlocking { |
| 86 | + s3SigV4a.putObject { |
| 87 | + bucket = multiRegionAccessPointArn |
| 88 | + key = objectKey |
| 89 | + } |
| 90 | + |
| 91 | + s3SigV4a.deleteObject { |
| 92 | + bucket = multiRegionAccessPointArn |
| 93 | + key = objectKey |
| 94 | + } |
| 95 | + } |
| 96 | + |
| 97 | + @Test |
| 98 | + fun testUnsupportedSigningAlgorithm(): Unit = runBlocking { |
| 99 | + val ex = assertFailsWith<UnsupportedSigningAlgorithmException> { |
| 100 | + s3West.putObject { |
| 101 | + bucket = multiRegionAccessPointArn |
| 102 | + key = objectKey |
| 103 | + } |
| 104 | + } |
| 105 | + |
| 106 | + assertEquals( |
| 107 | + ex.message, |
| 108 | + "SIGV4A support is not yet implemented for the default signer. For more information on how to enable it with the CRT signer, please refer to: https://a.co/3sf8533", |
| 109 | + ) |
| 110 | + } |
| 111 | +} |
0 commit comments