Skip to content

Commit c624b78

Browse files
committed
Add storage profile AWS STS setup test.
1 parent 7135566 commit c624b78

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

admin-cli/src/main/java/cloud/katta/cli/commands/setup/StorageProfileAwsStsSetup.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ public class StorageProfileAwsStsSetup extends AbstractStorageProfile {
3939
protected void call(final UUID uuid, final ApiClient apiClient) throws ApiException {
4040
final StorageProfileResourceApi storageProfileResourceApi = new StorageProfileResourceApi(apiClient);
4141

42+
call(uuid, storageProfileResourceApi);
43+
}
44+
45+
protected void call(UUID uuid, StorageProfileResourceApi storageProfileResourceApi) throws ApiException {
4246
storageProfileResourceApi.apiStorageprofileS3stsPut(new StorageProfileS3STSDto()
4347
.id(uuid)
4448
.name("AWS S3 STS")
@@ -58,7 +62,6 @@ protected void call(final UUID uuid, final ApiClient apiClient) throws ApiExcept
5862
// arn:aws:iam::XXXXXXX:role/testing.katta.cloud-kc-realms-tamarind-createbucket
5963
.stsRoleArnClient(String.format("%s-createbucket", rolePrefix))
6064
.stsRoleArnHub(String.format("%s-createbucket", rolePrefix))
61-
6265
.scheme("https")
6366
.port(443)
6467
);
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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 proxyMock = 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, proxyMock);
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(proxyMock, times(1)).apiStorageprofileS3stsPut(dto);
51+
Mockito.verify(proxyMock, times(1)).apiStorageprofileS3stsPut(any());
52+
}
53+
}

0 commit comments

Comments
 (0)