コード例 #1
0
        public async Task CreatePolicyAsyncTest()
        {
            // Create a policy with permissions to list Amazon S3 buckets
            var policy = await IAM_Basics.CreatePolicyAsync(Client, S3PolicyName, testPolicyDocument);

            Assert.Equal(policy.PolicyName, S3PolicyName);
            TestPolicy = policy;
        }
コード例 #2
0
        public async Task CreateUserAsyncTest()
        {
            var user = await IAM_Basics.CreateUserAsync(Client, UserName);

            Assert.NotNull(user);
            Assert.Equal(user.UserName, UserName);
            UserArn = user.Arn;
        }
コード例 #3
0
        public async Task CreateAccessKeyAsyncTest()
        {
            var accessKey = await IAM_Basics.CreateAccessKeyAsync(Client, UserName);

            Assert.NotNull(accessKey);

            // Save the key values for use with other tests.
            AccessKeyId = accessKey.AccessKeyId;
            SecretKey   = accessKey.SecretAccessKey;
        }
コード例 #4
0
        public async Task CreateRoleAsyncTest()
        {
            string testAssumeRolePolicy = "{" +
                                          "\"Version\": \"2012-10-17\"," +
                                          "\"Statement\": [{" +
                                          "\"Effect\": \"Allow\"," +
                                          "\"Principal\": {" +
                                          $"	\"AWS\": \"{UserArn}\""+
                                          "}," +
                                          "\"Action\": \"sts:AssumeRole\"" +
                                          "}]" +
                                          "}";

            // Create the role to allow listing the Amazon Simple Storage Service
            // (Amazon S3) buckets. Role names are not case sensitive and must
            // be unique to the account for which it is created.
            var role = await IAM_Basics.CreateRoleAsync(Client, RoleName, testAssumeRolePolicy);

            var roleArn = role.Arn;

            Assert.NotNull(role);
            Assert.Equal(role.RoleName, RoleName);
        }
コード例 #5
0
 public async Task AttachRoleAsyncTest()
 {
     // Attach the policy to the role we created earlier.
     await IAM_Basics.AttachRoleAsync(Client, TestPolicy.Arn, RoleName);
 }
コード例 #6
0
 public void DeleteResourcesTest()
 {
     // Delete all the resources created for the various tests.
     var success = IAM_Basics.DeleteResourcesAsync(Client, AccessKeyId, UserName, TestPolicy.Arn, RoleName);
 }