Skip to content

Commit e0d119d

Browse files
committed
Add IT for storageProfileAWSSTS command.
1 parent 2b2e650 commit e0d119d

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright (c) 2025 shift7 GmbH. All rights reserved.
3+
*/
4+
5+
package cloud.katta.cli.commands.setup;
6+
7+
import ch.cyberduck.core.PasswordStoreFactory;
8+
9+
import org.junit.jupiter.api.Test;
10+
11+
import java.util.Arrays;
12+
import java.util.Optional;
13+
import java.util.UUID;
14+
15+
import cloud.katta.cli.KattaSetupCli;
16+
import cloud.katta.client.api.StorageProfileResourceApi;
17+
import cloud.katta.client.model.Protocol;
18+
import cloud.katta.client.model.S3SERVERSIDEENCRYPTION;
19+
import cloud.katta.client.model.S3STORAGECLASSES;
20+
import cloud.katta.client.model.StorageProfileDto;
21+
import cloud.katta.client.model.StorageProfileS3STSDto;
22+
import cloud.katta.testcontainers.AbtractAdminCliIT;
23+
import picocli.CommandLine;
24+
25+
import static org.junit.jupiter.api.Assertions.*;
26+
27+
class StorageProfileAwsStsSetupIT extends AbtractAdminCliIT {
28+
29+
@Test
30+
public void testStorageProfileAwsStsSetup() throws Exception {
31+
final String accessToken = PasswordStoreFactory.get().findOAuthTokens(hubSession.getHost()).getAccessToken();
32+
final UUID storageProfileId = UUID.randomUUID();
33+
int rc = new CommandLine(new KattaSetupCli()).execute(
34+
"storageProfileAWSSTS",
35+
"--hubUrl", "http://localhost:8280",
36+
"--accessToken", accessToken,
37+
"--uuid", storageProfileId.toString(),
38+
"--rolePrefix", "arn:aws:iam::linguine:role/farfalle"
39+
);
40+
assertEquals(0, rc);
41+
final StorageProfileResourceApi storageProfileResourceApi = new StorageProfileResourceApi(hubSession.getClient());
42+
Optional<StorageProfileDto> profile = storageProfileResourceApi.apiStorageprofileGet(null).stream()
43+
.filter(p -> p.getActualInstance() instanceof StorageProfileS3STSDto)
44+
.filter(p -> p.getStorageProfileS3STSDto().getId().equals(storageProfileId)).findFirst();
45+
assertTrue(profile.isPresent());
46+
final StorageProfileS3STSDto dto = profile.get().getStorageProfileS3STSDto();
47+
assertEquals("AWS S3 STS", dto.getName());
48+
assertEquals(Protocol.S3_STS, dto.getProtocol());
49+
assertFalse(dto.getArchived());
50+
assertEquals("AWS S3 STS", dto.getName());
51+
assertEquals("https", dto.getScheme());
52+
assertNull(dto.getHostname());
53+
assertEquals(443, dto.getPort());
54+
assertFalse(dto.getWithPathStyleAccessEnabled());
55+
assertEquals(S3STORAGECLASSES.STANDARD, dto.getStorageClass());
56+
assertEquals("eu-west-1", dto.getRegion());
57+
assertEquals(Arrays.asList("eu-west-1", "eu-west-2", "eu-west-3"), dto.getRegions());
58+
assertEquals("katta", dto.getBucketPrefix());
59+
assertEquals("katta", dto.getBucketPrefix());
60+
assertEquals("arn:aws:iam::linguine:role/farfalle-createbucket", dto.getStsRoleArnClient());
61+
assertEquals("arn:aws:iam::linguine:role/farfalle-createbucket", dto.getStsRoleArnHub());
62+
assertNull(dto.getStsEndpoint());
63+
assertTrue(dto.getBucketVersioning());
64+
assertNull(dto.getBucketAcceleration());
65+
assertEquals(S3SERVERSIDEENCRYPTION.NONE, dto.getBucketEncryption());
66+
assertEquals("arn:aws:iam::linguine:role/farfalle-sts-chain-01", dto.getStsRoleArn());
67+
assertEquals("arn:aws:iam::linguine:role/farfalle-sts-chain-02", dto.getStsRoleArn2());
68+
assertNull(dto.getStsDurationSeconds());
69+
}
70+
}

0 commit comments

Comments
 (0)