|
| 1 | +/* |
| 2 | + * Copyright (c) 2025 shift7 GmbH. All rights reserved. |
| 3 | + */ |
| 4 | + |
| 5 | +package cloud.katta.cli.commands.setup; |
| 6 | + |
| 7 | +import org.junit.jupiter.api.Test; |
| 8 | +import org.mockito.Mockito; |
| 9 | + |
| 10 | +import java.util.Arrays; |
| 11 | +import java.util.UUID; |
| 12 | + |
| 13 | +import cloud.katta.client.ApiException; |
| 14 | +import cloud.katta.client.api.StorageProfileResourceApi; |
| 15 | +import cloud.katta.client.model.Protocol; |
| 16 | +import cloud.katta.client.model.S3SERVERSIDEENCRYPTION; |
| 17 | +import cloud.katta.client.model.S3STORAGECLASSES; |
| 18 | +import cloud.katta.client.model.StorageProfileS3STSDto; |
| 19 | + |
| 20 | +import static org.mockito.ArgumentMatchers.any; |
| 21 | +import static org.mockito.Mockito.times; |
| 22 | + |
| 23 | +class StorageProfileAwsStsSetupTest { |
| 24 | + @Test |
| 25 | + public void testCall() throws ApiException { |
| 26 | + final StorageProfileResourceApi api = Mockito.mock(StorageProfileResourceApi.class); |
| 27 | + final UUID vaultId = UUID.randomUUID(); |
| 28 | + final StorageProfileAwsStsSetup cli = new StorageProfileAwsStsSetup(); |
| 29 | + cli.bucketPrefix = "fancy"; |
| 30 | + cli.rolePrefix = "arn:aws:iam::1234:role/testing.katta.cloud-kc-realms-pepper"; |
| 31 | + cli.call(vaultId, api); |
| 32 | + |
| 33 | + final StorageProfileS3STSDto dto = new StorageProfileS3STSDto(); |
| 34 | + dto.setId(vaultId); |
| 35 | + dto.setName("AWS S3 STS"); |
| 36 | + dto.setProtocol(Protocol.S3_STS); |
| 37 | + dto.setArchived(false); |
| 38 | + dto.setScheme("https"); |
| 39 | + dto.setPort(443); |
| 40 | + dto.setWithPathStyleAccessEnabled(false); |
| 41 | + dto.setStorageClass(S3STORAGECLASSES.STANDARD); |
| 42 | + dto.setRegion("eu-west-1"); |
| 43 | + dto.setRegions(Arrays.asList("eu-west-1", "eu-west-2", "eu-west-3")); |
| 44 | + dto.bucketPrefix("fancy"); |
| 45 | + dto.stsRoleArnClient("arn:aws:iam::1234:role/testing.katta.cloud-kc-realms-pepper-createbucket"); |
| 46 | + dto.stsRoleArnHub("arn:aws:iam::1234:role/testing.katta.cloud-kc-realms-pepper-createbucket"); |
| 47 | + dto.setBucketEncryption(S3SERVERSIDEENCRYPTION.NONE); |
| 48 | + dto.stsRoleArn("arn:aws:iam::1234:role/testing.katta.cloud-kc-realms-pepper-sts-chain-01"); |
| 49 | + dto.stsRoleArn2("arn:aws:iam::1234:role/testing.katta.cloud-kc-realms-pepper-sts-chain-02"); |
| 50 | + Mockito.verify(api, times(1)).apiStorageprofileS3stsPut(dto); |
| 51 | + Mockito.verify(api, times(1)).apiStorageprofileS3stsPut(any()); |
| 52 | + } |
| 53 | +} |
0 commit comments