本文整理汇总了Java中com.hazelcast.config.AwsConfig.setIamRole方法的典型用法代码示例。如果您正苦于以下问题:Java AwsConfig.setIamRole方法的具体用法?Java AwsConfig.setIamRole怎么用?Java AwsConfig.setIamRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hazelcast.config.AwsConfig
的用法示例。
在下文中一共展示了AwsConfig.setIamRole方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAwsClient_getEndPoint
import com.hazelcast.config.AwsConfig; //导入方法依赖的package包/类
@Test
public void testAwsClient_getEndPoint() {
AwsConfig awsConfig = new AwsConfig();
awsConfig.setIamRole("test");
AWSClient awsClient = new AWSClient(awsConfig);
assertEquals("ec2.us-east-1.amazonaws.com", awsClient.getEndpoint());
}
示例2: testAwsClient_withDifferentHostHeader
import com.hazelcast.config.AwsConfig; //导入方法依赖的package包/类
@Test
public void testAwsClient_withDifferentHostHeader() {
AwsConfig awsConfig = new AwsConfig();
awsConfig.setIamRole("test");
awsConfig.setHostHeader("ec2.amazonaws.com.cn");
awsConfig.setRegion("cn-north-1");
AWSClient awsClient = new AWSClient(awsConfig);
assertEquals("ec2.cn-north-1.amazonaws.com.cn", awsClient.getEndpoint());
}
示例3: testAwsClient_withInvalidHostHeader
import com.hazelcast.config.AwsConfig; //导入方法依赖的package包/类
@Test(expected = InvalidConfigurationException.class)
public void testAwsClient_withInvalidHostHeader() {
AwsConfig awsConfig = new AwsConfig();
awsConfig.setIamRole("test");
awsConfig.setHostHeader("ec3.amazonaws.com.cn");
new AWSClient(awsConfig);
}
示例4: test_whenIamRoleExistsInConfig
import com.hazelcast.config.AwsConfig; //导入方法依赖的package包/类
@Test
public void test_whenIamRoleExistsInConfig() throws IOException {
final String someRole = "someRole";
final String uri = INSTANCE_METADATA_URI + IAM_SECURITY_CREDENTIALS_URI + someRole;
// some dummy creds. Look real, but they aren't.
final String accessKeyId = "ASIAJDOR231233BVE7GQ";
final String secretAccessKey = "QU5mTd40xnAbC5Mz2T3Fy7afQVrow+/tYq5GXMf7";
final String token = "FQoDYXdzEKX//////////wEaDN2Xh+ekVbV1KJrCqCK3A/Quuw8xCdZZbOPjzKLNc89n72z61BLt96hzlxTV6Vx1hDXLQNWRIx07hZVgmgGzzyr0DzYAcqKq7s2GUznWlaXhGHxhyo4nJUeBFbLyYPjbDAcnl84HItjy5bvtQ6fbDM7h2ZGuJrHi51KAhxWN/uEHyBKAIJd5RdXxVH4UTNxJFiqEw8GdaXDGK07186TfqSFCdlG+rhL35bN7WcJZuykIpynbeQpPeY4rJ0WJGoSJwt/RSkGwP+JRcYmv8Y7L1uSD2spJWO6etFeyyU63y0BL42MXWL38SQypxjLz+s1PozSDrV7zxsp4DQONn+adbSyAoveskD3xtDYsip1Ra0UCSYNKzmmh2XXF4fBBb6EPRixc1fnCIVDp0rfyCGO0VMuIloF5nWP9XsaRcR1mbJ7K/TuWgugduRBgyV2s1KgJuPni5cZ6ptEkPBb2b+92DjxEdQCAi6+WAdWliFiJ/P3T+qSJGLaxAeu0P0yb8E2xfCjEH6qOH3EM0KfgyJM5WJbXlYZTOZZXHaj26rlhe2k3wdL+UXf4geAzczphyOyp4QIGqaxe0xj08BKvSqngQb5X44oVR40oi7fOvwU=";
final String someDummyIamRole =
" {\n" +
" \"Code\" : \"Success\",\n" +
" \"LastUpdated\" : \"2016-10-04T12:08:24Z\",\n" +
" \"Type\" : \"AWS-HMAC\",\n" +
" \"AccessKeyId\" : \"" + accessKeyId + "\",\n" +
" \"SecretAccessKey\" : \"" + secretAccessKey + "\",\n" +
" \"Token\" : \"" + token + "\",\n" +
" \"Expiration\" : \"2016-10-04T18:19:39Z\"\n" +
" }\n";
AwsConfig awsConfig = new AwsConfig();
awsConfig.setIamRole(someRole);
DescribeInstances descriptor = spy(new DescribeInstances(awsConfig));
doReturn(someDummyIamRole).when(descriptor).retrieveRoleFromURI(uri);
descriptor.fillKeysFromIamRoles();
Assert.assertEquals("Could not parse access key from IAM role", accessKeyId, awsConfig.getAccessKey());
Assert.assertEquals("Could not parse secret key from IAM role", secretAccessKey, awsConfig.getSecretKey());
}