CreateTestUser() public method

public CreateTestUser ( ) : string
return string
示例#1
0
        public async Task TestCreateAccessKey()
        {
            using (var session = new IAMTestSession("TestCreateAccessKey", Client))
            {
                string username = session.CreateTestUser();
                string keyId    = null;
                try
                {
                    CreateAccessKeyResponse response =
                        await Client.CreateAccessKeyAsync(new CreateAccessKeyRequest()
                    {
                        UserName = username
                    });

                    keyId = response.AccessKey.AccessKeyId;
                    Assert.True(response.AccessKey.CreateDate.Date.CompareTo(DateTime.Now.Date) == 0);
                }
                finally
                {
                    if (keyId != null)
                    {
                        await Client.DeleteAccessKeyAsync(new DeleteAccessKeyRequest()
                        {
                            UserName = username, AccessKeyId = keyId
                        });
                    }
                }
            }
        }
示例#2
0
        public async Task TestDeleteAccessKey()
        {
            using (var session = new IAMTestSession("TestDeleteAccessKey", Client))
            {
                string   username = session.CreateTestUser();
                string[] keyIds   = new string[2];

                for (int i = 0; i < 2; i++)
                {
                    CreateAccessKeyResponse response =
                        await Client.CreateAccessKeyAsync(new CreateAccessKeyRequest()
                    {
                        UserName = username
                    });

                    keyIds[i] = response.AccessKey.AccessKeyId;
                }

                ListAccessKeysResponse lakRes =
                    await Client.ListAccessKeysAsync(new ListAccessKeysRequest()
                {
                    UserName = username
                });

                Assert.Equal(2, lakRes.AccessKeyMetadata.Count());

                await Client.DeleteAccessKeyAsync(new DeleteAccessKeyRequest()
                {
                    UserName = username, AccessKeyId = keyIds[0]
                });

                lakRes = await Client.ListAccessKeysAsync(new ListAccessKeysRequest()
                {
                    UserName = username
                });

                Assert.Equal(1, lakRes.AccessKeyMetadata.Count());
                Assert.Equal(keyIds[1], lakRes.AccessKeyMetadata[0].AccessKeyId);
            }
        }
示例#3
0
        public async Task TestListAccessKeys()
        {
            using (var session = new IAMTestSession("TestListAccessKeys", Client))
            {
                string   username = session.CreateTestUser();
                string[] keyIds   = new string[2];

                for (int i = 0; i < 2; i++)
                {
                    CreateAccessKeyResponse response =
                        await Client.CreateAccessKeyAsync(new CreateAccessKeyRequest()
                    {
                        UserName = username
                    });

                    keyIds[i] = response.AccessKey.AccessKeyId;
                }

                ListAccessKeysResponse listRes =
                    await Client.ListAccessKeysAsync(new ListAccessKeysRequest()
                {
                    UserName = username
                });

                int matches = 0;
                foreach (AccessKeyMetadata akm in listRes.AccessKeyMetadata)
                {
                    if (akm.AccessKeyId.Equals(keyIds[0]))
                    {
                        matches |= 1;
                    }
                    if (akm.AccessKeyId.Equals(keyIds[1]))
                    {
                        matches |= 2;
                    }
                }
                Assert.Equal(3, matches);
            }
        }
示例#4
0
        public async Task TestDeleteNonExistentAccessKeyException()
        {
            using (var session = new IAMTestSession("TestDeleteNonExistentAccessKeyException", Client))
            {
                string username = session.CreateTestUser();

                CreateAccessKeyResponse response = await Client.CreateAccessKeyAsync(new CreateAccessKeyRequest()
                {
                    UserName = username
                });

                string keyId = response.AccessKey.AccessKeyId;
                await Client.DeleteAccessKeyAsync(new DeleteAccessKeyRequest()
                {
                    UserName = username, AccessKeyId = keyId
                });

                await Assert.ThrowsAsync <NoSuchEntityException>(() => Client.DeleteAccessKeyAsync(new DeleteAccessKeyRequest()
                {
                    UserName = username, AccessKeyId = keyId
                }));
            }
        }