diff --git a/generator/.DevConfigs/72442c5a-03b6-40bf-a34e-4d9621624a42.json b/generator/.DevConfigs/72442c5a-03b6-40bf-a34e-4d9621624a42.json new file mode 100644 index 000000000000..21f1fcd66dbb --- /dev/null +++ b/generator/.DevConfigs/72442c5a-03b6-40bf-a34e-4d9621624a42.json @@ -0,0 +1,9 @@ +{ + "core": { + "updateMinimum": false, + "type": "Patch", + "changeLogMessages": [ + "Placeholder file for dry-run" + ] + } +} \ No newline at end of file diff --git a/sdk/test/IntegrationTests/MediaStoreData/IntegrationTests/MediaStoreData.cs b/sdk/test/IntegrationTests/MediaStoreData/IntegrationTests/MediaStoreData.cs deleted file mode 100644 index e922923cb266..000000000000 --- a/sdk/test/IntegrationTests/MediaStoreData/IntegrationTests/MediaStoreData.cs +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). - * You may not use this file except in compliance with the License. - * A copy of the License is located at - * - * http://aws.amazon.com/apache2.0 - * - * or in the "license" file accompanying this file. This file is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. See the License for the specific language governing - * permissions and limitations under the License. - */ -using System; -using System.IO; -using System.Net; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Amazon.MediaStore; -using Amazon.MediaStore.Model; -using Amazon.MediaStoreData; -using Amazon.MediaStoreData.Model; -using AWSSDK_DotNet.IntegrationTests.Utils; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using ContainerNotFoundException = Amazon.MediaStore.Model.ContainerNotFoundException; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - /// - /// Tests for AWS MediaStoreData service - /// - [TestClass] - public class MediaStoreData : TestBase - { - /// - /// Name of the container that we want to create in AWS MediaStore Data - /// - private const string ContainerName = "TestContainerNetStandard"; - /// - /// Object Path of the object that we want to create in AWS MediaStore Data - /// - private const string ObjectPath = "TestNetStandard"; - /// - /// Timeout for when a test to fail (in seconds) - /// - private const int TestTimeout = 300; - - /// - /// Creates a container in AWS MediaStore Data - /// - [TestInitialize] - public void Init() - { - UtilityMethods.WaitUntilSuccess(() => - { - // AWS Media Store requires a container in order to call PutObject - CreateContainer(ContainerName); - }); - } - - /// - /// Deletes created container - /// - [TestCleanup] - public void Cleanup() - { - UtilityMethods.WaitUntilSuccess(() => - { - // Delete the created container - DeleteContainer(ContainerName); - }); - } - - /// - /// Compresses a payload of type stream of a request using compression while calling . - /// - [Ignore("This test is currently turned off because at the time it was written, the models for this service" + - " did not have compression traits required to compress the payload of the request. We added those traits manually" + - " in the model and ran those tests to make sure that request compression feature works for streams.")] - [TestMethod] - [TestCategory("MediaStoreData")] - public void PutObjectTest() - { - UtilityMethods.WaitUntilException(() => - { - // Get endpoint Url of the created container - var endpoint = GetEndpointUrl(ContainerName); - - var config = new AmazonMediaStoreDataConfig - { - ServiceURL = endpoint, - DisableRequestCompression = false // Make sure that this flag is false in order to compress the stream - }; - - using (var client = new AmazonMediaStoreDataClient(config)) - { - var putObjectRequest = new PutObjectRequest - { - Path = ObjectPath, - Body = new MemoryStream(Encoding.UTF8.GetBytes("Testing 123")), // We are passing a stream to the payload - ContentType = "application/octet-stream" - }; - - // Upload the file to AWS MediaStore Data - var response = client.PutObject(putObjectRequest); - - Assert.AreEqual(HttpStatusCode.OK, response.HttpStatusCode); - - WaitForObjectToBeListed(client); - } - }, 5, TestTimeout); - } - - /// - /// Creates a container with name if it doesn't already exist. - /// - /// Name of the container that we want to delete - private void CreateContainer(string containerName) - { - var client = new AmazonMediaStoreClient(); - // Wait until an existing container has been deleted - var containerStatus = WaitUntilDescribeContainerConditionMet(client, containerName, (status) => status != ContainerStatus.DELETING, "Container is ready to use!"); - // Create a container only if it doesn't already exist - if (containerStatus == null || containerStatus != ContainerStatus.ACTIVE) - { - var containerRequest = new CreateContainerRequest() - { - ContainerName = containerName, - }; - - client.CreateContainer(containerRequest); - // Wait until container's status is set to active - WaitUntilDescribeContainerConditionMet(client, containerName, (status) => status == ContainerStatus.ACTIVE, "Container is ready to use!"); - } - } - - /// - /// Delete container given - /// - /// Name of the container that we want to delete - private void DeleteContainer(string containerName) - { - var endpoint = GetEndpointUrl(ContainerName); - - using (var client = new AmazonMediaStoreDataClient(endpoint)) - { - // Delete the objects (files) in the container - var listObjectsResponse = client.ListItems(new ListItemsRequest()); - - foreach (var item in listObjectsResponse.Items) - { - client.DeleteObject(new DeleteObjectRequest - { - Path = item.Name, - }); - - } - - var areObjectsDeleted = false; - // Wait for all objects to be deleted - do - { - var listItemsResponse = client.ListItems(new ListItemsRequest()); - var remainingObjects = listItemsResponse.Items; - - // Check if there are any objects left in the container - if (remainingObjects.Count == 0) - { - areObjectsDeleted = true; - Console.WriteLine("All objects in the container are deleted."); - } - else - { - // Sleep for a few seconds before checking again - Thread.Sleep(5000); - } - } while (!areObjectsDeleted); - } - - using (var client = new AmazonMediaStoreClient()) - { - var containerRequest = new DeleteContainerRequest() - { - ContainerName = containerName, - }; - - client.DeleteContainer(containerRequest); - } - } - - /// - /// Get endpoint Url based off - /// - /// Endpoint Url of the container holding this name - /// Endpoint url of the container - private string GetEndpointUrl(string containerName) - { - using (var client = new AmazonMediaStoreClient()) - { - var containerRequest = new DescribeContainerRequest() - { - ContainerName = containerName, - }; - - DescribeContainerResponse describeContainerResponse; - describeContainerResponse = client.DescribeContainer(containerRequest); - - return describeContainerResponse.Container.Endpoint; - } - } - - - // Define a delegate for the condition - delegate bool ConditionCheck(ContainerStatus containerStatus); - - /// - /// Call and wait until condition is met or an exception has been thrown - /// - /// client - /// Container name - /// When this condition is met, we stop calling - /// Console message for when the condiiton is met - /// Status of the container or null if an exception was thrown - private ContainerStatus WaitUntilDescribeContainerConditionMet(AmazonMediaStoreClient client, string containerName, ConditionCheck conditionCheck, string successMessage) - { - bool isConditionMet = false; - - do - { - try - { - var describeContainerResponse = client.DescribeContainer(new DescribeContainerRequest() - { - ContainerName = containerName - }); - - var containerStatus = describeContainerResponse.Container.Status; - - // Check if the specified condition is met - if (conditionCheck(containerStatus)) - { - isConditionMet = true; - Console.WriteLine(successMessage); - return containerStatus; - } - else - { - // Sleep for a few seconds before checking the status again - Thread.Sleep(5000); - } - } - // We don't have an existing container - catch (ContainerNotFoundException e) - { - Console.WriteLine(e); - return null; - } - } while (!isConditionMet); - - return null; - } - - /// - /// Wait until objects are listed in the container - /// - /// client - private void WaitForObjectToBeListed(AmazonMediaStoreDataClient client) - { - var isObjectProcessing = true; - - do - { - // Call DescribeObject to get the object's processing status - var describeObjectRequest = new ListItemsRequest - { - Path = "" - }; - - try - { - var describeObjectResponse = client.ListItems(describeObjectRequest); - - - // Check if the processing status is "Completed" - if (describeObjectResponse?.Items != null) - { - foreach (var item in describeObjectResponse.Items) - { - if (item.Name.Equals(ObjectPath)) - { - isObjectProcessing = false; - Console.WriteLine("Object processing is complete."); - } - } - } - else - { - // Object is still processing, wait for the specified interval before retrying - Thread.Sleep(5000); - } - } - catch (Exception e) - { - throw e; - } - } while (isObjectProcessing); - } - } - } diff --git a/sdk/test/Services/APIGateway/IntegrationTests/APIGateway.cs b/sdk/test/Services/APIGateway/IntegrationTests/APIGateway.cs index 065218b6dd59..194b0a95ab4a 100644 --- a/sdk/test/Services/APIGateway/IntegrationTests/APIGateway.cs +++ b/sdk/test/Services/APIGateway/IntegrationTests/APIGateway.cs @@ -1,29 +1,23 @@ -using System; +using Amazon.APIGateway; +using Amazon.APIGateway.Model; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; using System.Collections.Generic; using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using AWSSDK_DotNet.IntegrationTests.Utils; - -using Amazon.AWSSupport; -using Amazon.AWSSupport.Model; -using Amazon; -using System.IO; -using System.Text; -using Amazon.APIGateway.Model; -using Amazon.APIGateway; +using System.Threading.Tasks; namespace AWSSDK_DotNet.IntegrationTests.Tests { [TestClass] - public class APIGatewayTests : TestBase + [TestCategory("APIGateway")] + public class APIGatewayTests : TestBase { [ClassCleanup] - public static void ClassCleanup() + public static async Task ClassCleanup() { if (!string.IsNullOrEmpty(restApiId)) { - Client.DeleteRestApi(new DeleteRestApiRequest + await Client.DeleteRestApiAsync(new DeleteRestApiRequest { RestApiId = restApiId }); @@ -38,12 +32,12 @@ public static void ClassCleanup() private static string apiDescription = "RestApi created by dotnet tests at " + timestamp; [ClassInitialize] - public static void ClassInitialize(TestContext testContext) + public static async Task ClassInitialize(TestContext testContext) { - var createRestApi = Client.CreateRestApi(new CreateRestApiRequest + var createRestApi = await Client.CreateRestApiAsync(new CreateRestApiRequest { Name = apiName, - Description = apiDescription + Description = apiDescription }); Assert.AreEqual(apiDescription, createRestApi.Description); Assert.AreEqual(apiName, createRestApi.Name); @@ -53,28 +47,28 @@ public static void ClassInitialize(TestContext testContext) } [TestMethod] - [TestCategory("APIGateWay")] - public void TestResources() + public async Task TestResources() { - var allResources = GetResources().ToList(); + var allResources = (await GetResources()).ToList(); var rootResource = allResources.SingleOrDefault(r => r.ParentId == null); Assert.IsNotNull(rootResource); var pathPart = "test"; - var resourceId = Client.CreateResource(new CreateResourceRequest + var createResponse = await Client.CreateResourceAsync(new CreateResourceRequest { RestApiId = restApiId, ParentId = rootResource.Id, PathPart = pathPart - }).Id; + }); - var resources = GetResources().ToList(); + var resourceId = createResponse.Id; + var resources = (await GetResources()).ToList(); var resource = resources.Single(r => r.Id == resourceId); Assert.AreEqual(pathPart, resource.PathPart); Assert.AreEqual(rootResource.Path + pathPart, resource.Path); Assert.AreEqual(2, resources.Count); - Client.PutMethod(new PutMethodRequest + await Client.PutMethodAsync(new PutMethodRequest { RestApiId = restApiId, ResourceId = resourceId, @@ -82,7 +76,7 @@ public void TestResources() HttpMethod = "PUT" }); - Client.PutIntegration(new PutIntegrationRequest + await Client.PutIntegrationAsync(new PutIntegrationRequest { RestApiId = restApiId, ResourceId = resourceId, @@ -93,37 +87,43 @@ public void TestResources() }); } - private IEnumerable GetResources() + private async Task> GetResources() { + var resources = new List(); var request = new GetResourcesRequest { RestApiId = restApiId }; + do { - var response = Client.GetResources(request); + var response = await Client.GetResourcesAsync(request); request.Position = response.Position; - foreach (var r in response.Items) - yield return r; + if (response.Items != null) + { + foreach (var r in response.Items) + { + resources.Add(r); + } + } } while (!string.IsNullOrEmpty(request.Position)); + return resources; } [TestMethod] - [TestCategory("APIGateWay")] - public void TestRestApiCalls() + public async Task TestRestApiCalls() { - var apis = GetRestApis().ToList(); + var apis = (await GetRestApis()).ToList(); var api = apis.Single(r => string.Equals(r.Id, restApiId)); Assert.IsNotNull(api); - AssertExtensions.ExpectException(() => Client.GetRestApi(new GetRestApiRequest - { - RestApiId = "fakeid" - })); + await Assert.ThrowsExceptionAsync(() => + Client.GetRestApiAsync(new GetRestApiRequest { RestApiId = "fakeid" }) + ); - var getRestApi = Client.GetRestApi(new GetRestApiRequest + var getRestApi = await Client.GetRestApiAsync(new GetRestApiRequest { RestApiId = restApiId }); @@ -133,7 +133,7 @@ public void TestRestApiCalls() Assert.AreNotEqual(DateTime.SpecifyKind(default, DateTimeKind.Utc), getRestApi.CreatedDate); var newDescription = "New description!"; - Client.UpdateRestApi(new UpdateRestApiRequest + await Client.UpdateRestApiAsync(new UpdateRestApiRequest { RestApiId = restApiId, PatchOperations = new List @@ -147,7 +147,7 @@ public void TestRestApiCalls() } }); - getRestApi = Client.GetRestApi(new GetRestApiRequest + getRestApi = await Client.GetRestApiAsync(new GetRestApiRequest { RestApiId = restApiId }); @@ -156,7 +156,7 @@ public void TestRestApiCalls() Assert.IsFalse(string.IsNullOrEmpty(getRestApi.Id)); Assert.AreNotEqual(DateTime.SpecifyKind(default, DateTimeKind.Utc), getRestApi.CreatedDate); - Client.UpdateRestApi(new UpdateRestApiRequest + await Client.UpdateRestApiAsync(new UpdateRestApiRequest { RestApiId = restApiId, PatchOperations = new List @@ -171,32 +171,39 @@ public void TestRestApiCalls() }); } - private IEnumerable GetRestApis() + private async Task> GetRestApis() { + var apis = new List(); var request = new GetRestApisRequest { Limit = 1 }; do { - var response = Client.GetRestApis(request); + var response = await Client.GetRestApisAsync(request); request.Position = response.Position; - foreach (var r in response.Items) - yield return r; + + if (response.Items != null) + { + foreach (var r in response.Items) + { + apis.Add(r); + } + } } while (!string.IsNullOrEmpty(request.Position)); + return apis; } [TestMethod] - [TestCategory("APIGateWay")] - public void TestOtherOperations() + public async Task TestOtherOperations() { - var account = Client.GetAccount(new GetAccountRequest()); + var account = await Client.GetAccountAsync(new GetAccountRequest()); Assert.IsNotNull(account); Assert.IsNotNull(account.ThrottleSettings); Assert.AreNotEqual(0, account.ThrottleSettings.BurstLimit); Assert.AreNotEqual(0, account.ThrottleSettings.RateLimit); - var allCerts = GetAllCerts().ToList(); - + var allCerts = (await GetAllCerts()).ToList(); var certDescription = "something"; - var clientCert = Client.GenerateClientCertificate(new GenerateClientCertificateRequest + + var clientCert = await Client.GenerateClientCertificateAsync(new GenerateClientCertificateRequest { Description = certDescription }); @@ -208,25 +215,33 @@ public void TestOtherOperations() Assert.IsFalse(string.IsNullOrEmpty(clientCert.PemEncodedCertificate)); Assert.IsFalse(string.IsNullOrEmpty(clientCert.ClientCertificateId)); - var updatedCerts = GetAllCerts().ToList(); + var updatedCerts = (await GetAllCerts()).ToList(); Assert.AreNotEqual(allCerts.Count, updatedCerts.Count); - Client.DeleteClientCertificate(new DeleteClientCertificateRequest + await Client.DeleteClientCertificateAsync(new DeleteClientCertificateRequest { ClientCertificateId = clientCert.ClientCertificateId }); } - private static IEnumerable GetAllCerts() + private static async Task> GetAllCerts() { + var certificates = new List(); var request = new GetClientCertificatesRequest(); do { - var response = Client.GetClientCertificates(request); + var response = await Client.GetClientCertificatesAsync(request); request.Position = response.Position; - foreach (var cert in response.Items) - yield return cert; + + if (response.Items != null) + { + foreach (var cert in response.Items) + { + certificates.Add(cert); + } + } } while (!string.IsNullOrEmpty(request.Position)); + return certificates; } } } diff --git a/sdk/test/Services/AWSMarketplaceCommerceAnalytics/IntegrationTests/AWSMarketplaceCommerceAnalytics.cs b/sdk/test/Services/AWSMarketplaceCommerceAnalytics/IntegrationTests/AWSMarketplaceCommerceAnalytics.cs deleted file mode 100644 index 1589fa750a4d..000000000000 --- a/sdk/test/Services/AWSMarketplaceCommerceAnalytics/IntegrationTests/AWSMarketplaceCommerceAnalytics.cs +++ /dev/null @@ -1,186 +0,0 @@ - -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Amazon.AWSMarketplaceCommerceAnalytics; -using Amazon.AWSMarketplaceCommerceAnalytics.Model; -using Amazon.IdentityManagement; -using Amazon.IdentityManagement.Model; -using Amazon.SimpleNotificationService; -using Amazon.SimpleNotificationService.Model; -using Amazon.S3; -using Amazon.S3.Model; -using System; -using AWSSDK_DotNet.IntegrationTests.Utils; - - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class AWSMarketplaceCommerceAnalytics : TestBase - { - // You need to set the ExternalId provided by the service for your account before you can run the test. - const string ExternalId = ""; - - static string TrustPolicy = - @"{ - ""Version"": ""2012-10-17"", - ""Statement"": [ - { - ""Sid"": """", - ""Effect"": ""Allow"", - ""Principal"": { - ""AWS"": ""arn:aws:iam::452565589796:root"" - }, - ""Action"": ""sts:AssumeRole"", - ""Condition"": { - ""StringEquals"": { - ""sts:ExternalId"": """ + ExternalId + @""" - } - } - } - ] - }"; - - static string AccessPolicy = - @"{ - ""Version"": ""2012-10-17"", - ""Statement"": [ - { - ""Sid"": ""1"", - ""Effect"": ""Allow"", - ""Action"": [ - ""s3:PutObject"", - ""s3:GetBucketLocation"" - ], - ""Resource"": [ - ""*"" - ] - }, - { - ""Sid"": ""2"", - ""Effect"": ""Allow"", - ""Action"": [ - ""sns:Publish"", - ""sns:GetTopicAttributes"" - ], - ""Resource"": [ - ""*"" - ] - }, - { - ""Sid"": ""3"", - ""Effect"": ""Allow"", - ""Action"": [ - ""iam:GetRolePolicy"" - ], - ""Resource"": [ - ""*"" - ] - } - ] - }"; - - // This test needs account specific details. - // You need to set the ExternalId provided by the service for your account before you can run the test. - //[TestMethod] - [TestCategory("AWSMarketplaceCommerceAnalytics")] - public void GenerateDatasetTest() - { - var iamClient = new AmazonIdentityManagementServiceClient(); - var snsClient = new AmazonSimpleNotificationServiceClient(); - var s3Client = new AmazonS3Client(); - - string bucketName = null; - string topicArn = null; - Role role = null; - try - { - bucketName = UtilityMethods.GenerateName("GenerateDatasetTestBucket"); - s3Client.PutBucket(bucketName); - - var roleName = UtilityMethods.GenerateName("GenerateDatasetTestRole"); - var policyName = "MarketplacePolicy"; - // Create a role with trust policy - role = iamClient.CreateRole(new CreateRoleRequest - { - RoleName = roleName, - AssumeRolePolicyDocument = TrustPolicy - }).Role; - - // Set access policy - iamClient.PutRolePolicy(new PutRolePolicyRequest - { - RoleName = roleName, - PolicyDocument = AccessPolicy, - PolicyName = policyName - }); - - var snsTopicName = UtilityMethods.GenerateName("GenerateDatasetTestTopic"); - topicArn = snsClient.CreateTopic(snsTopicName).TopicArn; - - // Throws an error as this account does not have any reports - Utils.AssertExtensions.ExpectException - ( () => - Client.GenerateDataSet(new GenerateDataSetRequest - { - DataSetPublicationDate = DateTime.UtcNow, - DataSetType = DataSetType.DailyBusinessFees, - DestinationS3BucketName = bucketName, - SnsTopicArn = topicArn, - RoleNameArn = role.Arn - }) - ); - } - finally - { - s3Client.DeleteBucket(bucketName); - - if (role!=null) - { - iamClient.DeleteRolePolicy(new DeleteRolePolicyRequest - { - PolicyName = "MarketplacePolicy", - RoleName = role.RoleName - }); - - iamClient.DeleteRole(new DeleteRoleRequest - { - RoleName = role.RoleName - }); - } - - if (topicArn !=null) - { - snsClient.DeleteTopic(topicArn); - } - } - } - - [TestMethod] - [TestCategory("AWSMarketplaceCommerceAnalytics")] - public void TestInvalidInputs() - { - // Do not pass destination bucket, role ARN and SNS topic ARN. - Utils.AssertExtensions.ExpectException - (() => - Client.GenerateDataSet(new GenerateDataSetRequest - { - DataSetPublicationDate = DateTime.UtcNow, - DataSetType = DataSetType.DailyBusinessFees - }) - ); - - // Pass invalid ARN values - Utils.AssertExtensions.ExpectException - ( ()=> - Client.GenerateDataSet(new GenerateDataSetRequest - { - DataSetPublicationDate = DateTime.UtcNow, - DataSetType = DataSetType.DailyBusinessFees, - DestinationS3BucketName = "randomBucket", - RoleNameArn = "invalidArn", - SnsTopicArn = "invalidArn" - }) - ); - } - } -} diff --git a/sdk/test/Services/AWSMarketplaceCommerceAnalytics/IntegrationTests/AWSSDK.IntegrationTests.AWSMarketplaceCommerceAnalytics.NetFramework.csproj b/sdk/test/Services/AWSMarketplaceCommerceAnalytics/IntegrationTests/AWSSDK.IntegrationTests.AWSMarketplaceCommerceAnalytics.NetFramework.csproj deleted file mode 100644 index 5f59f84455ad..000000000000 --- a/sdk/test/Services/AWSMarketplaceCommerceAnalytics/IntegrationTests/AWSSDK.IntegrationTests.AWSMarketplaceCommerceAnalytics.NetFramework.csproj +++ /dev/null @@ -1,51 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.AWSMarketplaceCommerceAnalytics.NetFramework - AWSSDK.IntegrationTests.AWSMarketplaceCommerceAnalytics.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/AWSMarketplaceCommerceAnalytics/IntegrationTests/Config/462/App.config b/sdk/test/Services/AWSMarketplaceCommerceAnalytics/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/AWSMarketplaceCommerceAnalytics/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/AWSSupport/IntegrationTests/AWSSDK.IntegrationTests.AWSSupport.NetFramework.csproj b/sdk/test/Services/AWSSupport/IntegrationTests/AWSSDK.IntegrationTests.AWSSupport.NetFramework.csproj deleted file mode 100644 index 3fd01929cf85..000000000000 --- a/sdk/test/Services/AWSSupport/IntegrationTests/AWSSDK.IntegrationTests.AWSSupport.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.AWSSupport.NetFramework - AWSSDK.IntegrationTests.AWSSupport.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/AWSSupport/IntegrationTests/AWSSupport.cs b/sdk/test/Services/AWSSupport/IntegrationTests/AWSSupport.cs deleted file mode 100644 index 3197083c918e..000000000000 --- a/sdk/test/Services/AWSSupport/IntegrationTests/AWSSupport.cs +++ /dev/null @@ -1,221 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using AWSSDK_DotNet.IntegrationTests.Utils; - -using Amazon.AWSSupport; -using Amazon.AWSSupport.Model; -using Amazon; -using System.IO; -using System.Text; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - [TestCategory("AWSSupport")] - public class AWSSupportTests : TestBase - { - private static String - SUBJECT = ".NET SDK Test Case " + DateTime.UtcNow.Ticks, - CATEGORY_CODE = "apis", - SERVICE_CODE = "amazon-dynamodb", - COMMUNICATION_BODY = "This is a test case generated by the .NET SDK integration test suite", - LANGUAGE = "ja", - SEVERITY_CODE = "low", - ATTACHMENT_CONTENTS = "This is test data"; - - [ClassCleanup] - public static void ClassCleanup() - { - BaseClean(); - } - - // Test are disabled because not all acounts are subscribed to AWS Support - // [TestMethod] - public void TestCaseOperations() - { - string caseId = null; - - try - { - caseId = Client.CreateCase(new CreateCaseRequest - { - Subject = SUBJECT, - CategoryCode = CATEGORY_CODE, - ServiceCode = SERVICE_CODE, - Language = LANGUAGE, - SeverityCode = SEVERITY_CODE, - CommunicationBody = COMMUNICATION_BODY - }).CaseId; - - Assert.IsNotNull(caseId); - - var cases = Client.DescribeCases(new DescribeCasesRequest { Language = LANGUAGE }).Cases; - Assert.IsTrue(cases.Count > 0); - - cases = Client.DescribeCases(new DescribeCasesRequest { Language = LANGUAGE, CaseIdList = new List { caseId } }).Cases; - Assert.AreEqual(1, cases.Count); - - Assert.AreEqual(caseId, cases[0].CaseId); - Assert.AreEqual(CATEGORY_CODE, cases[0].CategoryCode); - Assert.AreEqual(LANGUAGE, cases[0].Language); - Assert.AreEqual(SERVICE_CODE, cases[0].ServiceCode); - Assert.AreEqual(SEVERITY_CODE, cases[0].SeverityCode); - Assert.IsTrue(cases[0].RecentCommunications.Communications.Count > 0); - - var attachmentData = new MemoryStream(Encoding.UTF8.GetBytes(ATTACHMENT_CONTENTS)); - var filename = "file1.txt"; - var attachmentSetId = Client.AddAttachmentsToSet(new AddAttachmentsToSetRequest - { - Attachments = new List - { - new Attachment - { - FileName = filename, - Data = attachmentData - } - } - }).AttachmentSetId; - - var result = Client.AddCommunicationToCase(new AddCommunicationToCaseRequest - { - CaseId = caseId, - CcEmailAddresses = new List { "aws-dr-tools-test@amazon.com" }, - CommunicationBody = COMMUNICATION_BODY, - AttachmentSetId = attachmentSetId - }); - - Assert.IsNotNull(result); - - var comms = Client.DescribeCommunications(new DescribeCommunicationsRequest { CaseId = caseId }).Communications; - Assert.IsTrue(comms.Count > 0); - Assert.AreEqual(caseId, comms[0].CaseId); - Assert.AreEqual(COMMUNICATION_BODY.Trim(), comms[0].Body.Trim()); - Assert.IsNotNull(comms[0].SubmittedBy); - Assert.IsNotNull(comms[0].TimeCreated); - - string attachmentId = null; - attachmentId = GetAttachmentId(comms, attachmentId); - Assert.IsNotNull(attachmentId); - - VerifyAttachment(attachmentData, filename, attachmentId); - - cases = Client.DescribeCases(new DescribeCasesRequest { Language = LANGUAGE, CaseIdList = new List { caseId }, IncludeCommunications = true }).Cases; - Assert.AreEqual(1, cases.Count); - var communications = cases[0].RecentCommunications; - attachmentId = GetAttachmentId(communications.Communications, attachmentId); - VerifyAttachment(attachmentData, filename, attachmentId); - } - finally - { - if (caseId != null) - { - Client.ResolveCase(new ResolveCaseRequest { CaseId = caseId }); - } - } - } - - private static void VerifyAttachment(MemoryStream attachmentData, string filename, string attachmentId) - { - var attachment = Client.DescribeAttachment(new DescribeAttachmentRequest - { - AttachmentId = attachmentId - }).Attachment; - Assert.IsNotNull(attachment); - Assert.AreEqual( - Encoding.UTF8.GetString(attachmentData.ToArray()), - Encoding.UTF8.GetString(attachment.Data.ToArray())); - Assert.AreEqual(filename, attachment.FileName); - } - - private static string GetAttachmentId(List comms, string attachmentId) - { - foreach (var comm in comms) - { - var attachmentSet = comm.AttachmentSet; - if (attachmentSet != null && attachmentSet.Count > 0) - { - foreach (var att in attachmentSet) - { - if (!string.IsNullOrEmpty(att.AttachmentId)) - attachmentId = att.AttachmentId; - } - } - } - return attachmentId; - } - - // Test are disabled because not all acounts are subscribed to AWS Support - // [TestMethod] - public void TestDescribeServices() - { - var services = Client.DescribeServices().Services; - Assert.IsTrue(services.Count > 0); - Assert.IsNotNull(services[0].Code); - Assert.IsNotNull(services[0].Name); - Assert.IsTrue(services[0].Categories.Count > 0); - Assert.IsNotNull(services[0].Categories[0].Code); - Assert.IsNotNull(services[0].Categories[0].Name); - - services = Client.DescribeServices(new DescribeServicesRequest { ServiceCodeList = new List { SERVICE_CODE } }).Services; - Assert.AreEqual(1, services.Count); - Assert.IsNotNull(services[0].Name); - Assert.AreEqual(SERVICE_CODE, services[0].Code); - } - - // Test are disabled because not all acounts are subscribed to AWS Support - // [TestMethod] - public void TestSeverityLevels() - { - var levels = Client.DescribeSeverityLevels().SeverityLevels; - Assert.IsTrue(levels.Count > 0); - Assert.IsNotNull(levels[0].Name); - Assert.IsNotNull(levels[0].Code); - } - - // Test are disabled because not all acounts are subscribed to AWS Support - // [TestMethod] - public void TestTrustedAdvisorChecks() - { - var checks = Client.DescribeTrustedAdvisorChecks(new DescribeTrustedAdvisorChecksRequest { Language = LANGUAGE }).Checks; - Assert.IsTrue(checks.Count > 0); - - var checkId = checks[0].Id; - Assert.IsNotNull(checks[0].Name); - Assert.IsNotNull(checks[0].Category); - Assert.IsNotNull(checks[0].Description); - Assert.IsTrue(checks[0].Metadata.Count > 0); - Assert.IsNotNull(checks[0].Metadata[0]); - - var statuses = Client.DescribeTrustedAdvisorCheckRefreshStatuses(new DescribeTrustedAdvisorCheckRefreshStatusesRequest { CheckIds = new List { checkId } }) - .Statuses; - - Assert.AreEqual(1, statuses.Count); - Assert.AreEqual(checkId, statuses[0].CheckId); - Assert.IsNotNull(statuses[0].Status); - Assert.IsNotNull(statuses[0].MillisUntilNextRefreshable); - - var status = Client.RefreshTrustedAdvisorCheck(new RefreshTrustedAdvisorCheckRequest { CheckId = checkId }).Status; - Assert.IsNotNull(status); - - var summaries = Client.DescribeTrustedAdvisorCheckSummaries(new DescribeTrustedAdvisorCheckSummariesRequest { CheckIds = new List { checkId } }) - .Summaries; - - Assert.AreEqual(1, summaries.Count); - Assert.AreEqual(checkId, summaries[0].CheckId); - Assert.IsNotNull(summaries[0].Status); - Assert.IsNotNull(summaries[0].Timestamp); - Assert.IsNotNull(summaries[0].ResourcesSummary); - Assert.IsNotNull(summaries[0].CategorySpecificSummary); - - var resultresult = Client.DescribeTrustedAdvisorCheckResult(new DescribeTrustedAdvisorCheckResultRequest { CheckId = checkId }) - .Result; - - Assert.IsNotNull(resultresult.Timestamp); - Assert.IsNotNull(resultresult.Status); - Assert.IsNotNull(resultresult.ResourcesSummary); - } - } -} diff --git a/sdk/test/Services/AWSSupport/IntegrationTests/Config/462/App.config b/sdk/test/Services/AWSSupport/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/AWSSupport/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/ApplicationDiscoveryService/IntegrationTests/AWSSDK.IntegrationTests.ApplicationDiscoveryService.NetFramework.csproj b/sdk/test/Services/ApplicationDiscoveryService/IntegrationTests/AWSSDK.IntegrationTests.ApplicationDiscoveryService.NetFramework.csproj deleted file mode 100644 index dec6d4c88fa3..000000000000 --- a/sdk/test/Services/ApplicationDiscoveryService/IntegrationTests/AWSSDK.IntegrationTests.ApplicationDiscoveryService.NetFramework.csproj +++ /dev/null @@ -1,51 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.ApplicationDiscoveryService.NetFramework - AWSSDK.IntegrationTests.ApplicationDiscoveryService.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/ApplicationDiscoveryService/IntegrationTests/ApplicationDiscoveryServiceTests.cs b/sdk/test/Services/ApplicationDiscoveryService/IntegrationTests/ApplicationDiscoveryServiceTests.cs deleted file mode 100644 index bb8c1ed48e97..000000000000 --- a/sdk/test/Services/ApplicationDiscoveryService/IntegrationTests/ApplicationDiscoveryServiceTests.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using AWSSDK_DotNet.IntegrationTests.Utils; - -using Amazon.Runtime; -using Amazon.ApplicationDiscoveryService; -using Amazon.ApplicationDiscoveryService.Model; -using Amazon; -using System.IO; -using System.Text; -using Amazon.APIGateway.Model; -using Amazon.APIGateway; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class ApplicationDiscoveryServiceTests : TestBase - { - [TestMethod] - [TestCategory("ApplicationDiscoveryService")] - public void TestListConfigurations() - { - IAmazonApplicationDiscoveryService client = new AmazonApplicationDiscoveryServiceClient(RegionEndpoint.USWest2); - try - { - ListConfigurationsRequest request = new ListConfigurationsRequest { ConfigurationType = ConfigurationItemType.PROCESS }; - ListConfigurationsResponse response = client.ListConfigurations(request); - Assert.IsNotNull(response.ResponseMetadata.RequestId); - } - catch (AmazonApplicationDiscoveryServiceException e) - { - // We're really just making sure we can contact this service. - // So an error from the service that the account isn't whitelisted is acceptable. - if (!e.Message.Contains("is not whitelisted to access")) - throw; - } - } - } -} \ No newline at end of file diff --git a/sdk/test/Services/ApplicationDiscoveryService/IntegrationTests/Config/462/App.config b/sdk/test/Services/ApplicationDiscoveryService/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/ApplicationDiscoveryService/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/AutoScaling/IntegrationTests/AWSSDK.IntegrationTests.AutoScaling.NetFramework.csproj b/sdk/test/Services/AutoScaling/IntegrationTests/AWSSDK.IntegrationTests.AutoScaling.NetFramework.csproj deleted file mode 100644 index 675f74d28071..000000000000 --- a/sdk/test/Services/AutoScaling/IntegrationTests/AWSSDK.IntegrationTests.AutoScaling.NetFramework.csproj +++ /dev/null @@ -1,51 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.AutoScaling.NetFramework - AWSSDK.IntegrationTests.AutoScaling.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/AutoScaling/IntegrationTests/AutoScaling.cs b/sdk/test/Services/AutoScaling/IntegrationTests/AutoScaling.cs deleted file mode 100644 index 6b3649db61d4..000000000000 --- a/sdk/test/Services/AutoScaling/IntegrationTests/AutoScaling.cs +++ /dev/null @@ -1,143 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using Amazon.IdentityManagement.Model; -using Amazon.Runtime; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using Amazon.EC2; -using Amazon.AutoScaling; -using Amazon.AutoScaling.Model; - -using AWSSDK_DotNet.IntegrationTests.Utils; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class AutoScaling : TestBase - { - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - [TestMethod] - [TestCategory("AutoScaling")] - public void DescribeAccountLimitsTest() - { - var response = Client.DescribeAccountLimits(); - var result = response; - Assert.IsNotNull(response); - Assert.IsNotNull(response.ResponseMetadata); - Assert.IsNotNull(response.ResponseMetadata.RequestId); - Assert.IsNotNull(result); - Assert.AreNotEqual(0, result.MaxNumberOfAutoScalingGroups); - Assert.AreNotEqual(0, result.MaxNumberOfLaunchConfigurations); - } - - [TestMethod] - [TestCategory("AutoScaling")] - public void NoParamDescribeAutoScalingGroupsTest() - { - var response = Client.DescribeAutoScalingGroups(); - Assert.IsNotNull(response); - } - - [TestMethod] - [TestCategory("AutoScaling")] - public void NoParamDescribePoliciesTest() - { - var response = Client.DescribePolicies(); - Assert.IsNotNull(response); - } - - [TestMethod] - [TestCategory("AutoScaling")] - public void NoParamDescribeScalingProcessTypesTest() - { - var response = Client.DescribeScalingProcessTypes(); - Assert.IsNotNull(response); - } - - [TestMethod] - [TestCategory("AutoScaling")] - public void NoParamDescribeScalingActivitiesTest() - { - var response = Client.DescribeScalingActivities(); - Assert.IsNotNull(response); - } - - [TestMethod] - [TestCategory("AutoScaling")] - public void NoParamDescribeNotificationConfigurationsTest() - { - var response = Client.DescribeNotificationConfigurations(); - Assert.IsNotNull(response); - } - - [TestMethod] - [TestCategory("AutoScaling")] - public void NoParamDescribeAutoScalingNotificationTypesTest() - { - var response = Client.DescribeAutoScalingNotificationTypes(); - Assert.IsNotNull(response); - } - - [TestMethod] - [TestCategory("AutoScaling")] - public void NoParamDescribeAutoScalingInstancesTest() - { - var response = Client.DescribeAutoScalingInstances(); - Assert.IsNotNull(response); - } - - [TestMethod] - [TestCategory("AutoScaling")] - public void NoParamDescribeLaunchConfigurationsTest() - { - var response = Client.DescribeLaunchConfigurations(); - Assert.IsNotNull(response); - } - - [TestMethod] - [TestCategory("AutoScaling")] - public void NoParamDescribeAdjustmentTypesTest() - { - var response = Client.DescribeAdjustmentTypes(); - Assert.IsNotNull(response); - } - - [TestMethod] - [TestCategory("AutoScaling")] - public void NoParamDescribeScheduledActionsTest() - { - var response = Client.DescribeScheduledActions(); - Assert.IsNotNull(response); - } - - [TestMethod] - [TestCategory("AutoScaling")] - public void NoParamDescribeMetricCollectionTypesTest() - { - var response = Client.DescribeMetricCollectionTypes(); - Assert.IsNotNull(response); - } - - [TestMethod] - [TestCategory("AutoScaling")] - public void NoParamDescribeTerminationTests() - { - var response = Client.DescribeTerminationPolicyTypes(); - Assert.IsTrue(response.TerminationPolicyTypes.Count > 0); - } - - private static bool ActivitiesPending(IEnumerable activities) - { - return activities.All(activity => !activity.StatusCode.Equals(ScalingActivityStatusCode.Cancelled) - && !activity.StatusCode.Equals(ScalingActivityStatusCode.Failed) - && !activity.StatusCode.Equals(ScalingActivityStatusCode.Successful)); - } - } -} diff --git a/sdk/test/Services/AutoScaling/IntegrationTests/Config/462/App.config b/sdk/test/Services/AutoScaling/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/AutoScaling/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/BedrockRuntime/IntegrationTests/AWSSDK.IntegrationTests.BedrockRuntime.NetFramework.csproj b/sdk/test/Services/BedrockRuntime/IntegrationTests/AWSSDK.IntegrationTests.BedrockRuntime.NetFramework.csproj deleted file mode 100644 index a4963c037da2..000000000000 --- a/sdk/test/Services/BedrockRuntime/IntegrationTests/AWSSDK.IntegrationTests.BedrockRuntime.NetFramework.csproj +++ /dev/null @@ -1,48 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.BedrockRuntime.NetFramework - AWSSDK.IntegrationTests.BedrpckRuntime.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/BedrockRuntime/IntegrationTests/BedrockRuntimeEventStreamTests.cs b/sdk/test/Services/BedrockRuntime/IntegrationTests/BedrockRuntimeEventStreamTests.cs deleted file mode 100644 index b5205a18466d..000000000000 --- a/sdk/test/Services/BedrockRuntime/IntegrationTests/BedrockRuntimeEventStreamTests.cs +++ /dev/null @@ -1,135 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Amazon.BedrockRuntime; -using Amazon.BedrockRuntime.Model; -using System.Threading.Tasks; -using System.IO; -using System.Text; -using System.Text.Json; -using System.Threading; -using System; -using System.Diagnostics.Contracts; -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - /// - /// To run these tests on your local development acccount, you need to request access to the bedrock models - /// 1. Go to AWS console. - /// 2. Type Bedrock in the search bar - /// 3. Select Model Access in the left hand side menu - /// 4. Click Manage model access - /// 5. Select all models and request access. - /// - /// Because this test requires explicit access to the models it is ignored. - /// - [TestClass] - [Ignore] - public class BedrockRuntimeEventStreamTests : TestBase - { -#if BCL - [TestMethod] - public async Task PayloadIsSentBackCorrectlyAsync() - { - AutoResetEvent endEvent = new AutoResetEvent(false); - var query = CreateStream("Who was the first US president"); - var response = await Client.InvokeModelWithResponseStreamAsync(new InvokeModelWithResponseStreamRequest - { - Accept = "*/*", - ContentType = "application/json", - Body = query, - ModelId = "anthropic.claude-v2" - }).ConfigureAwait(false); - var eventStream = response.Body; - Assert.IsNotNull(eventStream); - Assert.AreEqual(response.HttpStatusCode, System.Net.HttpStatusCode.OK); - string payloadString = null; - using (eventStream) - { - eventStream.ChunkReceived += (sender, e) => - { - var sizeOfPayload = e.EventStreamEvent.Bytes.Length; - using (StreamReader r = new StreamReader(e.EventStreamEvent.Bytes)) - { - payloadString = r.ReadToEnd(); - } - //Since we don't know the contents of the response from Bedrock, we just assert that we received a payload - //and that the size of the payload is equal to what we read from the stream - var payloadStringSize = Encoding.UTF8.GetByteCount(payloadString); - Assert.IsNotNull(payloadString); - Assert.AreEqual(payloadStringSize, sizeOfPayload); - endEvent.Set(); - }; - eventStream.StartProcessing(); - //the maximum we will wait for a response is 20 seconds, if a payload chunk is received - //we signal the end event and exit the test.We are purposely not waiting for the full response - //because it will take too much time. We just check the first streamed payload. - endEvent.WaitOne(TimeSpan.FromSeconds(20)); - } - } - [TestMethod] - public async Task RequestWithInvalidBodyReturnsValidationException() - { - AutoResetEvent endEvent = new AutoResetEvent(false); - var query = CreateStream("Who was the first US president", true); - var response = await Client.InvokeModelWithResponseStreamAsync(new InvokeModelWithResponseStreamRequest - { - Accept = "*/*", - ContentType = "application/json", - Body = query, - ModelId = "anthropic.claude-v2" - }).ConfigureAwait(false); - var eventStream = response.Body; - Assert.IsNotNull(eventStream); - Assert.AreEqual(response.HttpStatusCode, System.Net.HttpStatusCode.OK); - bool chunkReceived = false; - bool exceptionReceived = false; - using (eventStream) - { - eventStream.ChunkReceived += (sender, e) => - { - chunkReceived = true; - endEvent.Set(); - }; - eventStream.ExceptionReceived += (sender, e) => - { - exceptionReceived = true; - var actualException = e.EventStreamException.InnerException; - Assert.IsInstanceOfType(e.EventStreamException.InnerException, typeof(ValidationException)); - endEvent.Set(); - }; - eventStream.StartProcessing(); - - endEvent.WaitOne(TimeSpan.FromSeconds(20)); - } - Assert.IsTrue(exceptionReceived); - Assert.IsFalse(chunkReceived); - } -#endif - static MemoryStream CreateStream(string query, bool createInvalidInput = false) - { - StringBuilder promptValueBuilder = new StringBuilder(); - if (createInvalidInput) - promptValueBuilder.Append("INVALID INPUT QWEOASDASD"); - promptValueBuilder.Append("Human: "); - promptValueBuilder.Append(query); - if (!query.EndsWith(".")) - promptValueBuilder.Append("."); - promptValueBuilder.AppendLine(); - promptValueBuilder.AppendLine("Assistant: "); - MemoryStream stream = new MemoryStream(); - AnthropicClaudeV2Json jsonObject = new AnthropicClaudeV2Json - { - prompt = promptValueBuilder.ToString(), - max_tokens_to_sample = 300 - }; - JsonSerializer.Serialize(stream, jsonObject, typeof(AnthropicClaudeV2Json)); - - stream.Position = 0; - return stream; - } - private class AnthropicClaudeV2Json - { - public string prompt { get; set; } - public int max_tokens_to_sample { get; set; } - } - } -} - diff --git a/sdk/test/Services/CertificateManager/IntegrationTests/AWSSDK.IntegrationTests.CertificateManager.NetFramework.csproj b/sdk/test/Services/CertificateManager/IntegrationTests/AWSSDK.IntegrationTests.CertificateManager.NetFramework.csproj deleted file mode 100644 index d1ab68105350..000000000000 --- a/sdk/test/Services/CertificateManager/IntegrationTests/AWSSDK.IntegrationTests.CertificateManager.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.CertificateManager.NetFramework - AWSSDK.IntegrationTests.CertificateManager.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/CertificateManager/IntegrationTests/CertificateManager.cs b/sdk/test/Services/CertificateManager/IntegrationTests/CertificateManager.cs deleted file mode 100644 index 30426765e9e3..000000000000 --- a/sdk/test/Services/CertificateManager/IntegrationTests/CertificateManager.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using AWSSDK_DotNet.IntegrationTests.Utils; - -using Amazon; -using Amazon.CertificateManager; -using Amazon.CertificateManager.Model; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class CertificateManagerTests : TestBase - { - [ClassCleanup] - public static void ClassCleanup() - { - BaseClean(); - } - - - [ClassInitialize] - public static void ClassInitialize(TestContext testContext) - { - } - - [TestMethod] - [TestCategory("CertificateManager")] - public void TestListCertificates() - { - var response = Client.ListCertificates(); - Assert.IsNotNull(response); - - if (response.CertificateSummaryList.Any()) - { - foreach (var c in response.CertificateSummaryList) - { - Assert.IsFalse(string.IsNullOrEmpty(c.CertificateArn)); - Assert.IsFalse(string.IsNullOrEmpty(c.DomainName)); - } - } - } - - } -} diff --git a/sdk/test/Services/CertificateManager/IntegrationTests/Config/462/App.config b/sdk/test/Services/CertificateManager/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/CertificateManager/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/CloudDirectory/IntegrationTests/AWSSDK.IntegrationTests.CloudDirectory.NetFramework.csproj b/sdk/test/Services/CloudDirectory/IntegrationTests/AWSSDK.IntegrationTests.CloudDirectory.NetFramework.csproj deleted file mode 100644 index b5ad8515b97e..000000000000 --- a/sdk/test/Services/CloudDirectory/IntegrationTests/AWSSDK.IntegrationTests.CloudDirectory.NetFramework.csproj +++ /dev/null @@ -1,51 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.CloudDirectory.NetFramework - AWSSDK.IntegrationTests.CloudDirectory.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/CloudDirectory/IntegrationTests/CloudDirectory.cs b/sdk/test/Services/CloudDirectory/IntegrationTests/CloudDirectory.cs deleted file mode 100644 index fd94d0a9fa45..000000000000 --- a/sdk/test/Services/CloudDirectory/IntegrationTests/CloudDirectory.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Amazon; -using Amazon.ECR; -using Amazon.ECR.Model; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Amazon.CloudDirectory; -using Amazon.CloudDirectory.Model; -using AWSSDK_DotNet.CommonTest.Utils; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class CloudDirectory : TestBase - { - private const string ListObjectAttributesResponse = @"{""Attributes"":[{""Key"":{""FacetName"":""Person"",""Name"":""username"",""SchemaArn"":""arn:aws:clouddirectory:us-east-1:123456789012:directory/AQPCHP0oaUPOoPHKMr1kMTs/schema/person/1""},""Value"":{""BinaryValue"":null,""BooleanValue"":null,""DatetimeValue"":null,""NumberValue"":null,""StringValue"":""bob""}}],""NextToken"":null}"; - - [TestMethod] - [TestCategory("CloudDirectory")] - public void TestAttributes() - { - using(var servlet = new ResponseTestServlet()) - { - servlet.Response = ListObjectAttributesResponse; - - var config = new AmazonCloudDirectoryConfig { ServiceURL = servlet.ServiceURL }; - using(var client = new AmazonCloudDirectoryClient(config)) - { - var response = client.ListObjectAttributes(new ListObjectAttributesRequest()); - - var attribute = response.Attributes.SingleOrDefault(); - Assert.IsNotNull(attribute); - - var key = attribute.Key; - Assert.IsNotNull(key); - - Assert.AreEqual("Person", key.FacetName); - Assert.AreEqual("username", key.Name); - Assert.AreEqual("arn:aws:clouddirectory:us-east-1:123456789012:directory/AQPCHP0oaUPOoPHKMr1kMTs/schema/person/1", key.SchemaArn); - - var value = attribute.Value; - Assert.IsNotNull(value); - - Assert.IsNull(value.BinaryValue); - Assert.IsFalse(value.BooleanValue.HasValue); - Assert.IsNull(value.DatetimeValue); - Assert.IsNull(value.NumberValue); - Assert.AreEqual("bob", value.StringValue); - } - } - } - } -} diff --git a/sdk/test/Services/CloudDirectory/IntegrationTests/Config/462/App.config b/sdk/test/Services/CloudDirectory/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/CloudDirectory/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/CloudFormation/IntegrationTests/AWSSDK.IntegrationTests.CloudFormation.NetFramework.csproj b/sdk/test/Services/CloudFormation/IntegrationTests/AWSSDK.IntegrationTests.CloudFormation.NetFramework.csproj deleted file mode 100644 index a069f56cf848..000000000000 --- a/sdk/test/Services/CloudFormation/IntegrationTests/AWSSDK.IntegrationTests.CloudFormation.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.CloudFormation.NetFramework - AWSSDK.IntegrationTests.CloudFormation.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/CloudFormation/IntegrationTests/CloudFormation.cs b/sdk/test/Services/CloudFormation/IntegrationTests/CloudFormation.cs deleted file mode 100644 index 5eade6eab7bc..000000000000 --- a/sdk/test/Services/CloudFormation/IntegrationTests/CloudFormation.cs +++ /dev/null @@ -1,234 +0,0 @@ -using System; -using System.Linq; -using System.Threading; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using Amazon; -using Amazon.CloudFormation; -using Amazon.CloudFormation.Model; -using Amazon.Runtime; -using System.Collections.Generic; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class CloudFormation : TestBase - { - public const string TEMPLATE_URL = @"https://aws-vs-toolkit.s3.amazonaws.com/CloudFormationTemplates/SingleInstance.template"; - public const string TEMPLATE_TEXT = @"{ - ""AWSTemplateFormatVersion"" : ""2010-09-09"", - - ""Description"" : ""This is a sample template"", - - ""Parameters"" : { - ""TopicName"" : { - ""Type"" : ""String"", - ""Default"" : ""TheTopic"", - ""Description"" : ""A topic."" - }, - ""QueueName"" : { - ""Type"" : ""String"", - ""Default"" : ""TheQueue"", - ""Description"" : ""A queue."" - } - }, - - ""Resources"" : { - - ""TheQueue"" : { - ""Type"" : ""AWS::SQS::Queue"", - ""Properties"" : { - ""QueueName"" : { ""Ref"" : ""QueueName"" } - } - }, - - ""TheTopic"" : { - ""Type"" : ""AWS::SNS::Topic"", - ""Properties"" : { - ""TopicName"" : { ""Ref"" : ""TopicName"" }, - ""Subscription"" : [ - {""Protocol"" : ""sqs"", ""Endpoint"" : {""Fn::GetAtt"" : [ ""TheQueue"", ""Arn""]}} - ] - } - } - }, - - ""Outputs"" : { - ""TopicARN"" : { - ""Value"" : { ""Ref"" : ""TheTopic"" } - }, - ""QueueURL"" : { - ""Value"" : { ""Ref"" : ""TheQueue"" } - } - } -} -"; - - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - [TestMethod] - [TestCategory("CloudFormation")] - public void TestValidateTemplateURL() - { - ValidateTemplateResponse response = Client.ValidateTemplate(new ValidateTemplateRequest() { TemplateURL = TEMPLATE_URL }); - Assert.IsNotNull(response.ResponseMetadata.RequestId); - Assert.IsTrue(response.Parameters.Count > 0); - - foreach (TemplateParameter tp in response.Parameters) - { - Assert.IsNotNull(tp.ParameterKey); - } - } - - [TestMethod] - [TestCategory("CloudFormation")] - public void TestGetTemplateSummary() - { - GetTemplateSummaryResponse response = Client.GetTemplateSummary(new GetTemplateSummaryRequest - { - TemplateURL = TEMPLATE_URL - }); - VerifyTemplateSummary(response); - - response = Client.GetTemplateSummary(new GetTemplateSummaryRequest - { - TemplateBody = TEMPLATE_TEXT - }); - VerifyTemplateSummary(response); - } - - private static void VerifyTemplateSummary(GetTemplateSummaryResponse response) - { - Assert.IsNotNull(response.ResponseMetadata.RequestId); - if (AWSConfigs.InitializeCollections) - { - Assert.IsNotNull(response.Capabilities); - Assert.AreEqual(0, response.Capabilities.Count); - } - else - { - Assert.IsNull(response.Capabilities); - } - Assert.IsNull(response.CapabilitiesReason); - Assert.IsNotNull(response.Description); - Assert.IsNotNull(response.Parameters); - foreach (ParameterDeclaration pd in response.Parameters) - { - Assert.IsNotNull(pd.ParameterKey); - Assert.IsNotNull(pd.ParameterType); - Assert.IsNotNull(pd.Description); - } - Assert.IsNotNull(response.Version); - } - - [TestMethod] - [TestCategory("CloudFormation")] - public void EstimateCostTest() - { - EstimateTemplateCostResponse response = Client.EstimateTemplateCost(new EstimateTemplateCostRequest() { TemplateBody = TEMPLATE_TEXT }); - Assert.IsNotNull(response.Url); - } - - [TestMethod] - [TestCategory("CloudFormation")] - public void TestValidateTemplateBody() - { - ValidateTemplateResponse response = Client.ValidateTemplate(new ValidateTemplateRequest() { TemplateURL = TEMPLATE_URL }); - Assert.IsNotNull(response.ResponseMetadata.RequestId); - } - - [TestMethod] - [TestCategory("CloudFormation")] - public void TestInvalidTemplate() - { - try - { - ValidateTemplateResponse response = Client.ValidateTemplate(new ValidateTemplateRequest() { TemplateBody = @"{""Foo"" : ""Bar""}" }); - Assert.Fail("Should have thrown an exception"); - } - catch (AmazonCloudFormationException acfx) - { - Assert.AreEqual("ValidationError", acfx.ErrorCode); - Assert.AreEqual(ErrorType.Sender, acfx.ErrorType); - } - catch (Exception) - { - Assert.Fail("Should have thrown an AmazonCloudFormation Exception"); - } - } - - [TestMethod] - [TestCategory("CloudFormation")] - public void TestCreateStack() - { - string stackName = "test-stack-" + DateTime.UtcNow.Ticks; - try - { - CreateStackRequest createRequest = new CreateStackRequest - { - StackName = stackName, - TemplateBody = TEMPLATE_TEXT, - Parameters = new List - { - new Parameter - { - ParameterKey = "TopicName", - ParameterValue = "MyTopic" + DateTime.UtcNow.Ticks - }, - new Parameter - { - ParameterKey = "QueueName", - ParameterValue = "MyQueue" + DateTime.UtcNow.Ticks - } - } - }; - - Client.CreateStack(createRequest); - - WaitTillStackNotInProcess(stackName); - - var stack = Client.DescribeStacks(new DescribeStacksRequest - { - StackName = stackName - }).Stacks[0]; - - Assert.AreEqual(StackStatus.CREATE_COMPLETE , stack.StackStatus); - - var resources = Client.DescribeStackResources(new DescribeStackResourcesRequest - { - StackName = stackName - }).StackResources; - - Assert.AreEqual(2, resources.Count); - - GetTemplateSummaryResponse templateSummaryResponse = Client.GetTemplateSummary(new GetTemplateSummaryRequest - { - StackName = stackName - }); - VerifyTemplateSummary(templateSummaryResponse); - } - finally - { - WaitTillStackNotInProcess(stackName); - Client.DeleteStack(new DeleteStackRequest() { StackName = stackName }); - } - } - - static void WaitTillStackNotInProcess(string stackname) - { - DescribeStacksResponse response = null; - do - { - Thread.Sleep(2000); - response = Client.DescribeStacks(new DescribeStacksRequest - { - StackName = stackname - }); - } while (response.Stacks[0].StackStatus.Value.EndsWith("IN_PROGRESS")); - } - } -} diff --git a/sdk/test/Services/CloudFormation/IntegrationTests/Config/462/App.config b/sdk/test/Services/CloudFormation/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/CloudFormation/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/CloudFront/IntegrationTests/AWSSDK.IntegrationTests.CloudFront.NetFramework.csproj b/sdk/test/Services/CloudFront/IntegrationTests/AWSSDK.IntegrationTests.CloudFront.NetFramework.csproj deleted file mode 100644 index 05285938add8..000000000000 --- a/sdk/test/Services/CloudFront/IntegrationTests/AWSSDK.IntegrationTests.CloudFront.NetFramework.csproj +++ /dev/null @@ -1,51 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.CloudFront.NetFramework - AWSSDK.IntegrationTests.CloudFront.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/CloudFront/IntegrationTests/CloudFront.cs b/sdk/test/Services/CloudFront/IntegrationTests/CloudFront.cs deleted file mode 100644 index e2910162260d..000000000000 --- a/sdk/test/Services/CloudFront/IntegrationTests/CloudFront.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Threading; -using AWSSDK_DotNet.IntegrationTests.Tests; -using AWSSDK_DotNet.IntegrationTests.Utils; - -using Amazon.CloudFront; -using Amazon.CloudFront.Model; -using Amazon.S3.Model; -using Amazon.IdentityManagement.Model; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class CloudFront : TestBase - { - [TestMethod] - [TestCategory("CloudFront")] - public void ListDistributions() - { - var response = Client.ListDistributions(); - Assert.IsNotNull(response.DistributionList); - } - - [TestMethod] - [TestCategory("CloudFront")] - public void OriginTests() - { - var createRequest = new CreateCloudFrontOriginAccessIdentityRequest() - { - CloudFrontOriginAccessIdentityConfig = new CloudFrontOriginAccessIdentityConfig() - { - CallerReference = Guid.NewGuid().ToString(), - Comment = UtilityMethods.SDK_TEST_PREFIX - } - }; - var createResponse = Client.CreateCloudFrontOriginAccessIdentity(createRequest); - Assert.IsNotNull(createResponse.ETag); - Assert.IsNotNull(createResponse.CloudFrontOriginAccessIdentity.Id); - - var updateRequest = new UpdateCloudFrontOriginAccessIdentityRequest() - { - CloudFrontOriginAccessIdentityConfig = new CloudFrontOriginAccessIdentityConfig() - { - CallerReference = createRequest.CloudFrontOriginAccessIdentityConfig.CallerReference, - Comment = UtilityMethods.SDK_TEST_PREFIX + "update" - }, - Id = createResponse.CloudFrontOriginAccessIdentity.Id, - IfMatch = createResponse.ETag - }; - var updateResponse = Client.UpdateCloudFrontOriginAccessIdentity(updateRequest); - Assert.IsNotNull(updateResponse.ETag); - Assert.IsNotNull(updateResponse.CloudFrontOriginAccessIdentity.CloudFrontOriginAccessIdentityConfig.Comment); - - - var listResponse = Client.ListCloudFrontOriginAccessIdentities(); - Assert.IsTrue(listResponse.CloudFrontOriginAccessIdentityList.Items.Count > 0); - - var deleteRequest = new DeleteCloudFrontOriginAccessIdentityRequest() - { - Id = createResponse.CloudFrontOriginAccessIdentity.Id, - IfMatch = updateResponse.ETag - }; - var deleteResponse = Client.DeleteCloudFrontOriginAccessIdentity(deleteRequest); - Assert.IsNotNull(deleteResponse.ResponseMetadata.RequestId); - } - } -} diff --git a/sdk/test/Services/CloudFront/IntegrationTests/Config/462/App.config b/sdk/test/Services/CloudFront/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/CloudFront/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/CloudHSM/IntegrationTests/AWSSDK.IntegrationTests.CloudHSM.NetFramework.csproj b/sdk/test/Services/CloudHSM/IntegrationTests/AWSSDK.IntegrationTests.CloudHSM.NetFramework.csproj deleted file mode 100644 index 91aea634f4b1..000000000000 --- a/sdk/test/Services/CloudHSM/IntegrationTests/AWSSDK.IntegrationTests.CloudHSM.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.CloudHSM.NetFramework - AWSSDK.IntegrationTests.CloudHSM.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/CloudHSM/IntegrationTests/CloudHSM.cs b/sdk/test/Services/CloudHSM/IntegrationTests/CloudHSM.cs deleted file mode 100644 index 6b7e1df5e177..000000000000 --- a/sdk/test/Services/CloudHSM/IntegrationTests/CloudHSM.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using System.Linq; - -using Amazon; -using Amazon.CloudHSM; -using Amazon.CloudHSM.Model; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [Ignore("CloudHSM classic is not available to newly created AWS accounts.")] - [TestClass] - public class CloudHSM : TestBase - { - [TestMethod] - [TestCategory("CloudHSM")] - public void TestSimpleMethods() - { - var zones = Client.ListAvailableZones().AZList; - Assert.IsNotNull(zones); - Assert.IsTrue(zones.Count > 0); - var hsms = Client.ListHsms().HsmList; - Assert.IsNotNull(hsms); - } - - [TestMethod] - [TestCategory("CloudHSM")] - public void TestHapg() - { - var arn = Client.CreateHapg(new CreateHapgRequest { Label = Utils.UtilityMethods.GenerateName() }).HapgArn; - Assert.IsNotNull(arn); - - var hapgs = Client.ListHapgs().HapgList; - Assert.IsTrue(hapgs.Contains(arn)); - - var status = Client.DeleteHapg(arn).Status; - - Assert.IsNotNull(status); - } - } -} diff --git a/sdk/test/Services/CloudHSM/IntegrationTests/Config/462/App.config b/sdk/test/Services/CloudHSM/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/CloudHSM/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/CloudTrail/IntegrationTests/AWSSDK.IntegrationTests.CloudTrail.NetFramework.csproj b/sdk/test/Services/CloudTrail/IntegrationTests/AWSSDK.IntegrationTests.CloudTrail.NetFramework.csproj deleted file mode 100644 index 72726e981caf..000000000000 --- a/sdk/test/Services/CloudTrail/IntegrationTests/AWSSDK.IntegrationTests.CloudTrail.NetFramework.csproj +++ /dev/null @@ -1,51 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.CloudTrail.NetFramework - AWSSDK.IntegrationTests.CloudTrail.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/CloudTrail/IntegrationTests/CloudTrail.cs b/sdk/test/Services/CloudTrail/IntegrationTests/CloudTrail.cs deleted file mode 100644 index 26aae1cffc2f..000000000000 --- a/sdk/test/Services/CloudTrail/IntegrationTests/CloudTrail.cs +++ /dev/null @@ -1,193 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using Amazon.CloudTrail; -using Amazon.CloudTrail.Model; - -using Amazon.S3; -using Amazon.S3.Model; -using Amazon.S3.Util; - -using AWSSDK_DotNet.IntegrationTests.Utils; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class CloudTrail : TestBase - { - private static string _trailStorageBucketName = "sdk-dotnet-integ-test-trail-bucket-" + DateTime.UtcNow.Ticks; - private const string S3_PREFIX = "folder"; - - static AmazonS3Client s3Client; - - [ClassInitialize] - public static void ClassInitialize(TestContext testContext) - { - s3Client = new AmazonS3Client(); - try - { - AmazonS3Util.DeleteS3BucketWithObjects(s3Client, _trailStorageBucketName); - } - catch (Exception) { } - - s3Client.PutBucket(new PutBucketRequest - { - BucketName = _trailStorageBucketName, - CannedACL = S3CannedACL.BucketOwnerFullControl - }); - - var policy = UtilityMethods.GetResourceText("CloudTrailBucketPolicy.json"); - - // Inject newly created bucket and current account id - policy = policy.Replace("{BucketName}", _trailStorageBucketName) - .Replace("{Prefix}", S3_PREFIX) - .Replace("{AccountId}", UtilityMethods.AccountId); - - s3Client.PutBucketPolicy(new PutBucketPolicyRequest - { - BucketName = _trailStorageBucketName, - Policy = policy - }); - } - - [ClassCleanup] - public static void Cleanup() - { - var trails = Client.DescribeTrails(); - foreach (var trail in trails.TrailList) - { - if (trail.Name.Contains("dotnet-integ-test")) - { - Client.DeleteTrail(new DeleteTrailRequest - { - Name = trail.Name - }); - } - } - - AmazonS3Util.DeleteS3BucketWithObjects(s3Client, _trailStorageBucketName); - - BaseClean(); - - s3Client.Dispose(); - s3Client = null; - } - - [TestMethod] - [TestCategory("CloudTrail")] - public void CloudTrailIntegrationTest() - { - var trailsCount = Client.DescribeTrails(). - TrailList.Count; - - // Cloud Trail is already setup for this account so skip the test to not disturb - // the settings. - if (trailsCount != 0) - return; - - var trailName = "dotnet-integ-test-trail-" + DateTime.UtcNow.Ticks; - var trail = Client.CreateTrail(new CreateTrailRequest - { - Name = trailName, - IncludeGlobalServiceEvents = true, - S3BucketName = _trailStorageBucketName, - S3KeyPrefix = S3_PREFIX - }); - Assert.AreEqual(trail.Name, trailName); - Assert.AreEqual(trail.IncludeGlobalServiceEvents, true); - Assert.AreEqual(trail.S3BucketName, _trailStorageBucketName); - Assert.AreEqual(trail.S3KeyPrefix, S3_PREFIX); - Assert.AreEqual(trail.SnsTopicName, null); - Thread.Sleep(TimeSpan.FromSeconds(5)); - - var trails = Client.DescribeTrails(). - TrailList; - Assert.AreEqual(trails.Count, trailsCount + 1); - - var trailStatus = Client.GetTrailStatus(new GetTrailStatusRequest - { - Name = trailName - }); - Assert.AreEqual(trailStatus.IsLogging, false); - - Client.StartLogging(new StartLoggingRequest - { - Name = trailName - }); - Thread.Sleep(TimeSpan.FromSeconds(5)); - - trailStatus = Client.GetTrailStatus(new GetTrailStatusRequest - { - Name = trailName - }); - Assert.AreEqual(trailStatus.IsLogging, true); - - var endTime = DateTime.UtcNow; - var startTime = endTime.AddMinutes(-30); - - var request = new LookupEventsRequest - { - StartTime = startTime, - EndTime = endTime, - }; - var allEvents = LookupAllEvents(request).ToList(); - - if (allEvents.Count > 0) - { - var resourceNamesMap = new Dictionary(); - foreach (var e in allEvents) - { - var resources = e.Resources; - foreach (var r in resources) - { - if (!resourceNamesMap.ContainsKey(r.ResourceName)) - resourceNamesMap[r.ResourceName] = 0; - resourceNamesMap[r.ResourceName]++; - } - } - - var firstResourceNameKVP = resourceNamesMap.First(); - request.LookupAttributes = new List - { - new LookupAttribute - { - AttributeKey = LookupAttributeKey.ResourceName, - AttributeValue = firstResourceNameKVP.Key - } - }; - var filteredEvents = LookupAllEvents(request).ToList(); - Assert.AreEqual(firstResourceNameKVP.Value, filteredEvents.Count); - } - - Client.StopLogging(new StopLoggingRequest - { - Name = trailName - }); - Thread.Sleep(TimeSpan.FromSeconds(2)); - - Client.DeleteTrail(new DeleteTrailRequest - { - Name = trailName - }); - } - - private IEnumerable LookupAllEvents(LookupEventsRequest request = null) - { - if (request == null) - request = new LookupEventsRequest(); - do - { - var result = Client.LookupEvents(request); - request.NextToken = result.NextToken; - - var events = result.Events; - foreach (var e in events) - yield return e; - - } while (!string.IsNullOrEmpty(request.NextToken)); - } - } -} diff --git a/sdk/test/Services/CloudTrail/IntegrationTests/Config/462/App.config b/sdk/test/Services/CloudTrail/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/CloudTrail/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/CloudWatch/IntegrationTests/CloudWatch.cs b/sdk/test/Services/CloudWatch/IntegrationTests/CloudWatch.cs index f1ad16ade0e8..4fda833c8b52 100644 --- a/sdk/test/Services/CloudWatch/IntegrationTests/CloudWatch.cs +++ b/sdk/test/Services/CloudWatch/IntegrationTests/CloudWatch.cs @@ -1,53 +1,25 @@ using System; using System.Collections.Generic; -using System.Globalization; -using System.Threading; using Microsoft.VisualStudio.TestTools.UnitTesting; - -using Amazon; using Amazon.CloudWatch; using Amazon.CloudWatch.Model; -using System.Web.Profile; -using Amazon.Runtime.CredentialManagement; using Amazon.Runtime; using System.Net; +using System.Threading.Tasks; namespace AWSSDK_DotNet.IntegrationTests.Tests { [TestClass] public class CloudWatch : TestBase { - const string ALARM_BASENAME = "SDK-TEST-ALARM-"; - - [ClassCleanup] - public static void Cleanup() - { - var describeResult = Client.DescribeAlarms(new DescribeAlarmsRequest()); - List toDelete = new List(); - foreach (MetricAlarm alarm in describeResult.MetricAlarms) - { - if (alarm.MetricName.StartsWith(ALARM_BASENAME) || alarm.AlarmName.StartsWith("An Alarm Name 2")) - { - toDelete.Add(alarm.AlarmName); - } - } - if (toDelete.Count > 0) - { - DeleteAlarmsRequest delete = new DeleteAlarmsRequest() { AlarmNames = toDelete }; - Client.DeleteAlarms(delete); - } - BaseClean(); - } - [TestMethod] - public void PutMetricDataWithNonStreamingPayload() + public async Task PutMetricDataWithNonStreamingPayload() { var random = new Random(); - - var request = new PutMetricDataRequest() + var request = new PutMetricDataRequest { Namespace = "compression-test", - MetricData = new List() + MetricData = new List { new MetricDatum { MetricName = "test-request-compression-metric", Timestamp = DateTime.UtcNow, Unit = StandardUnit.Count, Value = random.Next(100) }, new MetricDatum { MetricName = "test-request-compression-metric", Timestamp = DateTime.UtcNow.AddSeconds(2), Unit = StandardUnit.Bytes, Value = random.Next(100) }, @@ -58,488 +30,12 @@ public void PutMetricDataWithNonStreamingPayload() } }; - var config = Client.Config as ClientConfig; config.RequestMinCompressionSizeBytes = 0; - var response = Client.PutMetricData(request); - + var response = await Client.PutMetricDataAsync(request); Assert.IsFalse(Client.Config.DisableRequestCompression); Assert.AreEqual(response.HttpStatusCode, HttpStatusCode.OK); } - - [TestMethod] - [TestCategory("CloudWatch")] - [ExpectedException(typeof(InvalidParameterCombinationException))] - public void CWExceptionTest() - { - try - { - GetMetricStatisticsRequest getMetricRequest = new GetMetricStatisticsRequest() - { - MetricName = "CPUUtilization", - Namespace = "AWS/EC2", - StartTime = DateTime.Parse("2008-02-26T19:00:00+00:00"), - EndTime = DateTime.Parse("2011-02-26T19:00:00+00:00"), - Statistics = new List { "Average" }, - Unit = "Percent", - Period = 60 - }; - var getMetricResult = Client.GetMetricStatistics(getMetricRequest); - } - catch (AmazonCloudWatchException e) - { - AssertValidException(e); - Assert.AreEqual("InvalidParameterCombination", e.ErrorCode); - throw e; - } - } - - [TestMethod] - [TestCategory("CloudWatch")] - public void BasicCRUD() - { - var listResult = Client.ListMetrics(new ListMetricsRequest()); - Assert.IsNotNull(listResult); - if (listResult.NextToken != null && listResult.NextToken.Length > 0) - { - listResult = Client.ListMetrics(new ListMetricsRequest() { NextToken = listResult.NextToken }); - Assert.IsTrue(listResult.Metrics.Count > 0); - } - - GetMetricStatisticsRequest getMetricRequest = new GetMetricStatisticsRequest() - { - MetricName = "NetworkIn", - Namespace = "AWS/EC2", - StartTime = DateTime.Parse("2008-01-01T19:00:00+00:00"), - EndTime = DateTime.Parse("2009-12-01T19:00:00+00:00"), - Statistics = new List { "Average" }, - Unit = "Percent", - Period = 42000, - }; - var getMetricResult = Client.GetMetricStatistics(getMetricRequest); - Assert.IsNotNull(getMetricResult); - Assert.IsNotNull(getMetricResult.Label); - } - - [TestMethod] - [TestCategory("CloudWatch")] - public void AlarmTest() - { - var alarmName = ALARM_BASENAME + DateTime.UtcNow.Ticks; - var putResponse = Client.PutMetricAlarm(new PutMetricAlarmRequest() - { - AlarmName = alarmName, - Threshold = 100, - Period = 120, - EvaluationPeriods = 60, - Namespace = "MyNamespace", - Unit = "Percent", - MetricName = "CPU", - Statistic = "Average", - ComparisonOperator = "GreaterThanThreshold", - AlarmDescription = "This is very important" - }); - try - { - var describeResponse = Client.DescribeAlarms(new DescribeAlarmsRequest() - { - AlarmNames = new List { alarmName } - }); - - Assert.AreEqual(1, describeResponse.MetricAlarms.Count); - MetricAlarm alarm = describeResponse.MetricAlarms[0]; - Assert.AreEqual(100, alarm.Threshold); - Assert.AreEqual(120, alarm.Period); - Assert.AreEqual(60, alarm.EvaluationPeriods); - Assert.AreEqual("MyNamespace", alarm.Namespace); - Assert.AreEqual(StandardUnit.Percent, alarm.Unit); - Assert.AreEqual(Statistic.Average, alarm.Statistic); - Assert.AreEqual(ComparisonOperator.GreaterThanThreshold, alarm.ComparisonOperator); - Assert.AreEqual("This is very important", alarm.AlarmDescription); - - - - var setResponse = Client.SetAlarmState(new SetAlarmStateRequest() - { - AlarmName = alarmName, - StateValue = "ALARM", - StateReason = "Just Testing" - }); - - describeResponse = Client.DescribeAlarms(new DescribeAlarmsRequest() - { - AlarmNames = new List { alarmName } - }); - alarm = describeResponse.MetricAlarms[0]; - Assert.IsTrue("ALARM".Equals(alarm.StateValue) || "INSUFFICIENT_DATA".Equals(alarm.StateValue)); - if ("ALARM".Equals(alarm.StateValue)) - { - Assert.AreEqual("Just Testing", alarm.StateReason); - } - - Client.EnableAlarmActions(new EnableAlarmActionsRequest() - { - AlarmNames = new List { alarmName } - }); - - describeResponse = Client.DescribeAlarms(new DescribeAlarmsRequest() - { - AlarmNames = new List { alarmName } - }); - alarm = describeResponse.MetricAlarms[0]; - Assert.IsTrue(alarm.ActionsEnabled.Value); - - Client.DisableAlarmActions(new DisableAlarmActionsRequest() - { - AlarmNames = new List { alarmName } - }); - - describeResponse = Client.DescribeAlarms(new DescribeAlarmsRequest() - { - AlarmNames = new List { alarmName } - }); - alarm = describeResponse.MetricAlarms[0]; - Assert.IsFalse(alarm.ActionsEnabled.Value); - - var describeMetricResponse = Client.DescribeAlarmsForMetric(new DescribeAlarmsForMetricRequest() - { - MetricName = "CPU", - Namespace = "MyNamespace" - }); - - alarm = null; - foreach (var a in describeMetricResponse.MetricAlarms) - { - if (a.AlarmName.Equals(alarmName)) - { - alarm = a; - break; - } - } - - Assert.IsNotNull(alarm); - - var describeHistory = Client.DescribeAlarmHistory(new DescribeAlarmHistoryRequest() - { - AlarmName = alarmName - }); - - Assert.IsTrue(describeHistory.AlarmHistoryItems.Count > 0); - } - finally - { - Client.DeleteAlarms(new DeleteAlarmsRequest() - { - AlarmNames = new List { alarmName } - }); - } - } - - const int ONE_WEEK_IN_MILLISECONDS = 1000 * 60 * 60 * 24 * 7; - const int ONE_HOUR_IN_MILLISECONDS = 1000 * 60 * 60; - - /** - * Tests that we can call the ListMetrics operation and correctly understand - * the response. - */ - [TestMethod] - [TestCategory("CloudWatch")] - public void TestListMetrics() - { - var result = Client.ListMetrics(new ListMetricsRequest()); - - bool seenDimensions = false; - Assert.IsTrue(result.Metrics.Count > 0); - foreach (Amazon.CloudWatch.Model.Metric metric in result.Metrics) - { - AssertNotEmpty(metric.MetricName); - AssertNotEmpty(metric.Namespace); - - if (metric.Dimensions != null) - { - foreach (Dimension dimension in metric.Dimensions) - { - seenDimensions = true; - AssertNotEmpty(dimension.Name); - AssertNotEmpty(dimension.Value); - } - } - } - Assert.IsTrue(seenDimensions); - - if (!string.IsNullOrEmpty(result.NextToken)) - { - result = Client.ListMetrics(new ListMetricsRequest() { NextToken = result.NextToken }); - Assert.IsTrue(result.Metrics.Count > 0); - } - } - - - - - /** - * Tests that we can call the GetMetricStatistics operation and correctly - * understand the response. - */ - [TestMethod] - [TestCategory("CloudWatch")] - public void TestGetMetricStatistics() - { - string measureName = "CPUUtilization"; - - GetMetricStatisticsRequest request = new GetMetricStatisticsRequest() - { - StartTime = DateTime.UtcNow.AddMilliseconds(-ONE_WEEK_IN_MILLISECONDS), - Namespace = "AWS/EC2", - Period = 60 * 60, - Dimensions = new List - { - new Dimension{ Name="InstanceType",Value="m1.small"} - }, - MetricName = measureName, - Statistics = new List { "Average", "Maximum", "Minimum", "Sum" }, - EndTime = DateTime.UtcNow - }; - var result = Client.GetMetricStatistics(request); - - AssertNotEmpty(result.Label); - Assert.AreEqual(measureName, result.Label); - } - - /** - * Tests setting the state for an alarm and reading its history. - */ - [TestMethod] - [TestCategory("CloudWatch")] - public void TestSetAlarmStateAndHistory() - { - String metricName = this.GetType().Name + DateTime.UtcNow.Ticks; - - PutMetricAlarmRequest[] rqs = CreateTwoNewAlarms(metricName); - - PutMetricAlarmRequest rq1 = rqs[0]; - PutMetricAlarmRequest rq2 = rqs[1]; - - /* - * Set the state - */ - SetAlarmStateRequest setAlarmStateRequest = new SetAlarmStateRequest() - { - AlarmName = rq1.AlarmName, - StateValue = "ALARM", - StateReason = "manual" - }; - Client.SetAlarmState(setAlarmStateRequest); - setAlarmStateRequest = new SetAlarmStateRequest() - { - AlarmName = rq2.AlarmName, - StateValue = "ALARM", - StateReason = "manual" - }; - - Client.SetAlarmState(setAlarmStateRequest); - - var describeResult = Client - .DescribeAlarmsForMetric( - new DescribeAlarmsForMetricRequest() - { - Dimensions = rq1.Dimensions, - MetricName = metricName, - Namespace = rq1.Namespace - }); - - Assert.AreEqual(2, describeResult.MetricAlarms.Count); - - foreach (MetricAlarm alarm in describeResult.MetricAlarms) - { - Assert.IsTrue(rq1.AlarmName.Equals(alarm.AlarmName) - || rq2.AlarmName.Equals(alarm.AlarmName)); - - Assert.IsTrue("ALARM".Equals(alarm.StateValue) || "INSUFFICIENT_DATA".Equals(alarm.StateValue)); - if ("ALARM".Equals(alarm.StateValue)) - { - Assert.AreEqual(setAlarmStateRequest.StateReason, alarm.StateReason); - } - } - - /* - * Get the history - */ - DescribeAlarmHistoryRequest alarmHistoryRequest = new DescribeAlarmHistoryRequest() - { - AlarmName = rq1.AlarmName, - HistoryItemType = "StateUpdate" - }; - - var historyResult = Client.DescribeAlarmHistory(alarmHistoryRequest); - Assert.IsTrue(historyResult.AlarmHistoryItems.Count > 0); - } - - /** - * Tests disabling and enabling alarms - */ - [TestMethod] - [TestCategory("CloudWatch")] - public void TestDisableEnableAlarms() - { - String metricName = this.GetType().Name + DateTime.UtcNow.Ticks; - - PutMetricAlarmRequest[] rqs = CreateTwoNewAlarms(metricName); - - PutMetricAlarmRequest rq1 = rqs[0]; - PutMetricAlarmRequest rq2 = rqs[1]; - - /* - * Disable - */ - DisableAlarmActionsRequest disable = new DisableAlarmActionsRequest() - { - AlarmNames = new List { rq1.AlarmName, rq2.AlarmName } - }; - Client.DisableAlarmActions(disable); - - var describeResult = Client.DescribeAlarmsForMetric(new DescribeAlarmsForMetricRequest() - { - Dimensions = rq1.Dimensions, - MetricName = metricName, - Namespace = rq1.Namespace - }); - - Assert.AreEqual(2, describeResult.MetricAlarms.Count); - foreach (MetricAlarm alarm in describeResult.MetricAlarms) - { - Assert.IsTrue(rq1.AlarmName.Equals(alarm.AlarmName) || rq2.AlarmName.Equals(alarm.AlarmName)); - Assert.IsFalse(alarm.ActionsEnabled.Value); - } - - /* - * Enable - */ - EnableAlarmActionsRequest enable = new EnableAlarmActionsRequest() - { - AlarmNames = new List { rq1.AlarmName, rq2.AlarmName } - }; - Client.EnableAlarmActions(enable); - - describeResult = Client.DescribeAlarmsForMetric(new DescribeAlarmsForMetricRequest() - { - Dimensions = rq1.Dimensions, - MetricName = metricName, - Namespace = rq1.Namespace - }); - - Assert.AreEqual(2, describeResult.MetricAlarms.Count); - foreach (MetricAlarm alarm in describeResult.MetricAlarms) - { - Assert.IsTrue(rq1.AlarmName.Equals(alarm.AlarmName) - || rq2.AlarmName.Equals(alarm.AlarmName)); - Assert.IsTrue(alarm.ActionsEnabled.Value); - } - } - - /** - * Tests creating alarms and describing them - */ - [TestMethod] - [TestCategory("CloudWatch")] - public void TestDescribeAlarms() - { - string metricName = this.GetType().Name + DateTime.UtcNow.Ticks; - - PutMetricAlarmRequest[] rqs = CreateTwoNewAlarms(metricName); - - PutMetricAlarmRequest rq1 = rqs[0]; - PutMetricAlarmRequest rq2 = rqs[1]; - - /* - * Describe them - */ - var describeResult = Client.DescribeAlarmsForMetric(new DescribeAlarmsForMetricRequest() - { - Dimensions = rq1.Dimensions, - MetricName = metricName, - Namespace = rq1.Namespace - }); - - Assert.AreEqual(2, describeResult.MetricAlarms.Count); - foreach (MetricAlarm alarm in describeResult.MetricAlarms) - { - Assert.IsTrue(rq1.AlarmName.Equals(alarm.AlarmName) || rq2.AlarmName.Equals(alarm.AlarmName)); - Assert.IsTrue(alarm.ActionsEnabled.Value); - } - } - - /** - * Creates two alarms on the metric name given and returns the two requests - * as an array. - */ - private PutMetricAlarmRequest[] CreateTwoNewAlarms(String metricName) - { - PutMetricAlarmRequest[] rqs = new PutMetricAlarmRequest[2]; - - /* - * Put two metric alarms - */ - rqs[0] = new PutMetricAlarmRequest() - { - ActionsEnabled = true, - AlarmDescription = "Some alarm description", - AlarmName = ALARM_BASENAME + metricName, - ComparisonOperator = "GreaterThanThreshold", - Dimensions = new List - { - new Dimension{Name="InstanceType",Value="m1.small"} - }, - EvaluationPeriods = 1, - MetricName = metricName, - Namespace = "AWS/EC2", - Period = 60, - Statistic = "Average", - Threshold = 1.0, - Unit = "Count" - }; - - Client.PutMetricAlarm(rqs[0]); - - rqs[1] = new PutMetricAlarmRequest() - { - ActionsEnabled = true, - AlarmDescription = "Some alarm description 2", - AlarmName = "An Alarm Name 2" + metricName, - ComparisonOperator = "GreaterThanThreshold", - Dimensions = new List - { - new Dimension{Name="InstanceType",Value="m1.small"} - }, - EvaluationPeriods = 1, - MetricName = metricName, - Namespace = "AWS/EC2", - Period = 60, - Statistic = "Average", - Threshold = 2.0, - Unit = "Count" - }; - Client.PutMetricAlarm(rqs[1]); - return rqs; - } - - void AssertNotEmpty(String s) - { - Assert.IsNotNull(s); - Assert.IsTrue(s.Length > 0); - } - private void AssertValidException(AmazonCloudWatchException e) - { - Assert.IsNotNull(e); - Assert.IsNotNull(e.ErrorCode); - Assert.IsNotNull(e.ErrorType); - Assert.IsNotNull(e.Message); - Assert.IsNotNull(e.RequestId); - Assert.IsNotNull(e.StatusCode); - Assert.IsTrue(e.ErrorCode.Length > 0); - Assert.IsTrue(e.Message.Length > 0); - Assert.IsTrue(e.RequestId.Length > 0); - } } } diff --git a/sdk/test/Services/CloudWatchEvents/IntegrationTests/AWSSDK.IntegrationTests.CloudWatchEvents.NetFramework.csproj b/sdk/test/Services/CloudWatchEvents/IntegrationTests/AWSSDK.IntegrationTests.CloudWatchEvents.NetFramework.csproj deleted file mode 100644 index ee2254c0feff..000000000000 --- a/sdk/test/Services/CloudWatchEvents/IntegrationTests/AWSSDK.IntegrationTests.CloudWatchEvents.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.CloudWatchEvents.NetFramework - AWSSDK.IntegrationTests.CloudWatchEvents.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/CloudWatchEvents/IntegrationTests/CloudWatchEvents.cs b/sdk/test/Services/CloudWatchEvents/IntegrationTests/CloudWatchEvents.cs deleted file mode 100644 index e0b5ad300d23..000000000000 --- a/sdk/test/Services/CloudWatchEvents/IntegrationTests/CloudWatchEvents.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Threading; -using AWSSDK_DotNet.IntegrationTests.Utils; - -using Amazon.CloudWatchEvents; -using Amazon.CloudWatchEvents.Model; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class CloudWatchEvents : TestBase - { - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - [TestMethod] - [TestCategory("CloudWatchEvents")] - public void TestCloudWatchEvents() - { - var rules = Client.ListRules().Rules; - - Assert.IsTrue(rules != null); - - string ruleName = UtilityMethods.GenerateName("CloudWatchEventRule"); - - var exception = AssertExtensions.ExpectException(() => - Client.DescribeRule(new DescribeRuleRequest { Name = ruleName })); - - try - { - var createRuleResponse = Client.PutRule(new PutRuleRequest - { - Name = ruleName, - State = RuleState.ENABLED, - ScheduleExpression = "rate(5 minutes)" - - }); - - Assert.IsFalse(string.IsNullOrEmpty(createRuleResponse.RuleArn)); - } - finally - { - Client.DeleteRule(new DeleteRuleRequest - { - Name = ruleName - }); - } - } - } -} \ No newline at end of file diff --git a/sdk/test/Services/CloudWatchEvents/IntegrationTests/Config/462/App.config b/sdk/test/Services/CloudWatchEvents/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/CloudWatchEvents/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/CloudWatchLogs/IntegrationTests/AWSSDK.IntegrationTests.CloudWatchLogs.NetFramework.csproj b/sdk/test/Services/CloudWatchLogs/IntegrationTests/AWSSDK.IntegrationTests.CloudWatchLogs.NetFramework.csproj deleted file mode 100644 index de8976c36b00..000000000000 --- a/sdk/test/Services/CloudWatchLogs/IntegrationTests/AWSSDK.IntegrationTests.CloudWatchLogs.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.CloudWatchLogs.NetFramework - AWSSDK.IntegrationTests.CloudWatchLogs.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/CloudWatchLogs/IntegrationTests/CloudWatchLogs.cs b/sdk/test/Services/CloudWatchLogs/IntegrationTests/CloudWatchLogs.cs deleted file mode 100644 index 5fa0ab83e943..000000000000 --- a/sdk/test/Services/CloudWatchLogs/IntegrationTests/CloudWatchLogs.cs +++ /dev/null @@ -1,152 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Threading; -using AWSSDK_DotNet.IntegrationTests.Utils; - -using Amazon.CloudWatchLogs; -using Amazon.CloudWatchLogs.Model; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class CloudWatchLogs : TestBase - { - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - [TestMethod] - [TestCategory("CloudWatchLogs")] - public void CRUDLogGroup() - { - var logGroupName = "sdk-dotnet-" + DateTime.UtcNow.Ticks; - Client.CreateLogGroup(new CreateLogGroupRequest - { - LogGroupName = logGroupName - }); - try - { - { - DescribeLogGroupsResponse response = Client.DescribeLogGroups(new DescribeLogGroupsRequest - { - LogGroupNamePrefix = logGroupName - }); - - Assert.AreEqual(1, response.LogGroups.Count); - Assert.IsNotNull(response.LogGroups[0].Arn); - Assert.IsNull(response.LogGroups[0].RetentionInDays); - - Client.PutRetentionPolicy(new PutRetentionPolicyRequest - { - LogGroupName = logGroupName, - RetentionInDays = 1 - }); - - response = Client.DescribeLogGroups(new DescribeLogGroupsRequest - { - LogGroupNamePrefix = logGroupName - }); - - Assert.AreEqual(1, response.LogGroups.Count); - Assert.AreEqual(1, response.LogGroups[0].RetentionInDays.GetValueOrDefault()); - } - - { - Client.CreateLogStream(new CreateLogStreamRequest - { - LogGroupName = logGroupName, - LogStreamName = "sample" - }); - - DescribeLogStreamsResponse describeResponse = Client.DescribeLogStreams(new DescribeLogStreamsRequest - { - LogGroupName = logGroupName, - LogStreamNamePrefix = "sample" - }); - - Assert.AreEqual(1, describeResponse.LogStreams.Count); - Assert.IsNotNull(describeResponse.LogStreams[0].Arn); - - PutLogEventsResponse putResponse1 = Client.PutLogEvents(new PutLogEventsRequest - { - LogGroupName = logGroupName, - LogStreamName = "sample", - LogEvents = new List - { - new InputLogEvent - { - Message = "First Data", - Timestamp = DateTime.UtcNow - } - } - }); - - // Pad the time so the 2 events are not at the same time. - Thread.Sleep(10); - - Client.PutLogEvents(new PutLogEventsRequest - { - SequenceToken = putResponse1.NextSequenceToken, - LogGroupName = logGroupName, - LogStreamName = "sample", - LogEvents = new List - { - new InputLogEvent - { - Message = "Second Data", - Timestamp = DateTime.UtcNow - } - } - }); - - GetLogEventsResponse getResponse = null; - - // Doing this in a loop to wait for the eventual consistency of the events - // being written to cloudwatch logs. - for (int i = 0; i < 20; i++) - { - - getResponse = Client.GetLogEvents(new GetLogEventsRequest - { - LogGroupName = logGroupName, - LogStreamName = "sample", - StartTime = DateTime.UtcNow.AddDays(-2), - EndTime = DateTime.UtcNow - }); - - if (getResponse.Events.Count == 2) - break; - - Thread.Sleep(1000 * 2); - } - - Assert.AreEqual(2, getResponse.Events.Count); - Assert.AreEqual("First Data", getResponse.Events[0].Message); - Assert.AreEqual(DateTime.UtcNow.Date, getResponse.Events[0].Timestamp.Value.Date); - - Assert.AreEqual("Second Data", getResponse.Events[1].Message); - Assert.AreEqual(DateTime.UtcNow.Date, getResponse.Events[1].Timestamp.Value.Date); - - Assert.IsTrue(getResponse.Events[0].Timestamp.Value < getResponse.Events[1].Timestamp.Value); - - - Client.DeleteLogStream(new DeleteLogStreamRequest - { - LogGroupName = logGroupName, - LogStreamName = "sample" - }); - } - } - finally - { - Client.DeleteLogGroup(new DeleteLogGroupRequest - { - LogGroupName = logGroupName - }); - } - } - } -} \ No newline at end of file diff --git a/sdk/test/Services/CloudWatchLogs/IntegrationTests/Config/462/App.config b/sdk/test/Services/CloudWatchLogs/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/CloudWatchLogs/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/CodeDeploy/IntegrationTests/AWSSDK.IntegrationTests.CodeDeploy.NetFramework.csproj b/sdk/test/Services/CodeDeploy/IntegrationTests/AWSSDK.IntegrationTests.CodeDeploy.NetFramework.csproj deleted file mode 100644 index cc06e93815a3..000000000000 --- a/sdk/test/Services/CodeDeploy/IntegrationTests/AWSSDK.IntegrationTests.CodeDeploy.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.CodeDeploy.NetFramework - AWSSDK.IntegrationTests.CodeDeploy.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/CodeDeploy/IntegrationTests/CodeDeploy.cs b/sdk/test/Services/CodeDeploy/IntegrationTests/CodeDeploy.cs deleted file mode 100644 index aef9460c500d..000000000000 --- a/sdk/test/Services/CodeDeploy/IntegrationTests/CodeDeploy.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Amazon; -using Amazon.CodeDeploy; -using Amazon.CodeDeploy.Model; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class CodeDeploy : TestBase - { - [TestMethod] - [TestCategory("CodeDeploy")] - public void TestListApplications() - { - Client.ListApplications(); - } - - [TestMethod] - [TestCategory("CodeDeploy")] - public void TestCreateApplication() - { - var appName = Utils.UtilityMethods.GenerateName(); - Client.CreateApplication(new CreateApplicationRequest { ApplicationName = appName }); - Assert.IsTrue(Client.ListApplications().Applications.Contains(appName)); - Client.DeleteApplication(new DeleteApplicationRequest { ApplicationName = appName }); - } - - [TestMethod] - [TestCategory("CodeDeploy")] - public void TestDeleteApplication() - { - var appName = Utils.UtilityMethods.GenerateName(); - Client.CreateApplication(new CreateApplicationRequest { ApplicationName = appName }); - Assert.IsTrue(Client.ListApplications().Applications.Contains(appName)); - Client.DeleteApplication(new DeleteApplicationRequest { ApplicationName = appName }); - Assert.IsFalse(Client.ListApplications().Applications.Contains(appName)); - } - } -} diff --git a/sdk/test/Services/CodeDeploy/IntegrationTests/Config/462/App.config b/sdk/test/Services/CodeDeploy/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/CodeDeploy/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/CognitoSync/IntegrationTests/AWSSDK.IntegrationTests.CognitoSync.NetFramework.csproj b/sdk/test/Services/CognitoSync/IntegrationTests/AWSSDK.IntegrationTests.CognitoSync.NetFramework.csproj deleted file mode 100644 index 192527e538cf..000000000000 --- a/sdk/test/Services/CognitoSync/IntegrationTests/AWSSDK.IntegrationTests.CognitoSync.NetFramework.csproj +++ /dev/null @@ -1,53 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.CognitoSync.NetFramework - AWSSDK.IntegrationTests.CognitoSync.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/CognitoSync/IntegrationTests/Config/462/App.config b/sdk/test/Services/CognitoSync/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/CognitoSync/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/CognitoSync/IntegrationTests/CognitoSync.cs b/sdk/test/Services/CognitoSync/UnitTests/Custom/CacheItemsTests.cs similarity index 62% rename from sdk/test/Services/CognitoSync/IntegrationTests/CognitoSync.cs rename to sdk/test/Services/CognitoSync/UnitTests/Custom/CacheItemsTests.cs index 2cfa20265a08..9a9cace70fbf 100644 --- a/sdk/test/Services/CognitoSync/IntegrationTests/CognitoSync.cs +++ b/sdk/test/Services/CognitoSync/UnitTests/Custom/CacheItemsTests.cs @@ -1,36 +1,13 @@ -using Amazon; -using Amazon.CognitoIdentity; -using Amazon.CognitoIdentity.Model; -using Amazon.CognitoSync; -using Amazon.CognitoSync.Model; -using Amazon.Runtime; -using Amazon.SecurityToken; -using Amazon.SimpleNotificationService; -using Amazon.SimpleNotificationService.Model; -using AWSSDK_DotNet.IntegrationTests.Utils; +using Amazon.CognitoSync; using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Threading; -namespace AWSSDK_DotNet.IntegrationTests.Tests +namespace AWSSDK.UnitTests.CognitoSync { [TestClass] - public class CognitoSync : TestBase + public class CacheItemsTests { - [TestCleanup] - public void Cleanup() - { - } - - [ClassCleanup] - public static void ClassCleanup() - { - BaseClean(); - } - [TestMethod] [TestCategory("CognitoSync")] public void CacheTest() diff --git a/sdk/test/Services/ConfigService/IntegrationTests/AWSSDK.IntegrationTests.ConfigService.NetFramework.csproj b/sdk/test/Services/ConfigService/IntegrationTests/AWSSDK.IntegrationTests.ConfigService.NetFramework.csproj deleted file mode 100644 index b3f1a52cc0f3..000000000000 --- a/sdk/test/Services/ConfigService/IntegrationTests/AWSSDK.IntegrationTests.ConfigService.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.ConfigService.NetFramework - AWSSDK.IntegrationTests.ConfigService.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/ConfigService/IntegrationTests/Config/462/App.config b/sdk/test/Services/ConfigService/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/ConfigService/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/ConfigService/IntegrationTests/ConfigServiceTests.cs b/sdk/test/Services/ConfigService/IntegrationTests/ConfigServiceTests.cs deleted file mode 100644 index 61b17a0aeb55..000000000000 --- a/sdk/test/Services/ConfigService/IntegrationTests/ConfigServiceTests.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; - - -using Amazon.ConfigService; -using Amazon.ConfigService.Model; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class ConfigServiceTests : TestBase - { - [TestMethod] - [TestCategory("ConfigService")] - public void TestDescribeConfigurationRecorderStatus() - { - Client.DescribeConfigurationRecorderStatus(new DescribeConfigurationRecorderStatusRequest - { - - }); - } - - - } -} diff --git a/sdk/test/Services/DataPipeline/IntegrationTests/AWSSDK.IntegrationTests.DataPipeline.NetFramework.csproj b/sdk/test/Services/DataPipeline/IntegrationTests/AWSSDK.IntegrationTests.DataPipeline.NetFramework.csproj deleted file mode 100644 index a09d998d2d81..000000000000 --- a/sdk/test/Services/DataPipeline/IntegrationTests/AWSSDK.IntegrationTests.DataPipeline.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.DataPipeline.NetFramework - AWSSDK.IntegrationTests.DataPipeline.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/DataPipeline/IntegrationTests/Config/462/App.config b/sdk/test/Services/DataPipeline/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/DataPipeline/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/DataPipeline/IntegrationTests/DataPipeline.cs b/sdk/test/Services/DataPipeline/IntegrationTests/DataPipeline.cs deleted file mode 100644 index dba4a8d859e1..000000000000 --- a/sdk/test/Services/DataPipeline/IntegrationTests/DataPipeline.cs +++ /dev/null @@ -1,127 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using Amazon.DataPipeline; -using Amazon.DataPipeline.Model; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class DataPipeline : TestBase - { - [TestMethod] - [TestCategory("DataPipeline")] - public void TestListPipelines() - { - var response = Client.ListPipelines(); - Assert.IsNotNull(response); - - // if test a/c had some pipelines, iterate through - // to verify marshal - if (response.PipelineIdList.Count > 0) - { - foreach (var p in response.PipelineIdList) - { - Assert.IsNotNull(p); - Assert.IsFalse(string.IsNullOrEmpty(p.Id)); - } - } - } - - //[TestMethod] - [TestCategory("DataPipeline")] - public void TestPipelineOperations() - { - const string testPipelineName = "dotnet-test-pipeline"; - const string testPipelineDescription = "dotnet test pipeline"; - - var testPipelineId = "dotnet-test-pipeline" + DateTime.UtcNow.ToFileTime(); - - const string testObjectId = "123"; - const string testObjectName = "object"; - - string createdPipelineId = null; - - try - { - var createPipelineResult - = Client.CreatePipeline(new CreatePipelineRequest - { - Name = testPipelineName, - UniqueId = testPipelineId, - Description = testPipelineDescription - }); - createdPipelineId = createPipelineResult.PipelineId; - Assert.IsNotNull(createdPipelineId); - - var pipelineObject = new PipelineObject { Id = testObjectId, Name = testObjectName }; - var field = new Field { Key = "workerGroup", StringValue = "dotnetsdk" }; - pipelineObject.Fields = new List { field }; - - var putPipelineDefinitionResult - = Client.PutPipelineDefinition(new PutPipelineDefinitionRequest - { - PipelineId = createdPipelineId, - PipelineObjects = new List { pipelineObject } - }); - Assert.IsFalse(putPipelineDefinitionResult.Errored.Value); - - var tags = new List - { - new Tag { Key = "tag1", Value = "42" }, - new Tag { Key = "tag2", Value = DateTime.UtcNow.ToString() } - }; - Client.AddTags(createdPipelineId, tags); - - var describeResult = Client.DescribePipelines(new List { createdPipelineId }).PipelineDescriptionList; - Assert.AreEqual(1, describeResult.Count); - Assert.AreEqual(tags.Count, describeResult.First().Tags.Count); - - Client.RemoveTags(createdPipelineId, new List { "tag1" }); - - describeResult = Client.DescribePipelines(new List { createdPipelineId }).PipelineDescriptionList; - Assert.AreEqual(1, describeResult.Count); - Assert.AreEqual(1, describeResult.First().Tags.Count); - - var activatePipelineResult = Client.ActivatePipeline(new ActivatePipelineRequest - { - PipelineId = createdPipelineId - }); - Assert.IsNotNull(activatePipelineResult); - - - var foundPipeline = false; - for (int retries = 0; retries < 5 && !foundPipeline; retries++) - { - Thread.Sleep(1000 * retries); - - var listRequest = new ListPipelinesRequest(); - var listResponse = new ListPipelinesResponse(); - do - { - listRequest.Marker = listResponse.Marker; - listResponse = Client.ListPipelines(listRequest); - if (listResponse.PipelineIdList.Count > 0) - { - if (listResponse.PipelineIdList.Any(p => p.Id.Equals(createdPipelineId) && p.Name.Equals(testPipelineName))) - { - foundPipeline = true; - break; - } - } - } while (!string.IsNullOrEmpty(listResponse.Marker)); - } - Assert.IsTrue(foundPipeline); - } - finally - { - if (!string.IsNullOrEmpty(createdPipelineId)) - { - Client.DeletePipeline(new DeletePipelineRequest { PipelineId = createdPipelineId }); - } - } - } - } -} diff --git a/sdk/test/Services/DatabaseMigrationService/IntegrationTests/AWSSDK.IntegrationTests.DatabaseMigrationService.NetFramework.csproj b/sdk/test/Services/DatabaseMigrationService/IntegrationTests/AWSSDK.IntegrationTests.DatabaseMigrationService.NetFramework.csproj deleted file mode 100644 index 343f8054b28f..000000000000 --- a/sdk/test/Services/DatabaseMigrationService/IntegrationTests/AWSSDK.IntegrationTests.DatabaseMigrationService.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.DatabaseMigrationService.NetFramework - AWSSDK.IntegrationTests.DatabaseMigrationService.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/DatabaseMigrationService/IntegrationTests/Config/462/App.config b/sdk/test/Services/DatabaseMigrationService/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/DatabaseMigrationService/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/DatabaseMigrationService/IntegrationTests/DataMigrationTests.cs b/sdk/test/Services/DatabaseMigrationService/IntegrationTests/DataMigrationTests.cs deleted file mode 100644 index 5b85e3e410fb..000000000000 --- a/sdk/test/Services/DatabaseMigrationService/IntegrationTests/DataMigrationTests.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using Amazon.DatabaseMigrationService; -using Amazon.DatabaseMigrationService.Model; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class DataMigrationTests : TestBase - { - [TestMethod] - [TestCategory("DatabaseMigrationService")] - public void TestDescribeEndpoints() - { - var response = Client.DescribeEndpoints(new DescribeEndpointsRequest { }); - Assert.IsNotNull(response); - } - } -} diff --git a/sdk/test/Services/DirectConnect/IntegrationTests/AWSSDK.IntegrationTests.DirectConnect.NetFramework.csproj b/sdk/test/Services/DirectConnect/IntegrationTests/AWSSDK.IntegrationTests.DirectConnect.NetFramework.csproj deleted file mode 100644 index 1e435eaa39a3..000000000000 --- a/sdk/test/Services/DirectConnect/IntegrationTests/AWSSDK.IntegrationTests.DirectConnect.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.DirectConnect.NetFramework - AWSSDK.IntegrationTests.DirectConnect.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/DirectConnect/IntegrationTests/Config/462/App.config b/sdk/test/Services/DirectConnect/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/DirectConnect/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/DirectConnect/IntegrationTests/DirectConnect.cs b/sdk/test/Services/DirectConnect/IntegrationTests/DirectConnect.cs deleted file mode 100644 index 8fac598675e9..000000000000 --- a/sdk/test/Services/DirectConnect/IntegrationTests/DirectConnect.cs +++ /dev/null @@ -1,112 +0,0 @@ -using System; -using Amazon.DirectConnect; -using Amazon.DirectConnect.Model; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class DirectConnect : TestBase - { - [TestMethod] - [TestCategory("DirectConnect")] - public void TestDescribeConnections() - { - var response = Client.DescribeConnections(); - Assert.IsNotNull(response); - - if (response.Connections.Count > 0) - { - // if we got some connections, verify that the data that is - // mandatory when creating a connection marshalled correctly - foreach (var c in response.Connections) - { - Assert.IsFalse(string.IsNullOrEmpty(c.ConnectionId)); - Assert.IsFalse(string.IsNullOrEmpty(c.ConnectionName)); - Assert.IsFalse(string.IsNullOrEmpty(c.Location)); - Assert.IsFalse(string.IsNullOrEmpty(c.Bandwidth)); - } - } - } - - [TestMethod] - [TestCategory("DirectConnect")] - public void TestDescribeLocations() - { - var response = Client.DescribeLocations(); - Assert.IsNotNull(response); - - if (response.Locations.Count > 0) - { - foreach (var l in response.Locations) - { - Assert.IsFalse(string.IsNullOrEmpty(l.LocationCode)); - Assert.IsFalse(string.IsNullOrEmpty(l.LocationName)); - } - } - } - - [TestMethod] - [TestCategory("DirectConnect")] - public void TestDescribeVirtualGateways() - { - var response = Client.DescribeVirtualGateways(); - Assert.IsNotNull(response); - - if (response.VirtualGateways.Count > 0) - { - foreach (var vg in response.VirtualGateways) - { - Assert.IsFalse(string.IsNullOrEmpty(vg.VirtualGatewayId)); - Assert.IsFalse(string.IsNullOrEmpty(vg.VirtualGatewayState)); - } - } - } - - [TestMethod] - [TestCategory("DirectConnect")] - public void TestDescribeVirtualInterfaces() - { - var response = Client.DescribeVirtualInterfaces(); - Assert.IsNotNull(response); - - if (response.VirtualInterfaces.Count > 0) - { - foreach (var vi in response.VirtualInterfaces) - { - Assert.IsFalse(string.IsNullOrEmpty(vi.ConnectionId)); - Assert.IsFalse(string.IsNullOrEmpty(vi.VirtualInterfaceId)); - } - } - } - - // Test constraint: account must have permissions to create connections - //[TestMethod] - //[TestCategory("DirectConnect")] - public void TestCreateDeleteConnection() - { - const string BANDWIDTH = "1Gbps"; - - var locations = Client.DescribeLocations().Locations; - var connectionName = "dotnet-test-connection" + DateTime.UtcNow.Ticks; - string connectionId = null; - - try - { - var connection = Client.CreateConnection(new CreateConnectionRequest - { - Bandwidth = BANDWIDTH, - ConnectionName = connectionName, - Location = locations[0].LocationCode - }); - - connectionId = connection.ConnectionId; - } - finally - { - if (!string.IsNullOrEmpty(connectionId)) - Client.DeleteConnection(new DeleteConnectionRequest { ConnectionId = connectionId }); - } - } - } -} diff --git a/sdk/test/Services/DirectoryService/IntegrationTests/AWSSDK.IntegrationTests.DirectoryService.NetFramework.csproj b/sdk/test/Services/DirectoryService/IntegrationTests/AWSSDK.IntegrationTests.DirectoryService.NetFramework.csproj deleted file mode 100644 index 285699009ead..000000000000 --- a/sdk/test/Services/DirectoryService/IntegrationTests/AWSSDK.IntegrationTests.DirectoryService.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.DirectoryService.NetFramework - AWSSDK.IntegrationTests.DirectoryService.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/DirectoryService/IntegrationTests/Config/462/App.config b/sdk/test/Services/DirectoryService/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/DirectoryService/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/DirectoryService/IntegrationTests/DirectoryService.cs b/sdk/test/Services/DirectoryService/IntegrationTests/DirectoryService.cs deleted file mode 100644 index ddc3de417499..000000000000 --- a/sdk/test/Services/DirectoryService/IntegrationTests/DirectoryService.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using Amazon.DirectoryService; -using Amazon.DirectoryService.Model; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class DirectoryService : TestBase - { - [TestMethod] - [TestCategory("DirectoryService")] - public void TestGetDirectoryLimits() - { - var response = Client.GetDirectoryLimits(); - Assert.IsNotNull(response); - Assert.IsTrue(response.DirectoryLimits.ConnectedDirectoriesLimit > 0); - } - } -} \ No newline at end of file diff --git a/sdk/test/Services/DynamoDBStreams/IntegrationTests/ServiceTests.cs b/sdk/test/Services/DynamoDBStreams/IntegrationTests/ServiceTests.cs index a56090729eda..1b441cae123f 100644 --- a/sdk/test/Services/DynamoDBStreams/IntegrationTests/ServiceTests.cs +++ b/sdk/test/Services/DynamoDBStreams/IntegrationTests/ServiceTests.cs @@ -1,10 +1,5 @@ using Amazon.DynamoDBStreams; -using AWSSDK_DotNet.IntegrationTests.Tests; using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Threading.Tasks; namespace AWSSDK_DotNet.IntegrationTests.Tests.DynamoDBStreams @@ -14,16 +9,18 @@ public partial class DynamoDBStreamsTests : TestBase { - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - [TestMethod] - [TestCategory("EC2")] - public void TestDescribeAmazonImages() + public async Task TestDescribeAmazonImages() { - // perform a filtered query to (a) test parameter marshalling - // and (b) cut down the time to run -- an unfiltered request - // yields a lot of images - var request = new DescribeImagesRequest() + // perform a filtered query to cut down the time to run -- an unfiltered request + // yields a lot of images. + var request = new DescribeImagesRequest { - Owners = new List { "amazon" } + Owners = new List { "amazon" }, + MaxResults = 10, }; - var response = Client.DescribeImages(request); + var response = await Client.DescribeImagesAsync(request); Assert.IsNotNull(response); Assert.IsNotNull(response.Images); } [TestMethod] - [TestCategory("EC2")] - public void TestDescribeAmazonImagesWithDryRun() + public async Task TestDescribeAmazonImagesWithDryRun() { - var request = new DescribeImagesRequest() + var request = new DescribeImagesRequest { DryRun = true, Owners = new List { "amazon" }, }; - - var assertedException = Assert.ThrowsException( () => { - Client.DescribeImages(request); - }); - + + var assertedException = await Assert.ThrowsExceptionAsync(() => Client.DescribeImagesAsync(request)); Assert.AreEqual(HttpStatusCode.PreconditionFailed, assertedException.StatusCode); Assert.AreEqual("DryRunOperation", assertedException.ErrorCode); } -#if ASYNC_AWAIT [TestMethod] - [TestCategory("EC2")] - public async System.Threading.Tasks.Task TestDescribeAmazonImagesCancellationTest() + public async Task TestDescribeAmazonImagesCancellationTest() { - // perform a filtered query to (a) test parameter marshalling - // and (b) cut down the time to run -- an unfiltered request - // yields a lot of images - var request = new DescribeImagesRequest() + // perform a filtered query to cut down the time to run -- an unfiltered request + // yields a lot of images. + var request = new DescribeImagesRequest { Owners = new List { "amazon" } }; @@ -76,7 +58,7 @@ public async System.Threading.Tasks.Task TestDescribeAmazonImagesCancellationTes var token = cts.Token; try { - var response = await Client.DescribeImagesAsync(request,token); + await Client.DescribeImagesAsync(request, token); } catch (OperationCanceledException exception) { @@ -86,6 +68,5 @@ public async System.Threading.Tasks.Task TestDescribeAmazonImagesCancellationTes } Assert.Fail("An OperationCanceledException was not thrown"); } -#endif } } diff --git a/sdk/test/Services/EC2/IntegrationTests/DescribeImagesUnmarshallTest.cs b/sdk/test/Services/EC2/IntegrationTests/DescribeImagesUnmarshallTest.cs deleted file mode 100644 index eae4fe565ea2..000000000000 --- a/sdk/test/Services/EC2/IntegrationTests/DescribeImagesUnmarshallTest.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using Amazon.EC2; -using Amazon.EC2.Model; -using Amazon.EC2.Model.Internal.MarshallTransformations; -using Amazon.Runtime.Internal.Transform; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace AWSSDK_DotNet.IntegrationTests.Tests.EC2 -{ - [TestClass] - public class DescribeImagesUnmarshallTest - { - } -} diff --git a/sdk/test/Services/EC2/IntegrationTests/SecurityGroupTests.cs b/sdk/test/Services/EC2/IntegrationTests/SecurityGroupTests.cs index 39e6f142f55e..f00dab335944 100644 --- a/sdk/test/Services/EC2/IntegrationTests/SecurityGroupTests.cs +++ b/sdk/test/Services/EC2/IntegrationTests/SecurityGroupTests.cs @@ -1,25 +1,27 @@ -using Amazon; -using Amazon.EC2; +using Amazon.EC2; using Amazon.EC2.Model; using AWSSDK_DotNet.IntegrationTests.Utils; using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; namespace AWSSDK_DotNet.IntegrationTests.Tests.EC2 { [TestClass] + [TestCategory("EC2")] public class SecurityGroupTests : TestBase { private static readonly string SECURITY_GROUP_NAME = "test-sg"; private static string SECURITY_GROUP_ID; - private static readonly Tag DotNetTag = new Tag("purpose", ".NET SDK integ test"); + private static readonly TimeSpan WAIT_TIMEOUT = TimeSpan.FromMinutes(5); - public SecurityGroupTests() + [ClassInitialize] + public static async Task ClassInitialize(TestContext testContext) { - var createVpcResponse = Client.CreateVpc(new CreateVpcRequest + var createVpcResponse = await Client.CreateVpcAsync(new CreateVpcRequest { CidrBlock = "10.0.0.0/16", TagSpecifications = new List @@ -32,18 +34,16 @@ public SecurityGroupTests() } }); - UtilityMethods.WaitUntilSuccess(() => + await UtilityMethods.WaitUntilAsync(async () => { - var describVpcsResponse = DescribeVpcsByTag(); + var describVpcsResponse = await DescribeVpcsByTag(); if (describVpcsResponse.Vpcs.Count > 0) { return; } + }, WAIT_TIMEOUT); - throw new Exception("VPC not ready yet, will continue waiting."); - }); - - var createSecurityGroup = Client.CreateSecurityGroup(new CreateSecurityGroupRequest + var createSecurityGroup = await Client.CreateSecurityGroupAsync(new CreateSecurityGroupRequest { GroupName = SECURITY_GROUP_NAME, Description = "Test security Group", @@ -58,27 +58,25 @@ public SecurityGroupTests() } }); - UtilityMethods.WaitUntilSuccess(() => + await UtilityMethods.WaitUntilAsync(async () => { - var describeSecurityGroupsResponse = DescribeSecurityGroupsByTag(); + var describeSecurityGroupsResponse = await DescribeSecurityGroupsByTag(); if (describeSecurityGroupsResponse.SecurityGroups.Count > 0) { return; } - - throw new Exception("Security Group not ready yet, will continue waiting."); - }); + }, WAIT_TIMEOUT); SECURITY_GROUP_ID = createSecurityGroup.GroupId; } [ClassCleanup] - public static void Cleanup() + public static async Task ClassCleanup() { - UtilityMethods.WaitUntilSuccess(() => + await UtilityMethods.WaitUntilAsync(async () => { // clean up all .net tagged security groups - var describeSecurityGroupsResponse = DescribeSecurityGroupsByTag(); + var describeSecurityGroupsResponse = await DescribeSecurityGroupsByTag(); foreach (var group in describeSecurityGroupsResponse.SecurityGroups) { Client.DeleteSecurityGroup(new DeleteSecurityGroupRequest @@ -88,7 +86,7 @@ public static void Cleanup() } // clean up all .net tagged vpcs - var describVpcsResponse = DescribeVpcsByTag(); + var describVpcsResponse = await DescribeVpcsByTag(); foreach (var vpc in describVpcsResponse.Vpcs) { Client.DeleteVpc(new DeleteVpcRequest @@ -96,7 +94,7 @@ public static void Cleanup() VpcId = vpc.VpcId }); } - }); + }, WAIT_TIMEOUT); BaseClean(); } @@ -109,63 +107,68 @@ public static void Cleanup() /// 2. A RevokeSecurityGroupEgressRequest operation is perfomed to remove all the IpPermissions added to the security group. /// [TestMethod] - [TestCategory("EC2")] - public void IpRangeRoundTripTest() + public async Task IpRangeRoundTripTest() { -#pragma warning disable CS0618 - var describeSecurityGroupsResponse = DescribeSecurityGroupById(); + var describeSecurityGroupsResponse = await DescribeSecurityGroupById(); + + var testCollection = new List + { + "0.0.0.0/7" + }; - var testCollection = new List(); - var authorizeSecurityGroupEgressRequest = new AuthorizeSecurityGroupEgressRequest(); - authorizeSecurityGroupEgressRequest.GroupId = SECURITY_GROUP_ID; - IpPermission authorizeSecurityGroupEgressPermission = new IpPermission() + var authorizeSecurityGroupEgressRequest = new AuthorizeSecurityGroupEgressRequest + { + GroupId = SECURITY_GROUP_ID + }; + + var authorizeSecurityGroupEgressPermission = new IpPermission { Ipv4Ranges = new List { - new IpRange{ CidrIp = "0.0.0.0/7", Description = "test"} - } + new IpRange{ CidrIp = "0.0.0.0/7", Description = "test" } + }, + IpProtocol = "ICMP", + FromPort = -1, + ToPort = -1 }; - testCollection.Add("0.0.0.0/7"); - authorizeSecurityGroupEgressPermission.IpProtocol = "ICMP"; - authorizeSecurityGroupEgressPermission.FromPort = -1; - authorizeSecurityGroupEgressPermission.ToPort = -1; - authorizeSecurityGroupEgressRequest.IpPermissions = new List { authorizeSecurityGroupEgressPermission }; - var authorizeSecurityGroupEgressResponse = Client.AuthorizeSecurityGroupEgress(authorizeSecurityGroupEgressRequest); + authorizeSecurityGroupEgressRequest.IpPermissions = new List { authorizeSecurityGroupEgressPermission }; + var authorizeSecurityGroupEgressResponse = await Client.AuthorizeSecurityGroupEgressAsync(authorizeSecurityGroupEgressRequest); Assert.IsNotNull(authorizeSecurityGroupEgressResponse); - UtilityMethods.WaitUntilSuccess(() => + describeSecurityGroupsResponse = await DescribeSecurityGroupById(); + var revokeSecurityGroupEgressRequest = new RevokeSecurityGroupEgressRequest { - describeSecurityGroupsResponse = DescribeSecurityGroupById(); - }); - - var revokeSecurityGroupEgressRequest = new RevokeSecurityGroupEgressRequest(); - revokeSecurityGroupEgressRequest.GroupId = SECURITY_GROUP_ID; - revokeSecurityGroupEgressRequest.IpPermissions = new List { describeSecurityGroupsResponse.SecurityGroups[0].IpPermissionsEgress[1] }; - var revokeSecurityGroupIngressResponse = Client.RevokeSecurityGroupEgress(revokeSecurityGroupEgressRequest); + GroupId = SECURITY_GROUP_ID, + IpPermissions = new List { describeSecurityGroupsResponse.SecurityGroups[0].IpPermissionsEgress[1] } + }; + var revokeSecurityGroupIngressResponse = await Client.RevokeSecurityGroupEgressAsync(revokeSecurityGroupEgressRequest); Assert.IsNotNull(revokeSecurityGroupIngressResponse); - UtilityMethods.WaitUntilSuccess(() => + await UtilityMethods.WaitUntilAsync(async () => { - describeSecurityGroupsResponse = DescribeSecurityGroupById(); + describeSecurityGroupsResponse = await DescribeSecurityGroupById(); var ipEgress = describeSecurityGroupsResponse.SecurityGroups[0].IpPermissionsEgress ?? new List(); Assert.IsFalse(ipEgress - .Where(p => p.Ipv4Ranges != null && (p.Ipv4Ranges.Contains(new IpRange { CidrIp = "0.0.0.0/7", Description = "test" }))).ToList().Any()); - }); + .Where(p => p.Ipv4Ranges != null && p.Ipv4Ranges.Contains(new IpRange { CidrIp = "0.0.0.0/7", Description = "test" })) + .ToList() + .Any() + ); + }, WAIT_TIMEOUT); } - private static DescribeSecurityGroupsResponse DescribeSecurityGroupById() + private static async Task DescribeSecurityGroupById() { var describeSecurityGroupRequest = new DescribeSecurityGroupsRequest { GroupIds = new List { SECURITY_GROUP_ID } }; - return Client.DescribeSecurityGroups(describeSecurityGroupRequest); + return await Client.DescribeSecurityGroupsAsync(describeSecurityGroupRequest); } - private static DescribeSecurityGroupsResponse DescribeSecurityGroupsByTag() + private static async Task DescribeSecurityGroupsByTag() { var describeSecurityGroupRequest = new DescribeSecurityGroupsRequest { @@ -174,11 +177,11 @@ private static DescribeSecurityGroupsResponse DescribeSecurityGroupsByTag() new Filter("tag-value", new List { DotNetTag.Value }), } }; - - return Client.DescribeSecurityGroups(describeSecurityGroupRequest); + + return await Client.DescribeSecurityGroupsAsync(describeSecurityGroupRequest); } - private static DescribeVpcsResponse DescribeVpcsByTag() + private static async Task DescribeVpcsByTag() { var describeVpcsRequest = new DescribeVpcsRequest { @@ -188,7 +191,7 @@ private static DescribeVpcsResponse DescribeVpcsByTag() } }; - return Client.DescribeVpcs(describeVpcsRequest); + return await Client.DescribeVpcsAsync(describeVpcsRequest); } } } diff --git a/sdk/test/Services/EC2/IntegrationTests/TaggingTests.cs b/sdk/test/Services/EC2/IntegrationTests/TaggingTests.cs index 990498aee428..1b67dbaab382 100644 --- a/sdk/test/Services/EC2/IntegrationTests/TaggingTests.cs +++ b/sdk/test/Services/EC2/IntegrationTests/TaggingTests.cs @@ -1,73 +1,77 @@ -using System; +using Amazon.EC2; +using Amazon.EC2.Model; +using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Collections.Generic; using System.Linq; -using System.Threading; -using Amazon.IdentityManagement.Model; -using Amazon.Runtime; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using Amazon.EC2; -using Amazon.EC2.Model; - -using AWSSDK_DotNet.IntegrationTests.Utils; +using System.Threading.Tasks; namespace AWSSDK_DotNet.IntegrationTests.Tests.EC2 { [TestClass] + [TestCategory("EC2")] public class TaggingTests : TestBase { private const string tagName = "DotNetNullTestTag"; + [TestMethod] - [TestCategory("EC2")] - public void TestNullTags() + public async Task TestNullTags() { - var vpcId = Client.CreateVpc(new CreateVpcRequest + var createResponse = await Client.CreateVpcAsync(new CreateVpcRequest { CidrBlock = "10.0.0.0/16", InstanceTenancy = Tenancy.Default - }).Vpc.VpcId; + }); // Wait to make sure VPC exists - Thread.Sleep(2000); + var vpcId = createResponse.Vpc.VpcId; + await Task.Delay(2000); + try { - Client.CreateTags(new CreateTagsRequest + await Client.CreateTagsAsync(new CreateTagsRequest { Resources = new List { vpcId }, - Tags = new List - { - new Amazon.EC2.Model.Tag(tagName, "") - } + Tags = new List + { + new Tag(tagName, "") + } }); - var tagDescriptions = Client.DescribeTags(new DescribeTagsRequest + var describeTagsResponse = await Client.DescribeTagsAsync(new DescribeTagsRequest { Filters = new List { new Filter("resource-id", new List { vpcId }) } - }).Tags; + }); + + var tagDescriptions = describeTagsResponse.Tags; TagDescription newTag = null; + foreach (var tag in tagDescriptions) + { if (tag.Key == tagName) + { newTag = tag; + } + } Assert.IsNotNull(newTag); Assert.IsTrue(string.IsNullOrEmpty(newTag.Value)); var tags = tagDescriptions - .Select(td => new Amazon.EC2.Model.Tag(td.Key, td.Value ?? "")) + .Select(td => new Tag(td.Key, td.Value ?? "")) .ToList(); - Client.CreateTags(new CreateTagsRequest + await Client.CreateTagsAsync(new CreateTagsRequest { Resources = new List { vpcId }, Tags = tags }); tags = tagDescriptions - .Select(td => new Amazon.EC2.Model.Tag(td.Key, td.Value)) + .Select(td => new Tag(td.Key, td.Value)) .ToList(); - Client.CreateTags(new CreateTagsRequest + await Client.CreateTagsAsync(new CreateTagsRequest { Resources = new List { vpcId }, Tags = tags @@ -75,7 +79,7 @@ public void TestNullTags() } finally { - Client.DeleteVpc(new DeleteVpcRequest + await Client.DeleteVpcAsync(new DeleteVpcRequest { VpcId = vpcId }); diff --git a/sdk/test/Services/ECR/IntegrationTests/AWSSDK.IntegrationTests.ECR.NetFramework.csproj b/sdk/test/Services/ECR/IntegrationTests/AWSSDK.IntegrationTests.ECR.NetFramework.csproj deleted file mode 100644 index 785c55bb2242..000000000000 --- a/sdk/test/Services/ECR/IntegrationTests/AWSSDK.IntegrationTests.ECR.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.ECR.NetFramework - AWSSDK.IntegrationTests.ECR.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/ECR/IntegrationTests/Config/462/App.config b/sdk/test/Services/ECR/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/ECR/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/ECR/IntegrationTests/ECR.cs b/sdk/test/Services/ECR/IntegrationTests/ECR.cs deleted file mode 100644 index 5bec59a13274..000000000000 --- a/sdk/test/Services/ECR/IntegrationTests/ECR.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Amazon; -using Amazon.ECR; -using Amazon.ECR.Model; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class ECR : TestBase - { - [TestMethod] - [TestCategory("ECR")] - public void TestRepos() - { - var repoName = Utils.UtilityMethods.GenerateName("ecs-repo-"); - var repo = Client.CreateRepository(new CreateRepositoryRequest { RepositoryName = repoName }).Repository; - - var repos = Client.DescribeRepositories(new DescribeRepositoriesRequest { }); - - Assert.IsTrue(repos.Repositories - .Select(r => r.RepositoryName) - .Contains(repo.RepositoryName)); - - var images = Client.ListImages(new ListImagesRequest { RegistryId = repo.RegistryId, RepositoryName = repo.RepositoryName}).ImageIds; - - Assert.IsFalse(images.Any()); - - Client.DeleteRepository(new DeleteRepositoryRequest { RegistryId = repo.RegistryId, RepositoryName = repo.RepositoryName }); - } - } -} diff --git a/sdk/test/Services/ECS/IntegrationTests/CredentialsTests.cs b/sdk/test/Services/ECS/IntegrationTests/CredentialsTests.cs index af66ac798c27..dbd782bca477 100644 --- a/sdk/test/Services/ECS/IntegrationTests/CredentialsTests.cs +++ b/sdk/test/Services/ECS/IntegrationTests/CredentialsTests.cs @@ -1,52 +1,13 @@ -using System; -using System.Collections.Generic; +using Amazon.Runtime; +using Amazon.Runtime.CredentialManagement; using Microsoft.VisualStudio.TestTools.UnitTesting; - -using AWSSDK_DotNet.IntegrationTests.Utils; -using Amazon.Runtime; -using Amazon; -using Amazon.S3; using System.IO; -using System.Net; -using System.Diagnostics; -using System.Reflection; -using AWSSDK_DotNet.CommonTest.Utils; -using Amazon.Runtime.CredentialManagement; namespace AWSSDK_DotNet.IntegrationTests.Tests { [TestClass] public class CredentialsTests { - [TestMethod] - [TestCategory("General")] - [TestCategory("RequiresIAMUser")] - public void TestSessionCredentials() - { - using (var sts = new Amazon.SecurityToken.AmazonSecurityTokenServiceClient()) - { - AWSCredentials credentials = sts.GetSessionToken().Credentials; - - using (var ec2 = new Amazon.EC2.AmazonEC2Client(credentials)) - { - var regions = ec2.DescribeRegions().Regions; - Console.WriteLine(regions.Count); - } - - using (var s3 = new Amazon.S3.AmazonS3Client(credentials)) - { - var buckets = s3.ListBuckets().Buckets; - Console.WriteLine(buckets.Count); - } - - using (var swf = new Amazon.SimpleWorkflow.AmazonSimpleWorkflowClient(credentials)) - { - var domains = swf.ListDomains(new Amazon.SimpleWorkflow.Model.ListDomainsRequest { RegistrationStatus = "REGISTERED" }).DomainInfos; - Console.WriteLine(domains.Infos.Count); - } - } - } - [TestMethod] [TestCategory("General")] public void TestCredentialsFile() diff --git a/sdk/test/Services/ECS/IntegrationTests/ECS.cs b/sdk/test/Services/ECS/IntegrationTests/ECS.cs deleted file mode 100644 index bfcd3b56d4d0..000000000000 --- a/sdk/test/Services/ECS/IntegrationTests/ECS.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Amazon; -using Amazon.ECS; -using Amazon.ECS.Model; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class ECS : TestBase - { - [TestMethod] - [TestCategory("ECS")] - public void ListClusters() - { - var clusters = Client.ListClusters(new ListClustersRequest()); - Assert.IsTrue(clusters.ClusterArns.Count >= 0); - - foreach (var cluster in clusters.ClusterArns) - { - Assert.IsFalse(string.IsNullOrEmpty(cluster)); - } - } - } -} diff --git a/sdk/test/Services/ElastiCache/IntegrationTests/AWSSDK.IntegrationTests.ElastiCache.NetFramework.csproj b/sdk/test/Services/ElastiCache/IntegrationTests/AWSSDK.IntegrationTests.ElastiCache.NetFramework.csproj deleted file mode 100644 index c250aa1bbc36..000000000000 --- a/sdk/test/Services/ElastiCache/IntegrationTests/AWSSDK.IntegrationTests.ElastiCache.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.ElastiCache.NetFramework - AWSSDK.IntegrationTests.ElastiCache.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/ElastiCache/IntegrationTests/Config/462/App.config b/sdk/test/Services/ElastiCache/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/ElastiCache/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/ElastiCache/IntegrationTests/ElastiCache.cs b/sdk/test/Services/ElastiCache/IntegrationTests/ElastiCache.cs deleted file mode 100644 index 12e3b5bbd100..000000000000 --- a/sdk/test/Services/ElastiCache/IntegrationTests/ElastiCache.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System; -using System.Threading; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using Amazon; -using Amazon.ElastiCache; -using Amazon.ElastiCache.Model; -using Amazon.Runtime; -using AWSSDK_DotNet.IntegrationTests.Utils; -using AWSSDK_DotNet.IntegrationTests.Tests; -using System.Collections.Generic; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class ElastiCache : TestBase - { - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("ElastiCache")] - public void TestCacheParameterGroups() - { - var groupName = "SDKDotNetTestGroup"; - - try - { - var delRequest = new DeleteCacheParameterGroupRequest(); - delRequest.CacheParameterGroupName = groupName; - Client.DeleteCacheParameterGroup(delRequest); - } - catch (Exception) { } - - var request = new CreateCacheParameterGroupRequest(groupName, "memcached1.4", "testing"); - - var res = Client.CreateCacheParameterGroup(request); - try - { - var response = Client.DescribeCacheParameterGroups(); - var found = false; - foreach (var group in response.CacheParameterGroups) - { - Assert.IsNotNull(group.CacheParameterGroupFamily); - Assert.IsNotNull(group.CacheParameterGroupName); - - if (group.CacheParameterGroupName.Equals(groupName, StringComparison.OrdinalIgnoreCase)) - found = true; - } - Assert.IsTrue(found); - } - finally - { - var delRequest = new DeleteCacheParameterGroupRequest(); - delRequest.CacheParameterGroupName = groupName; - Client.DeleteCacheParameterGroup(delRequest); - } - } - - [TestMethod] - [TestCategory("ElastiCache")] - public void TestDescribeCacheClusters() - { - var response = Client.DescribeCacheClusters(); - if (response.CacheClusters != null) - { - foreach (var cluster in response.CacheClusters) - { - Assert.IsNotNull(cluster.CacheClusterId); - } - } - } - - [TestMethod] - [TestCategory("ElastiCache")] - public void TestDescribeEngineVersions() - { - var response = Client.DescribeCacheEngineVersions(); - foreach (var version in response.CacheEngineVersions) - { - Assert.IsNotNull(version.EngineVersion); - } - } - } -} diff --git a/sdk/test/Services/ElasticBeanstalk/IntegrationTests/AWSSDK.IntegrationTests.ElasticBeanstalk.NetFramework.csproj b/sdk/test/Services/ElasticBeanstalk/IntegrationTests/AWSSDK.IntegrationTests.ElasticBeanstalk.NetFramework.csproj deleted file mode 100644 index 59d2e31a55c0..000000000000 --- a/sdk/test/Services/ElasticBeanstalk/IntegrationTests/AWSSDK.IntegrationTests.ElasticBeanstalk.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.ElasticBeanstalk.NetFramework - AWSSDK.IntegrationTests.ElasticBeanstalk.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/ElasticBeanstalk/IntegrationTests/Beanstalk.cs b/sdk/test/Services/ElasticBeanstalk/IntegrationTests/Beanstalk.cs deleted file mode 100644 index 8d21d9dd209c..000000000000 --- a/sdk/test/Services/ElasticBeanstalk/IntegrationTests/Beanstalk.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using Amazon.ElasticBeanstalk; -using Amazon.ElasticBeanstalk.Model; - -using AWSSDK_DotNet.IntegrationTests.Utils; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class Beanstalk : TestBase - { - - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - [TestMethod] - [TestCategory("ElasticBeanstalk")] - public void ListAvailableSolutionStacksTest() - { - ListAvailableSolutionStacksResponse response = Client.ListAvailableSolutionStacks(new ListAvailableSolutionStacksRequest()); - Assert.IsNotNull(response); - Assert.IsTrue(response.SolutionStacks.Count > 0); - foreach (string stack in response.SolutionStacks) - { - Assert.IsNotNull(stack); - } - } - - [TestMethod] - [TestCategory("ElasticBeanstalk")] - public void CheckDNSAvailabilityTest() - { - CheckDNSAvailabilityRequest request = new CheckDNSAvailabilityRequest() - { - CNAMEPrefix = "mycnamecheck" + DateTime.UtcNow.Ticks - }; - - CheckDNSAvailabilityResponse response = Client.CheckDNSAvailability(request); - Assert.IsTrue(response.Available.Value); - Assert.IsNotNull(response.FullyQualifiedCNAME); - } - - [TestMethod] - [TestCategory("ElasticBeanstalk")] - public void CRUDApplication() - { - string applicationName = "dotnet-integ-app" + DateTime.UtcNow.Ticks; - CreateApplicationRequest createRequest = new CreateApplicationRequest() - { - ApplicationName = applicationName, - Description = "Test Application" - }; - - CreateApplicationResponse createResponse = Client.CreateApplication(createRequest); - Assert.IsNotNull(createResponse.ResponseMetadata.RequestId); - - try - { - DescribeApplicationsResponse describeResponse = Client.DescribeApplications(new DescribeApplicationsRequest() { ApplicationNames = new List() { applicationName } }); - Assert.AreEqual(1, describeResponse.Applications.Count); - ApplicationDescription app = describeResponse.Applications[0]; - Assert.AreEqual(applicationName, app.ApplicationName); - Assert.AreEqual("Test Application", app.Description); - Assert.AreNotEqual(DateTime.MinValue, app.DateCreated); - Assert.AreNotEqual(DateTime.MinValue, app.DateUpdated); - - UpdateApplicationRequest updateRequest = new UpdateApplicationRequest() - { - ApplicationName = applicationName, - Description = "updated description" - }; - UpdateApplicationResponse updateResponse = Client.UpdateApplication(updateRequest); - Assert.AreEqual(applicationName, updateResponse.Application.ApplicationName); - Assert.AreEqual("updated description", updateResponse.Application.Description); - } - finally - { - Client.DeleteApplication(new DeleteApplicationRequest() { ApplicationName = applicationName }); - } - } - } -} diff --git a/sdk/test/Services/ElasticBeanstalk/IntegrationTests/Config/462/App.config b/sdk/test/Services/ElasticBeanstalk/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/ElasticBeanstalk/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/ElasticLoadBalancing/IntegrationTests/AWSSDK.IntegrationTests.ElasticLoadBalancing.NetFramework.csproj b/sdk/test/Services/ElasticLoadBalancing/IntegrationTests/AWSSDK.IntegrationTests.ElasticLoadBalancing.NetFramework.csproj deleted file mode 100644 index a7c400e5b778..000000000000 --- a/sdk/test/Services/ElasticLoadBalancing/IntegrationTests/AWSSDK.IntegrationTests.ElasticLoadBalancing.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.ElasticLoadBalancing.NetFramework - AWSSDK.IntegrationTests.ElasticLoadBalancing.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/ElasticLoadBalancing/IntegrationTests/Config/462/App.config b/sdk/test/Services/ElasticLoadBalancing/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/ElasticLoadBalancing/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/ElasticLoadBalancing/IntegrationTests/ElasticLoadBalancing.cs b/sdk/test/Services/ElasticLoadBalancing/IntegrationTests/ElasticLoadBalancing.cs deleted file mode 100644 index 71643e6b728c..000000000000 --- a/sdk/test/Services/ElasticLoadBalancing/IntegrationTests/ElasticLoadBalancing.cs +++ /dev/null @@ -1,206 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Threading; -using AWSSDK_DotNet.IntegrationTests.Utils; - -using Amazon.ElasticLoadBalancing; -using Amazon.ElasticLoadBalancing.Model; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class ElasticLoadBalancing : TestBase - { - const string SDK_TEST_PREFIX = "aws-net-sdk"; - public const String AVAILABILITY_ZONE_1 = "us-east-1c"; - public const String AVAILABILITY_ZONE_2 = "us-east-1b"; - - public const String PROTOCOL = "HTTP"; - string loadBalancerName; - - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - [TestCleanup] - public void TestCleanup() - { - if (loadBalancerName != null) - { - Client.DeleteLoadBalancer(new DeleteLoadBalancerRequest() - { - LoadBalancerName = loadBalancerName - }); - } - } - - [TestMethod] - [TestCategory("ElasticLoadBalancing")] - public void TestBasicDescribe() - { - Client.DescribeLoadBalancers(); - } - - [Ignore("Excluding tests that need IAM Write/Permissions management. CreateLoadBalancer requires iam:CreateServiceLinkedRole.")] - [TestMethod] - [TestCategory("ElasticLoadBalancing")] - public void TestLoadBalancerOperations() - { - loadBalancerName = SDK_TEST_PREFIX+"-lb" + DateTime.UtcNow.Ticks; - Listener expectedListener = new Listener() - { - InstancePort = 8080, - LoadBalancerPort = 80, - Protocol = PROTOCOL - }; - - // Create a load balancer - string dnsName = Client.CreateLoadBalancer( - new CreateLoadBalancerRequest() - { - LoadBalancerName = loadBalancerName, - AvailabilityZones = new List() { AVAILABILITY_ZONE_1 }, - Listeners = new List() { expectedListener } - }).DNSName; - try - { - Assert.IsFalse(string.IsNullOrEmpty(dnsName)); - - - // Configure health checks - HealthCheck expectedHealthCheck = new HealthCheck() - { - Interval = 120, - Target = "HTTP:80/ping", - Timeout = 60, - UnhealthyThreshold = 9, - HealthyThreshold = 10 - }; - - HealthCheck createdHealthCheck = Client.ConfigureHealthCheck( - new ConfigureHealthCheckRequest() - { - LoadBalancerName = loadBalancerName, - HealthCheck = expectedHealthCheck - }).HealthCheck; - Assert.AreEqual(expectedHealthCheck.HealthyThreshold, createdHealthCheck.HealthyThreshold); - Assert.AreEqual(expectedHealthCheck.Interval, createdHealthCheck.Interval); - Assert.AreEqual(expectedHealthCheck.Target, createdHealthCheck.Target); - Assert.AreEqual(expectedHealthCheck.Timeout, createdHealthCheck.Timeout); - Assert.AreEqual(expectedHealthCheck.UnhealthyThreshold, createdHealthCheck.UnhealthyThreshold); - - - // Describe - List loadBalancerDescriptions = - Client.DescribeLoadBalancers( - new DescribeLoadBalancersRequest() - { - LoadBalancerNames = new List() { loadBalancerName } - } - ).LoadBalancerDescriptions; - Assert.AreEqual(1, loadBalancerDescriptions.Count); - LoadBalancerDescription loadBalancer = loadBalancerDescriptions[0]; - Assert.AreEqual(loadBalancerName, loadBalancer.LoadBalancerName); - Assert.AreEqual(1, loadBalancer.AvailabilityZones.Count); - Assert.IsTrue(loadBalancer.AvailabilityZones.Contains(AVAILABILITY_ZONE_1)); - Assert.IsNotNull(loadBalancer.CreatedTime); - Assert.AreEqual(dnsName, loadBalancer.DNSName); - Assert.AreEqual(expectedHealthCheck.Target, loadBalancer.HealthCheck.Target); - Assert.IsTrue(loadBalancer.Instances.Count == 0); - Assert.AreEqual(1, loadBalancer.ListenerDescriptions.Count); - Assert.AreEqual((double)8080, (double)loadBalancer.ListenerDescriptions[0].Listener.InstancePort, 0.0); - Assert.AreEqual((double)80, (double)loadBalancer.ListenerDescriptions[0].Listener.LoadBalancerPort, 0.0); - Assert.AreEqual(PROTOCOL, loadBalancer.ListenerDescriptions[0].Listener.Protocol); - Assert.AreEqual(loadBalancerName, loadBalancer.LoadBalancerName); - Assert.IsNotNull(loadBalancer.SourceSecurityGroup); - Assert.IsNotNull(loadBalancer.SourceSecurityGroup.GroupName); - Assert.IsNotNull(loadBalancer.SourceSecurityGroup.OwnerAlias); - - - // Enabled AZs - List availabilityZones = - Client.EnableAvailabilityZonesForLoadBalancer( - new EnableAvailabilityZonesForLoadBalancerRequest() - { - LoadBalancerName = loadBalancerName, - AvailabilityZones = new List() { AVAILABILITY_ZONE_2 } - } - ).AvailabilityZones; - Assert.AreEqual(2, availabilityZones.Count); - Assert.IsTrue(availabilityZones.Contains(AVAILABILITY_ZONE_1)); - Assert.IsTrue(availabilityZones.Contains(AVAILABILITY_ZONE_2)); - - Thread.Sleep(1000 * 10); - - // Disable AZs - availabilityZones = - Client.DisableAvailabilityZonesForLoadBalancer( - new DisableAvailabilityZonesForLoadBalancerRequest() - { - LoadBalancerName = loadBalancerName, - AvailabilityZones = new List() { AVAILABILITY_ZONE_2 } - } - ).AvailabilityZones; - Assert.AreEqual(1, availabilityZones.Count); - Assert.IsTrue(availabilityZones.Contains(AVAILABILITY_ZONE_1)); - Assert.IsFalse(availabilityZones.Contains(AVAILABILITY_ZONE_2)); - - // Create LB stickiness policy - String policyName = SDK_TEST_PREFIX + "-policy-" + DateTime.UtcNow.Ticks; - Client.CreateLBCookieStickinessPolicy(new CreateLBCookieStickinessPolicyRequest() - { - LoadBalancerName = loadBalancerName, - PolicyName = policyName - }); - - - // Attach the policy to a listener - Client.SetLoadBalancerPoliciesOfListener(new SetLoadBalancerPoliciesOfListenerRequest() - { - LoadBalancerName = loadBalancerName, - LoadBalancerPort = 80, - PolicyNames = new List() { policyName } - }); - Assert.IsTrue(DoesLoadBalancerHaveListenerWithPolicy(loadBalancerName, policyName)); - - // Remove the policy from the listener - Client.SetLoadBalancerPoliciesOfListener(new SetLoadBalancerPoliciesOfListenerRequest() - { - LoadBalancerName = loadBalancerName, - LoadBalancerPort = 80 - }); - Assert.IsFalse(DoesLoadBalancerHaveListenerWithPolicy(loadBalancerName, policyName)); - - // Delete the policy - Client.DeleteLoadBalancerPolicy(new DeleteLoadBalancerPolicyRequest(loadBalancerName, policyName)); - } - finally - { - // Delete the test load balancer - Client.DeleteLoadBalancer(new DeleteLoadBalancerRequest() { LoadBalancerName = loadBalancerName }); - } - - } - - private bool DoesLoadBalancerHaveListenerWithPolicy(String loadBalancerName, String policyName) - { - List loadBalancers = Client.DescribeLoadBalancers( - new DescribeLoadBalancersRequest() { LoadBalancerNames = new List() { loadBalancerName } }) - .LoadBalancerDescriptions; - - if (loadBalancers.Count == 0) Assert.Fail("Unknown load balancer: " + loadBalancerName); - - List listeners = loadBalancers[0].ListenerDescriptions; - foreach (ListenerDescription listener in listeners) - { - if (listener.PolicyNames.Contains(policyName)) - return true; - } - - return false; - } - } -} diff --git a/sdk/test/Services/ElasticLoadBalancingV2/IntegrationTests/AWSSDK.IntegrationTests.ElasticLoadBalancingV2.NetFramework.csproj b/sdk/test/Services/ElasticLoadBalancingV2/IntegrationTests/AWSSDK.IntegrationTests.ElasticLoadBalancingV2.NetFramework.csproj deleted file mode 100644 index 44ee562c1d82..000000000000 --- a/sdk/test/Services/ElasticLoadBalancingV2/IntegrationTests/AWSSDK.IntegrationTests.ElasticLoadBalancingV2.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.ElasticLoadBalancingV2.NetFramework - AWSSDK.IntegrationTests.ElasticLoadBalancingV2.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/ElasticLoadBalancingV2/IntegrationTests/Config/462/App.config b/sdk/test/Services/ElasticLoadBalancingV2/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/ElasticLoadBalancingV2/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/ElasticLoadBalancingV2/IntegrationTests/ElasticLoadBalancingV2.cs b/sdk/test/Services/ElasticLoadBalancingV2/IntegrationTests/ElasticLoadBalancingV2.cs deleted file mode 100644 index c8dfefd13210..000000000000 --- a/sdk/test/Services/ElasticLoadBalancingV2/IntegrationTests/ElasticLoadBalancingV2.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Threading; -using AWSSDK_DotNet.IntegrationTests.Utils; -using System.Linq; - -using Amazon.ElasticLoadBalancingV2; -using Amazon.ElasticLoadBalancingV2.Model; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class ElasticLoadBalancingV2 : TestBase - { - private static string loadBalancerName = "dotnet-test-" + DateTime.UtcNow.ToFileTime(); - private static string loadBalancerArn = null; - - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - [TestCleanup] - public void TestCleanup() - { - if (!string.IsNullOrEmpty(loadBalancerArn)) - { - Client.DeleteLoadBalancer(new DeleteLoadBalancerRequest - { - LoadBalancerArn = loadBalancerArn - }); - } - } - - [TestMethod] - [TestCategory("ElasticLoadBalancingV2")] - public void BasicTest() - { - Client.DescribeLoadBalancers(new DescribeLoadBalancersRequest - { - }); - } - } -} diff --git a/sdk/test/Services/Elasticsearch/IntegrationTests/AWSSDK.IntegrationTests.Elasticsearch.NetFramework.csproj b/sdk/test/Services/Elasticsearch/IntegrationTests/AWSSDK.IntegrationTests.Elasticsearch.NetFramework.csproj deleted file mode 100644 index 81189551bcfe..000000000000 --- a/sdk/test/Services/Elasticsearch/IntegrationTests/AWSSDK.IntegrationTests.Elasticsearch.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.Elasticsearch.NetFramework - AWSSDK.IntegrationTests.Elasticsearch.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/Elasticsearch/IntegrationTests/Config/462/App.config b/sdk/test/Services/Elasticsearch/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/Elasticsearch/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/Elasticsearch/IntegrationTests/Elasticsearch.cs b/sdk/test/Services/Elasticsearch/IntegrationTests/Elasticsearch.cs deleted file mode 100644 index dec1e58ddace..000000000000 --- a/sdk/test/Services/Elasticsearch/IntegrationTests/Elasticsearch.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Threading; -using AWSSDK_DotNet.IntegrationTests.Utils; - -using Amazon.Elasticsearch; -using Amazon.Elasticsearch.Model; -using AWSSDK_DotNet.IntegrationTests.Tests; - - - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class Elasticsearch : TestBase - { - // Test temporarily disabled. - //[TestMethod] - //[TestCategory("Elasticsearch")] - public void TestElasticsearchOperations() - { - var domainName = UtilityMethods.GenerateName("domain"); - - Client.CreateElasticsearchDomain(new CreateElasticsearchDomainRequest - { - DomainName = domainName - }); - Thread.Sleep(2000); - - try - { - var domainNames = Client.ListDomainNames(new ListDomainNamesRequest()).DomainNames; - Assert.IsTrue(domainNames.Exists(d => d.DomainName.Equals(domainName))); - - var domains = Client.DescribeElasticsearchDomains(new DescribeElasticsearchDomainsRequest - { - DomainNames = new List { domainName } - }).DomainStatusList; - Assert.IsTrue(domains.Exists(d => d.DomainName.Equals(domainName))); - } - finally - { - Client.DeleteElasticsearchDomain(new DeleteElasticsearchDomainRequest - { - DomainName = domainName - }); - } - } - - } -} diff --git a/sdk/test/Services/GameLift/IntegrationTests/GameLift.cs b/sdk/test/Services/GameLift/IntegrationTests/GameLift.cs index 1a9b4c485bd7..3e8896822f7a 100644 --- a/sdk/test/Services/GameLift/IntegrationTests/GameLift.cs +++ b/sdk/test/Services/GameLift/IntegrationTests/GameLift.cs @@ -1,91 +1,100 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Amazon.GameLift; +using Amazon.GameLift; using Amazon.GameLift.Model; -using AWSSDK_DotNet.IntegrationTests.Utils; -using AWSSDK_DotNet.IntegrationTests.Tests; +using Amazon.S3; +using Amazon.S3.Model; using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.IO; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Threading.Tasks; namespace AWSSDK_DotNet.IntegrationTests.Tests { [TestClass] + [TestCategory("GameLift")] public class GameLift : TestBase { - private static List createdBuilds = new List(); + private static readonly List createdBuilds = new List(); [ClassCleanup] - public static void Cleanup() + public static async Task Cleanup() { - foreach(var build in createdBuilds) + foreach (var build in createdBuilds) { - Client.DeleteBuild(build); + await Client.DeleteBuildAsync(build); } BaseClean(); } [TestMethod] - [TestCategory("GameLift")] - public void CrudCalls() + public async Task CrudCalls() { - var originalBuilds = GetAllBuilds().ToList(); + var originalBuilds = (await GetAllBuilds()).ToList(); var timestamp = DateTime.UtcNow.ToFileTime().ToString(); - var newBuild = Client.CreateBuild(new CreateBuildRequest + var createRespone = await Client.CreateBuildAsync(new CreateBuildRequest { Name = "TestBuild-" + timestamp, Version = timestamp, OperatingSystem = Amazon.GameLift.OperatingSystem.AMAZON_LINUX_2 - }).Build; + }); + + var newBuild = createRespone.Build; createdBuilds.Add(newBuild.BuildId); - var builds = GetAllBuilds().ToList(); + var builds = (await GetAllBuilds()).ToList(); Assert.AreNotEqual(originalBuilds.Count, builds.Count); - Client.UpdateBuild(new UpdateBuildRequest + await Client.UpdateBuildAsync(new UpdateBuildRequest { BuildId = newBuild.BuildId, Name = newBuild.Name + "_2", Version = newBuild.Version + "_2" }); - var uploadCreds = Client.RequestUploadCredentials(newBuild.BuildId); + var uploadCreds = await Client.RequestUploadCredentialsAsync(newBuild.BuildId); var storageLocation = uploadCreds.StorageLocation; var credentials = uploadCreds.UploadCredentials; - using(var s3client = new Amazon.S3.AmazonS3Client(credentials)) + + using (var s3client = new AmazonS3Client(credentials)) { - var putResponse = s3client.PutObject(new Amazon.S3.Model.PutObjectRequest + var putResponse = await s3client.PutObjectAsync(new PutObjectRequest { BucketName = storageLocation.Bucket, Key = storageLocation.Key, ContentBody = "test content" }); - Console.WriteLine(putResponse.ContentLength); + Assert.AreEqual(HttpStatusCode.OK, putResponse.HttpStatusCode); } - Client.DeleteBuild(newBuild.BuildId); + await Client.DeleteBuildAsync(newBuild.BuildId); createdBuilds.Remove(newBuild.BuildId); - builds = GetAllBuilds().ToList(); + builds = (await GetAllBuilds()).ToList(); Assert.AreEqual(originalBuilds.Count, builds.Count); } - private static IEnumerable GetAllBuilds(BuildStatus status = null) + private static async Task> GetAllBuilds(BuildStatus status = null) { + var builds = new List(); var request = new ListBuildsRequest { Status = status }; + do { - var response = Client.ListBuilds(request); + var response = await Client.ListBuildsAsync(request); request.NextToken = response.NextToken; - foreach (var build in response.Builds) - yield return build; + + if (response.Builds != null) + { + builds.AddRange(response.Builds); + } } while (!string.IsNullOrEmpty(request.NextToken)); + return builds; } } } diff --git a/sdk/test/Services/Glacier/IntegrationTests/AWSSDK.IntegrationTests.Glacier.NetFramework.csproj b/sdk/test/Services/Glacier/IntegrationTests/AWSSDK.IntegrationTests.Glacier.NetFramework.csproj deleted file mode 100644 index ae49000678e9..000000000000 --- a/sdk/test/Services/Glacier/IntegrationTests/AWSSDK.IntegrationTests.Glacier.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.Glacier.NetFramework - AWSSDK.IntegrationTests.Glacier.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/Glacier/IntegrationTests/Config/462/App.config b/sdk/test/Services/Glacier/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/Glacier/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/Glacier/IntegrationTests/Glacier.cs b/sdk/test/Services/Glacier/IntegrationTests/Glacier.cs deleted file mode 100644 index 407ca9e436fb..000000000000 --- a/sdk/test/Services/Glacier/IntegrationTests/Glacier.cs +++ /dev/null @@ -1,144 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Amazon.Glacier; -using Amazon.Glacier.Model; -using AWSSDK_DotNet.IntegrationTests.Utils; -using AWSSDK_DotNet.IntegrationTests.Tests; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.IO; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class Glacier : TestBase - { - private const long CONTENT_LENGTH = 1024 * 1024 * 5; - - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - [TestMethod] - [TestCategory("Glacier")] - public void ListCalls() - { - var testingVaultName = "dotnet-sdk-test" + DateTime.UtcNow.Ticks.ToString(); - Client.CreateVault(new CreateVaultRequest() - { - VaultName = testingVaultName - }); - Assert.IsNotNull(Client.ListJobs(new ListJobsRequest { VaultName = testingVaultName })); - Assert.IsNotNull(Client.ListMultipartUploads(new ListMultipartUploadsRequest { VaultName = testingVaultName })); - Assert.IsNotNull(Client.ListVaults(new ListVaultsRequest())); - - Client.DeleteVault(new DeleteVaultRequest { VaultName = testingVaultName }); - } - - // Commented out because the would leave data in glacier that would cost money - //[TestMethod] - //[TestCategory("Glacier")] - public void TestSimpleUpload() - { - var testingVaultName = "dotnet-sdk-test" + DateTime.UtcNow.Ticks.ToString(); - Client.CreateVault(new CreateVaultRequest() - { - VaultName = testingVaultName - }); - const string accountID = "-"; - string archiveID = null; - - try - { - var memoryStream = new MemoryStream(Encoding.ASCII.GetBytes("data to archive")); - var uploadArchiveRequest = new UploadArchiveRequest - { - VaultName = testingVaultName, - Body = memoryStream, - Checksum = TreeHashGenerator.CalculateTreeHash(memoryStream), - AccountId = accountID, - ArchiveDescription = "my first archive" - }; - - var response = Client.UploadArchive(uploadArchiveRequest); - archiveID = response.ArchiveId; - } - finally - { - Client.DeleteArchive(new DeleteArchiveRequest { AccountId = accountID, VaultName = testingVaultName, ArchiveId = archiveID }); - } - } - - // Commented out because the would leave data in glacier that would cost money - //[TestMethod] - //[TestCategory("Glacier")] - public void TestMultiPartUpload() - { - var testingVaultName = "dotnet-sdk-test" + DateTime.UtcNow.Ticks.ToString(); - Client.CreateVault(new CreateVaultRequest() - { - VaultName = testingVaultName - }); - - InitiateMultipartUploadRequest initRequest = new InitiateMultipartUploadRequest() - { - VaultName = testingVaultName, - ArchiveDescription = "dotnet mp upload", - PartSize = 1048576 - }; - InitiateMultipartUploadResponse initResponse = Client.InitiateMultipartUpload(initRequest); - string uploadId = initResponse.UploadId; - - - MemoryStream totalStream = new MemoryStream(); - for (int i = 0; i < 1048576 + 1048576 / 2; i++) - { - totalStream.WriteByte((byte)(i % byte.MaxValue)); - } - totalStream.Position = 0; - - List md5s = new List(); - long currentPosition = 0; - long partSize = 1048576; - while (totalStream.Position < totalStream.Length) - { - Stream partStream = GlacierUtils.CreatePartStream(totalStream, partSize); - string checkSum = TreeHashGenerator.CalculateTreeHash(partStream); - md5s.Add(checkSum); - - UploadMultipartPartRequest partRequest = new UploadMultipartPartRequest() - { - VaultName = testingVaultName, - UploadId = uploadId, - Body = partStream, - Checksum = checkSum - }; - partRequest.SetRange(currentPosition, currentPosition + partStream.Length - 1); - Client.UploadMultipartPart(partRequest); - currentPosition += partStream.Length; - } - - CompleteMultipartUploadRequest compRequest = new CompleteMultipartUploadRequest() - { - VaultName = testingVaultName, - UploadId = uploadId, - ArchiveSize = totalStream.Length.ToString(), - Checksum = TreeHashGenerator.CalculateTreeHash(md5s) - }; - CompleteMultipartUploadResponse compResponse = Client.CompleteMultipartUpload(compRequest); - Assert.IsNotNull(compResponse.Location); - Assert.IsNotNull(compResponse.Checksum); - string archiveId = compResponse.ArchiveId; - - DeleteArchiveRequest delArchiveRequest = new DeleteArchiveRequest() - { - VaultName = testingVaultName, - ArchiveId = archiveId - }; - DeleteArchiveResponse delArchiveResponse = Client.DeleteArchive(delArchiveRequest); - } - } -} diff --git a/sdk/test/Services/IdentityManagement/IntegrationTests/AccessKeyTests.cs b/sdk/test/Services/IdentityManagement/IntegrationTests/AccessKeyTests.cs deleted file mode 100644 index 69ba15dc9502..000000000000 --- a/sdk/test/Services/IdentityManagement/IntegrationTests/AccessKeyTests.cs +++ /dev/null @@ -1,204 +0,0 @@ -using System; -using System.Text; -using System.Collections.Generic; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using AWSSDK_DotNet.IntegrationTests.Utils; -using Amazon.IdentityManagement; -using Amazon.IdentityManagement.Model; - -namespace AWSSDK_DotNet.IntegrationTests.Tests.IAM -{ - /// - /// Summary description for AccessKeyTests - /// - [TestClass] - public class AccessKeyTests : TestBase - { - public AccessKeyTests() - { - } - - private TestContext testContextInstance; - - /// - ///Gets or sets the test context which provides - ///information about and functionality for the current test run. - /// - public TestContext TestContext - { - get - { - return testContextInstance; - } - set - { - testContextInstance = value; - } - } - - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - [TestInitialize] - public void TestSetup() - { - IAMUtil.DeleteUsersAndGroupsInTestNameSpace(Client); - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestCreateAccessKey() - { - string username = IAMUtil.CreateTestUser(Client); - string keyId = null; - try - { - CreateAccessKeyResponse response = - Client.CreateAccessKey(new CreateAccessKeyRequest() { UserName = username }); - keyId = response.AccessKey.AccessKeyId; - Assert.IsTrue(response.AccessKey.CreateDate.Value.Date.CompareTo(DateTime.UtcNow.Date) == 0); - } - finally - { - if (keyId != null) - Client.DeleteAccessKey(new DeleteAccessKeyRequest() { UserName = username,AccessKeyId = keyId }); - - IAMUtil.DeleteTestUsers(Client, username); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - [ExpectedException(typeof(NoSuchEntityException))] - public void TestCreateAccessKeyNonExistentUserException() - { - string username = "sdk-testuser-" + DateTime.UtcNow.Ticks; - - Client.CreateAccessKey(new CreateAccessKeyRequest() { UserName = username }); - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestListAccessKeys() - { - string username = IAMUtil.CreateTestUser(Client); - string[] keyIds = new string[2]; - try - { - for (int i = 0; i < 2; i++) - { - CreateAccessKeyResponse response = - Client.CreateAccessKey(new CreateAccessKeyRequest() { UserName = username }); - - keyIds[i] = response.AccessKey.AccessKeyId; - } - - ListAccessKeysResponse listRes = - Client.ListAccessKeys(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.AreEqual(3, matches); - - } - finally - { - IAMUtil.DeleteTestUsers(Client, username); - } - } - - // There is a limit of 2 access keys per user - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - [ExpectedException(typeof(LimitExceededException))] - public void TestLimitExceedException() - { - string username = IAMUtil.CreateTestUser(Client); - - try - { - for (int i = 0; i < 3; i++) - { - Client.CreateAccessKey(new CreateAccessKeyRequest() { UserName = username }); - } - } - finally - { - IAMUtil.DeleteTestUsers(Client, username); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestDeleteAccessKey() - { - string username = IAMUtil.CreateTestUser(Client); - string[] keyIds = new string[2]; - try - { - for (int i = 0; i < 2; i++) - { - CreateAccessKeyResponse response = - Client.CreateAccessKey(new CreateAccessKeyRequest() { UserName = username }); - - keyIds[i] = response.AccessKey.AccessKeyId; - } - - ListAccessKeysResponse lakRes = - Client.ListAccessKeys(new ListAccessKeysRequest() { UserName = username }); - - Assert.AreEqual(2, lakRes.AccessKeyMetadata.Count()); - - Client.DeleteAccessKey(new DeleteAccessKeyRequest() { UserName = username, AccessKeyId = keyIds[0] }); - - lakRes = Client.ListAccessKeys(new ListAccessKeysRequest() { UserName = username }); - - Assert.AreEqual(1, lakRes.AccessKeyMetadata.Count()); - Assert.AreEqual(keyIds[1], lakRes.AccessKeyMetadata[0].AccessKeyId); - } - finally - { - IAMUtil.DeleteTestUsers(Client, username); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - [ExpectedException(typeof(NoSuchEntityException))] - public void TestDeleteNonExistentAccessKeyException() - { - string username = IAMUtil.CreateTestUser(Client); - try - { - CreateAccessKeyResponse response = - Client.CreateAccessKey(new CreateAccessKeyRequest() { UserName = username }); - - string keyId = response.AccessKey.AccessKeyId; - - Client.DeleteAccessKey(new DeleteAccessKeyRequest() { UserName = username, AccessKeyId = keyId }); - Client.DeleteAccessKey(new DeleteAccessKeyRequest() { UserName = username, AccessKeyId = keyId }); - } - finally - { - IAMUtil.DeleteTestUsers(Client, username); - } - } - } -} diff --git a/sdk/test/Services/IdentityManagement/IntegrationTests/AccountAliasTests.cs b/sdk/test/Services/IdentityManagement/IntegrationTests/AccountAliasTests.cs deleted file mode 100644 index 30698e468913..000000000000 --- a/sdk/test/Services/IdentityManagement/IntegrationTests/AccountAliasTests.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.Text; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using AWSSDK_DotNet.IntegrationTests.Utils; - -using Amazon.Runtime; -using Amazon.IdentityManagement; -using Amazon.IdentityManagement.Model; - - - -namespace AWSSDK_DotNet.IntegrationTests.Tests.IAM -{ - /// - /// Summary description for AccountAliasTests - /// - [TestClass] - public class AccountAliasTests : TestBase - { - public AccountAliasTests() - { - } - - private TestContext testContextInstance; - - /// - ///Gets or sets the test context which provides - ///information about and functionality for the current test run. - /// - public TestContext TestContext - { - get - { - return testContextInstance; - } - set - { - testContextInstance = value; - } - } - - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - [TestMethod] - [TestCategory("IdentityManagement")] - [TestCategory("RequiresIAMUser")] - public void ListAccessKeys() - { - ListAccessKeysResponse response = Client.ListAccessKeys(); - Assert.IsNotNull(response); - Assert.IsNotNull(response.AccessKeyMetadata); - Assert.AreNotEqual(0, response.AccessKeyMetadata.Count); - foreach (var akm in response.AccessKeyMetadata) - { - Assert.IsNotNull(akm); - Assert.IsNotNull(akm.AccessKeyId); - Assert.IsNotNull(akm.Status); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void CreateAccountAlias() - { - string alias = "dotnetalias" + DateTime.UtcNow.Ticks; - CreateAccountAliasRequest createRequest = new CreateAccountAliasRequest() - { - AccountAlias = alias - }; - - CreateAccountAliasResponse createResponse = Client.CreateAccountAlias(createRequest); - Assert.IsNotNull(createResponse.ResponseMetadata.RequestId); - try - { - ListAccountAliasesResponse listResponse = Client.ListAccountAliases(new ListAccountAliasesRequest()); - Assert.IsNotNull(listResponse.ResponseMetadata.RequestId); - Assert.AreEqual(alias, listResponse.AccountAliases[0]); - } - finally - { - DeleteAccountAliasResponse deleteResponse = Client.DeleteAccountAlias(new DeleteAccountAliasRequest() - { - AccountAlias = alias - }); - Assert.IsNotNull(deleteResponse.ResponseMetadata.RequestId); - } - } - - } -} diff --git a/sdk/test/Services/IdentityManagement/IntegrationTests/AssumeRoleAWSCredentialsTest.cs b/sdk/test/Services/IdentityManagement/IntegrationTests/AssumeRoleAWSCredentialsTest.cs deleted file mode 100644 index 07b14bf62d1b..000000000000 --- a/sdk/test/Services/IdentityManagement/IntegrationTests/AssumeRoleAWSCredentialsTest.cs +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). - * You may not use this file except in compliance with the License. - * A copy of the License is located at - * - * http://aws.amazon.com/apache2.0 - * - * or in the "license" file accompanying this file. This file is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. See the License for the specific language governing - * permissions and limitations under the License. - */ -using Amazon.Runtime; -using Amazon.S3; -using Amazon.S3.Model; -using Amazon.SecurityToken; -using Amazon.SecurityToken.Model; -using AWSSDK_DotNet.IntegrationTests.Utils; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using System.Net; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class AssumeRoleAWSCredentialsTest - { - private const string CredentialErrorMessage = "Error calling AssumeRole for role "; - private const string TestUserName = "shared-credentials-file-user"; - private const string TestRoleName = "shared-credentials-file-role"; - private const string MfaCallbackErrorMessage = "The MfaSerialNumber has been set but the MfaTokenCodeCallback hasn't"; - private const string SecurityTokenErrorMessage = "The security token included in the request is invalid"; - private static readonly string MfaTokenCodeErrorMessage = "Making sure the MFA Token Code callback is being called."; - private static readonly string TestExternalId = Guid.NewGuid().ToString(); - private static readonly string TestMfaSerialNumber = Guid.NewGuid().ToString(); - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("SecurityToken")] - [TestCategory("IdentityManagement")] - public void MfaProfileTokenCodeCallback() - { - // Since it's not practical to integ test the MFA, at least test that the callback to get - // the MFA token code is being called correctly. - // (An AssumeRoleAWSCredentials object with an MFA token code callback has been tested manually.) - AssertExtensions.ExpectException(() => - { - throw AssertExtensions.ExpectException(() => - { - TestAssumeRoleProfile(null, null, TestMfaSerialNumber, () => - { - throw new Exception(MfaTokenCodeErrorMessage); - }, true, false); - }, typeof(AmazonClientException), new Regex(CredentialErrorMessage)).InnerException; - }, typeof(Exception), MfaTokenCodeErrorMessage); - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("SecurityToken")] - [TestCategory("IdentityManagement")] - public void MfaProfileNoTokenCodeCallback() - { - AssertExtensions.ExpectException(() => - { - throw AssertExtensions.ExpectException(() => - { - TestAssumeRoleProfile(null, null, TestMfaSerialNumber, null, true, false); - }, typeof(AmazonClientException), new Regex(CredentialErrorMessage)).InnerException; - }, typeof(InvalidOperationException), new Regex(MfaCallbackErrorMessage)); - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("SecurityToken")] - [TestCategory("IdentityManagement")] - public void NoExternalIdButExpected() - { - AssertExtensions.ExpectException(() => - { - throw AssertExtensions.ExpectException(() => - { - TestAssumeRoleProfile(null, TestExternalId, null, null, true, false); - }, typeof(AmazonClientException), new Regex(CredentialErrorMessage)).InnerException; - }, typeof(AmazonSecurityTokenServiceException), new Regex(SecurityTokenErrorMessage)); - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("SecurityToken")] - [TestCategory("IdentityManagement")] - public void ExternalIdProvidedButNotExpected() - { - AssertExtensions.ExpectException(() => - { - throw AssertExtensions.ExpectException(() => - { - TestAssumeRoleProfile(TestExternalId, null, null, null, true, false); - }, typeof(AmazonClientException), new Regex(CredentialErrorMessage)).InnerException; - }, typeof(AmazonSecurityTokenServiceException), new Regex(SecurityTokenErrorMessage)); - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("SecurityToken")] - [TestCategory("IdentityManagement")] - public void ExternalId() - { - TestAssumeRoleProfile(TestExternalId, TestExternalId, null, null, false, false); - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("SecurityToken")] - [TestCategory("IdentityManagement")] - public void NoExternalId() - { - TestAssumeRoleProfile(null, null, null, null, false, false); - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("SecurityToken")] - [TestCategory("IdentityManagement")] - public void AssumeRoleWithSessionCredentials() - { - TestAssumeRoleProfile(null, null, null, null, false, true); - } - - public void TestAssumeRoleProfile(string roleExternalId, string credentialsExternalId, - string mfaSerialNumber, Func mfaTokenCallback, bool expectFailure, bool sessionCredsAsSource) - { - try - { - // clean up at start in case a test dies in the middle of clean up and is restarted - IAMTestUtil.CleanupTestRoleAndUser(TestRoleName, TestUserName); - - var roleArn = "arn:aws:iam::" + UtilityMethods.AccountId + ":role/" + TestRoleName; - var newCredentials = IAMTestUtil.CreateTestRoleAndUser(TestRoleName, TestUserName, roleExternalId); - var sourceCredentials = sessionCredsAsSource ? GetSessionCredentials(newCredentials) : newCredentials; - - var options = new AssumeRoleAWSCredentialsOptions() - { - ExternalId = credentialsExternalId, - MfaSerialNumber = mfaSerialNumber, - MfaTokenCodeCallback = mfaTokenCallback - }; - - var assumeRoleCredentials = new AssumeRoleAWSCredentials(sourceCredentials, roleArn, TestRoleName, options); - - TestCredentials(assumeRoleCredentials, expectFailure); - } - finally - { - IAMTestUtil.CleanupTestRoleAndUser(TestRoleName, TestUserName); - } - } - - private AWSCredentials GetSessionCredentials(AWSCredentials credentials) - { - using (var stsClient = new AmazonSecurityTokenServiceClient(credentials)) - { - GetSessionTokenResponse response = null; - - // wait for eventual consistency of user creation - UtilityMethods.WaitUntil(() => - { - try - { - response = stsClient.GetSessionToken(); - return true; - } - catch (AmazonSecurityTokenServiceException e) - { - if (String.Equals(e.ErrorCode, "InvalidClientTokenId", StringComparison.OrdinalIgnoreCase)) - return false; - else - throw e; - } - }); - - Assert.IsNotNull(response); - Assert.IsNotNull(response.Credentials); - - return new SessionAWSCredentials(response.Credentials.AccessKeyId, - response.Credentials.SecretAccessKey, response.Credentials.SessionToken); - } - } - - private static void TestCredentials(AssumeRoleAWSCredentials assumeRoleCredentials, bool expectFailure) - { - ListBucketsResponse response = null; - using (var client = new AmazonS3Client(assumeRoleCredentials)) - { - // user/role setup may not be complete - // so retry for a bit before giving up - var stopTime = DateTime.UtcNow.AddSeconds(30); - while (response == null && DateTime.UtcNow < stopTime) - { - var doSleep = true; - try - { - response = client.ListBuckets(); - Assert.AreEqual(HttpStatusCode.OK, response.HttpStatusCode); - doSleep = false; - } - catch (AmazonClientException) - { - // no need to retry if we're expecting a failure - if (expectFailure) - { - throw; - } - } - catch (AmazonServiceException) - { - } - - if (doSleep) - { - Thread.Sleep(1000); - } - } - } - - if (expectFailure) - { - Assert.Fail("The test did not receive the expected authentication failure."); - } - else - { - Assert.IsNotNull(response, "Unable to use AssumeRoleCredentials to successfully complete a request."); - } - } - } -} diff --git a/sdk/test/Services/IdentityManagement/IntegrationTests/DualstackTests.cs b/sdk/test/Services/IdentityManagement/IntegrationTests/DualstackTests.cs index 7e15e2a5d0b5..623500eb04c5 100644 --- a/sdk/test/Services/IdentityManagement/IntegrationTests/DualstackTests.cs +++ b/sdk/test/Services/IdentityManagement/IntegrationTests/DualstackTests.cs @@ -3,6 +3,7 @@ using Amazon.S3.Model; using Microsoft.VisualStudio.TestTools.UnitTesting; using System; +using System.Threading.Tasks; namespace AWSSDK_DotNet.IntegrationTests.Tests.S3 { @@ -12,6 +13,7 @@ namespace AWSSDK_DotNet.IntegrationTests.Tests.S3 /// successfully. /// [TestClass] + [TestCategory("S3")] public class DualstackTests { RegionEndpoint[] testRegions = new RegionEndpoint[] @@ -27,8 +29,7 @@ public class DualstackTests /// both virtual host and path style addressing. /// [TestMethod] - [TestCategory("S3")] - public void TestSomeRegionsResolveV4Signing() + public async Task TestSomeRegionsResolveV4Signing() { foreach (var testRegion in testRegions) { @@ -38,17 +39,17 @@ public void TestSomeRegionsResolveV4Signing() UseDualstackEndpoint = true }; - executeSomeBucketOperations(config); + await ExecuteSomeBucketOperations(config); } } - private void executeSomeBucketOperations(AmazonS3Config s3Config) + private async Task ExecuteSomeBucketOperations(AmazonS3Config s3Config) { using (var s3Client = new AmazonS3Client(s3Config)) { // Call ListBuckets first to verify that AmazonS3PostMarshallHandler.ProcessRequestHandlers // correctly computes the endpoint when no bucket name is present. - var listBucketsResponse = s3Client.ListBuckets(); + var listBucketsResponse = await s3Client.ListBucketsAsync(); Assert.IsNotNull(listBucketsResponse); Assert.IsFalse(string.IsNullOrEmpty(listBucketsResponse.ResponseMetadata.RequestId)); @@ -61,17 +62,26 @@ private void executeSomeBucketOperations(AmazonS3Config s3Config) { //S3 Express doesn't support dualstack endpoints so we skip these in the tests. if (bucket.BucketName.Contains("--x-s3") || bucket.BucketName.Contains("-d-s3")) + { continue; + } + try { - var bucketLocationResponse = s3Client.GetBucketLocation(bucket.BucketName); + var bucketLocationResponse = await s3Client.GetBucketLocationAsync(bucket.BucketName); if (string.IsNullOrEmpty(bucketLocationResponse.Location) && s3Config.RegionEndpoint == RegionEndpoint.USEast1) + { bucketName = bucket.BucketName; + } else if (string.Equals(s3Config.RegionEndpoint.SystemName, bucketLocationResponse.Location, StringComparison.OrdinalIgnoreCase)) + { bucketName = bucket.BucketName; + } if (!string.IsNullOrEmpty(bucketName)) + { break; + } } catch(AmazonS3Exception e) { @@ -80,9 +90,9 @@ private void executeSomeBucketOperations(AmazonS3Config s3Config) } } - if(!string.IsNullOrEmpty(bucketName)) + if (!string.IsNullOrEmpty(bucketName)) { - var listObjectsResponse = s3Client.ListObjects(new ListObjectsRequest { BucketName = bucketName }); + var listObjectsResponse = await s3Client.ListObjectsAsync(new ListObjectsRequest { BucketName = bucketName }); Assert.IsNotNull(listObjectsResponse); Assert.IsNotNull(listObjectsResponse.ResponseMetadata); } @@ -94,8 +104,7 @@ private void executeSomeBucketOperations(AmazonS3Config s3Config) /// endpoint. /// [TestMethod] - [TestCategory("S3")] - public void TestHttpAccessOnDualstackEndpoint() + public async Task TestHttpAccessOnDualstackEndpoint() { var config = new AmazonS3Config { @@ -106,7 +115,7 @@ public void TestHttpAccessOnDualstackEndpoint() using (var s3Client = new AmazonS3Client(config)) { - var listBucketsResponse = s3Client.ListBuckets(); + var listBucketsResponse = await s3Client.ListBucketsAsync(); Assert.IsNotNull(listBucketsResponse); Assert.IsFalse(string.IsNullOrEmpty(listBucketsResponse.ResponseMetadata.RequestId)); } @@ -116,8 +125,7 @@ public void TestHttpAccessOnDualstackEndpoint() /// Tests we can invoke a dualstack endpoint using a service endpoint override. /// [TestMethod] - [TestCategory("S3")] - public void TestExplicitDualstackEndpoint() + public async Task TestExplicitDualstackEndpoint() { var config = new AmazonS3Config { @@ -126,7 +134,7 @@ public void TestExplicitDualstackEndpoint() using (var s3Client = new AmazonS3Client(config)) { - var listBucketsResponse = s3Client.ListBuckets(); + var listBucketsResponse = await s3Client.ListBucketsAsync(); Assert.IsNotNull(listBucketsResponse); Assert.IsFalse(string.IsNullOrEmpty(listBucketsResponse.ResponseMetadata.RequestId)); } diff --git a/sdk/test/Services/IdentityManagement/IntegrationTests/GroupTests.cs b/sdk/test/Services/IdentityManagement/IntegrationTests/GroupTests.cs deleted file mode 100644 index d48a2fc4ac0c..000000000000 --- a/sdk/test/Services/IdentityManagement/IntegrationTests/GroupTests.cs +++ /dev/null @@ -1,510 +0,0 @@ -using System; -using System.Text; -using System.Collections.Generic; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using AWSSDK_DotNet.IntegrationTests.Utils; -using Amazon.IdentityManagement; -using Amazon.IdentityManagement.Model; - -namespace AWSSDK_DotNet.IntegrationTests.Tests.IAM -{ - /// - /// Summary description for GroupTests - /// - [TestClass] - public class GroupTests : TestBase - { - public GroupTests() - { - } - - private TestContext testContextInstance; - - /// - ///Gets or sets the test context which provides - ///information about and functionality for the current test run. - /// - public TestContext TestContext - { - get - { - return testContextInstance; - } - set - { - testContextInstance = value; - } - } - - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - [TestInitialize] - public void PreTestRun() - { - IAMUtil.DeleteUsersAndGroupsInTestNameSpace(Client); - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestCreateGetGroup() - { - string groupname = Guid.NewGuid().ToString().Replace('-', '0'); - - try - { - Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname }); - GetGroupResponse response = Client.GetGroup(new GetGroupRequest() { GroupName = groupname }); - Assert.AreNotEqual(DateTime.MinValue, response.Group.CreateDate); - Assert.AreEqual(0, response.Users.Count()); - } - finally - { - Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname }); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestGroupWithUsers() - { - string - username1 = "user1" + DateTime.UtcNow.Ticks, - username2 = "user2" + DateTime.UtcNow.Ticks, - username3 = "user3" + DateTime.UtcNow.Ticks, - groupname = "group" + DateTime.UtcNow.Ticks; - - try - { - Client.CreateUser(new CreateUserRequest() { UserName = username1, Path = IAMUtil.TEST_PATH }); - Client.CreateUser(new CreateUserRequest() { UserName = username2, Path = IAMUtil.TEST_PATH }); - Client.CreateUser(new CreateUserRequest() { UserName = username3, Path = IAMUtil.TEST_PATH }); - - Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname, Path = IAMUtil.TEST_PATH }); - - Client.AddUserToGroup(new AddUserToGroupRequest() { GroupName = groupname, UserName = username1 }); - Client.AddUserToGroup(new AddUserToGroupRequest() { GroupName = groupname, UserName = username2 }); - Client.AddUserToGroup(new AddUserToGroupRequest() { GroupName = groupname, UserName = username3 }); - - GetGroupResponse response = - Client.GetGroup(new GetGroupRequest() { GroupName = groupname }); - - Assert.AreEqual(3, response.Users.Count()); - Assert.AreEqual(false, response.IsTruncated); - - int matches = 0; - - foreach (User u in response.Users) - { - if (u.UserName.Equals(username1)) - matches |= 1; - if (u.UserName.Equals(username2)) - matches |= 2; - if (u.UserName.Equals(username3)) - matches |= 4; - } - - Assert.AreEqual(7, matches); - } - finally - { - Client.RemoveUserFromGroup(new RemoveUserFromGroupRequest() { GroupName = groupname, UserName = username1 }); - Client.RemoveUserFromGroup(new RemoveUserFromGroupRequest() { GroupName = groupname, UserName = username2 }); - Client.RemoveUserFromGroup(new RemoveUserFromGroupRequest() { GroupName = groupname, UserName = username3 }); - Client.DeleteUser(new DeleteUserRequest() { UserName = username1 }); - Client.DeleteUser(new DeleteUserRequest() { UserName = username2 }); - Client.DeleteUser(new DeleteUserRequest() { UserName = username3 }); - Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname }); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestRemoveUsersFromGroup() - { - string - username1 = "user1" + DateTime.UtcNow.Ticks, - username2 = "user2" + DateTime.UtcNow.Ticks, - username3 = "user3" + DateTime.UtcNow.Ticks, - groupname = "group" + DateTime.UtcNow.Ticks; - - try - { - Client.CreateUser(new CreateUserRequest() { UserName = username1, Path = IAMUtil.TEST_PATH }); - Client.CreateUser(new CreateUserRequest() { UserName = username2, Path = IAMUtil.TEST_PATH }); - Client.CreateUser(new CreateUserRequest() { UserName = username3, Path = IAMUtil.TEST_PATH }); - - Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname, Path = IAMUtil.TEST_PATH }); - - Client.AddUserToGroup(new AddUserToGroupRequest() { GroupName = groupname, UserName = username1 }); - Client.AddUserToGroup(new AddUserToGroupRequest() { GroupName = groupname, UserName = username2 }); - Client.AddUserToGroup(new AddUserToGroupRequest() { GroupName = groupname, UserName = username3 }); - - GetGroupResponse response = - Client.GetGroup(new GetGroupRequest() { GroupName = groupname }); - - Assert.AreEqual(3, response.Users.Count()); - - Client.RemoveUserFromGroup(new RemoveUserFromGroupRequest() { GroupName = groupname, UserName = username2 }); - - response = - Client.GetGroup(new GetGroupRequest() { GroupName = groupname }); - - Assert.AreEqual(2, response.Users.Count()); - - int matches = 0; - - foreach (User u in response.Users) - { - if (u.UserName.Equals(username1)) - matches |= 1; - if (u.UserName.Equals(username2)) - Assert.Fail(); - if (u.UserName.Equals(username3)) - matches |= 4; - } - - Assert.AreEqual(5, matches); - } - finally - { - Client.RemoveUserFromGroup(new RemoveUserFromGroupRequest() { GroupName = groupname, UserName = username1 }); - Client.RemoveUserFromGroup(new RemoveUserFromGroupRequest() { GroupName = groupname, UserName = username3 }); - Client.DeleteUser(new DeleteUserRequest() { UserName = username1 }); - Client.DeleteUser(new DeleteUserRequest() { UserName = username2 }); - Client.DeleteUser(new DeleteUserRequest() { UserName = username3 }); - Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname }); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestGroupPaging() - { - string - username1 = "user1" + DateTime.UtcNow.Ticks, - username2 = "user2" + DateTime.UtcNow.Ticks, - username3 = "user3" + DateTime.UtcNow.Ticks, - username4 = "user4" + DateTime.UtcNow.Ticks, - groupname = "group" + DateTime.UtcNow.Ticks; - - - try - { - Client.CreateUser(new CreateUserRequest() { UserName = username1, Path = IAMUtil.TEST_PATH }); - Client.CreateUser(new CreateUserRequest() { UserName = username2, Path = IAMUtil.TEST_PATH }); - Client.CreateUser(new CreateUserRequest() { UserName = username3, Path = IAMUtil.TEST_PATH }); - Client.CreateUser(new CreateUserRequest() { UserName = username4, Path = IAMUtil.TEST_PATH }); - - Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname, Path = IAMUtil.TEST_PATH }); - - Client.AddUserToGroup(new AddUserToGroupRequest() { GroupName = groupname, UserName = username1 }); - Client.AddUserToGroup(new AddUserToGroupRequest() { GroupName = groupname, UserName = username2 }); - Client.AddUserToGroup(new AddUserToGroupRequest() { GroupName = groupname, UserName = username3 }); - Client.AddUserToGroup(new AddUserToGroupRequest() { GroupName = groupname, UserName = username4 }); - - GetGroupResponse response = - Client.GetGroup(new GetGroupRequest() { GroupName = groupname, MaxItems = 2 }); - - Assert.AreEqual(2, response.Users.Count()); - Assert.AreEqual(true, response.IsTruncated); - - string marker = response.Marker; - - int matches = 0; - - foreach (User u in response.Users) - { - if (u.UserName.Equals(username1)) - matches |= 1; - if (u.UserName.Equals(username2)) - matches |= 2; - if (u.UserName.Equals(username3)) - matches |= 4; - if (u.UserName.Equals(username4)) - matches |= 8; - } - - response = Client.GetGroup(new GetGroupRequest() { GroupName = groupname, Marker = marker }); - - Assert.AreEqual(2, response.Users.Count()); - Assert.AreEqual(false, response.IsTruncated); - - foreach (User u in response.Users) - { - if (u.UserName.Equals(username1)) - matches |= 1; - if (u.UserName.Equals(username2)) - matches |= 2; - if (u.UserName.Equals(username3)) - matches |= 4; - if (u.UserName.Equals(username4)) - matches |= 8; - } - - Assert.AreEqual(15, matches); - } - finally - { - Client.RemoveUserFromGroup(new RemoveUserFromGroupRequest() { GroupName = groupname, UserName = username1 }); - Client.RemoveUserFromGroup(new RemoveUserFromGroupRequest() { GroupName = groupname, UserName = username2 }); - Client.RemoveUserFromGroup(new RemoveUserFromGroupRequest() { GroupName = groupname, UserName = username3 }); - Client.RemoveUserFromGroup(new RemoveUserFromGroupRequest() { GroupName = groupname, UserName = username4 }); - Client.DeleteUser(new DeleteUserRequest() { UserName = username1 }); - Client.DeleteUser(new DeleteUserRequest() { UserName = username2 }); - Client.DeleteUser(new DeleteUserRequest() { UserName = username3 }); - Client.DeleteUser(new DeleteUserRequest() { UserName = username4 }); - Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname }); - - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestListGroupWithPaths() - { - - string - groupname1 = "group1" + DateTime.UtcNow.Ticks, - groupname2 = "group2" + DateTime.UtcNow.Ticks, - groupname3 = "group3" + DateTime.UtcNow.Ticks, - groupname4 = "group4" + DateTime.UtcNow.Ticks; - - string - pathA = IAMUtil.MakePath("A"), - pathB = IAMUtil.MakePath("B"); - - try - { - Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname1, Path = pathA }); - Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname2, Path = pathA }); - Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname3, Path = pathB }); - Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname4, Path = pathB }); - - ListGroupsResponse response = - Client.ListGroups(new ListGroupsRequest() { PathPrefix = pathA }); - - Assert.AreEqual(2, response.Groups.Count()); - - int matches = 0; - - foreach (Group g in response.Groups) - { - if(g.GroupName.Equals(groupname1)) - matches |= 1; - if(g.GroupName.Equals(groupname2)) - matches |= 2; - if(g.GroupName.Equals(groupname3)) - Assert.Fail(); - if(g.GroupName.Equals(groupname4)) - Assert.Fail(); - } - - response = Client.ListGroups(new ListGroupsRequest() { PathPrefix = pathB }); - - Assert.AreEqual(2, response.Groups.Count()); - - foreach (Group g in response.Groups) - { - if (g.GroupName.Equals(groupname1)) - Assert.Fail(); - if (g.GroupName.Equals(groupname2)) - Assert.Fail(); - if (g.GroupName.Equals(groupname3)) - matches |= 4; - if (g.GroupName.Equals(groupname4)) - matches |= 8; - } - - Assert.AreEqual(15, matches); - - } - finally - { - Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname1 }); - Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname2 }); - Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname3 }); - Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname4 }); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestListGroupsPaging() - { - string - groupname1 = "group1" + DateTime.UtcNow.Ticks, - groupname2 = "group2" + DateTime.UtcNow.Ticks, - groupname3 = "group3" + DateTime.UtcNow.Ticks, - groupname4 = "group4" + DateTime.UtcNow.Ticks; - - - try - { - Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname1, Path = IAMUtil.TEST_PATH }); - Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname2, Path = IAMUtil.TEST_PATH }); - Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname3, Path = IAMUtil.TEST_PATH }); - Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname4, Path = IAMUtil.TEST_PATH }); - - ListGroupsResponse response = - Client.ListGroups(new ListGroupsRequest()); - Assert.IsTrue(response.Groups.Count >= 4); - - response = - Client.ListGroups(new ListGroupsRequest() { MaxItems = 2, PathPrefix = IAMUtil.TEST_PATH }); - - Assert.AreEqual(2, response.Groups.Count()); - Assert.AreEqual(true, response.IsTruncated); - - string marker = response.Marker; - - int matches = 0; - - foreach (Group g in response.Groups) - { - if (g.GroupName.Equals(groupname1)) - matches |= 1; - if (g.GroupName.Equals(groupname2)) - matches |= 2; - if (g.GroupName.Equals(groupname3)) - matches |= 4; - if (g.GroupName.Equals(groupname4)) - matches |= 8; - } - - response = Client.ListGroups(new ListGroupsRequest() { Marker = marker, PathPrefix = IAMUtil.TEST_PATH }); - - Assert.AreEqual(2, response.Groups.Count()); - Assert.AreEqual(false, response.IsTruncated); - - foreach (Group g in response.Groups) - { - if (g.GroupName.Equals(groupname1)) - matches |= 1; - if (g.GroupName.Equals(groupname2)) - matches |= 2; - if (g.GroupName.Equals(groupname3)) - matches |= 4; - if (g.GroupName.Equals(groupname4)) - matches |= 8; - } - - Assert.AreEqual(15, matches); - - } - finally - { - Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname1 }); - Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname2 }); - Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname3 }); - Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname4 }); - } - - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - [ExpectedException(typeof(NoSuchEntityException))] - public void AddUserToNonExistentGroup() - { - string - username = "user" + DateTime.UtcNow.Ticks, - grpname = "group" + DateTime.UtcNow.Ticks; - try - { - Client.CreateUser(new CreateUserRequest() { UserName = username, Path = IAMUtil.TEST_PATH }); - Client.AddUserToGroup(new AddUserToGroupRequest() { GroupName = grpname, UserName = username }); - } - finally - { - Client.DeleteUser(new DeleteUserRequest() { UserName = username }); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - [ExpectedException(typeof(EntityAlreadyExistsException))] - public void TestDoubleCreation() - { - string - grpname = "group" + DateTime.UtcNow.Ticks; - - try - { - Client.CreateGroup(new CreateGroupRequest() { GroupName = grpname, Path = IAMUtil.TEST_PATH }); - Client.CreateGroup(new CreateGroupRequest() { GroupName = grpname, Path = IAMUtil.TEST_PATH }); - } - finally - { - Client.DeleteGroup(new DeleteGroupRequest() { GroupName = grpname }); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - [ExpectedException(typeof(DeleteConflictException))] - public void TestDeleteUserInGroupThrowsException() - { - string - username = "user" + DateTime.UtcNow.Ticks, - grpname = "group" + DateTime.UtcNow.Ticks; - - try - { - Client.CreateUser(new CreateUserRequest() { UserName = username, Path = IAMUtil.TEST_PATH }); - Client.CreateGroup(new CreateGroupRequest() { GroupName = grpname, Path = IAMUtil.TEST_PATH }); - Client.AddUserToGroup(new AddUserToGroupRequest() { UserName = username, GroupName = grpname }); - - Client.DeleteUser(new DeleteUserRequest() { UserName = username }); - } - finally - { - Client.RemoveUserFromGroup(new RemoveUserFromGroupRequest() { UserName = username, GroupName = grpname }); - Client.DeleteUser(new DeleteUserRequest() { UserName = username }); - Client.DeleteGroup(new DeleteGroupRequest() { GroupName = grpname }); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - [ExpectedException(typeof(DeleteConflictException))] - public void TestDeleteGroupWithUsersThrowsException() - { - string - username = "user" + DateTime.UtcNow.Ticks, - grpname = "group" + DateTime.UtcNow.Ticks; - - - try - { - Client.CreateUser(new CreateUserRequest() { UserName = username, Path = IAMUtil.TEST_PATH }); - Client.CreateGroup(new CreateGroupRequest() { GroupName = grpname, Path = IAMUtil.TEST_PATH }); - Client.AddUserToGroup(new AddUserToGroupRequest() { UserName = username, GroupName = grpname }); - - Client.DeleteGroup(new DeleteGroupRequest() { GroupName = grpname }); - } - finally - { - Client.RemoveUserFromGroup(new RemoveUserFromGroupRequest() { UserName = username, GroupName = grpname }); - Client.DeleteUser(new DeleteUserRequest() { UserName = username }); - Client.DeleteGroup(new DeleteGroupRequest() { GroupName = grpname }); - } - } - - } -} diff --git a/sdk/test/Services/IdentityManagement/IntegrationTests/LoginProfileTests.cs b/sdk/test/Services/IdentityManagement/IntegrationTests/LoginProfileTests.cs deleted file mode 100644 index 3cb0826507b5..000000000000 --- a/sdk/test/Services/IdentityManagement/IntegrationTests/LoginProfileTests.cs +++ /dev/null @@ -1,153 +0,0 @@ -using System; -using System.Text; -using System.Collections.Generic; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Threading; - -using AWSSDK_DotNet.IntegrationTests.Utils; -using Amazon.IdentityManagement; -using Amazon.IdentityManagement.Model; - -namespace AWSSDK_DotNet.IntegrationTests.Tests.IAM -{ - /// - /// Summary description for LoginProfileTests - /// - [TestClass] - public class LoginProfileTests : TestBase - { - public LoginProfileTests() - { - } - - private TestContext testContextInstance; - - /// - ///Gets or sets the test context which provides - ///information about and functionality for the current test run. - /// - public TestContext TestContext - { - get - { - return testContextInstance; - } - set - { - testContextInstance = value; - } - } - - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - [TestInitialize] - public void TestSetup() - { - IAMUtil.DeleteUsersAndGroupsInTestNameSpace(Client); - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestCreateGetLoginProfile() - { - string username = IAMUtil.CreateTestUser(Client); - string password = "strongpassword"; - - try - { - CreateLoginProfileResponse createRes = - Client.CreateLoginProfile(new CreateLoginProfileRequest - { - UserName = username, - Password = password, - PasswordResetRequired = true - }); - - Thread.Sleep(3 * 3600); - - Assert.AreEqual(username, createRes.LoginProfile.UserName); - - GetLoginProfileResponse getRes = - Client.GetLoginProfile(new GetLoginProfileRequest() { UserName = username }); - Assert.AreNotEqual(DateTime.MinValue, getRes.LoginProfile.CreateDate); - - var login = getRes.LoginProfile; - Assert.AreEqual(username, login.UserName); - Assert.IsTrue(login.PasswordResetRequired.Value); - - - Client.UpdateLoginProfile(new UpdateLoginProfileRequest - { - UserName = username, - Password = password, - PasswordResetRequired = false - }); - - Assert.AreEqual(username, createRes.LoginProfile.UserName); - - getRes = Client.GetLoginProfile(new GetLoginProfileRequest() { UserName = username }); - Assert.AreNotEqual(DateTime.MinValue, getRes.LoginProfile.CreateDate); - - login = getRes.LoginProfile; - Assert.AreEqual(username, login.UserName); - Assert.IsFalse(login.PasswordResetRequired.Value); - } - finally - { - IAMUtil.DeleteTestUsers(Client, username); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - [ExpectedException(typeof(EntityAlreadyExistsException))] - public void TestCreateLoginProfileTwiceException() - { - string username = IAMUtil.CreateTestUser(Client); - string password = "strong-password"; - - try - { - Client.CreateLoginProfile(new CreateLoginProfileRequest() { UserName = username, Password = password }); - Thread.Sleep(3 * 3600); - Client.CreateLoginProfile(new CreateLoginProfileRequest() { UserName = username, Password = password }); - } - finally - { - IAMUtil.DeleteTestUsers(Client, username); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - [ExpectedException(typeof(NoSuchEntityException))] - public void TestDeleteLoginProfile() - { - string username = IAMUtil.CreateTestUser(Client); - string password = "strong-password"; - - try - { - Client.CreateLoginProfile(new CreateLoginProfileRequest() { UserName = username, Password = password }); - Thread.Sleep(3 * 3600); - Client.DeleteLoginProfile(new DeleteLoginProfileRequest() { UserName = username }); - Thread.Sleep(3 * 3600); - GetLoginProfileResponse getRes = - Client.GetLoginProfile(new GetLoginProfileRequest() { UserName = username }); - } - finally - { - IAMUtil.DeleteTestUsers(Client, username); - } - } - - } -} diff --git a/sdk/test/Services/IdentityManagement/IntegrationTests/PasswordPolicyTests.cs b/sdk/test/Services/IdentityManagement/IntegrationTests/PasswordPolicyTests.cs deleted file mode 100644 index 6fad7f8d2655..000000000000 --- a/sdk/test/Services/IdentityManagement/IntegrationTests/PasswordPolicyTests.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using System.Text; -using System.Collections.Generic; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using AWSSDK_DotNet.IntegrationTests.Utils; -using Amazon.IdentityManagement; -using Amazon.IdentityManagement.Model; - -namespace AWSSDK_DotNet.IntegrationTests.Tests.IAM -{ - /// - /// Summary description for PasswordPolicyTests - /// - [TestClass] - public class PasswordPolicyTests : TestBase - { - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void CRUDPasswordPolicy() - { - var request = new UpdateAccountPasswordPolicyRequest - { - RequireNumbers = true, - RequireSymbols = true, - MinimumPasswordLength = 8, - RequireLowercaseCharacters = true, - RequireUppercaseCharacters = true, - - AllowUsersToChangePassword = true, - PasswordReusePrevention = 1, - MaxPasswordAge = 90, - HardExpiry = true - }; - Client.UpdateAccountPasswordPolicy(request); - - try - { - var policy = Client.GetAccountPasswordPolicy().PasswordPolicy; - Assert.AreEqual(request.RequireNumbers, policy.RequireNumbers); - Assert.AreEqual(request.RequireSymbols, policy.RequireSymbols); - Assert.AreEqual(request.MinimumPasswordLength, policy.MinimumPasswordLength); - Assert.AreEqual(request.RequireLowercaseCharacters, policy.RequireLowercaseCharacters); - Assert.AreEqual(request.RequireUppercaseCharacters, policy.RequireUppercaseCharacters); - Assert.AreEqual(request.AllowUsersToChangePassword, policy.AllowUsersToChangePassword); - Assert.AreEqual(request.PasswordReusePrevention, policy.PasswordReusePrevention); - Assert.AreEqual(request.MaxPasswordAge, policy.MaxPasswordAge); - Assert.AreEqual(request.HardExpiry, policy.HardExpiry); - //Assert.IsTrue(policy.ExpirePasswords); - - Client.UpdateAccountPasswordPolicy(); - - policy = Client.GetAccountPasswordPolicy().PasswordPolicy; - Assert.IsFalse(policy.RequireNumbers.Value); - Assert.IsFalse(policy.RequireSymbols.Value); - } - finally - { - Client.DeleteAccountPasswordPolicy(); - } - } - } -} diff --git a/sdk/test/Services/IdentityManagement/IntegrationTests/PolicyTests.cs b/sdk/test/Services/IdentityManagement/IntegrationTests/PolicyTests.cs deleted file mode 100644 index b0571527a34e..000000000000 --- a/sdk/test/Services/IdentityManagement/IntegrationTests/PolicyTests.cs +++ /dev/null @@ -1,856 +0,0 @@ -using System; -using System.Text; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using AWSSDK_DotNet.IntegrationTests.Utils; -using Amazon.IdentityManagement; -using Amazon.IdentityManagement.Model; -using System.Threading; - -namespace AWSSDK_DotNet.IntegrationTests.Tests.IAM -{ - [TestClass] - public class PolicyTests : TestBase - { - public static string - TEST_ALLOW_POLICY = @"{""Statement"":[{""Effect"":""Allow"",""Action"":""*"",""Resource"":""*""}]}", - TEST_VERSIONED_POLICY = @"{""Version"": ""2012-10-17"",""Statement"":[{""Effect"":""Allow"",""Action"":""*"",""Resource"":""*""}]}", - TEST_DENY_POLICY = @"{""Statement"":[{""Effect"":""Deny"",""Action"":""*"",""Resource"":""*""}]}"; - - - - public PolicyTests() - { - } - - private TestContext testContextInstance; - - /// - ///Gets or sets the test context which provides - ///information about and functionality for the current test run. - /// - public TestContext TestContext - { - get - { - return testContextInstance; - } - set - { - testContextInstance = value; - } - } - - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - [TestInitialize] - public void TestSetup() - { - IAMUtil.DeleteUsersAndGroupsInTestNameSpace(Client); - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestPrincipalPolicies() - { - string groupname = "sdk-testgroup-" + DateTime.UtcNow.Ticks; - string policyName = "strong-password"; - string policy = @"{ - ""Version"": ""2012-10-17"", - ""Statement"": [{ - ""Effect"": ""Allow"", - ""Action"": ""dynamodb:*"", - ""Resource"": ""arn:aws:dynamodb:us-east-1:123456789012:table/${aws:username}"" - }] -}"; - try - { - // create group - var groupArn = Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname, Path = IAMUtil.TEST_PATH }).Group.Arn; - - // attach policy - Client.PutGroupPolicy( - new PutGroupPolicyRequest() - { - GroupName = groupname, - PolicyName = policyName, - PolicyDocument = policy - }); - - // test group policy - GetGroupPolicyResponse groupInfo = - Client.GetGroupPolicy(new GetGroupPolicyRequest() { GroupName = groupname, PolicyName = policyName }); - Assert.AreEqual(groupname, groupInfo.GroupName); - Assert.AreEqual(policyName, groupInfo.PolicyName); - Assert.AreEqual(policy, HttpUtility.UrlDecode(groupInfo.PolicyDocument)); - - // get context keys - var contextKeyNames = Client.GetContextKeysForPrincipalPolicy(new GetContextKeysForPrincipalPolicyRequest - { - PolicySourceArn = groupArn - }).ContextKeyNames; - Assert.IsNotNull(contextKeyNames); - Assert.AreEqual(1, contextKeyNames.Count); - Assert.IsTrue(contextKeyNames.Contains("aws:username")); - - - // simulate policy - var response = Client.SimulatePrincipalPolicy(new SimulatePrincipalPolicyRequest - { - PolicySourceArn = groupArn, - ActionNames = new List - { - "dynamodb:PutItem" - }, - ResourceArns = new List - { - "arn:aws:dynamodb:us-east-1:123456789012:table/bob" - }, - ContextEntries = new List - { - new ContextEntry - { - ContextKeyName = "aws:username", - ContextKeyType = ContextKeyTypeEnum.String, - ContextKeyValues = new List - { - "bob" - } - } - } - }); - var results = response.EvaluationResults; - Assert.IsNotNull(results); - Assert.AreEqual(1, results.Count); - var result = results.First(); - Assert.AreEqual(PolicyEvaluationDecisionType.Allowed, result.EvalDecision); - - response = Client.SimulatePrincipalPolicy(new SimulatePrincipalPolicyRequest - { - PolicySourceArn = groupArn, - ActionNames = new List - { - "dynamodb:PutItem" - }, - ResourceArns = new List - { - "arn:aws:dynamodb:us-east-1:123456789012:table/bob" - }, - ContextEntries = new List - { - new ContextEntry - { - ContextKeyName = "aws:username", - ContextKeyType = ContextKeyTypeEnum.String, - ContextKeyValues = new List - { - "alice" - } - } - } - }); - results = response.EvaluationResults; - Assert.IsNotNull(results); - Assert.AreEqual(1, results.Count); - result = results.First(); - Assert.AreEqual(PolicyEvaluationDecisionType.ImplicitDeny, result.EvalDecision); - } - finally - { - Client.DeleteGroupPolicy(new DeleteGroupPolicyRequest() { GroupName = groupname, PolicyName = policyName }); - Client.DeleteGroup(new DeleteGroupRequest { GroupName = groupname }); - } - } - - - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestCustomPolicies() - { - var s3SamplePolicy = @"{ - ""Version"": ""2012-10-17"", - ""Statement"": [ - { - ""Effect"": ""Allow"", - ""Action"": [ - ""s3:ListAllMyBuckets"", - ""s3:GetBucketLocation"" - ], - ""Resource"": ""arn:aws:s3:::*"" - }, - { - ""Effect"": ""Allow"", - ""Action"": ""s3:ListBucket"", - ""Resource"": ""arn:aws:s3:::test-bucket123"", - ""Condition"": {""StringLike"": {""s3:prefix"": [ - """", - ""home/"", - ""home/${aws:username}/"" - ]}} - }, - { - ""Effect"": ""Allow"", - ""Action"": ""s3:*"", - ""Resource"": [ - ""arn:aws:s3:::test-bucket123/home/${aws:username}"", - ""arn:aws:s3:::test-bucket123/home/${aws:username}/*"" - ] - } - ] -}"; - var contextKeys = Client.GetContextKeysForCustomPolicy(new GetContextKeysForCustomPolicyRequest - { - PolicyInputList = new List - { - s3SamplePolicy - } - }).ContextKeyNames; - Assert.IsNotNull(contextKeys); - Assert.AreNotEqual(0, contextKeys.Count); - Assert.IsTrue(contextKeys.Contains("s3:prefix")); - Assert.IsTrue(contextKeys.Contains("aws:username")); - - var response = Client.SimulateCustomPolicy(new SimulateCustomPolicyRequest - { - ActionNames = new List - { - "s3:ListBucket" - }, - PolicyInputList = new List - { - s3SamplePolicy - }, - ResourceArns = new List - { - "arn:aws:s3:::test-bucket123" - }, - ContextEntries = new List - { - new ContextEntry - { - ContextKeyName = "s3:prefix", - ContextKeyType = ContextKeyTypeEnum.String, - ContextKeyValues = new List - { - "home/bob/" - } - }, - new ContextEntry - { - ContextKeyName = "aws:username", - ContextKeyType = ContextKeyTypeEnum.String, - ContextKeyValues = new List - { - "bob" - } - } - } - }); - var results = response.EvaluationResults; - Assert.AreEqual(1, results.Count); - var result = results.First(); - Assert.IsNotNull(result); - Assert.AreEqual(PolicyEvaluationDecisionType.Allowed, result.EvalDecision); - - response = Client.SimulateCustomPolicy(new SimulateCustomPolicyRequest - { - ActionNames = new List - { - "s3:ListBucket" - }, - PolicyInputList = new List - { - s3SamplePolicy - }, - ResourceArns = new List - { - "arn:aws:s3:::test-bucket123" - }, - ContextEntries = new List - { - new ContextEntry - { - ContextKeyName = "s3:prefix", - ContextKeyType = ContextKeyTypeEnum.String, - ContextKeyValues = new List - { - "home/alice/" - } - }, - new ContextEntry - { - ContextKeyName = "aws:username", - ContextKeyType = ContextKeyTypeEnum.String, - ContextKeyValues = new List - { - "bob" - } - } - } - }); - results = response.EvaluationResults; - Assert.AreEqual(1, results.Count); - result = results.First(); - Assert.IsNotNull(result); - Assert.AreEqual(PolicyEvaluationDecisionType.ImplicitDeny, result.EvalDecision); - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestPutGetUserPolicy() - { - string username = IAMUtil.CreateTestUser(Client); - string policyName = "test-policy-" + DateTime.UtcNow.Ticks; - - try - { - Client.PutUserPolicy( - new PutUserPolicyRequest() - { - UserName = username, - PolicyName = policyName, - PolicyDocument = TEST_ALLOW_POLICY - }); - - GetUserPolicyResponse response = - Client.GetUserPolicy(new GetUserPolicyRequest() { UserName = username, PolicyName = policyName }); - - Assert.AreEqual(username, response.UserName); - Assert.AreEqual(policyName, response.PolicyName); - Assert.AreEqual(TEST_ALLOW_POLICY, HttpUtility.UrlDecode(response.PolicyDocument)); - } - finally - { - IAMUtil.DeleteTestUsers(Client, username); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestPutGetGroupPolicy() - { - string groupname = "sdk-testgroup-" + DateTime.UtcNow.Ticks; - string policyName = "strong-password"; - - try - { - Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname, Path = IAMUtil.TEST_PATH }); - - Client.PutGroupPolicy( - new PutGroupPolicyRequest() - { - GroupName = groupname, - PolicyName = policyName, - PolicyDocument = TEST_ALLOW_POLICY - }); - - GetGroupPolicyResponse response = - Client.GetGroupPolicy(new GetGroupPolicyRequest() { GroupName = groupname, PolicyName = policyName }); - - Assert.AreEqual(groupname, response.GroupName); - Assert.AreEqual(policyName, response.PolicyName); - Assert.AreEqual(TEST_ALLOW_POLICY, HttpUtility.UrlDecode(response.PolicyDocument)); - } - finally - { - Client.DeleteGroupPolicy(new DeleteGroupPolicyRequest() { GroupName = groupname, PolicyName = policyName }); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - [ExpectedException(typeof(NoSuchEntityException))] - public void TestGetNonExistantPolicy() - { - string username = IAMUtil.CreateTestUser(Client); - string policyName = "test-policy-" + DateTime.UtcNow.Ticks; - - try - { - GetUserPolicyResponse response = - Client.GetUserPolicy(new GetUserPolicyRequest() { UserName = username, PolicyName = policyName }); - } - finally - { - IAMUtil.DeleteTestUsers(Client); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestListUserPolicies() - { - string username = IAMUtil.CreateTestUser(Client); - string[] policyNames = new string[3]; - int nPolicies = 3; - - try - { - for (int i = 0; i < nPolicies; i++) - { - policyNames[i] = "test-policy-" + DateTime.UtcNow.Ticks + i; - Client.PutUserPolicy(new PutUserPolicyRequest() - { - UserName = username, - PolicyName = policyNames[i], - PolicyDocument = TEST_ALLOW_POLICY - }); - } - - ListUserPoliciesResponse response = - Client.ListUserPolicies(new ListUserPoliciesRequest() { UserName = username }); - - Assert.AreEqual(nPolicies, response.PolicyNames.Count()); - - int matches = 0; - foreach (string name in response.PolicyNames) - { - for (int i = 0; i < nPolicies; i++) - { - if (name.Equals(policyNames[i])) - matches |= (1 << i); - } - } - Assert.AreEqual((1 << nPolicies) - 1, matches); - } - finally - { - IAMUtil.DeleteTestUsers(Client, username); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestListGroupPolicies() - { - string grpname = "sdk-testgroup-" + DateTime.UtcNow.Ticks; - string[] policyNames = new string[3]; - int nPolicies = 3; - - try - { - Client.CreateGroup(new CreateGroupRequest() { GroupName = grpname, Path = IAMUtil.TEST_PATH }); - - for (int i = 0; i < nPolicies; i++) - { - policyNames[i] = "test-policy-" + DateTime.UtcNow.Ticks + i; - Client.PutGroupPolicy(new PutGroupPolicyRequest() - { - GroupName = grpname, - PolicyName = policyNames[i], - PolicyDocument = TEST_ALLOW_POLICY - }); - } - - ListGroupPoliciesResponse response = - Client.ListGroupPolicies(new ListGroupPoliciesRequest() { GroupName = grpname }); - - Assert.AreEqual(nPolicies, response.PolicyNames.Count()); - - int matches = 0; - foreach (string name in response.PolicyNames) - { - for (int i = 0; i < nPolicies; i++) - { - if (name.Equals(policyNames[i])) - matches |= (1 << i); - } - } - Assert.AreEqual((1 << nPolicies) - 1, matches); - } - finally - { - for (int i = 0; i < nPolicies; i++) - { - Client.DeleteGroupPolicy(new DeleteGroupPolicyRequest() { GroupName = grpname, PolicyName = policyNames[i] }); - } - - Client.DeleteGroup(new DeleteGroupRequest() {GroupName = grpname }); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestListUserPoliciesPaging() - { - string username = IAMUtil.CreateTestUser(Client); - int nPolicies = 4; - string[] policyNames = new string[nPolicies]; - - try - { - for (int i = 0; i < nPolicies; i++) - { - policyNames[i] = "test-policy-" + DateTime.UtcNow.Ticks + i; - Client.PutUserPolicy(new PutUserPolicyRequest() - { - UserName = username, - PolicyName = policyNames[i], - PolicyDocument = TEST_ALLOW_POLICY - }); - } - - ListUserPoliciesResponse response = - Client.ListUserPolicies(new ListUserPoliciesRequest() { UserName = username, MaxItems = 2 }); - - Assert.AreEqual(2, response.PolicyNames.Count()); - Assert.AreEqual(true, response.IsTruncated); - string marker = response.Marker; - - int matches = 0; - foreach (string name in response.PolicyNames) - { - for (int i = 0; i < nPolicies; i++) - { - if (name.Equals(policyNames[i])) - matches |= (1 << i); - } - } - - response = Client.ListUserPolicies(new ListUserPoliciesRequest() { UserName = username, Marker = marker }); - - Assert.AreEqual(nPolicies - 2, response.PolicyNames.Count()); - Assert.AreEqual(false, response.IsTruncated); - - foreach (string name in response.PolicyNames) - { - for (int i = 0; i < nPolicies; i++) - { - if (name.Equals(policyNames[i])) - matches |= (1 << i); - } - } - - Assert.AreEqual((1 << nPolicies) - 1, matches); - } - finally - { - IAMUtil.DeleteTestUsers(Client, username); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestListGroupPoliciesPaging() - { - string grpname = "sdk-testgroup-" + DateTime.UtcNow.Ticks; - int nPolicies = 3; - string[] policyNames = new string[nPolicies]; - - try - { - Client.CreateGroup(new CreateGroupRequest() {GroupName = grpname, Path = IAMUtil.TEST_PATH }); - - for (int i = 0; i < nPolicies; i++) - { - policyNames[i] = "test-policy-" + DateTime.UtcNow.Ticks + i; - Client.PutGroupPolicy(new PutGroupPolicyRequest() - { - GroupName = grpname, - PolicyName = policyNames[i], - PolicyDocument = TEST_ALLOW_POLICY - }); - } - - ListGroupPoliciesResponse response = - Client.ListGroupPolicies(new ListGroupPoliciesRequest() { GroupName = grpname, MaxItems = 2 }); - - Assert.AreEqual(2, response.PolicyNames.Count()); - Assert.AreEqual(true, response.IsTruncated); - string marker = response.Marker; - - int matches = 0; - foreach (string name in response.PolicyNames) - { - for (int i = 0; i < nPolicies; i++) - { - if (name.Equals(policyNames[i])) - matches |= (1 << i); - } - } - - response = Client.ListGroupPolicies(new ListGroupPoliciesRequest() { GroupName = grpname, Marker = marker }); - - Assert.AreEqual(nPolicies - 2, response.PolicyNames.Count()); - Assert.AreEqual(false, response.IsTruncated); - - foreach (string name in response.PolicyNames) - { - for (int i = 0; i < nPolicies; i++) - { - if (name.Equals(policyNames[i])) - matches |= (1 << i); - } - } - - Assert.AreEqual((1 << nPolicies) - 1, matches); - } - finally - { - for (int i = 0; i < nPolicies; i++) - { - Client.DeleteGroupPolicy(new DeleteGroupPolicyRequest() { GroupName = grpname, PolicyName = policyNames[i] }); - } - - Client.DeleteGroup(new DeleteGroupRequest() { GroupName = grpname }); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestDeleteUserPolicy() - { - string username = IAMUtil.CreateTestUser(Client); - string pName = "sdk-policy-" + DateTime.UtcNow.Ticks; - - try - { - Client.PutUserPolicy(new PutUserPolicyRequest() - { - UserName = username, - PolicyName = pName, - PolicyDocument = TEST_ALLOW_POLICY - }); - - ListUserPoliciesResponse response = - Client.ListUserPolicies(new ListUserPoliciesRequest() { UserName = username }); - - Assert.AreEqual(1, response.PolicyNames.Count()); - - Client.DeleteUserPolicy(new DeleteUserPolicyRequest() { UserName = username, PolicyName = pName }); - - response = Client.ListUserPolicies(new ListUserPoliciesRequest() { UserName = username }); - - Assert.AreEqual(0, response.PolicyNames.Count()); - } - finally - { - IAMUtil.DeleteTestUsers(Client, username); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestDeleteGroupPolicy() - { - string groupname = "sdk-testgroup-" + DateTime.UtcNow.Ticks; - string pName = "test-policy-" + DateTime.UtcNow.Ticks; - - try - { - Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname, Path = IAMUtil.TEST_PATH }); - - Client.PutGroupPolicy(new PutGroupPolicyRequest() - { - GroupName = groupname, - PolicyName = pName, - PolicyDocument = TEST_ALLOW_POLICY - }); - - ListGroupPoliciesResponse response = - Client.ListGroupPolicies(new ListGroupPoliciesRequest() { GroupName = groupname }); - - Assert.AreEqual(1, response.PolicyNames.Count()); - - Client.DeleteGroupPolicy(new DeleteGroupPolicyRequest() { GroupName = groupname, PolicyName = pName }); - - response = Client.ListGroupPolicies(new ListGroupPoliciesRequest() { GroupName = groupname }); - - Assert.AreEqual(0, response.PolicyNames.Count()); - } - finally - { - Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname }); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - [ExpectedException(typeof(NoSuchEntityException))] - public void TestDeleteNonExistentGroupPolicyException() - { - string groupname = "sdk-testgroup-" + DateTime.UtcNow.Ticks; - - try - { - Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname, Path = IAMUtil.TEST_PATH }); - Client.DeleteGroupPolicy(new DeleteGroupPolicyRequest() { GroupName = groupname, PolicyName = "test-policy-" + DateTime.UtcNow.Ticks }); - } - finally - { - Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname }); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - [ExpectedException(typeof(NoSuchEntityException))] - public void TestGetNonExistentGroupPolicyException() - { - string groupname = "sdk-testgroup-" + DateTime.UtcNow.Ticks; - - try - { - Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname, Path = IAMUtil.TEST_PATH }); - Client.GetGroupPolicy(new GetGroupPolicyRequest() { GroupName = groupname, PolicyName = "test-policy-" + DateTime.UtcNow.Ticks }); - } - finally - { - Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname }); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - [ExpectedException(typeof(NoSuchEntityException))] - public void TestDeleteNonExistentUserPolicyException() - { - string username = IAMUtil.CreateTestUser(Client); - - try - { - Client.DeleteUserPolicy(new DeleteUserPolicyRequest() { UserName = username, PolicyName = "test-policy-" + DateTime.UtcNow.Ticks }); - } - finally - { - IAMUtil.DeleteTestUsers(Client, username); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - [ExpectedException(typeof(NoSuchEntityException))] - public void TestGetNonExistentUserPolicyException() - { - string username = IAMUtil.CreateTestUser(Client); - - try - { - Client.GetUserPolicy(new GetUserPolicyRequest() { UserName = username, PolicyName = "test-policy-" + DateTime.UtcNow.Ticks }); - } - finally - { - IAMUtil.DeleteTestUsers(Client, username); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - [ExpectedException(typeof(MalformedPolicyDocumentException))] - public void TestPutUserPolicyMalformedPolicyDocumentException() - { - string username = IAMUtil.CreateTestUser(Client); - string policyName = "test-policy-" + DateTime.UtcNow.Ticks; - - try - { - Client.PutUserPolicy(new PutUserPolicyRequest() - { - UserName = username, - PolicyName = policyName, - PolicyDocument = "[" - }); - } - finally - { - IAMUtil.DeleteTestUsers(Client, username); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestCreateManagedPolicy() - { - string policyName = "test-policy-" + DateTime.UtcNow.Ticks; - string arn = null; - - Client.CreatePolicy(new CreatePolicyRequest { PolicyName = policyName, PolicyDocument = TEST_VERSIONED_POLICY }); - try - { - arn = UtilityMethods.WaitUntilSuccess(() => FindPolicy(policyName)); - } - finally - { - if (arn != null) - Client.DeletePolicy(new DeletePolicyRequest { PolicyArn = arn }); - } - } - - private static string FindPolicy(string policyName) - { - string arn = null; - var policies = ListAllPolicies().ToList(); - var found = false; - foreach (var policy in policies) - { - if (policy.PolicyName.Equals(policyName)) - { - found = true; - arn = policy.Arn; - } - } - - Assert.IsTrue(found); - Assert.IsNotNull(arn); - return arn; - } - - private static IEnumerable ListAllPolicies() - { - var request = new ListPoliciesRequest(); - ListPoliciesResponse response; - do - { - response = Client.ListPolicies(request); - foreach (var p in response.Policies) - yield return p; - - request.Marker = response.Marker; - } while (response.IsTruncated.Value); - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestAttachManagedPolicy() - { - string username = IAMUtil.CreateTestUser(Client); - string policyName = "sdk-policy-" + DateTime.UtcNow.Ticks; - - var policyArn = Client.CreatePolicy(new CreatePolicyRequest { PolicyName = policyName, PolicyDocument = TEST_VERSIONED_POLICY }).Policy.Arn; - - try - { - Client.AttachUserPolicy(new AttachUserPolicyRequest { UserName = username, PolicyArn = policyArn }); - Client.DetachUserPolicy(new DetachUserPolicyRequest { UserName = username, PolicyArn = policyArn }); - } - finally - { - IAMUtil.DeleteTestUsers(Client, username); - } - } - } -} diff --git a/sdk/test/Services/IdentityManagement/IntegrationTests/RolesTests.cs b/sdk/test/Services/IdentityManagement/IntegrationTests/RolesTests.cs deleted file mode 100644 index bc02efab84c5..000000000000 --- a/sdk/test/Services/IdentityManagement/IntegrationTests/RolesTests.cs +++ /dev/null @@ -1,347 +0,0 @@ -using System; -using System.Text; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using AWSSDK_DotNet.IntegrationTests.Utils; -using Amazon.IdentityManagement; -using Amazon.IdentityManagement.Model; - -namespace AWSSDK_DotNet.IntegrationTests.Tests.IAM -{ - [TestClass] - public class RolesTests : TestBase - { - private static IAmazonIdentityManagementService client = Client; - - public static string roleName = "TestRole"; - public static string policyName = "TestPolicy"; - public static string profileName = "TestProfile"; - public static string path = "/"; - public static string - TEST_ALLOW_POLICY = @"{""Statement"":[{""Effect"":""Allow"",""Action"":""*"",""Resource"":""*""}]}", - TEST_DENY_POLICY = @"{""Statement"":[{""Effect"":""Deny"",""Action"":""*"",""Resource"":""*""}]}", - TEST_ASSUME_ALLOW_POLICY = "{\"Statement\":[{\"Principal\":{\"Service\":[\"ec2.amazonaws.com\"]},\"Effect\":\"Allow\",\"Action\":[\"sts:AssumeRole\"]}]}", - TEST_ASSUME_DENY_POLICY = "{\"Statement\":[{\"Principal\":{\"Service\":[\"ec2.amazonaws.com\"]},\"Effect\":\"Deny\",\"Action\":[\"sts:AssumeRole\"]}]}"; - - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - [TestInitialize] - public void TestSetup() - { - //IAMUtil.DeleteUsersAndGroupsInTestNameSpace(); - } - - [TestCleanup] - public void TestCleanup() - { - var roles = GetRoles(); - if (roles.Any(r => string.Equals(r.RoleName, roleName))) - { - var rolePolicies = client.ListRolePolicies(new ListRolePoliciesRequest - { - RoleName = roleName - }).PolicyNames; - - foreach (var rolePolicy in rolePolicies) - { - client.DeleteRolePolicy(new DeleteRolePolicyRequest - { - RoleName = roleName, - PolicyName = rolePolicy - }); - } - - client.DeleteRole(new DeleteRoleRequest - { - RoleName = roleName - }); - } - - var profiles = client.ListInstanceProfiles().InstanceProfiles; - if (profiles.Any(p => string.Equals(p.InstanceProfileName, profileName))) - { - client.DeleteInstanceProfile(new DeleteInstanceProfileRequest - { - InstanceProfileName = profileName - }); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void Roles() - { - var roles = GetRoles(); - Assert.IsNotNull(roles); - int originalCount = roles.Count; - - var newRole = client.CreateRole(new CreateRoleRequest - { - RoleName = roleName, - Path = path, - AssumeRolePolicyDocument = TEST_ASSUME_ALLOW_POLICY - }).Role; - Assert.IsNotNull(newRole); - - roles = GetRoles(); - Assert.IsNotNull(roles); - Assert.AreEqual(originalCount + 1, roles.Count); - - AssertExtensions.ExpectException(() => client.GetRole(new GetRoleRequest { RoleName = "bar" })); - - var role = client.GetRole(new GetRoleRequest - { - RoleName = roleName - }); - Assert.IsNotNull(role); - - var rolePolicies = client.ListRolePolicies(new ListRolePoliciesRequest - { - RoleName = roleName - }).PolicyNames; - Assert.AreEqual(0, rolePolicies.Count); - - AssertExtensions.ExpectException(() => client.DeleteRole(new DeleteRoleRequest { RoleName = "bar" })); - - roles = GetRoles(); - Assert.IsNotNull(roles); - Assert.AreEqual(originalCount + 1, roles.Count); - - client.DeleteRole(new DeleteRoleRequest - { - RoleName = roleName - }); - - roles = GetRoles(); - Assert.IsNotNull(roles); - Assert.AreEqual(originalCount, roles.Count); - - AssertExtensions.ExpectException(() => client.GetRole(new GetRoleRequest { RoleName = roleName })); - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void RolePolicies() - { - client.CreateRole(new CreateRoleRequest - { - RoleName = roleName, - Path = path, - AssumeRolePolicyDocument = TEST_ASSUME_ALLOW_POLICY - }); - - var rolePolicies = client.ListRolePolicies(new ListRolePoliciesRequest - { - RoleName = roleName - }).PolicyNames; - Assert.AreEqual(0, rolePolicies.Count); - - AssertExtensions.ExpectException(() => client.GetRolePolicy(new GetRolePolicyRequest - { - RoleName = roleName, - PolicyName = policyName - })); - - AssertExtensions.ExpectException(() => client.DeleteRolePolicy(new DeleteRolePolicyRequest - { - RoleName = roleName, - PolicyName = policyName - })); - - client.PutRolePolicy(new PutRolePolicyRequest - { - RoleName = roleName, - PolicyName = policyName, - PolicyDocument = TEST_DENY_POLICY - }); - - var roles = GetRoles(); - Assert.IsNotNull(roles); - - var policyResult = client.GetRolePolicy(new GetRolePolicyRequest - { - RoleName = roleName, - PolicyName = policyName - }); - - Assert.IsNotNull(policyResult); - Assert.AreEqual(roleName, policyResult.RoleName); - Assert.AreEqual(policyName, policyResult.PolicyName); - Assert.AreEqual(TEST_DENY_POLICY, Uri.UnescapeDataString(policyResult.PolicyDocument)); - - rolePolicies = client.ListRolePolicies(new ListRolePoliciesRequest - { - RoleName = roleName - }).PolicyNames; - Assert.AreEqual(1, rolePolicies.Count); - - var role = client.GetRole(new GetRoleRequest - { - RoleName = roleName - }).Role; - Assert.IsNotNull(role); - - client.DeleteRolePolicy(new DeleteRolePolicyRequest - { - RoleName = roleName, - PolicyName = policyName - }); - - AssertExtensions.ExpectException(() => client.GetRolePolicy(new GetRolePolicyRequest - { - RoleName = roleName, - PolicyName = policyName - })); - - AssertExtensions.ExpectException(() => client.DeleteRolePolicy(new DeleteRolePolicyRequest - { - RoleName = roleName, - PolicyName = policyName - })); - - rolePolicies = client.ListRolePolicies(new ListRolePoliciesRequest - { - RoleName = roleName - }).PolicyNames; - Assert.AreEqual(0, rolePolicies.Count); - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void IdentityProfiles() - { - var profiles = client.ListInstanceProfiles().InstanceProfiles; - int originalCount = profiles.Count; - - AssertExtensions.ExpectException(() => client.GetInstanceProfile(new GetInstanceProfileRequest - { - InstanceProfileName = profileName - })); - - var newProfile = client.CreateInstanceProfile(new CreateInstanceProfileRequest - { - InstanceProfileName = profileName, - Path = path - }).InstanceProfile; - Assert.IsNotNull(newProfile); - - profiles = client.ListInstanceProfiles().InstanceProfiles; - Assert.AreEqual(originalCount + 1, profiles.Count); - - var profile = client.GetInstanceProfile(new GetInstanceProfileRequest - { - InstanceProfileName = profileName - }).InstanceProfile; - Assert.IsNotNull(profile); - - AssertExtensions.ExpectException(() => client.ListInstanceProfilesForRole(new ListInstanceProfilesForRoleRequest - { - RoleName = roleName - })); - - // add role to profile - var newRole = client.CreateRole(new CreateRoleRequest - { - RoleName = roleName, - Path = path, - AssumeRolePolicyDocument = TEST_ASSUME_ALLOW_POLICY - }).Role; - Assert.IsNotNull(newRole); - - client.AddRoleToInstanceProfile(new AddRoleToInstanceProfileRequest - { - InstanceProfileName = profileName, - RoleName = roleName - }); - var roleProfiles = client.ListInstanceProfilesForRole(new ListInstanceProfilesForRoleRequest - { - RoleName = roleName - }).InstanceProfiles; - Assert.AreEqual(1, roleProfiles.Count); - - client.RemoveRoleFromInstanceProfile(new RemoveRoleFromInstanceProfileRequest - { - InstanceProfileName = profileName, - RoleName = roleName - }); - roleProfiles = client.ListInstanceProfilesForRole(new ListInstanceProfilesForRoleRequest - { - RoleName = roleName - }).InstanceProfiles; - Assert.AreEqual(0, roleProfiles.Count); - - client.DeleteInstanceProfile(new DeleteInstanceProfileRequest - { - InstanceProfileName = profileName - }); - - AssertExtensions.ExpectException(() => client.DeleteInstanceProfile(new DeleteInstanceProfileRequest - { - InstanceProfileName = profileName - })); - - profiles = client.ListInstanceProfiles().InstanceProfiles; - Assert.AreEqual(originalCount, profiles.Count); - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void AssumeRolePolicyDocument() - { - client.CreateRole(new CreateRoleRequest - { - RoleName = roleName, - Path = path, - AssumeRolePolicyDocument = TEST_ASSUME_ALLOW_POLICY - }); - - var role = client.GetRole(new GetRoleRequest - { - RoleName = roleName - }).Role; - Assert.IsNotNull(role); - Assert.IsNotNull(role.AssumeRolePolicyDocument); - - client.UpdateAssumeRolePolicy(new UpdateAssumeRolePolicyRequest - { - RoleName = roleName, - PolicyDocument = TEST_ASSUME_DENY_POLICY - }); - - role = client.GetRole(new GetRoleRequest - { - RoleName = roleName - }).Role; - Assert.IsNotNull(role); - Assert.IsNotNull(role.AssumeRolePolicyDocument); - } - - private List GetRoles() - { - var roles = new List(); - string nextMarker = null; - do - { - var response = client.ListRoles(new ListRolesRequest - { - Marker = nextMarker - }); - nextMarker = response.Marker; - roles.AddRange(response.Roles); - } while (!string.IsNullOrEmpty(nextMarker)); - - return roles; - } - } -} diff --git a/sdk/test/Services/IdentityManagement/IntegrationTests/UserTests.cs b/sdk/test/Services/IdentityManagement/IntegrationTests/UserTests.cs deleted file mode 100644 index 61c8bd65ad53..000000000000 --- a/sdk/test/Services/IdentityManagement/IntegrationTests/UserTests.cs +++ /dev/null @@ -1,353 +0,0 @@ -using System; -using System.Text; -using System.Collections.Generic; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using AWSSDK_DotNet.IntegrationTests.Utils; -using Amazon.IdentityManagement; -using Amazon.IdentityManagement.Model; - -namespace AWSSDK_DotNet.IntegrationTests.Tests.IAM -{ - /// - /// Summary description for GetUserTest - /// - [TestClass] - public class UserTests : TestBase - { - public UserTests() - { - } - - private TestContext testContextInstance; - - /// - ///Gets or sets the test context which provides - ///information about and functionality for the current test run. - /// - public TestContext TestContext - { - get - { - return testContextInstance; - } - set - { - testContextInstance = value; - } - } - - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - [TestInitialize] - public void PreTestRun() - { - IAMUtil.DeleteUsersAndGroupsInTestNameSpace(Client); - } - - [TestMethod] - [TestCategory("IdentityManagement")] - [TestCategory("RequiresIAMUser")] - public void TestGetUserImplicit() - { - GetUserRequest request = new GetUserRequest(); - - GetUserResponse response = Client.GetUser(request); - Assert.IsFalse(string.IsNullOrEmpty(response.User.Arn)); - - // The assert will succeed if you run with root credentials. - //Assert.AreEqual(string.Format("arn:aws:iam::{0}:root", response.User.UserId), response.User.Arn); - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestCreateGetUser() - { - string username = "sdk-testuser-" + DateTime.UtcNow.Ticks; - - try - { - CreateUserRequest request = new CreateUserRequest() { UserName = username, Path = IAMUtil.TEST_PATH }; - CreateUserResponse response = Client.CreateUser(request); - Assert.AreEqual(username, response.User.UserName); - GetUserResponse getResponse = Client.GetUser(new GetUserRequest() { UserName = username }); - Assert.AreEqual(username, getResponse.User.UserName); - Assert.AreNotEqual(DateTime.MinValue, getResponse.User.CreateDate); - } - finally - { - Client.DeleteUser(new DeleteUserRequest() { UserName = username }); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestListUsers() - { - string username1 = IAMUtil.CreateTestUser(Client); - string username2 = IAMUtil.CreateTestUser(Client); - string username3 = IAMUtil.CreateTestUser(Client); - try - { - ListUsersResponse response = Client.ListUsers(new ListUsersRequest() { PathPrefix = IAMUtil.TEST_PATH }); - - Assert.AreEqual(3, response.Users.Count()); - - int matches = 0; - foreach(User user in response.Users) - { - if (user.UserName.Equals(username1)) - matches |= 1; - if (user.UserName.Equals(username2)) - matches |= 2; - if (user.UserName.Equals(username3)) - matches |= 4; - } - Assert.AreEqual(7, matches); - } - finally - { - IAMUtil.DeleteTestUsers(Client, username1, username2, username3); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestUserWithPath() - { - string username = "sdk-testuser-" + DateTime.UtcNow.Ticks; - string path = IAMUtil.MakePath("one", "two", "three"); - try - { - Client.CreateUser(new CreateUserRequest() { UserName = username, Path = path }); - GetUserResponse response = Client.GetUser(new GetUserRequest() { UserName = username }); - Assert.AreEqual(username, response.User.UserName); - Assert.AreEqual(path, response.User.Path); - } - finally - { - IAMUtil.DeleteTestUsers(Client, username); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestListUsersByPath() - { - string username1 = "sdk-testuser1-" + DateTime.UtcNow.Ticks; - string username2 = "sdk-testuser2-" + DateTime.UtcNow.Ticks; - string username3 = "sdk-testuser3-" + DateTime.UtcNow.Ticks; - string username4 = "sdk-testuser4-" + DateTime.UtcNow.Ticks; - - string pathA = IAMUtil.MakePath("A"); - string pathB = IAMUtil.MakePath("B"); - - try - { - Client.CreateUser(new CreateUserRequest() { UserName = username1, Path = pathA }); - Client.CreateUser(new CreateUserRequest() { UserName = username2, Path = pathA }); - Client.CreateUser(new CreateUserRequest() { UserName = username3, Path = pathB }); - Client.CreateUser(new CreateUserRequest() { UserName = username4, Path = pathA }); - - ListUsersResponse response = Client.ListUsers(new ListUsersRequest() { PathPrefix = pathA }); - - Assert.AreEqual(3, response.Users.Count()); - - int matches = 0; - - foreach (User u in response.Users) - { - if (u.UserName.Equals(username1)) - matches |= 1; - if (u.UserName.Equals(username2)) - matches |= 2; - if (u.UserName.Equals(username4)) - matches |= 4; - if (u.UserName.Equals(username3)) - Assert.Fail(); - } - Assert.AreEqual(7, matches); - - response = Client.ListUsers(new ListUsersRequest(){ PathPrefix = pathB }); - - Assert.AreEqual(1, response.Users.Count()); - - matches = 0; - - foreach (User u in response.Users) - { - if (u.UserName.Equals(username1)) - Assert.Fail(); - if (u.UserName.Equals(username2)) - Assert.Fail(); - if (u.UserName.Equals(username4)) - Assert.Fail(); - if (u.UserName.Equals(username3)) - matches = 1; - } - Assert.AreEqual(1, matches); - - response = Client.ListUsers(new ListUsersRequest(){ PathPrefix = IAMUtil.TEST_PATH }); - Assert.AreEqual(4, response.Users.Count()); - - } - finally - { - IAMUtil.DeleteTestUsers(Client, username1, username2, username3, username4); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestListUsersMaxResults() - { - string username1 = IAMUtil.CreateTestUser(Client); - string username2 = IAMUtil.CreateTestUser(Client); - string username3 = IAMUtil.CreateTestUser(Client); - string username4 = IAMUtil.CreateTestUser(Client); - - try - { - ListUsersResponse response = Client.ListUsers(new ListUsersRequest() { MaxItems = 2, PathPrefix = IAMUtil.TEST_PATH }); - - Assert.AreEqual(2, response.Users.Count()); - Assert.AreEqual(true, response.IsTruncated); - - int matches = 0; - - foreach (User u in response.Users) - { - if (u.UserName.Equals(username1)) - matches |= 1; - if (u.UserName.Equals(username2)) - matches |= 2; - if (u.UserName.Equals(username4)) - matches |= 3; - if (u.UserName.Equals(username3)) - matches |= 4; - } - - string marker = response.Marker; - - response = Client.ListUsers(new ListUsersRequest() { PathPrefix = IAMUtil.TEST_PATH, Marker = marker }); - - Assert.AreEqual(2, response.Users.Count()); - Assert.AreEqual(false, response.IsTruncated); - - foreach (User u in response.Users) - { - if (u.UserName.Equals(username1)) - matches |= 1; - if (u.UserName.Equals(username2)) - matches |= 2; - if (u.UserName.Equals(username4)) - matches |= 3; - if (u.UserName.Equals(username3)) - matches |= 4; - } - - Assert.AreEqual(7, matches); - } - finally - { - IAMUtil.DeleteTestUsers(Client, username1, username2, username3, username4); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - public void TestUpdateUser() - { - string - username = "sdk-testuser-" + DateTime.UtcNow.Ticks, - newusername = "sdk-testnewuser-" + DateTime.UtcNow.Ticks; - string - firstPath = IAMUtil.MakePath("first"), - secondPath = IAMUtil.MakePath("second"); - - try - { - Client.CreateUser(new CreateUserRequest() { UserName = username, Path = firstPath }); - - GetUserResponse response = Client.GetUser(new GetUserRequest() { UserName = username }); - Assert.AreEqual(firstPath, response.User.Path); - - string id = response.User.UserId; - - Client.UpdateUser(new UpdateUserRequest() { UserName = username, NewPath = secondPath, NewUserName = newusername }); - - response = Client.GetUser(new GetUserRequest() { UserName = newusername }); - - Assert.AreEqual(newusername, response.User.UserName); - Assert.AreEqual(secondPath, response.User.Path); - Assert.AreEqual(id, response.User.UserId); - } - finally - { - Client.DeleteUser(new DeleteUserRequest() { UserName = newusername }); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - [ExpectedException(typeof(NoSuchEntityException))] - public void TestDeleteUser() - { - string username = "sdk-testuser-" + DateTime.UtcNow.Ticks; - - Client.CreateUser(new CreateUserRequest() {UserName = username, Path = IAMUtil.TEST_PATH }); - - GetUserResponse response = Client.GetUser(new GetUserRequest() { UserName = username }); - Assert.AreEqual(username, response.User.UserName); - - Client.DeleteUser(new DeleteUserRequest() { UserName = username }); - - Client.GetUser(new GetUserRequest() { UserName = username }); - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - [ExpectedException(typeof(EntityAlreadyExistsException))] - public void TestDoubleCreateUser() - { - string username = "sdk-testuser-" + DateTime.UtcNow.Ticks; - - try - { - Client.CreateUser(new CreateUserRequest() { UserName = username, Path = IAMUtil.TEST_PATH }); - Client.CreateUser(new CreateUserRequest() { UserName = username, Path = IAMUtil.TEST_PATH }); - } - finally - { - Client.DeleteUser(new DeleteUserRequest() { UserName = username }); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("IdentityManagement")] - [ExpectedException(typeof(NoSuchEntityException))] - public void TestUpdateNonexistantUser() - { - string username = "sdk-testuser-" + DateTime.UtcNow.Ticks; - - Client.UpdateUser(new UpdateUserRequest() { UserName = username, NewPath = "/lala/" }); - } - - - - } -} diff --git a/sdk/test/Services/IdentityManagement/IntegrationTests/Util.cs b/sdk/test/Services/IdentityManagement/IntegrationTests/Util.cs deleted file mode 100644 index 886e232a43a5..000000000000 --- a/sdk/test/Services/IdentityManagement/IntegrationTests/Util.cs +++ /dev/null @@ -1,119 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Amazon.IdentityManagement; -using Amazon.IdentityManagement.Model; - -using AWSSDK_DotNet.IntegrationTests.Utils; - -namespace AWSSDK_DotNet.IntegrationTests.Tests.IAM -{ - class IAMUtil - { - public static string TEST_PATH = "/IntegrationTests/IAM/"; - - public static string MakePath(params string[] elements) - { - string path = TEST_PATH; - foreach (string s in elements) - { - path = string.Format("{0}{1}/", path, s); - } - - return path; - } - - public static void DeleteUsersAndGroupsInTestNameSpace(AmazonIdentityManagementServiceClient client) - { - ListGroupsResponse lgRes = client.ListGroups(new ListGroupsRequest() { PathPrefix = TEST_PATH }); - if (lgRes.Groups != null) - { - foreach (Group g in lgRes.Groups) - { - GetGroupResponse ggRes = client.GetGroup(new GetGroupRequest() { GroupName = g.GroupName }); - foreach (User u in ggRes.Users) - { - client.RemoveUserFromGroup(new RemoveUserFromGroupRequest() { GroupName = g.GroupName, UserName = u.UserName }); - } - client.DeleteGroup(new DeleteGroupRequest() { GroupName = g.GroupName }); - } - } - - ListUsersResponse luRes = client.ListUsers(new ListUsersRequest() { PathPrefix = TEST_PATH }); - if (luRes.Users != null) - { - foreach (User u in luRes.Users) - { - DeleteTestUsers(client, u.UserName); - } - } - } - - public static void DeleteAccessKeysForUser(AmazonIdentityManagementServiceClient client, string username) - { - ListAccessKeysResponse response = client.ListAccessKeys(new ListAccessKeysRequest() { UserName = username }); - if (response.AccessKeyMetadata != null) - { - foreach (AccessKeyMetadata akm in response.AccessKeyMetadata) - { - client.DeleteAccessKey(new DeleteAccessKeyRequest() { UserName = username, AccessKeyId = akm.AccessKeyId }); - } - } - } - - public static void DeleteUserPoliciesForUser(AmazonIdentityManagementServiceClient client, string username) - { - ListUserPoliciesResponse response = - client.ListUserPolicies(new ListUserPoliciesRequest() { UserName = username }); - - if (response.PolicyNames != null) - { - foreach (string pName in response.PolicyNames) - { - client.DeleteUserPolicy(new DeleteUserPolicyRequest() { UserName = username, PolicyName = pName }); - } - } - } - - public static void DeleteCertificatesForUser(AmazonIdentityManagementServiceClient client, string username) - { - ListSigningCertificatesResponse response = - client.ListSigningCertificates(new ListSigningCertificatesRequest() { UserName = username }); - - if (response.Certificates != null) - { - foreach (SigningCertificate cert in response.Certificates) - { - client.DeleteSigningCertificate(new DeleteSigningCertificateRequest() { UserName = username, CertificateId = cert.CertificateId }); - } - } - } - - public static string CreateTestUser(AmazonIdentityManagementServiceClient client) - { - string username = "sdk-testuser-" + DateTime.UtcNow.Ticks; - client.CreateUser(new CreateUserRequest() { UserName = username, Path = TEST_PATH }); - return username; - } - - public static void DeleteTestUsers(AmazonIdentityManagementServiceClient client, params string[] usernames) - { - UtilityMethods.WaitUntilSuccess(() => { - foreach (string s in usernames) - { - DeleteAccessKeysForUser(client, s); - DeleteUserPoliciesForUser(client, s); - DeleteCertificatesForUser(client, s); - try - { - client.DeleteLoginProfile(new DeleteLoginProfileRequest() { UserName = s }); - } catch { } - - client.DeleteUser(new DeleteUserRequest() { UserName = s }); - } - }); - } - } -} diff --git a/sdk/test/Services/ImportExport/IntegrationTests/AWSSDK.IntegrationTests.ImportExport.NetFramework.csproj b/sdk/test/Services/ImportExport/IntegrationTests/AWSSDK.IntegrationTests.ImportExport.NetFramework.csproj deleted file mode 100644 index 33c92729d8e5..000000000000 --- a/sdk/test/Services/ImportExport/IntegrationTests/AWSSDK.IntegrationTests.ImportExport.NetFramework.csproj +++ /dev/null @@ -1,51 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.ImportExport.NetFramework - AWSSDK.IntegrationTests.ImportExport.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/ImportExport/IntegrationTests/Config/462/App.config b/sdk/test/Services/ImportExport/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/ImportExport/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/ImportExport/IntegrationTests/ImportExport.cs b/sdk/test/Services/ImportExport/IntegrationTests/ImportExport.cs deleted file mode 100644 index 1d1a1e2c0409..000000000000 --- a/sdk/test/Services/ImportExport/IntegrationTests/ImportExport.cs +++ /dev/null @@ -1,181 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using Amazon.ImportExport; -using Amazon.ImportExport.Model; -using Amazon.Runtime; - -using Amazon.S3; -using Amazon.S3.Model; -using Amazon.S3.Util; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class ImportExport : TestBase - { - const string IMPORT_MANIFEST = -@"bucket: @BUCKET@ -accessKeyId: @ACCESS_KEY_ID@ -manifestVersion: 1.3 -eraseDevice: true -deviceId: 123 -notificationEmail: john.doe@example.com -returnAddress: - name: Amazon.com ATTN:Joe Random - street1: 5555555 5th Ave - city: Seattle - stateOrProvince: WA - postalCode: 98104 - phoneNumber: 206-555-1000 - country: USA -"; - - const string EXPORT_MANIFEST = -@"manifestVersion: 1.2 -accessKeyId: @ACCESS_KEY_ID@ -deviceId: 532404500021 -logBucket: @BUCKET@ -trueCryptPassword: apassword -logPrefix: logs/ -fileSystem: NTFS -notificationEmail: john.doe@example.com -operations: - - exportBucket: @BUCKET@ -returnAddress: - name: Amazon.com ATTN Joe Random - street1: 1200 12th Ave S. - city: Seattle - stateOrProvince: WA - postalCode: 98114 - phoneNumber: 206-266-0000 - country: USA -"; - - static AmazonS3Client s3Client; - - static string bucketName; - - [ClassInitialize] - public static void ClassInitialize(TestContext testContext) - { - s3Client = new AmazonS3Client(); - - // Add test data to export - bucketName = "sdk-import-test" + DateTime.UtcNow.Ticks; - s3Client.PutBucket(new PutBucketRequest { BucketName = bucketName }); - s3Client.PutObject(new PutObjectRequest - { - BucketName = bucketName, - Key = "data.txt", - ContentBody = "import-export-data" - }); - } - - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - - if(s3Client != null) - { - AmazonS3Util.DeleteS3BucketWithObjects(s3Client, bucketName); - s3Client.Dispose(); - s3Client = null; - } - } - - [Ignore] - [TestMethod] - [TestCategory("ImportExport")] - public void TestImportExport() - { - // CreateJob - CreateJobRequest createJobRequest = new CreateJobRequest - { - JobType = JobType.Import, - Manifest = GetSampleManifestText(IMPORT_MANIFEST) - }; - var createJobResponse = Client.CreateJob(createJobRequest); - string createdJobId = createJobResponse.JobId; - Assert.IsNotNull(createdJobId); - Assert.AreEqual(JobType.Import, createJobResponse.JobType); - Assert.IsNotNull(createJobResponse.Signature); - Assert.IsNotNull(createJobResponse.SignatureFileContents); - - - // UpdateJob - UpdateJobRequest updateJobRequest = new UpdateJobRequest - { - JobId = createdJobId, - JobType = JobType.Export, - Manifest = GetSampleManifestText(EXPORT_MANIFEST) - }; - Client.UpdateJob(updateJobRequest); - - - // ListJobs - var listJobsResponse = Client.ListJobs(new ListJobsRequest { MaxJobs = 100 }); - Assert.IsNotNull(listJobsResponse.IsTruncated); - Job job = FindJob(createdJobId, listJobsResponse.Jobs); - Assert.IsNotNull(job); - Assert.IsTrue(job.CreationDate > DateTime.MinValue); - Assert.IsFalse(job.IsCanceled.Value); - Assert.AreEqual(createdJobId, job.JobId); - Assert.AreEqual(JobType.Export, job.JobType); - Assert.IsFalse(job.IsCanceled.Value); - - - // GetStatus - var getStatusResponse = Client.GetStatus(new GetStatusRequest { JobId = createdJobId }); - Assert.IsNotNull(getStatusResponse.CreationDate); - Assert.IsNotNull(getStatusResponse.CurrentManifest); - Assert.AreEqual(createdJobId, getStatusResponse.JobId); - Assert.AreEqual(JobType.Export, getStatusResponse.JobType); - Assert.IsNotNull(getStatusResponse.ProgressMessage); - Assert.IsNotNull(getStatusResponse.LocationMessage); - Assert.IsNotNull(getStatusResponse.LocationCode); - Assert.IsNotNull(getStatusResponse.Signature); - Assert.AreEqual(0, getStatusResponse.ErrorCount); - Assert.IsNotNull(getStatusResponse.ProgressMessage); - Assert.IsNotNull(getStatusResponse.SignatureFileContents); - Assert.IsNull(getStatusResponse.Carrier); - Assert.IsNull(getStatusResponse.TrackingNumber); - Assert.IsNull(getStatusResponse.LogBucket); - Assert.IsNull(getStatusResponse.LogKey); - - - // Cancel our test job - Client.CancelJob(new CancelJobRequest { JobId = createdJobId }); - AssertJobIsCancelled(createdJobId); - createdJobId = null; - } - - private Job FindJob(String jobId, List jobs) - { - var job = jobs.Find(item => item.JobId == jobId); - - if (job == null) - Assert.Fail("Expected to find a job with ID '" + jobId + "', but didn't"); - return job; - } - - private void AssertJobIsCancelled(string jobId) - { - Job job = FindJob(jobId, Client.ListJobs(new ListJobsRequest()).Jobs); - Assert.IsTrue(job.IsCanceled.Value); - } - - - - private string GetSampleManifestText(string manifest) - { - manifest = manifest.Replace("@BUCKET@", bucketName); - manifest = manifest.Replace("@ACCESS_KEY_ID@", "AAAEXAMPLE"); - - return manifest; - } - - } -} diff --git a/sdk/test/Services/Inspector/IntegrationTests/AWSSDK.IntegrationTests.Inspector.NetFramework.csproj b/sdk/test/Services/Inspector/IntegrationTests/AWSSDK.IntegrationTests.Inspector.NetFramework.csproj deleted file mode 100644 index 0d5aa79d1bc0..000000000000 --- a/sdk/test/Services/Inspector/IntegrationTests/AWSSDK.IntegrationTests.Inspector.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.Inspector.NetFramework - AWSSDK.IntegrationTests.Inspector.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/Inspector/IntegrationTests/Config/462/App.config b/sdk/test/Services/Inspector/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/Inspector/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/Inspector/IntegrationTests/Inspector.cs b/sdk/test/Services/Inspector/IntegrationTests/Inspector.cs deleted file mode 100644 index 4ef6ad3d1d80..000000000000 --- a/sdk/test/Services/Inspector/IntegrationTests/Inspector.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using Amazon.Inspector; -using Amazon.Inspector.Model; -using Amazon.Runtime; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - /* Tests disabled pending update to new 2016-02-16 API version - [TestClass] - public class Inspector : TestBase - { - [TestInitialize] - public void Init() - { - SetEndpoint(Client, "https://inspector.us-west-2.amazonaws.com", "us-west-2"); - } - - [TestMethod] - public void TestListOperation() - { - Client.ListApplications(new ListApplicationsRequest { }); - } - - [TestMethod] - public void TestErrorMessageUnmarshalling() - { - try - { - Client.CreateResourceGroup(@"{""foo"":""bar""}"); - } - catch (AmazonInspectorException e) - { - Assert.IsNotNull(e.Message); - } - } - - [TestMethod] - public void TestCrudOperations() - { - var groupTags = @"[{""key"": ""foo"", ""values"" :[""bar"",""baz""]}]"; - var groupArn = Client.CreateResourceGroup(new CreateResourceGroupRequest - { - ResourceGroupTags = groupTags, - }).ResourceGroupArn; - - Assert.IsNotNull(groupArn); - - var appName = Utils.UtilityMethods.GenerateName(); - var appArn = Client.CreateApplication(new CreateApplicationRequest { ApplicationName = appName, ResourceGroupArn = groupArn }).ApplicationArn; - - Assert.IsNotNull(appArn); - - var app = Utils.UtilityMethods.WaitUntilSuccess(() => - Client.DescribeApplication(new DescribeApplicationRequest { ApplicationArn = appArn}).Application); - - Assert.AreEqual(appName, app.ApplicationName); - Assert.AreEqual(appArn, app.ApplicationArn); - Assert.AreEqual(groupArn, app.ResourceGroupArn); - - Client.UpdateApplication(new UpdateApplicationRequest { ApplicationArn = appArn, ApplicationName = appName + "X", ResourceGroupArn = groupArn }); - - app = Utils.UtilityMethods.WaitUntilSuccess(() => - Client.DescribeApplication(new DescribeApplicationRequest { ApplicationArn = appArn }).Application); - - Assert.AreEqual(appName + "X", app.ApplicationName); - - Client.DeleteApplication(new DeleteApplicationRequest { ApplicationArn = appArn }); - } - - }*/ -} diff --git a/sdk/test/Services/IoT/IntegrationTests/AWSSDK.IntegrationTests.IoT.NetFramework.csproj b/sdk/test/Services/IoT/IntegrationTests/AWSSDK.IntegrationTests.IoT.NetFramework.csproj deleted file mode 100644 index b48c38452ee9..000000000000 --- a/sdk/test/Services/IoT/IntegrationTests/AWSSDK.IntegrationTests.IoT.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.IoT.NetFramework - AWSSDK.IntegrationTests.IoT.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/IoT/IntegrationTests/Config/462/App.config b/sdk/test/Services/IoT/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/IoT/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/IoT/IntegrationTests/IoT.cs b/sdk/test/Services/IoT/IntegrationTests/IoT.cs deleted file mode 100644 index ba89ce10ef5c..000000000000 --- a/sdk/test/Services/IoT/IntegrationTests/IoT.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using Amazon.IoT; -using Amazon.IoT.Model; -using Amazon.Runtime; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class IoT : TestBase - { - [TestMethod] - [TestCategory("IoT")] - public void TestListCall() - { - Client.ListPolicies(new ListPoliciesRequest { AscendingOrder = true }); - } - - [TestMethod] - [TestCategory("IoT")] - public void TestThingOperations() - { - var thingName = Utils.UtilityMethods.GenerateName(); - var thingArn = Client.CreateThing(new CreateThingRequest - { - ThingName = thingName, - AttributePayload = new AttributePayload { Attributes = new Dictionary { { "foo", "bar" } } } - }).ThingArn; - - Assert.IsNotNull(thingArn); - - var attr = Client.DescribeThing(new DescribeThingRequest { ThingName = thingName }).Attributes; - - Assert.IsTrue(attr.ContainsKey("foo")); - Assert.AreEqual("bar", attr["foo"]); - - Utils.UtilityMethods.WaitUntilSuccess(() => - Client.DeleteThing(new DeleteThingRequest { ThingName = thingName }) - ); - } - - [TestMethod] - [TestCategory("IoT")] - public void TestErrorMessage() - { - try - { - Client.CreatePolicy("Foobar", "{}"); - } - catch (AmazonIoTException e) - { - Assert.IsNotNull(e.Message); - } - } - - [TestMethod] - [TestCategory("IoT")] - public void TestCertificateOperations() - { - var response = Client.CreateKeysAndCertificate(new CreateKeysAndCertificateRequest { }); - Assert.IsNotNull(response.CertificateArn); - Assert.IsNotNull(response.CertificateId); - Assert.IsNotNull(response.CertificatePem); - Assert.IsNotNull(response.KeyPair.PublicKey); - Assert.IsNotNull(response.KeyPair.PrivateKey); - - - Client.CreateKeysAndCertificate(false); - - Utils.UtilityMethods.WaitUntilSuccess(() => - Client.DeleteCertificate(new DeleteCertificateRequest { CertificateId = response.CertificateId }) - ); - } - } -} diff --git a/sdk/test/Services/IotData/IntegrationTests/IotData.cs b/sdk/test/Services/IotData/IntegrationTests/IotData.cs index 4eb063867bf0..8b6770a8f98d 100644 --- a/sdk/test/Services/IotData/IntegrationTests/IotData.cs +++ b/sdk/test/Services/IotData/IntegrationTests/IotData.cs @@ -1,46 +1,47 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; - +using Amazon.IoT; +using Amazon.IoT.Model; using Amazon.IotData; using Amazon.IotData.Model; -using Amazon.Runtime; - -using System.IO; using AWSSDK_DotNet.IntegrationTests.Utils; -using Amazon.IoT.Model; -using Amazon.IoT; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.IO; +using System.Linq; using System.Net; +using System.Text; +using System.Threading.Tasks; namespace AWSSDK_DotNet.IntegrationTests.Tests { [TestClass] + [TestCategory("IoTData")] public class IotData { private const string TopicThatRequiresUrlEncoding = "X$aws/,topic"; - private static string THING_NAME = null; private static string CREATED_THING_NAME = null; static AmazonIotDataClient Client = null; [ClassInitialize] - public static void ClassInitialize(TestContext testContext) + public static async Task ClassInitialize(TestContext testContext) { Client = new AmazonIotDataClient("https://data-ats.iot.us-east-1.amazonaws.com/"); using (var iotClient = new AmazonIoTClient()) { - var things = iotClient.ListThings().Things; + var listResponse = await iotClient.ListThingsAsync(); + var things = listResponse.Things; + var firstThing = things.FirstOrDefault(); if (firstThing == null) { THING_NAME = "dotnettest" + DateTime.UtcNow.ToFileTime(); - iotClient.CreateThing(new CreateThingRequest + await iotClient.CreateThingAsync(new CreateThingRequest { ThingName = THING_NAME }); + CREATED_THING_NAME = THING_NAME; } else @@ -51,27 +52,23 @@ public static void ClassInitialize(TestContext testContext) } [ClassCleanup] - public static void Cleanup() + public static async Task Cleanup() { if (!string.IsNullOrEmpty(CREATED_THING_NAME)) { using (var iotClient = new AmazonIoTClient()) { - iotClient.DeleteThing(CREATED_THING_NAME); + await iotClient.DeleteThingAsync(CREATED_THING_NAME); } } - if (Client != null) - { - Client.Dispose(); - } + Client?.Dispose(); } [TestMethod] - [TestCategory("IoTData")] - public void PublishTopicWithUrlEncodedCharacters() + public async Task PublishTopicWithUrlEncodedCharacters() { - var response = Client.Publish(new PublishRequest + var response = await Client.PublishAsync(new PublishRequest { Topic = TopicThatRequiresUrlEncoding }); @@ -79,86 +76,76 @@ public void PublishTopicWithUrlEncodedCharacters() } [TestMethod] - [TestCategory("IotData")] - public void IotDataTests() + public async Task IotDataTests() { var topicName = "$aws/things/" + THING_NAME + "/shadow/update"; - Client.Publish(new PublishRequest + await Client.PublishAsync(new PublishRequest { Topic = topicName, Qos = 1, Payload = new MemoryStream(new byte[] { 1, 2, 3, 4 }) }); - Client.Publish(new PublishRequest + await Client.PublishAsync(new PublishRequest { Topic = topicName, Qos = 1 }); topicName = "$aws/things/" + THING_NAME + "/shadow/get"; - Client.Publish(new PublishRequest + await Client.PublishAsync(new PublishRequest { Topic = topicName, Qos = 1, Payload = new MemoryStream(new byte[] { 1, 2, 3, 4 }) }); - Client.Publish(new PublishRequest + await Client.PublishAsync(new PublishRequest { Topic = topicName, Qos = 1 }); - - var payload = new MemoryStream(System.Text.Encoding.UTF8.GetBytes( - @"{ ""state"": {}}" - )); - var updateThingShadowResponse = Client.UpdateThingShadow(new UpdateThingShadowRequest + var payload = new MemoryStream(Encoding.UTF8.GetBytes(@"{ ""state"": {}}")); + var updateThingShadowResponse = await Client.UpdateThingShadowAsync(new UpdateThingShadowRequest { ThingName = THING_NAME, Payload = payload }); Assert.IsTrue(payload.Length < updateThingShadowResponse.Payload.Length); - var getThingShadowResponse = Client.GetThingShadow(new GetThingShadowRequest + var getThingShadowResponse = await Client.GetThingShadowAsync(new GetThingShadowRequest { ThingName = THING_NAME }); Assert.IsTrue(getThingShadowResponse.Payload.Length > 0); - var deleteThingShadowResponse = Client.DeleteThingShadow(new DeleteThingShadowRequest + var deleteThingShadowResponse = await Client.DeleteThingShadowAsync(new DeleteThingShadowRequest { ThingName = THING_NAME }); - Assert.IsTrue(getThingShadowResponse.Payload.Length > 0); + Assert.IsTrue(deleteThingShadowResponse.Payload.Length > 0); } [TestMethod] - [TestCategory("IotData")] - public void IotDataErrorTests() + public async Task IotDataErrorTests() { - var exception = AssertExtensions.ExpectException(()=> - { - Client.UpdateThingShadow(new UpdateThingShadowRequest + await Assert.ThrowsExceptionAsync(() => + Client.UpdateThingShadowAsync(new UpdateThingShadowRequest { Payload = new MemoryStream(new byte[] { 1, 2, 3, 4 }) - }); - }); + }) + ); - exception = AssertExtensions.ExpectException(() => - { - Client.UpdateThingShadow(new UpdateThingShadowRequest()); - }); + await Assert.ThrowsExceptionAsync(() => + Client.UpdateThingShadowAsync(new UpdateThingShadowRequest()) + ); - exception = AssertExtensions.ExpectException(() => - { - Client.UpdateThingShadow(new UpdateThingShadowRequest + await Assert.ThrowsExceptionAsync(() => + Client.UpdateThingShadowAsync(new UpdateThingShadowRequest { - ThingName = THING_NAME, - Payload = new MemoryStream(System.Text.Encoding.UTF8.GetBytes("{}")) - }); - }); - + ThingName = THING_NAME, + Payload = new MemoryStream(Encoding.UTF8.GetBytes("{}")) + }) + ); } - } } diff --git a/sdk/test/Services/KeyManagementService/IntegrationTests/AWSSDK.IntegrationTests.KeyManagementService.NetFramework.csproj b/sdk/test/Services/KeyManagementService/IntegrationTests/AWSSDK.IntegrationTests.KeyManagementService.NetFramework.csproj deleted file mode 100644 index aeb9432fc5c4..000000000000 --- a/sdk/test/Services/KeyManagementService/IntegrationTests/AWSSDK.IntegrationTests.KeyManagementService.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.KeyManagementService.NetFramework - AWSSDK.IntegrationTests.KeyManagementService.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/KeyManagementService/IntegrationTests/KeyManagementService.cs b/sdk/test/Services/KeyManagementService/IntegrationTests/KeyManagementService.cs deleted file mode 100644 index 29730495d55b..000000000000 --- a/sdk/test/Services/KeyManagementService/IntegrationTests/KeyManagementService.cs +++ /dev/null @@ -1,368 +0,0 @@ -using System; -using System.Linq; -using System.Collections.Generic; -using System.Threading; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using Amazon.KeyManagementService; -using Amazon.KeyManagementService.Model; -using Amazon.Runtime; -using System.IO; -using System.Text; -using AWSSDK_DotNet.IntegrationTests.Utils; - - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class KeyManagementService : TestBase - { - private const string keyDescription = ".NET Test Key"; - private const string copyText = " Copy"; - private const int keySize = 1024; - private const int numberOfRandomBytes = 1023; - private const string testContents = "This is test data"; - private static string keyAlias = "alias/net_key" + DateTime.UtcNow.ToFileTime(); - private static MemoryStream testData = new MemoryStream(Encoding.UTF8.GetBytes(testContents)); - private static TimeSpan keyMaxWait = TimeSpan.FromSeconds(30); - private static TimeSpan keyDescribeWait = TimeSpan.FromSeconds(5); - private static List allOperations = new List - { - "Decrypt", - "Encrypt", - "GenerateDataKey", - "GenerateDataKeyWithoutPlaintext", - "ReEncryptFrom", - "ReEncryptTo", - "CreateGrant" - }; - - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - // This test is disabled because it creates resources that cannot be removed, KMS keys. - //[TestMethod] - [TestCategory("KeyManagementService")] - public void TestService() - { - var keys = GetKeys(); - var keysCount = keys.Count; - - var keyMetadata = Client.CreateKey(new CreateKeyRequest - { - KeyUsage = KeyUsageType.ENCRYPT_DECRYPT, - Description = keyDescription - }).KeyMetadata; - ValidateKeyMetadata(keyMetadata, keyEnabled: true); - var keyId = keyMetadata.KeyId; - string reEncryptKeyId = null; - - try - { - keys = GetKeys(); - Assert.AreEqual(keysCount + 1, keys.Count); - - keyMetadata = Client.DescribeKey(keyId).KeyMetadata; - ValidateKeyMetadata(keyMetadata, keyEnabled: true); - - TestAliases(keyId); - - TestGrants(keyId); - - TestEncryption(keyId, out reEncryptKeyId); - - TestGeneration(keyId); - - TestKeyChanges(keyId); - - TestRotation(keyId); - } - catch (Exception e) - { - Console.WriteLine(e.ToString()); - throw; - } - finally - { - if (keyId != null) - Client.DisableKey(keyId); - if (reEncryptKeyId != null) - Client.DisableKey(reEncryptKeyId); - } - } - - private void TestGeneration(string keyId) - { - var gdkResult = Client.GenerateDataKey(new GenerateDataKeyRequest - { - KeyId = keyId, - NumberOfBytes = keySize, - }); - Assert.IsNotNull(gdkResult.CiphertextBlob); - Assert.IsNotNull(gdkResult.Plaintext); - Assert.IsNotNull(gdkResult.KeyId); - Assert.IsTrue(gdkResult.KeyId.IndexOf(keyId, StringComparison.OrdinalIgnoreCase) >= 0); - Assert.AreEqual(keySize, gdkResult.Plaintext.Length); - - var gdkwpResult = Client.GenerateDataKeyWithoutPlaintext(new GenerateDataKeyWithoutPlaintextRequest - { - KeyId = keyId, - KeySpec = DataKeySpec.AES_256, - }); - Assert.IsNotNull(gdkwpResult.CiphertextBlob); - Assert.IsNotNull(gdkwpResult.KeyId); - Assert.IsTrue(gdkwpResult.KeyId.IndexOf(keyId, StringComparison.OrdinalIgnoreCase) >= 0); - - var random = Client.GenerateRandom(numberOfRandomBytes).Plaintext; - Assert.IsNotNull(random); - Assert.AreEqual(numberOfRandomBytes, random.Length); - } - - private void TestEncryption(string keyId, out string reEncryptKeyId) - { - var encryptResponse = Client.Encrypt(new EncryptRequest - { - KeyId = keyId, - Plaintext = testData - }); - Assert.IsTrue(encryptResponse.KeyId.IndexOf(keyId, StringComparison.OrdinalIgnoreCase) >= 0); - var cb = encryptResponse.CiphertextBlob; - Assert.IsNotNull(cb); - Assert.AreNotEqual(0, cb.Length); - - var decryptResponse = Client.Decrypt(new DecryptRequest - { - CiphertextBlob = cb - }); - Assert.IsTrue(decryptResponse.KeyId.IndexOf(keyId, StringComparison.OrdinalIgnoreCase) >= 0); - var plaintext = decryptResponse.Plaintext; - - ValidateEncryptedData(cb, plaintext); - - reEncryptKeyId = Client.CreateKey(new CreateKeyRequest - { - KeyUsage = KeyUsageType.ENCRYPT_DECRYPT, - Description = keyDescription + " For ReEncryption" - }).KeyMetadata.KeyId; - - var reEncryptResponse = Client.ReEncrypt(new ReEncryptRequest - { - CiphertextBlob = cb, - DestinationKeyId = reEncryptKeyId - }); - Assert.IsTrue(reEncryptResponse.SourceKeyId.IndexOf(keyId, StringComparison.OrdinalIgnoreCase) >= 0); - Assert.IsTrue(reEncryptResponse.KeyId.IndexOf(reEncryptKeyId, StringComparison.OrdinalIgnoreCase) >= 0); - var reEncryptedCb = reEncryptResponse.CiphertextBlob; - - decryptResponse = Client.Decrypt(new DecryptRequest - { - CiphertextBlob = reEncryptedCb - }); - Assert.IsTrue(decryptResponse.KeyId.IndexOf(reEncryptKeyId, StringComparison.OrdinalIgnoreCase) >= 0); - plaintext = decryptResponse.Plaintext; - - ValidateEncryptedData(cb, plaintext); - } - - private void TestKeyChanges(string keyId) - { - Client.DisableKey(keyId); - ValidateKey(keyId, keyEnabled: false); - - Client.EnableKey(keyId); - ValidateKey(keyId, keyEnabled: true); - - var newKeyDescription = keyDescription + copyText; - Client.UpdateKeyDescription(keyId, newKeyDescription); - ValidateKey(keyId, keyEnabled: true, isCopy: true); - - var policyNames = Client.ListKeyPolicies(new ListKeyPoliciesRequest - { - KeyId = keyId - }).PolicyNames; - Assert.AreEqual(1, policyNames.Count); - var policyName = policyNames.First(); - - var policy = Client.GetKeyPolicy(keyId, policyName).Policy; - Assert.IsTrue(policy.Length > 0); - Client.PutKeyPolicy(keyId, policy, policyName); - policyNames = Client.ListKeyPolicies(new ListKeyPoliciesRequest - { - KeyId = keyId - }).PolicyNames; - Assert.AreEqual(1, policyNames.Count); - } - - private void TestGrants(string keyId) - { - var accountId = UtilityMethods.AccountId; - - var grants = GetGrants(keyId); - var grantsCount = grants.Count; - - var createdGrant = Client.CreateGrant(new CreateGrantRequest - { - KeyId = keyId, - GranteePrincipal = accountId, - Operations = allOperations, - RetiringPrincipal = accountId - }); - var grantId = createdGrant.GrantId; - var grantToken = createdGrant.GrantToken; - - grants = GetGrants(keyId); - Assert.AreEqual(grantsCount + 1, grants.Count); - - var grant = GetGrant(keyId, grantId); - Assert.IsNotNull(grant); - - Client.RetireGrant(grantToken); - grant = GetGrant(keyId, grantId); - Assert.IsNull(grant); - - Client.RevokeGrant(grantId, keyId); - grant = GetGrant(keyId, grantId); - Assert.IsNull(grant); - } - - private void TestRotation(string keyId) - { - var rotationEnabled = Client.GetKeyRotationStatus(keyId).KeyRotationEnabled.Value; - Assert.IsFalse(rotationEnabled); - - Client.EnableKeyRotation(keyId); - rotationEnabled = Client.GetKeyRotationStatus(keyId).KeyRotationEnabled.Value; - Assert.IsTrue(rotationEnabled); - - Client.DisableKeyRotation(keyId); - rotationEnabled = Client.GetKeyRotationStatus(keyId).KeyRotationEnabled.Value; - Assert.IsFalse(rotationEnabled); - } - - private void TestAliases(string keyId) - { - var aliases = GetAliases(); - var aliasesCount = aliases.Count; - - Client.CreateAlias(keyAlias, keyId); - aliases = GetAliases(); - Assert.AreEqual(aliasesCount + 1, aliases.Count); - - Client.DeleteAlias(keyAlias); - aliases = GetAliases(); - Assert.AreEqual(aliasesCount, aliases.Count); - } - - public static List GetKeys() - { - var keys = new List(); - string nextMarker = null; - do - { - var response = Client.ListKeys(new ListKeysRequest - { - Marker = nextMarker - }); - nextMarker = response.NextMarker; - keys.AddRange(response.Keys); - - } while (!string.IsNullOrEmpty(nextMarker)); - - return keys; - } - private List GetAliases() - { - var aliases = new List(); - string nextMarker = null; - do - { - var response = Client.ListAliases(new ListAliasesRequest - { - Marker = nextMarker - }); - nextMarker = response.NextMarker; - aliases.AddRange(response.Aliases); - - } while (!string.IsNullOrEmpty(nextMarker)); - - return aliases; - } - private List GetGrants(string keyId) - { - var grants = new List(); - string nextMarker = null; - do - { - var response = Client.ListGrants(new ListGrantsRequest - { - KeyId = keyId, - Marker = nextMarker - }); - nextMarker = response.NextMarker; - grants.AddRange(response.Grants); - - } while (!string.IsNullOrEmpty(nextMarker)); - - return grants; - } - private GrantListEntry GetGrant(string keyId, string grantId) - { - var grants = GetGrants(keyId); - foreach (var grant in grants) - if (string.Equals(grant.GrantId, grantId, StringComparison.OrdinalIgnoreCase)) - return grant; - return null; - } - - private void ValidateEncryptedData(MemoryStream cb, MemoryStream plaintext) - { - var sourceBytes = testData.ToArray(); - var encryptedBytes = cb.ToArray(); - var decryptedBytes = plaintext.ToArray(); - - CollectionAssert.AreEqual(sourceBytes, decryptedBytes); - CollectionAssert.AreNotEqual(sourceBytes, encryptedBytes); - - var text = Encoding.UTF8.GetString(decryptedBytes); - Assert.AreEqual(testContents, text); - } - private void ValidateKey(string keyId, bool keyEnabled, bool isCopy = false) - { - var stopTime = DateTime.UtcNow + keyMaxWait; - - KeyMetadata keyMetadata = null; - while(DateTime.UtcNow < stopTime) - { - try - { - keyMetadata = Client.DescribeKey(keyId).KeyMetadata; - ValidateKeyMetadata(keyMetadata, keyEnabled); - break; - } - catch(AssertFailedException) - { - Thread.Sleep(keyDescribeWait); - } - } - - ValidateKeyMetadata(keyMetadata, keyEnabled); - } - private static void ValidateKeyMetadata(KeyMetadata keyMetadata, bool keyEnabled, bool isCopy = false) - { - Assert.IsNotNull(keyMetadata); - Assert.IsNotNull(keyMetadata.Arn); - Assert.IsNotNull(keyMetadata.AWSAccountId); - Assert.IsNotNull(keyMetadata.Description); - Assert.IsTrue(keyMetadata.Description.IndexOf(keyDescription, StringComparison.Ordinal) >= 0); - if (isCopy) - Assert.IsTrue(keyMetadata.Description.IndexOf(copyText, StringComparison.Ordinal) >= 0); - Assert.IsNotNull(keyMetadata.KeyId); - Assert.AreEqual(keyMetadata.KeyUsage, KeyUsageType.ENCRYPT_DECRYPT); - Assert.AreEqual(keyEnabled, keyMetadata.Enabled); - Assert.AreNotEqual(DateTime.MinValue, keyMetadata.CreationDate); - } - } -} diff --git a/sdk/test/Services/Kinesis/IntegrationTests/AWSSDK.IntegrationTests.Kinesis.NetFramework.csproj b/sdk/test/Services/Kinesis/IntegrationTests/AWSSDK.IntegrationTests.Kinesis.NetFramework.csproj deleted file mode 100644 index 90515aef53ef..000000000000 --- a/sdk/test/Services/Kinesis/IntegrationTests/AWSSDK.IntegrationTests.Kinesis.NetFramework.csproj +++ /dev/null @@ -1,52 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.Kinesis.NetFramework - AWSSDK.IntegrationTests.Kinesis.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/Kinesis/IntegrationTests/Config/462/App.config b/sdk/test/Services/Kinesis/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/Kinesis/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/Kinesis/IntegrationTests/Kinesis.cs b/sdk/test/Services/Kinesis/IntegrationTests/Kinesis.cs deleted file mode 100644 index 92e35a13f52f..000000000000 --- a/sdk/test/Services/Kinesis/IntegrationTests/Kinesis.cs +++ /dev/null @@ -1,129 +0,0 @@ -using System; -using System.Linq; -using System.Collections.Generic; -using System.Threading; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using Amazon.Kinesis; -using Amazon.Kinesis.Model; -using Amazon.Runtime; -using AWSSDK_DotNet.IntegrationTests.Utils; - - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class Kinesis : TestBase - { - [ClassCleanup] - public static void Cleanup() - { - // Delete all dotnet integ test streams. - var streamNames = Client.ListStreams().StreamNames; - foreach (var streamName in streamNames) - { - if (streamName.Contains("dotnet-integ-test-stream")) - { - try - { - Client.DeleteStream(new DeleteStreamRequest - { - StreamName = streamName - }); - } - catch(Exception e) - { - Console.WriteLine("Failed to delete stream {0}: {1}", streamName, e.Message); - } - } - } - - // BaseClean(); - } - - - [TestMethod] - [TestCategory("Kinesis")] - public void KinesisCRUD() - { - var streamName = "dotnet-integ-test-stream-" + DateTime.UtcNow.Ticks; - Action waitUntilStreamActive = () => UtilityMethods.WaitUntil(() => - Client.DescribeStream(new DescribeStreamRequest { StreamName = streamName }).StreamDescription.StreamStatus == StreamStatus.ACTIVE); - - // Create a stream. - Client.CreateStream(new CreateStreamRequest - { - ShardCount = 1, - StreamName = streamName - }); - - // Describe the stream. - var stream = Client.DescribeStream(new DescribeStreamRequest - { - StreamName = streamName - }).StreamDescription; - Assert.AreEqual(stream.HasMoreShards, false); - Assert.IsFalse(string.IsNullOrEmpty(stream.StreamARN)); - Assert.AreEqual(stream.StreamName, streamName); - Assert.IsTrue(stream.StreamStatus == StreamStatus.CREATING); - - waitUntilStreamActive(); - - var retentionHours = stream.RetentionPeriodHours; - var newRetentionHours = retentionHours * 2; - - Client.IncreaseStreamRetentionPeriod(streamName, newRetentionHours); - waitUntilStreamActive(); - stream = Client.DescribeStream(new DescribeStreamRequest - { - StreamName = streamName - }).StreamDescription; - Assert.AreEqual(newRetentionHours, stream.RetentionPeriodHours); - - Client.DecreaseStreamRetentionPeriod(streamName, retentionHours); - waitUntilStreamActive(); - stream = Client.DescribeStream(new DescribeStreamRequest - { - StreamName = streamName - }).StreamDescription; - Assert.AreEqual(retentionHours, stream.RetentionPeriodHours); - - // List streams. - var streamNames = Client.ListStreams().StreamNames; - Assert.IsTrue(streamNames.Count > 0); - Assert.IsTrue(streamNames.Contains(streamName)); - - // Delete the stream. - Client.DeleteStream(new DeleteStreamRequest - { - StreamName = streamName - }); - stream = Client.DescribeStream(new DescribeStreamRequest - { - StreamName = streamName - }).StreamDescription; - Assert.IsTrue(stream.StreamStatus == StreamStatus.DELETING); - } - - private StreamDescription WaitForStreamToBeActive(string streamName) - { - while (true) - { - var stream = Client.DescribeStream(new DescribeStreamRequest - { - StreamName = streamName - }).StreamDescription; - - if (stream.StreamStatus != StreamStatus.ACTIVE) - { - Thread.Sleep(5 * 1000); - continue; - } - else - { - return stream; - } - } - } - } -} diff --git a/sdk/test/Services/Kinesis/IntegrationTests/KinesisFirehose.cs b/sdk/test/Services/Kinesis/IntegrationTests/KinesisFirehose.cs deleted file mode 100644 index 899692f724e6..000000000000 --- a/sdk/test/Services/Kinesis/IntegrationTests/KinesisFirehose.cs +++ /dev/null @@ -1,275 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using Amazon.KinesisFirehose; -using Amazon.KinesisFirehose.Model; -using Amazon.IdentityManagement; -using Amazon.S3; -using Amazon.IdentityManagement.Model; -using Amazon.S3.Util; -using System.IO; -using AWSSDK_DotNet.IntegrationTests.Utils; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class KinesisFirehose : TestBase - { - private static string TestAccountId = UtilityMethods.AccountId; - static IAmazonIdentityManagementService iamClient = new AmazonIdentityManagementServiceClient(); - static AmazonS3Client s3Client = new AmazonS3Client(); - - private string BucketName = null; - private string RoleName = null; - private string PolicyName = null; - private string DeliveryStreamName = null; - - public static readonly string FirehoseAssumeRolePolicyDocumentFormat = -@"{{ - ""Version"": ""2012-10-17"", - ""Statement"": [ - {{ - ""Sid"": """", - ""Effect"": ""Allow"", - ""Principal"": {{ - ""Service"": ""firehose.amazonaws.com"" - }}, - ""Action"": ""sts:AssumeRole"", - ""Condition"": {{ - ""StringEquals"": {{ - ""sts:ExternalId"": ""{0}"" - }} - }} - }} - ] -}} -".Trim(); - - private static string RolePolicyDocumentFormat = -@"{{ - ""Version"": ""2012-10-17"", - ""Statement"": [ - {{ - ""Sid"": """", - ""Effect"": ""Allow"", - ""Action"": [ - ""s3:AbortMultipartUpload"", - ""s3:GetBucketLocation"", - ""s3:GetObject"", - ""s3:ListBucket"", - ""s3:ListBucketMultipartUploads"", - ""s3:PutObject"" - ], - ""Resource"": [ - ""arn:aws:s3:::{0}"", - ""arn:aws:s3:::{0}/*"" - ] - }} - ] -}}"; - - - [TestInitialize] - public void TestInitialize() - { - // Create S3 Bucket - BucketName = "sdk-dotnet-integ-test-bucket-firehose" + DateTime.UtcNow.Ticks; - s3Client.PutBucket(BucketName); - - // Create IAM Role - RoleName = "NetFirehoseTestRole" + DateTime.UtcNow.Ticks; - if (string.IsNullOrEmpty(TestAccountId)) - Assert.Fail("TestAccountId must be specified to run these tests"); - - var iamCreateResponse = iamClient.CreateRole(new CreateRoleRequest - { - RoleName = RoleName, - AssumeRolePolicyDocument = string.Format(FirehoseAssumeRolePolicyDocumentFormat, TestAccountId) - }); - string roleArn = iamCreateResponse.Role.Arn; - Assert.IsNotNull(roleArn); - - // Attach Policy to Role - PolicyName = "NetFirehoseTestRolePolicy" + DateTime.UtcNow.Ticks; - iamClient.PutRolePolicy(new PutRolePolicyRequest() - { - PolicyDocument = string.Format(RolePolicyDocumentFormat, BucketName), - PolicyName = PolicyName, - RoleName = RoleName - }); - - // Wait for eventual consistency of role. - Thread.Sleep(TimeSpan.FromSeconds(10)); - - // Create Firehose Delivery Stream - string bucketArn = "arn:aws:s3:::" + BucketName; - DeliveryStreamName = "dotnet-test-delivery-stream" + DateTime.UtcNow.Ticks; - string deliveryStreamArn = Client.CreateDeliveryStream(new CreateDeliveryStreamRequest() - { - DeliveryStreamName = DeliveryStreamName, - S3DestinationConfiguration = new S3DestinationConfiguration() - { - BucketARN = bucketArn, - RoleARN = roleArn - } - }).DeliveryStreamARN; - if (string.IsNullOrEmpty(deliveryStreamArn)) - { - Assert.Fail("Expected a deliveryStreamArn value"); - } - - // Wait for Delivery Stream to be active - DeliveryStreamStatus streamStatus = DeliveryStreamStatus.CREATING; - var timeout = DateTime.UtcNow.AddSeconds(120); - while (streamStatus != DeliveryStreamStatus.ACTIVE && DateTime.UtcNow.Ticks < timeout.Ticks) - { - streamStatus = Client.DescribeDeliveryStream(new DescribeDeliveryStreamRequest() - { - DeliveryStreamName = DeliveryStreamName - }).DeliveryStreamDescription.DeliveryStreamStatus; - Assert.AreNotEqual(streamStatus, DeliveryStreamStatus.DELETING); - Thread.Sleep(TimeSpan.FromSeconds(2)); - } - Assert.AreNotEqual(streamStatus, DeliveryStreamStatus.CREATING, "Did not exit CREATING state within time limit."); - } - - [TestCleanup] - public void TestCleanup() - { - try - { - // Check if stream status qualifies it to be deleted. - var streamStatus = Client.DescribeDeliveryStream(new DescribeDeliveryStreamRequest() - { - DeliveryStreamName = DeliveryStreamName - }).DeliveryStreamDescription.DeliveryStreamStatus; - - if (streamStatus == DeliveryStreamStatus.ACTIVE || streamStatus == DeliveryStreamStatus.DELETING) - Client.DeleteDeliveryStream(DeliveryStreamName); - } - - catch (Exception) - {} - - try - { - // Delete Role Policy - iamClient.DeleteRolePolicy(new DeleteRolePolicyRequest() - { - RoleName = RoleName, - PolicyName = PolicyName - }); - - // Delete Role - iamClient.DeleteRole(new DeleteRoleRequest() - { - RoleName = RoleName - }); - } - - catch (Exception) - {} - - try - { - // Delete Bucket - AmazonS3Util.DeleteS3BucketWithObjects(s3Client, BucketName); - } - - catch(Exception) - {} - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("Kinesis")] - public void TestListDeliveryStreams() - { - List streamNames = Client.ListDeliveryStreams().DeliveryStreamNames; - Assert.IsNotNull(streamNames); - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("Kinesis")] - public void TestPutRecord() - { - using (var data = new MemoryStream()) - { - using (var writer = new StreamWriter(data)) - { - writer.Write("DATAdataDATAdataDATAdata"); - writer.Flush(); - data.Position = 0; - } - string recordId = Client.PutRecord(DeliveryStreamName, new Record() { Data = data }).RecordId; - if (string.IsNullOrEmpty(recordId)) - { - Assert.Fail("Expected recordId to have a value."); - } - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("Kinesis")] - [ExpectedException(typeof(ResourceNotFoundException))] - public void TestPutRecordNonExistantStream() - { - using (var data = new MemoryStream()) - { - using (var writer = new StreamWriter(data)) - { - writer.Write("DATAdataDATAdataDATAdata"); - writer.Flush(); - data.Position = 0; - } - - Client.PutRecord("NonExistantStream", new Record() { Data = data }); - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("Kinesis")] - public void TestPutRecordBatch() - { - int recordCount = 8; - - List records = new List(); - try - { - for (int i = 0; i < recordCount; i++) - { - var data = new MemoryStream(); - using (var writer = new StreamWriter(data)) - { - writer.Write(string.Format("DATA{0}data{0}DATA{0}data{0}DATA{0}data{0}", i)); - writer.Flush(); - data.Position = 0; - } - records.Add(new Record { Data = data }); - } - var response = Client.PutRecordBatch(DeliveryStreamName, records); - - HashSet recordIds = new HashSet(); - foreach (var individualResponse in response.RequestResponses) - { - recordIds.Add(individualResponse.RecordId); - } - - Assert.AreEqual(recordIds.Count, recordCount); - Assert.AreEqual(response.FailedPutCount, 0, "Expected FailedPutCount == 0"); - } - finally - { - foreach (var record in records) - { - record.Data.Dispose(); - } - } - } - } -} diff --git a/sdk/test/Services/Lambda/IntegrationTests/AWSSDK.IntegrationTests.Lambda.NetFramework.csproj b/sdk/test/Services/Lambda/IntegrationTests/AWSSDK.IntegrationTests.Lambda.NetFramework.csproj deleted file mode 100644 index bf30c3349444..000000000000 --- a/sdk/test/Services/Lambda/IntegrationTests/AWSSDK.IntegrationTests.Lambda.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.Lambda.NetFramework - AWSSDK.IntegrationTests.Lambda.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/Lambda/IntegrationTests/Config/462/App.config b/sdk/test/Services/Lambda/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/Lambda/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/Lambda/IntegrationTests/LambdaTests.cs b/sdk/test/Services/Lambda/IntegrationTests/LambdaTests.cs deleted file mode 100644 index ea752f954fff..000000000000 --- a/sdk/test/Services/Lambda/IntegrationTests/LambdaTests.cs +++ /dev/null @@ -1,442 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using System.Collections.Generic; -using System.Threading; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using Amazon.Auth.AccessControlPolicy; -using Amazon.IdentityManagement; -using Amazon.IdentityManagement.Model; -using Amazon.Lambda; -using Amazon.Lambda.Model; -using Amazon.Runtime; -using System.Threading.Tasks; -using System.Net; -using Amazon.Lambda.Model.Internal.MarshallTransformations; -using System.Runtime.InteropServices.ComTypes; -using System.Runtime.Remoting.Messaging; - -#if BCL -using System.IO.Compression; -using System.Text; -using AWSSDK_DotNet.IntegrationTests.Utils; -#endif - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class LambdaTests : TestBase - { - static readonly string LAMBDA_ASSUME_ROLE_POLICY = -@" -{ - ""Version"": ""2012-10-17"", - ""Statement"": [ - { - ""Sid"": """", - ""Effect"": ""Allow"", - ""Principal"": { - ""Service"": ""lambda.amazonaws.com"" - }, - ""Action"": ""sts:AssumeRole"" - } - ] -} -".Trim(); - - static IAmazonIdentityManagementService iamClient = new AmazonIdentityManagementServiceClient(); - static List createdFunctionNames = new List(); - static List createdRoleNames = new List(); - const string HELLO_SCRIPT = -@"console.log('Loading event'); -exports.handler = function(event, context) { - console.log(""value = "" + event.Key); - context.done(null, ""Hello World:"" + event.Key + "", "" + context.System); // SUCCESS with message -}"; - const string STREAMIFY_RESPONSE_SCRIPT = - @" -import util from 'util'; -import stream from 'stream'; -const { Readable } = stream; -const pipeline = util.promisify(stream.pipeline); - -export const handler = awslambda.streamifyResponse(async (event, responseStream, _context) => { - const requestStream = Readable.from(Buffer.from(new Array(1024*1024).join( '🚣' ))); - await pipeline(requestStream, responseStream); -}); -"; - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - [TestCleanup] - public void TestCleanup() - { - DeleteCreatedFunctions(Client); - } - - public static void DeleteCreatedFunctions(IAmazonLambda lambdaClient) - { - var deletedFunctions = new List(); - foreach(var function in createdFunctionNames) - { - try - { - lambdaClient.DeleteFunction(function); - deletedFunctions.Add(function); - } - catch { } - } - - foreach (var df in deletedFunctions) - createdFunctionNames.Remove(df); - } - - [TestMethod] - [TestCategory("Lambda")] - public void ListFunctionsTest() - { - var functions = EnumerateFunctions().ToList(); - } - - public static IEnumerable EnumerateFunctions() - { - var request = new ListFunctionsRequest(); - do - { - var response = Client.ListFunctions(request); - request.Marker = response.NextMarker; - foreach (var function in response.Functions) - yield return function; - } while (!string.IsNullOrEmpty(request.Marker)); - } - - // This test depends on functionality that is only in 4.5 -#if BCL - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("Lambda")] - public void PolicyAndPermissionTest() - { - string functionName; - string iamRoleName = null; - bool iamRoleCreated = false; - try - { - string iamRoleArn; - string functionArn; - CreateLambdaFunction(out functionName, out functionArn, out iamRoleName, out iamRoleArn, HELLO_SCRIPT, Runtime.Nodejs43); - - var publishResponse = Client.PublishVersion(new PublishVersionRequest - { - FunctionName = functionName - }); - var version = publishResponse.Version; - - var apr = new AddPermissionRequest - { - FunctionName = functionName, - SourceAccount = "999999999999", - SourceArn = "arn:aws:s3:::cloudtrail-999999999999", - StatementId = "id1", - Principal = "s3.amazonaws.com", - Action = "lambda:InvokeFunction", - Qualifier = version - }; - - var addResponse = Client.AddPermission(apr); - var statement = addResponse.Statement; - var expectedFunctionName = functionArn + ":" + version; - // verify that the qualifier (in query string) got sent to the server correctly - // by checking that the function with the qualifier (version) is specified in the - // statement we get back from the service - Assert.IsTrue(statement.IndexOf(expectedFunctionName, StringComparison.Ordinal) >= 0); - - var policy = Client.GetPolicy(new Amazon.Lambda.Model.GetPolicyRequest - { - FunctionName = functionName, - Qualifier = version - }).Policy; - // verify that the function is part of the policy - Assert.IsTrue(policy.IndexOf(expectedFunctionName, StringComparison.Ordinal) >= 0); - } - finally - { - if (iamRoleCreated) - iamClient.DeleteRole(new DeleteRoleRequest { RoleName = iamRoleName }); - } - } - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("Lambda")] - public async Task StreamifyLambdaResponseTest() - { - try - { - //Arrange - var functionName = "HelloWorld-" + DateTime.UtcNow.Ticks; - var iamRoleName = "Lambda-" + DateTime.UtcNow.Ticks; - var request = new CreateRoleRequest - { - RoleName = iamRoleName, - AssumeRolePolicyDocument = LAMBDA_ASSUME_ROLE_POLICY - }; - var iamRoleResponse = UtilityMethods.WaitUntilSuccess(() => iamClient.CreateRole(request)); - SetupPolicies(iamRoleName); - var iamRole = iamRoleResponse.Role; - MemoryStream stream = CreateScriptStream(STREAMIFY_RESPONSE_SCRIPT); - string handlerName = "helloworld.handler"; - var uploadRequest = new CreateFunctionRequest - { - FunctionName = functionName, - Code = new FunctionCode - { - ZipFile = stream - }, - Handler = handlerName, - Runtime = Runtime.Nodejs14X, - Role = iamRole.Arn - }; - var uploadResponse = UtilityMethods.WaitUntilSuccess( () => Client.CreateFunction(uploadRequest)); - GetFunctionRequest getFunctionRequest = new GetFunctionRequest - { - FunctionName = functionName - }; - int attempts = 0; - while(true || attempts < 5) // do not wait for longer than 10 seconds - { - var responseState = Client.GetFunction(getFunctionRequest); - if (responseState.Configuration.State == State.Active) - break; - Thread.Sleep(2000); - attempts++; - } - Assert.IsTrue(uploadResponse.CodeSize > 0); - Assert.IsNotNull(uploadResponse.FunctionArn); - // Get the function with a presigned URL to the uploaded code - var getFunctionResponse = await Client.GetFunctionAsync(functionName); - Assert.AreEqual(handlerName, getFunctionResponse.Configuration.Handler); - Assert.IsNotNull(getFunctionResponse.Code.Location); - - // Get the function's configuration only - var getFunctionConfiguration = await Client.GetFunctionConfigurationAsync(functionName); - Assert.AreEqual(handlerName, getFunctionConfiguration.Handler); - createdFunctionNames.Add(functionName); - var endWaitHandle = new AutoResetEvent(false); - InvokeWithResponseStreamResponse response; - try - { - response = await Client.InvokeWithResponseStreamAsync(new InvokeWithResponseStreamRequest() - { - FunctionName = functionName, - InvocationType = ResponseStreamingInvocationType.DryRun - }); - using (var eventStream = response.EventStream) - { - // Since everything happens on a background thread, exceptions are raised as events. - // Here, we are just throwing the exception received. - eventStream.ExceptionReceived += (sender, args) => - { - endWaitHandle.Set(); - throw args.EventStreamException; - }; - - eventStream.EventReceived += (sender, args) => - Console.WriteLine($"Received {args.EventStreamEvent.GetType().Name}!"); - eventStream.PayloadChunkReceived += (sender, args) => - Console.WriteLine($"Received {args.EventStreamEvent.GetType().Name}!"); - eventStream.InvokeCompleteReceived += (sender, args) => endWaitHandle.Set(); - - eventStream.StartProcessing(); - endWaitHandle.WaitOne(TimeSpan.FromSeconds(10)); // if we get the data sooner it will exit and not wait. - Assert.AreEqual(HttpStatusCode.OK, response.HttpStatusCode); - } - } - catch (Exception) - { - throw; - } - - } - catch(Exception) - { - throw; - } - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("Lambda")] - public void LambdaFunctionTest() - { - string functionName; - string iamRoleName = null; - bool iamRoleCreated = false; - try - { - string iamRoleArn; - string functionArn; - CreateLambdaFunction(out functionName, out functionArn, out iamRoleName, out iamRoleArn, HELLO_SCRIPT, Runtime.Nodejs43); - - // List all the functions and make sure the newly uploaded function is in the collection - UtilityMethods.WaitUntilSuccess(() => - { - var functions = EnumerateFunctions().ToList(); - var function = functions.FirstOrDefault(x => x.FunctionName == functionName); - Assert.IsNotNull(function); - Assert.AreEqual("helloworld.handler", function.Handler); - Assert.AreEqual(iamRoleArn, function.Role); - }); - - // Get the function with a presigned URL to the uploaded code - var getFunctionResponse = Client.GetFunction(functionName); - Assert.AreEqual("helloworld.handler", getFunctionResponse.Configuration.Handler); - Assert.IsNotNull(getFunctionResponse.Code.Location); - - // Get the function's configuration only - var getFunctionConfiguration = Client.GetFunctionConfiguration(functionName); - Assert.AreEqual("helloworld.handler", getFunctionConfiguration.Handler); - - // Call the function - var invokeResponse = Client.Invoke(new InvokeRequest { FunctionName = functionName }); - Assert.AreEqual(invokeResponse.StatusCode, 202); // Status Code Accepted - - var clientContext = @"{""System"": ""Windows""}"; - var clientContextBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(clientContext)); - var request = new InvokeRequest - { - FunctionName = functionName, - InvocationType = InvocationType.RequestResponse, - LogType = LogType.None, - ClientContext = clientContext, - Payload = @"{""Key"": ""testing""}" - }; - Assert.AreEqual(clientContext, request.ClientContext); - Assert.AreEqual(clientContextBase64, request.ClientContextBase64); - - // Call the function sync - var invokeSyncResponse = Client.Invoke(request); - Assert.IsNull(invokeSyncResponse.FunctionError); - Assert.IsNull(invokeSyncResponse.LogResult); - Assert.IsNotNull(invokeSyncResponse.Payload); - Assert.AreNotEqual(0, invokeSyncResponse.Payload.Length); - Assert.AreNotEqual(0, invokeSyncResponse.StatusCode); - - // Call the function sync, dry run, no payload - invokeSyncResponse = Client.Invoke(new InvokeRequest - { - FunctionName = functionName, - InvocationType = InvocationType.DryRun, - LogType = LogType.None, - ClientContext = clientContext, - Payload = @"{""Key"": ""testing""}" - }); - Assert.IsNull(invokeSyncResponse.FunctionError); - Assert.IsNull(invokeSyncResponse.LogResult); - Assert.IsNotNull(invokeSyncResponse.Payload); - Assert.AreEqual(0, invokeSyncResponse.Payload.Length); - Assert.AreNotEqual(0, invokeSyncResponse.StatusCode); - - // Call the function sync, pass non-JSON payload - invokeSyncResponse = Client.Invoke(new InvokeRequest - { - FunctionName = functionName, - InvocationType = InvocationType.RequestResponse, - LogType = LogType.None, - ClientContext = clientContext, - Payload = @"""Key"": ""testing""" - }); - Assert.IsNotNull(invokeSyncResponse.FunctionError); - Assert.IsNull(invokeSyncResponse.LogResult); - Assert.IsNotNull(invokeSyncResponse.Payload); - Assert.AreNotEqual(0, invokeSyncResponse.Payload.Length); - Assert.AreNotEqual(0, invokeSyncResponse.StatusCode); - } - finally - { - if (iamRoleCreated) - iamClient.DeleteRole(new DeleteRoleRequest { RoleName = iamRoleName }); - } - } - - public static void CreateLambdaFunction(out string functionName, out string functionArn, out string iamRoleName, out string iamRoleArn, string functionCode, Runtime runtime) - { - functionName = "HelloWorld-" + DateTime.UtcNow.Ticks; - iamRoleName = "Lambda-" + DateTime.UtcNow.Ticks; - - CreateLambdaFunction(functionName, iamRoleName, out iamRoleArn, out functionArn, functionCode, runtime); - } - - private static void SetupPolicies(string iamRoleName) - { - var statement = new Amazon.Auth.AccessControlPolicy.Statement( - Amazon.Auth.AccessControlPolicy.Statement.StatementEffect.Allow); - statement.Actions.Add("s3:PutObject"); - statement.Actions.Add("s3:GetObject"); - statement.Resources.Add(new Resource("*")); - - var policy = new Amazon.Auth.AccessControlPolicy.Policy(); - policy.Statements.Add(statement); - - iamClient.PutRolePolicy(new PutRolePolicyRequest - { - RoleName = iamRoleName, - PolicyName = "admin", - PolicyDocument = policy.ToJson() - }); - - } - - public static void CreateLambdaFunction(string functionName, string iamRoleName, out string iamRoleArn, out string functionArn, string functionCode, Runtime runtime) - { - var iamCreateResponse = iamClient.CreateRole(new CreateRoleRequest - { - RoleName = iamRoleName, - AssumeRolePolicyDocument = LAMBDA_ASSUME_ROLE_POLICY - }); - iamRoleArn = iamCreateResponse.Role.Arn; - SetupPolicies(iamRoleName); - - MemoryStream stream = CreateScriptStream(functionCode); - var uploadRequest = new CreateFunctionRequest - { - FunctionName = functionName, - Code = new FunctionCode - { - ZipFile = stream - }, - Handler = "helloworld.handler", - Runtime = runtime, - Role = iamCreateResponse.Role.Arn - }; - - var uploadResponse = UtilityMethods.WaitUntilSuccess(() => Client.CreateFunction(uploadRequest)); - createdFunctionNames.Add(functionName); - - Assert.IsTrue(uploadResponse.CodeSize > 0); - Assert.IsNotNull(uploadResponse.FunctionArn); - - functionArn = uploadResponse.FunctionArn; - } - - private static MemoryStream CreateScriptStream(string functionCode) - { - MemoryStream stream = new MemoryStream(); - using (ZipArchive archive = new ZipArchive(stream, ZipArchiveMode.Create, true)) - { - var entry = archive.CreateEntry("helloworld.js"); - using (var entryStream = entry.Open()) - using (var writer = new StreamWriter(entryStream)) - { - writer.Write(functionCode); - } - } - stream.Position = 0; - return stream; - } -#endif - } -} \ No newline at end of file diff --git a/sdk/test/Services/MachineLearning/IntegrationTests/AWSSDK.IntegrationTests.MachineLearning.NetFramework.csproj b/sdk/test/Services/MachineLearning/IntegrationTests/AWSSDK.IntegrationTests.MachineLearning.NetFramework.csproj deleted file mode 100644 index 64f4ddef2e11..000000000000 --- a/sdk/test/Services/MachineLearning/IntegrationTests/AWSSDK.IntegrationTests.MachineLearning.NetFramework.csproj +++ /dev/null @@ -1,51 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.MachineLearning.NetFramework - AWSSDK.IntegrationTests.MachineLearning.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/MachineLearning/IntegrationTests/Config/462/App.config b/sdk/test/Services/MachineLearning/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/MachineLearning/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/MachineLearning/IntegrationTests/MachineLearning.cs b/sdk/test/Services/MachineLearning/IntegrationTests/MachineLearning.cs deleted file mode 100644 index 2ce5ef0a6b7d..000000000000 --- a/sdk/test/Services/MachineLearning/IntegrationTests/MachineLearning.cs +++ /dev/null @@ -1,183 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Amazon.MachineLearning; -using Amazon.MachineLearning.Model; -using AWSSDK_DotNet.IntegrationTests.Utils; -using AWSSDK_DotNet.IntegrationTests.Tests; -using Amazon.S3; -using Amazon.S3.Model; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Amazon.S3.Util; -using System.Threading; - - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class MachineLearning : TestBase - { - static AmazonS3Client s3Client = new AmazonS3Client(); - static string DATA_SCHEMA = @"{ - ""version"": ""1.0"", - ""recordAnnotationFieldName"": null, - ""recordWeightFieldName"": null, - ""targetFieldName"": ""a"", - ""dataFormat"": ""CSV"", - ""dataFileContainsHeader"": false, - ""variables"": [ - { - ""fieldName"": ""a"", - ""fieldType"": ""BINARY"" - }, - { - ""fieldName"": ""b"", - ""fieldType"": ""NUMERIC"" - }, - { - ""fieldName"": ""c"", - ""fieldType"": ""CATEGORICAL"" - }, - { - ""fieldName"": ""d"", - ""fieldType"": ""TEXT"" - } - ] - }"; - - static string testRunId = UtilityMethods.GenerateName(); - static string bucketName = testRunId; - - - [ClassInitialize] - public static void Setup(TestContext ctx) - { - s3Client.PutBucket(bucketName); - } - - [ClassCleanup] - public static void Teardown() - { - AmazonS3Util.DeleteS3BucketWithObjects(s3Client, bucketName); - - var models = Client.DescribeMLModels(new DescribeMLModelsRequest { - FilterVariable = MLModelFilterVariable.Name, - Prefix = testRunId - }).Results; - - foreach (var model in models) - { - try - { - if (model.EndpointInfo.EndpointStatus != RealtimeEndpointStatus.NONE) - Client.DeleteRealtimeEndpoint(new DeleteRealtimeEndpointRequest { MLModelId = model.MLModelId }); - Client.DeleteMLModel(new DeleteMLModelRequest { MLModelId = model.MLModelId }); - } - catch - { - Console.WriteLine("Failed to remove Model with id={0}", model.MLModelId); - } - } - - var dataSources = Client.DescribeDataSources(new DescribeDataSourcesRequest { - FilterVariable = DataSourceFilterVariable.DataLocationS3, - Prefix = "s3://" + testRunId - }).Results; - - foreach (var ds in dataSources) - { - try - { - Client.DeleteDataSource(new DeleteDataSourceRequest { DataSourceId = ds.DataSourceId }); - } - catch - { - Console.WriteLine("Failed to remove DataSource with id={0}", ds.DataSourceId); - } - } - } - - - //[TestMethod] - [TestCategory("MachineLearning")] - public void TestCreateModel() - { - s3Client.PutObject(new PutObjectRequest { - BucketName = bucketName, - Key = "data.csv", - ContentBody = "0, 42, foo, bar", - CannedACL = S3CannedACL.PublicRead - }); - - var dataLocation = String.Format("s3://{0}/data.csv", bucketName); - - var dataSourceId = Client.CreateDataSourceFromS3(new CreateDataSourceFromS3Request { - ComputeStatistics = true, - DataSpec = new S3DataSpec - { - DataLocationS3 = dataLocation, - DataSchema = DATA_SCHEMA - } - }).DataSourceId; - - var source = Client.DescribeDataSources(new DescribeDataSourcesRequest - { - FilterVariable = DataSourceFilterVariable.DataLocationS3, - EQ = dataLocation - }).Results.FirstOrDefault(); - - Assert.IsNotNull(source); - - var modelName = UtilityMethods.GenerateName(testRunId); - - var modelId = Client.CreateMLModel(new CreateMLModelRequest { - MLModelName = modelName, - TrainingDataSourceId = dataSourceId, - MLModelType = MLModelType.BINARY - }).MLModelId; - - UtilityMethods.WaitUntil(() => { - var model = Client.DescribeMLModels(new DescribeMLModelsRequest { - FilterVariable = MLModelFilterVariable.Name, - EQ = modelName - }).Results.First(); - - return model.Status == EntityStatus.COMPLETED; - }, 30, 1800); - - var uri = Client.CreateRealtimeEndpoint(new CreateRealtimeEndpointRequest - { - MLModelId = modelId - }).RealtimeEndpointInfo.EndpointUrl; - - UtilityMethods.WaitUntil(() => { - var model = Client.DescribeMLModels(new DescribeMLModelsRequest - { - FilterVariable = MLModelFilterVariable.Name, - EQ = modelName - }).Results.First(); - - return model.EndpointInfo.EndpointStatus == RealtimeEndpointStatus.READY; - }, 30, 1800); - - Assert.IsNotNull(uri); - - // READY doesn't mean ready... - - Thread.Sleep(TimeSpan.FromSeconds(10)); - - var prediction = Client.Predict(new PredictRequest - { - MLModelId = modelId, - PredictEndpoint = uri, - Record = new Dictionary { - {"b", "123"}, {"c", "oop"}, {"d", "goop"} - } - }).Prediction; - - Assert.IsNotNull(prediction); - } - } - -} diff --git a/sdk/test/Services/Polly/IntegrationTests/PollyTests.cs b/sdk/test/Services/Polly/IntegrationTests/PollyTests.cs index 9966ba8c693b..b353427ad14f 100644 --- a/sdk/test/Services/Polly/IntegrationTests/PollyTests.cs +++ b/sdk/test/Services/Polly/IntegrationTests/PollyTests.cs @@ -16,41 +16,39 @@ using Amazon; using Amazon.Polly; using Amazon.Polly.Model; -using Amazon.SecurityToken; -using Amazon.SecurityToken.Model; using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Net; using System; using System.Collections.Generic; using System.IO; +using System.Linq; +using System.Net; using System.Text; using System.Text.Json; -using System.Linq; +using System.Threading.Tasks; namespace AWSSDK_DotNet.IntegrationTests.Tests.Polly { [TestClass] + [TestCategory("Polly")] public class PollyTests { [TestMethod] - [TestCategory("Polly")] - public void HappyCaseAPI() + public async Task HappyCaseAPI() { using (var client = new AmazonPollyClient(RegionEndpoint.USWest2)) { - var response = client.SynthesizeSpeech(GetMp3Request()); + var response = await client.SynthesizeSpeechAsync(GetMp3Request()); Assert.AreEqual(HttpStatusCode.OK, response.HttpStatusCode); Assert.IsTrue(response.AudioStream.ReadByte() > -1); } } [TestMethod] - [TestCategory("Polly")] - public void APIWithSpeechMarks() + public async Task APIWithSpeechMarks() { using (var client = new AmazonPollyClient(RegionEndpoint.USWest2)) { - var response = client.SynthesizeSpeech(GetSpeechMarkRequest()); + var response = await client.SynthesizeSpeechAsync(GetSpeechMarkRequest()); Assert.AreEqual(HttpStatusCode.OK, response.HttpStatusCode); using (var streamReader = new StreamReader(response.AudioStream)) { @@ -61,14 +59,12 @@ public void APIWithSpeechMarks() } [TestMethod] - [TestCategory("Polly")] public void HappyCasePresignedUrl() { AssertPreSignedUrl(SynthesizeSpeechUtil.GeneratePresignedUrl(RegionEndpoint.USWest2, GetMp3Request())); } [TestMethod] - [TestCategory("Polly")] public void PresignedUrlWithSpeechMarks() { var data = AssertPreSignedUrl(SynthesizeSpeechUtil.GeneratePresignedUrl(RegionEndpoint.USWest2, GetSpeechMarkRequest())); @@ -76,20 +72,6 @@ public void PresignedUrlWithSpeechMarks() } [TestMethod] - [TestCategory("Polly")] - [TestCategory("RequiresIAMUser")] - public void PresignedUrlWithSessionToken() - { - var stsClient = new AmazonSecurityTokenServiceClient(RegionEndpoint.USWest2); - var response = stsClient.GetSessionToken(new GetSessionTokenRequest - { - DurationSeconds = 900 - }); - AssertPreSignedUrl(SynthesizeSpeechUtil.GeneratePresignedUrl(response.Credentials, RegionEndpoint.USWest2, GetMp3Request())); - } - - [TestMethod] - [TestCategory("Polly")] public void EnsureIsUrlEncoded() { var request = GetMp3Request(); @@ -130,7 +112,7 @@ private static byte[] AssertPreSignedUrl(string url) private static SynthesizeSpeechRequest GetMp3Request() { - return new SynthesizeSpeechRequest() + return new SynthesizeSpeechRequest { VoiceId = "Joanna", Text = "Hello", @@ -140,7 +122,7 @@ private static SynthesizeSpeechRequest GetMp3Request() private static SynthesizeSpeechRequest GetSpeechMarkRequest() { - return new SynthesizeSpeechRequest() + return new SynthesizeSpeechRequest { VoiceId = "Joanna", Text = "Hello", diff --git a/sdk/test/Services/RDS/IntegrationTests/AWSSDK.IntegrationTests.RDS.NetFramework.csproj b/sdk/test/Services/RDS/IntegrationTests/AWSSDK.IntegrationTests.RDS.NetFramework.csproj deleted file mode 100644 index 60d8535a9b5a..000000000000 --- a/sdk/test/Services/RDS/IntegrationTests/AWSSDK.IntegrationTests.RDS.NetFramework.csproj +++ /dev/null @@ -1,51 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.RDS.NetFramework - AWSSDK.IntegrationTests.RDS.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/RDS/IntegrationTests/BasicDescribes.cs b/sdk/test/Services/RDS/IntegrationTests/BasicDescribes.cs deleted file mode 100644 index fd3ee0f859ba..000000000000 --- a/sdk/test/Services/RDS/IntegrationTests/BasicDescribes.cs +++ /dev/null @@ -1,490 +0,0 @@ -using System; -using Amazon.ElasticTranscoder.Model; -using Amazon.RDS; -using Amazon.RDS.Model; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace AWSSDK_DotNet.IntegrationTests.Tests.RDS -{ - [TestClass] - public class BasicDescribes : TestBase - { - [TestMethod] - [TestCategory("RDS")] - public void TestDescribeDBEngineVersions() - { - var response = Client.DescribeDBEngineVersions(); - Assert.IsNotNull(response); - - string dbEngine = null; - if (response.DBEngineVersions.Count > 0) - { - foreach (var dbev in response.DBEngineVersions) - { - Assert.IsFalse(string.IsNullOrEmpty(dbev.Engine)); - if (dbEngine == null) - dbEngine = dbev.Engine; - - Assert.IsFalse(string.IsNullOrEmpty(dbev.EngineVersion)); - } - } - - if (dbEngine != null) - { - // can perform a filtering test - var specificEngineResponse = - Client.DescribeDBEngineVersions(new DescribeDBEngineVersionsRequest {Engine = dbEngine}); - Assert.IsNotNull(specificEngineResponse); - foreach (var dbev in specificEngineResponse.DBEngineVersions) - { - Assert.AreEqual(dbev.Engine, dbEngine); - } - } - } - - [TestMethod] - [TestCategory("RDS")] - public void TestDescribeDBEngineVersionsForFamily() - { - var response = Client.DescribeDBParameterGroups(); - Assert.IsNotNull(response); - - if (response.DBParameterGroups.Count > 0) - { - var dbParamGroupFamily = response.DBParameterGroups[0]; - - var describeResponse = Client.DescribeDBEngineVersions(new DescribeDBEngineVersionsRequest - { - DBParameterGroupFamily = dbParamGroupFamily.DBParameterGroupFamily - }); - Assert.IsNotNull(response); - - if (describeResponse.DBEngineVersions != null && describeResponse.DBEngineVersions.Count > 0) - { - foreach (var dbev in describeResponse.DBEngineVersions) - { - Assert.IsTrue(dbev.DBParameterGroupFamily.Equals(dbParamGroupFamily.DBParameterGroupFamily)); - } - } - } - } - - [TestMethod] - [TestCategory("RDS")] - public void TestDescribeDBParameterGroups() - { - var response = Client.DescribeDBParameterGroups(); - Assert.IsNotNull(response); - - if (response.DBParameterGroups.Count > 0) - { - foreach (var dbpg in response.DBParameterGroups) - { - Assert.IsFalse(string.IsNullOrEmpty(dbpg.DBParameterGroupFamily)); - Assert.IsFalse(string.IsNullOrEmpty(dbpg.DBParameterGroupName)); - } - } - } - - [TestMethod] - [TestCategory("RDS")] - public void TestDescribeDBInstances() - { - var response = Client.DescribeDBInstances(); - Assert.IsNotNull(response); - - string dbInstanceIdentifier = null; - if (response.DBInstances != null && response.DBInstances.Count > 0) - { - foreach (var dbi in response.DBInstances) - { - Assert.IsFalse(string.IsNullOrEmpty(dbi.DBInstanceIdentifier)); - if (dbInstanceIdentifier == null) - dbInstanceIdentifier = dbi.DBInstanceIdentifier; - - Assert.IsFalse(string.IsNullOrEmpty(dbi.Engine)); - Assert.IsFalse(string.IsNullOrEmpty(dbi.EngineVersion)); - - if (dbi.DBParameterGroups.Count > 0) - { - foreach (var dbpg in dbi.DBParameterGroups) - { - Assert.IsFalse(string.IsNullOrEmpty(dbpg.DBParameterGroupName)); - } - } - } - } - - if (dbInstanceIdentifier != null) - { - // can do a further filtering test - var specificIdResponse = - Client.DescribeDBInstances(new DescribeDBInstancesRequest - { - DBInstanceIdentifier = dbInstanceIdentifier - }); - Assert.IsNotNull(specificIdResponse); - Assert.AreEqual(specificIdResponse.DBInstances.Count, 1); - } - } - - [TestMethod] - [TestCategory("RDS")] - public void DescribeDBSecurityGroups() - { - var response = Client.DescribeDBSecurityGroups(); - Assert.IsNotNull(response); - - string dbSecurityGroupName = null; - if (response.DBSecurityGroups != null && response.DBSecurityGroups.Count > 0) - { - foreach (var dbsg in response.DBSecurityGroups) - { - Assert.IsFalse(string.IsNullOrEmpty(dbsg.DBSecurityGroupName)); - if (dbSecurityGroupName == null) - dbSecurityGroupName = dbsg.DBSecurityGroupName; - - Assert.IsFalse(string.IsNullOrEmpty(dbsg.OwnerId)); - } - } - - if (dbSecurityGroupName != null) - { - // perform a filtering test - var specificGroupResponse = - Client.DescribeDBSecurityGroups(new DescribeDBSecurityGroupsRequest - { - DBSecurityGroupName = dbSecurityGroupName - }); - Assert.IsNotNull(specificGroupResponse); - Assert.AreEqual(specificGroupResponse.DBSecurityGroups.Count, 1); - } - } - - [TestMethod] - [TestCategory("RDS")] - public void DescribeDBSnapshots() - { - var response = Client.DescribeDBSnapshots(); - Assert.IsNotNull(response); - - string dbInstanceIdentifier = null; - string dbSnapshotIdentifier = null; - - if (response.DBSnapshots != null && response.DBSnapshots.Count > 0) - { - foreach (var dbss in response.DBSnapshots) - { - Assert.IsFalse(string.IsNullOrEmpty(dbss.DBInstanceIdentifier)); - if (dbInstanceIdentifier == null) - dbInstanceIdentifier = dbss.DBInstanceIdentifier; - - Assert.IsFalse(string.IsNullOrEmpty(dbss.DBSnapshotIdentifier)); - if (dbSnapshotIdentifier == null) - dbSnapshotIdentifier = dbss.DBSnapshotIdentifier; - } - } - - if (dbInstanceIdentifier != null) - { - var specificInstanceResponse = - Client.DescribeDBSnapshots(new DescribeDBSnapshotsRequest - { - DBInstanceIdentifier = dbInstanceIdentifier - }); - Assert.IsNotNull(specificInstanceResponse); - Assert.IsTrue(specificInstanceResponse.DBSnapshots.Count > 0); - } - - if (dbSnapshotIdentifier != null) - { - var specificSnapshotResponse = - Client.DescribeDBSnapshots(new DescribeDBSnapshotsRequest - { - DBSnapshotIdentifier = dbSnapshotIdentifier - }); - Assert.IsNotNull(specificSnapshotResponse); - Assert.AreEqual(specificSnapshotResponse.DBSnapshots.Count, 1); - } - } - - [TestMethod] - [TestCategory("RDS")] - public void DescribeDBSubnetGroups() - { - var response = Client.DescribeDBSubnetGroups(); - Assert.IsNotNull(response); - - string dbSubnetGroupName = null; - if (response.DBSubnetGroups != null && response.DBSubnetGroups.Count > 0) - { - foreach (var dbsng in response.DBSubnetGroups) - { - Assert.IsFalse(string.IsNullOrEmpty(dbsng.DBSubnetGroupName)); - if (dbSubnetGroupName == null) - dbSubnetGroupName = dbsng.DBSubnetGroupName; - - if (dbsng.Subnets.Count > 0) - { - foreach (var s in dbsng.Subnets) - { - Assert.IsFalse(string.IsNullOrEmpty(s.SubnetIdentifier)); - Assert.IsNotNull(s.SubnetAvailabilityZone); - Assert.IsFalse(string.IsNullOrEmpty(s.SubnetAvailabilityZone.Name)); - } - } - } - } - - if (dbSubnetGroupName != null) - { - var specificSubnetResponse = - Client.DescribeDBSubnetGroups(new DescribeDBSubnetGroupsRequest - { - DBSubnetGroupName = dbSubnetGroupName - }); - Assert.IsNotNull(specificSubnetResponse); - Assert.AreEqual(specificSubnetResponse.DBSubnetGroups.Count, 1); - } - } - - [TestMethod] - [TestCategory("RDS")] - public void DescribeEventCategories() - { - var response = Client.DescribeEventCategories(); - Assert.IsNotNull(response); - - string sourceType = null; - if (response.EventCategoriesMapList.Count > 0) - { - foreach (var ec in response.EventCategoriesMapList) - { - Assert.IsFalse(string.IsNullOrEmpty(ec.SourceType)); - if (sourceType == null) - sourceType = ec.SourceType; - - if (ec.EventCategories.Count > 0) - { - foreach (var cat in ec.EventCategories) - { - Assert.IsFalse(string.IsNullOrEmpty(cat)); - } - } - } - } - - if (sourceType != null) - { - var specificSourceResponse = - Client.DescribeEventCategories(new DescribeEventCategoriesRequest {SourceType = sourceType}); - Assert.IsNotNull(specificSourceResponse); - - Assert.AreEqual(specificSourceResponse.EventCategoriesMapList.Count, 1); - } - } - - [TestMethod] - [TestCategory("RDS")] - public void DescribeEventSubscriptions() - { - // subscriptions depend on what account has set up, so simply verify we get a response - var response = Client.DescribeEventSubscriptions(); - Assert.IsNotNull(response); - } - - [TestMethod] - [TestCategory("RDS")] - public void DescribeEvents() - { - var response = Client.DescribeEvents(); - Assert.IsNotNull(response); - - string sourceIdentifier = null; - string sourceType = null; - if (response.Events != null && response.Events.Count > 0) - { - foreach (var e in response.Events) - { - Assert.IsFalse(string.IsNullOrEmpty(e.SourceType)); - Assert.IsFalse(string.IsNullOrEmpty(e.SourceIdentifier)); - if (sourceIdentifier == null) - { - sourceIdentifier = e.SourceIdentifier; - sourceType = e.SourceType; - } - - if (e.EventCategories.Count > 0) - { - foreach (var ec in e.EventCategories) - { - Assert.IsFalse(string.IsNullOrEmpty(ec)); - } - } - } - } - - if (sourceIdentifier != null) - { - var specificSourceResponse = - Client.DescribeEvents(new DescribeEventsRequest {SourceIdentifier = sourceIdentifier, SourceType = sourceType }); - Assert.IsNotNull(specificSourceResponse); - } - } - - [TestMethod] - [TestCategory("RDS")] - public void DescribeReservedDBInstances() - { - var response = Client.DescribeReservedDBInstances(); - Assert.IsNotNull(response); - - string reservedInstanceId = null; - string dbInstanceClass = null; - - if (response.ReservedDBInstances != null && response.ReservedDBInstances.Count > 0) - { - foreach (var rdbi in response.ReservedDBInstances) - { - Assert.IsFalse(string.IsNullOrEmpty(rdbi.ReservedDBInstanceId)); - if (reservedInstanceId == null) - reservedInstanceId = rdbi.ReservedDBInstanceId; - Assert.IsFalse(string.IsNullOrEmpty(rdbi.DBInstanceClass)); - if (dbInstanceClass == null) - dbInstanceClass = rdbi.DBInstanceClass; - } - } - - if (dbInstanceClass != null) - { - var specificClassResponse = - Client.DescribeReservedDBInstances(new DescribeReservedDBInstancesRequest - { - DBInstanceClass = dbInstanceClass - }); - Assert.IsNotNull(specificClassResponse); - Assert.IsTrue(specificClassResponse.ReservedDBInstances.Count > 0); - } - - if (reservedInstanceId != null) - { - var specificInstanceResponse = - Client.DescribeReservedDBInstances(new DescribeReservedDBInstancesRequest - { - ReservedDBInstanceId = reservedInstanceId - }); - Assert.IsNotNull(specificInstanceResponse); - Assert.AreEqual(specificInstanceResponse.ReservedDBInstances.Count, 1); - } - } - - [TestMethod] - [TestCategory("RDS")] - public void DescribeReservedDBInstancesOfferings() - { - var response = Client.DescribeReservedDBInstancesOfferings(); - Assert.IsNotNull(response); - - string offeringId = null; - string offeringType = null; - - if (response.ReservedDBInstancesOfferings.Count > 0) - { - foreach (var ro in response.ReservedDBInstancesOfferings) - { - Assert.IsFalse(string.IsNullOrEmpty(ro.OfferingType)); - if (offeringType == null) - offeringType = ro.OfferingType; - Assert.IsFalse(string.IsNullOrEmpty(ro.ReservedDBInstancesOfferingId)); - if (offeringId == null) - offeringId = ro.ReservedDBInstancesOfferingId; - } - } - - if (offeringType != null) - { - var specificTypeResponse = - Client.DescribeReservedDBInstancesOfferings(new DescribeReservedDBInstancesOfferingsRequest - { - OfferingType = offeringType - }); - Assert.IsNotNull(specificTypeResponse); - Assert.IsTrue(specificTypeResponse.ReservedDBInstancesOfferings.Count > 0); - } - - if (offeringId != null) - { - var specificIdResponse = - Client.DescribeReservedDBInstancesOfferings(new DescribeReservedDBInstancesOfferingsRequest - { - ReservedDBInstancesOfferingId = offeringId - }); - Assert.IsNotNull(specificIdResponse); - Assert.AreEqual(specificIdResponse.ReservedDBInstancesOfferings.Count, 1); - } - } - - [TestMethod] - [TestCategory("RDS")] - public void TestDescribeAccountAttributes() - { - var result = Client.DescribeAccountAttributes(); - var quotas = result.AccountQuotas; - Assert.IsNotNull(quotas); - Assert.AreNotEqual(0, quotas.Count); - foreach(var quota in quotas) - { - Assert.IsFalse(string.IsNullOrEmpty(quota.AccountQuotaName)); - Assert.AreNotEqual(0, quota.Max); - } - } - [TestMethod] - [TestCategory("RDS")] - public void TestDescribeCertificates() - { - var request = new DescribeCertificatesRequest(); - - do - { - var response = Client.DescribeCertificates(request); - var certificates = response.Certificates; - Assert.IsNotNull(certificates); - Assert.AreNotEqual(0, certificates.Count); - - foreach(var cert in certificates) - { - Assert.IsNotNull(cert); - Assert.IsFalse(string.IsNullOrEmpty(cert.CertificateIdentifier)); - Assert.IsFalse(string.IsNullOrEmpty(cert.CertificateType)); - Assert.IsFalse(string.IsNullOrEmpty(cert.Thumbprint)); - Assert.IsTrue(cert.ValidFrom > DateTime.MinValue); - Assert.IsTrue(cert.ValidFrom < cert.ValidTill); - } - - request.Marker = response.Marker; - } while (!string.IsNullOrEmpty(request.Marker)); - } - - [TestMethod] - [TestCategory("RDS")] - public void TestDescribeDBInstanceException() - { - try - { - Client.DescribeDBInstances(new DescribeDBInstancesRequest - { - DBInstanceIdentifier = Guid.NewGuid().ToString("N") - }); - Assert.Fail("Expected exception not thrown"); - } - catch (AmazonRDSException nfe) - { - Assert.IsFalse(string.IsNullOrEmpty(nfe.ErrorCode)); - Assert.IsFalse(string.IsNullOrEmpty(nfe.Message)); - Assert.IsFalse(string.IsNullOrEmpty(nfe.RequestId)); - Assert.IsTrue((int)(nfe.StatusCode) >= 400); - } - } - - } -} diff --git a/sdk/test/Services/RDS/IntegrationTests/Config/462/App.config b/sdk/test/Services/RDS/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/RDS/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/RDS/IntegrationTests/DBParameters.cs b/sdk/test/Services/RDS/IntegrationTests/DBParameters.cs deleted file mode 100644 index e247559144d6..000000000000 --- a/sdk/test/Services/RDS/IntegrationTests/DBParameters.cs +++ /dev/null @@ -1,157 +0,0 @@ -using System; -using System.Collections.Generic; -using Amazon.RDS; -using Amazon.RDS.Model; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace AWSSDK_DotNet.IntegrationTests.Tests.RDS -{ - [TestClass] - public class DBParameters : TestBase - { - [TestMethod] - [TestCategory("RDS")] - public void TestDBParameterOperations() - { - const string engine = "mysql5.5"; - var parameterGroupName = "dotnet-test-param-group-" + DateTime.UtcNow.Ticks; - DBParameterGroup parameterGroup = null; - DBParameterGroup parameterGroup2 = null; - - try - { - // Create a parameter group - parameterGroup = Client.CreateDBParameterGroup( - new CreateDBParameterGroupRequest - { - DBParameterGroupName = parameterGroupName, - Description = "description", - DBParameterGroupFamily = engine - }).DBParameterGroup; - Assert.AreEqual(parameterGroupName, parameterGroup.DBParameterGroupName); - Assert.AreEqual("description", parameterGroup.Description); - Assert.IsTrue(parameterGroup.DBParameterGroupFamily.StartsWith("mysql")); - - // Describe it - var dbParameterGroups = Client.DescribeDBParameterGroups( - new DescribeDBParameterGroupsRequest - { - DBParameterGroupName = parameterGroupName, - MaxRecords = 20 - } - ).DBParameterGroups; - - Assert.AreEqual(1, dbParameterGroups.Count); - Assert.AreEqual(parameterGroupName, dbParameterGroups[0].DBParameterGroupName); - Assert.AreEqual("description", dbParameterGroups[0].Description); - Assert.IsTrue(dbParameterGroups[0].DBParameterGroupFamily.StartsWith("mysql")); - - - // Describe the params in a group - var parameters = Client.DescribeDBParameters( - new DescribeDBParametersRequest - { - DBParameterGroupName = parameterGroupName, - MaxRecords = 20 - } - ).Parameters; - // We can't request a specific parameter, so we rely on the fact that most - // parameters will have the following fields populated. - assertValidParameter(parameters[0]); - - - // Describe the defaults for an engine - var engineDefaultParameters = Client.DescribeEngineDefaultParameters( - new DescribeEngineDefaultParametersRequest - { - DBParameterGroupFamily = engine, - MaxRecords = 20 - }).EngineDefaults; - Assert.AreEqual(engine, engineDefaultParameters.DBParameterGroupFamily); - Assert.IsFalse(engineDefaultParameters.Parameters.Count == 0); - assertValidParameter(engineDefaultParameters.Parameters[0]); - - - // Reset the parameter group - var resetParameterGroupName = Client.ResetDBParameterGroup( - new ResetDBParameterGroupRequest - { - DBParameterGroupName = parameterGroupName, - ResetAllParameters = true - } - ).DBParameterGroupName; - Assert.AreEqual(parameterGroupName, resetParameterGroupName); - - - // Modify the parameter group - var newParameter = new Parameter - { - ParameterName = "character_set_client", - ParameterValue = "ascii", - ApplyMethod = "immediate" - }; - - var modifyDbParameterGroupRequest = new ModifyDBParameterGroupRequest - { - DBParameterGroupName = parameterGroupName, - Parameters = new List { newParameter } - }; - - var modifiedParameterGroupName = Client.ModifyDBParameterGroup(modifyDbParameterGroupRequest) - .DBParameterGroupName; - Assert.AreEqual(parameterGroupName, modifiedParameterGroupName); - - // Copy the parameter group - parameterGroup2 = Client.CopyDBParameterGroup(new CopyDBParameterGroupRequest - { - SourceDBParameterGroupIdentifier = parameterGroupName, - TargetDBParameterGroupIdentifier = parameterGroupName + "copy", - TargetDBParameterGroupDescription = "Copy of " + parameterGroupName - }).DBParameterGroup; - Assert.AreEqual(parameterGroupName + "copy", parameterGroup2.DBParameterGroupName); - Assert.AreEqual("Copy of " + parameterGroupName, parameterGroup2.Description); - Assert.IsTrue(parameterGroup2.DBParameterGroupFamily.StartsWith("mysql")); - } - finally - { - if (parameterGroup != null) - { - Client.DeleteDBParameterGroup(new DeleteDBParameterGroupRequest - { - DBParameterGroupName = parameterGroup.DBParameterGroupName - }); - } - if (parameterGroup2 != null) - { - Client.DeleteDBParameterGroup(new DeleteDBParameterGroupRequest - { - DBParameterGroupName = parameterGroup2.DBParameterGroupName - }); - } - } - } - - /** - * Sanity checks a parameter to assert that the basic fields are populated. - * If any missing data is found, this method will fail the current test. - * - * @param parameter - * The parameter to check. - */ - void assertValidParameter(Parameter parameter) - { - assertNotEmpty(parameter.AllowedValues); - assertNotEmpty(parameter.ApplyType); - assertNotEmpty(parameter.DataType); - assertNotEmpty(parameter.Description); - assertNotEmpty(parameter.ParameterName); - assertNotEmpty(parameter.Source); - } - - void assertNotEmpty(String s) - { - Assert.IsNotNull(s); - Assert.IsTrue(s.Length > 0); - } - } -} diff --git a/sdk/test/Services/RDS/IntegrationTests/DescribeOrderableDBInstanceOptions.cs b/sdk/test/Services/RDS/IntegrationTests/DescribeOrderableDBInstanceOptions.cs deleted file mode 100644 index 7cf0625aa884..000000000000 --- a/sdk/test/Services/RDS/IntegrationTests/DescribeOrderableDBInstanceOptions.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using Amazon.RDS; -using Amazon.RDS.Model; - -namespace AWSSDK_DotNet.IntegrationTests.Tests.RDS -{ - [TestClass] - public class DescribeOrderableDBInstanceOptions: TestBase - { - [TestMethod] - [TestCategory("RDS")] - public void TestDescribeOrderableDBInstanceOptions() - { - const string engine = "mysql"; - var response = - Client.DescribeOrderableDBInstanceOptions(new DescribeOrderableDBInstanceOptionsRequest - { - Engine = engine - }); - Assert.IsNotNull(response); - - Assert.IsNotNull(response.OrderableDBInstanceOptions); - foreach (var opt in response.OrderableDBInstanceOptions) - { - Assert.IsNotNull(opt.AvailabilityZones); - Assert.IsTrue(opt.AvailabilityZones.Count > 0); - Assert.IsFalse(string.IsNullOrEmpty(opt.DBInstanceClass)); - Assert.AreEqual(engine, opt.Engine); - Assert.IsFalse(string.IsNullOrEmpty(opt.EngineVersion)); - Assert.IsFalse(string.IsNullOrEmpty(opt.LicenseModel)); - Assert.IsNotNull(opt.MultiAZCapable); - Assert.IsNotNull(opt.ReadReplicaCapable); - } - } - - [TestMethod] - [TestCategory("RDS")] - public void TestInvalidParam() - { - try - { - Client.DescribeOrderableDBInstanceOptions(new DescribeOrderableDBInstanceOptionsRequest - { - Engine = "mysql", - LicenseModel = "not-a-valid-license", - }); - } - catch (AmazonRDSException ex) - { - Assert.IsNotNull(ex.Message); - Assert.IsTrue(ex.Message.IndexOf("license model", StringComparison.OrdinalIgnoreCase) >= 0); - return; - } - catch (Exception ex) - { - Assert.Fail("Unexpected exception thrown:" + ex); - } - - Assert.Fail("No exception thrown"); - } - - [TestMethod] - [TestCategory("RDS")] - public void TestEngineMissing() - { - try - { - Client.DescribeOrderableDBInstanceOptions(new DescribeOrderableDBInstanceOptionsRequest()); - } - catch (AmazonRDSException ex) - { - Assert.IsNotNull(ex.Message); - return; - } - catch (Exception ex) - { - Assert.Fail("Unexpected exception thrown:" + ex); - } - - Assert.Fail("No exception thrown"); - } - } -} diff --git a/sdk/test/Services/Route53/IntegrationTests/Route53.cs b/sdk/test/Services/Route53/IntegrationTests/Route53.cs index b83f17bcd6a4..a125f13c0cdd 100644 --- a/sdk/test/Services/Route53/IntegrationTests/Route53.cs +++ b/sdk/test/Services/Route53/IntegrationTests/Route53.cs @@ -1,25 +1,25 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Amazon; +using Amazon.Route53; +using Amazon.Route53.Model; +using AWSSDK_DotNet.IntegrationTests.Utils; +using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; using System.Linq; -using System.Text; - -using Amazon.Route53; -using Amazon.Route53.Model; using System.Threading; -using Amazon; -using AWSSDK_DotNet.IntegrationTests.Utils; +using System.Threading.Tasks; namespace AWSSDK_DotNet.IntegrationTests.Tests { [TestClass] + [TestCategory("Route53")] public class Route53 : TestBase { private const string COMMENT = "comment"; private const string ZONE_NAME = "aws.sdk.com."; + private static string CALLER_REFERENCE { get { return Guid.NewGuid().ToString(); } } - private static TimeSpan pollingPeriod = TimeSpan.FromSeconds(30); - private static TimeSpan maxWaitTime = TimeSpan.FromMinutes(5); + private static readonly TimeSpan maxWaitTime = TimeSpan.FromMinutes(5); // The ID of the zone we created in this test private string createdZoneId; @@ -34,14 +34,14 @@ public static void Cleanup() } // Ensures the HostedZone we create during this test is correctly released. - [TestCleanup()] - public void TearDown() + [TestCleanup] + public async Task TearDown() { if (!string.IsNullOrEmpty(createdZoneId)) { try { - Client.DeleteHostedZone(new DeleteHostedZoneRequest { Id = createdZoneId }); + await Client.DeleteHostedZoneAsync(new DeleteHostedZoneRequest { Id = createdZoneId }); } catch { } } @@ -50,10 +50,10 @@ public void TearDown() // Runs through a number of the APIs in the Route 53 client to make sure we can // correct send requests and unmarshall responses. [TestMethod] - [TestCategory("Route53")] - public void TestRoute53() + public async Task TestRoute53() { - var geoLocations = Client.ListGeoLocations().GeoLocationDetailsList; + var listGeoLocationsResponse = await Client.ListGeoLocationsAsync(); + var geoLocations = listGeoLocationsResponse.GeoLocationDetailsList; Assert.IsNotNull(geoLocations); Assert.AreNotEqual(0, geoLocations.Count); @@ -63,28 +63,31 @@ public void TestRoute53() CallerReference = CALLER_REFERENCE, HostedZoneConfig = new HostedZoneConfig { Comment = COMMENT } }; - // Create Hosted Zone - var createResponse = UtilityMethods.WaitUntilSuccess( - () => Client.CreateHostedZone(createRequest) - ); + // Create Hosted Zone + CreateHostedZoneResponse createResponse = null; + await UtilityMethods.WaitUntilAsync(async () => + { + createResponse = await Client.CreateHostedZoneAsync(createRequest); + }, maxWaitTime); createdZoneId = createResponse.HostedZone.Id; createdZoneChangeId = createResponse.ChangeInfo.Id; - assertValidCreatedHostedZone(createResponse.HostedZone); - assertValidDelegationSet(createResponse.DelegationSet); - assertValidChangeInfo(createResponse.ChangeInfo); + AssertValidCreatedHostedZone(createResponse.HostedZone); + AssertValidDelegationSet(createResponse.DelegationSet); + AssertValidChangeInfo(createResponse.ChangeInfo); Assert.IsNotNull(createResponse.Location); // Get Hosted Zone GetHostedZoneRequest getRequest = new GetHostedZoneRequest { Id = createdZoneId }; - var getHostedZoneResponse = Client.GetHostedZone(getRequest); - assertValidDelegationSet(getHostedZoneResponse.DelegationSet); - assertValidCreatedHostedZone(getHostedZoneResponse.HostedZone); + var getHostedZoneResponse = await Client.GetHostedZoneAsync(getRequest); + AssertValidDelegationSet(getHostedZoneResponse.DelegationSet); + AssertValidCreatedHostedZone(getHostedZoneResponse.HostedZone); // List Hosted Zones - List hostedZones = Client.ListHostedZones().HostedZones; + var listZonesResponse = await Client.ListHostedZonesAsync(); + var hostedZones = listZonesResponse.HostedZones; Assert.IsTrue(hostedZones.Count > 0); foreach (HostedZone hostedZone in hostedZones) { @@ -94,9 +97,13 @@ public void TestRoute53() } // List Resource Record Sets - ListResourceRecordSetsRequest listRequest = new ListResourceRecordSetsRequest { HostedZoneId = createdZoneId, MaxItems = "10" }; - List resourceRecordSets = Client.ListResourceRecordSets(listRequest).ResourceRecordSets; + var listRecordSetsResponse = await Client.ListResourceRecordSetsAsync(new ListResourceRecordSetsRequest + { + HostedZoneId = createdZoneId, + MaxItems = "10" + }); + var resourceRecordSets = listRecordSetsResponse.ResourceRecordSets; Assert.IsTrue(resourceRecordSets.Count > 0); ResourceRecordSet existingResourceRecordSet = resourceRecordSets[0]; foreach (ResourceRecordSet rrset in resourceRecordSets) @@ -107,12 +114,11 @@ public void TestRoute53() Assert.IsTrue(rrset.ResourceRecords.Count > 0); } - // Get Change - ChangeInfo changeInfo = Client.GetChange(new GetChangeRequest { Id = createdZoneChangeId }).ChangeInfo; + var getChangeResponse = await Client.GetChangeAsync(new GetChangeRequest { Id = createdZoneChangeId }); + ChangeInfo changeInfo = getChangeResponse.ChangeInfo; Assert.IsTrue(changeInfo.Id.EndsWith(createdZoneChangeId)); - assertValidChangeInfo(changeInfo); - + AssertValidChangeInfo(changeInfo); // Change Resource Record Sets ResourceRecordSet newResourceRecordSet = new ResourceRecordSet @@ -124,32 +130,32 @@ public void TestRoute53() HealthCheckId = null }; - changeInfo = Client.ChangeResourceRecordSets(new ChangeResourceRecordSetsRequest + var changeResponse = await Client.ChangeResourceRecordSetsAsync(new ChangeResourceRecordSetsRequest { HostedZoneId = createdZoneId, ChangeBatch = new ChangeBatch { Comment = COMMENT, - Changes = new List - { + Changes = new List + { new Change { Action = "DELETE", ResourceRecordSet = existingResourceRecordSet }, new Change { Action = "CREATE", ResourceRecordSet = newResourceRecordSet } } } - }).ChangeInfo; + }); - assertValidChangeInfo(changeInfo); + changeInfo = changeResponse.ChangeInfo; + AssertValidChangeInfo(changeInfo); // Delete Hosted Zone - var deleteHostedZoneResult = Client.DeleteHostedZone(new DeleteHostedZoneRequest { Id = createdZoneId }); - assertValidChangeInfo(deleteHostedZoneResult.ChangeInfo); + var deleteHostedZoneResult = await Client.DeleteHostedZoneAsync(new DeleteHostedZoneRequest { Id = createdZoneId }); + AssertValidChangeInfo(deleteHostedZoneResult.ChangeInfo); } [TestMethod] - [TestCategory("Route53")] - public void HealthCheckTests() + public async Task HealthCheckTests() { - var createRequest = new CreateHealthCheckRequest() + var createRequest = new CreateHealthCheckRequest { CallerReference = Guid.NewGuid().ToString(), HealthCheckConfig = new HealthCheckConfig() @@ -161,13 +167,13 @@ public void HealthCheckTests() FailureThreshold = 5 } }; - var createResponse = Client.CreateHealthCheck(createRequest); + var createResponse = await Client.CreateHealthCheckAsync(createRequest); Assert.IsNotNull(createResponse.HealthCheck.Id); Assert.AreEqual(10, createResponse.HealthCheck.HealthCheckConfig.RequestInterval); Assert.AreEqual(5, createResponse.HealthCheck.HealthCheckConfig.FailureThreshold); string healthCheckId = createResponse.HealthCheck.Id; - var listResponse = Client.ListHealthChecks(); + var listResponse = await Client.ListHealthChecksAsync(); Assert.IsNotNull(listResponse.HealthChecks.FirstOrDefault(x => x.Id == healthCheckId)); GetHealthCheckStatusResponse status = null; @@ -177,7 +183,7 @@ public void HealthCheckTests() { try { - status = Client.GetHealthCheckStatus(new GetHealthCheckStatusRequest + status = await Client.GetHealthCheckStatusAsync(new GetHealthCheckStatusRequest { HealthCheckId = healthCheckId }); @@ -185,29 +191,35 @@ public void HealthCheckTests() } catch (NoSuchHealthCheckException) { - Thread.Sleep(TimeSpan.FromSeconds(10)); + await Task.Delay(TimeSpan.FromSeconds(10)); } } Assert.IsNotNull(status); if (status.HealthCheckObservations == null) + { Assert.IsFalse(AWSConfigs.InitializeCollections); + } else + { Assert.IsNotNull(status.HealthCheckObservations); + } - var healthCheck = Client.GetHealthCheck(new GetHealthCheckRequest + var getResponse = await Client.GetHealthCheckAsync(new GetHealthCheckRequest { HealthCheckId = healthCheckId - }).HealthCheck; + }); + var healthCheck = getResponse.HealthCheck; Assert.IsNotNull(healthCheck); Assert.IsNotNull(healthCheck.Id); Assert.IsNotNull(healthCheck.HealthCheckConfig); - var tagSet = Client.ListTagsForResource(new ListTagsForResourceRequest + var listTagsBeforeResponse = await Client.ListTagsForResourceAsync(new ListTagsForResourceRequest { ResourceType = TagResourceType.Healthcheck, ResourceId = healthCheckId - }).ResourceTagSet; + }); + var tagSet = listTagsBeforeResponse.ResourceTagSet; Assert.IsNotNull(tagSet); Assert.IsNotNull(tagSet.ResourceId); @@ -221,7 +233,7 @@ public void HealthCheckTests() Assert.IsNull(tagSet.Tags); } - Client.ChangeTagsForResource(new ChangeTagsForResourceRequest + await Client.ChangeTagsForResourceAsync(new ChangeTagsForResourceRequest { ResourceType = TagResourceType.Healthcheck, ResourceId = healthCheckId, @@ -231,11 +243,12 @@ public void HealthCheckTests() } }); - tagSet = Client.ListTagsForResource(new ListTagsForResourceRequest + var listTagsAfterResponse = await Client.ListTagsForResourceAsync(new ListTagsForResourceRequest { ResourceType = TagResourceType.Healthcheck, ResourceId = healthCheckId - }).ResourceTagSet; + }); + tagSet = listTagsAfterResponse.ResourceTagSet; Assert.IsNotNull(tagSet); Assert.IsNotNull(tagSet.ResourceId); Assert.IsNotNull(tagSet.ResourceType); @@ -244,9 +257,9 @@ public void HealthCheckTests() Assert.AreEqual("Test", tagSet.Tags[0].Key); Assert.AreEqual("true", tagSet.Tags[0].Value); - Client.DeleteHealthCheck(new DeleteHealthCheckRequest() { HealthCheckId = healthCheckId }); + await Client.DeleteHealthCheckAsync(new DeleteHealthCheckRequest { HealthCheckId = healthCheckId }); - listResponse = Client.ListHealthChecks(); + listResponse = await Client.ListHealthChecksAsync(); if (listResponse.HealthChecks != null) { Assert.IsNull(listResponse.HealthChecks.FirstOrDefault(x => x.Id == healthCheckId)); @@ -254,119 +267,27 @@ public void HealthCheckTests() } [TestMethod] - [TestCategory("Route53")] - [Ignore("Excluding flaky Route53 delegation set test.")] - public void DelegationSetTests() + public async Task VPCTests() { - List createdSets = new List(); - - var sets = Client.ListReusableDelegationSets(new ListReusableDelegationSetsRequest()); - var setCount = sets.DelegationSets.Count; - - var callerReference = "DNSMigration" + DateTime.UtcNow.ToFileTime(); - var createResponse = Client.CreateReusableDelegationSet(new CreateReusableDelegationSetRequest - { - CallerReference = callerReference - }); - Assert.IsNotNull(createResponse.Location); - var delegationSet = createResponse.DelegationSet; - Assert.IsNotNull(delegationSet); - Assert.IsNotNull(delegationSet.CallerReference); - Assert.IsNotNull(delegationSet.Id); - Assert.IsNotNull(delegationSet.NameServers); - Assert.AreNotEqual(0, delegationSet.NameServers.Count); - createdSets.Add(delegationSet.Id); - - sets = Client.ListReusableDelegationSets(new ListReusableDelegationSetsRequest()); - Assert.AreEqual(setCount + 1, sets.DelegationSets.Count); - - CreateHostedZoneRequest createRequest = new CreateHostedZoneRequest - { - Name = ZONE_NAME, - CallerReference = CALLER_REFERENCE, - HostedZoneConfig = new HostedZoneConfig { Comment = COMMENT }, - DelegationSetId = delegationSet.Id - }; - createdZoneId = UtilityMethods.WaitUntilSuccess(() => - Client.CreateHostedZone(createRequest).HostedZone.Id - ); - - var hostedZoneInfo = Client.GetHostedZone(new GetHostedZoneRequest - { - Id = createdZoneId - }); - Assert.IsNotNull(hostedZoneInfo.VPCs); - Assert.IsFalse(hostedZoneInfo.HostedZone.Config.PrivateZone.Value); - Assert.AreEqual(delegationSet.Id, hostedZoneInfo.DelegationSet.Id); - - var hostedZones = Client.ListHostedZones(new ListHostedZonesRequest - { - DelegationSetId = delegationSet.Id - }).HostedZones; - Assert.AreEqual(1, hostedZones.Count); - - // add a second set - callerReference = "DNSMigration" + DateTime.UtcNow.ToFileTime(); - createResponse = Client.CreateReusableDelegationSet(new CreateReusableDelegationSetRequest - { - CallerReference = callerReference - }); - delegationSet = createResponse.DelegationSet; - createdSets.Add(delegationSet.Id); - - int totalSetCount = 0; - string nextMarker = null; - do - { - var response = Client.ListReusableDelegationSets(new ListReusableDelegationSetsRequest - { - MaxItems = "1", - Marker = nextMarker - }); - totalSetCount += response.DelegationSets.Count; - nextMarker = response.NextMarker; - } while (!string.IsNullOrEmpty(nextMarker)); - Assert.AreEqual(setCount + 2, totalSetCount); - - Client.DeleteHostedZone(new DeleteHostedZoneRequest - { - Id = createdZoneId - }); - createdZoneId = null; - - foreach (var setId in createdSets) - { - Client.DeleteReusableDelegationSet(new DeleteReusableDelegationSetRequest - { - Id = setId - }); - } - - sets = Client.ListReusableDelegationSets(new ListReusableDelegationSetsRequest()); - Assert.AreEqual(setCount, sets.DelegationSets.Count); - } - - [TestMethod] - [TestCategory("Route53")] - public void VPCTests() - { - var vpc1 = CreateVPC(); - var vpc2 = CreateVPC(); + var vpc1 = await CreateVPC(); + var vpc2 = await CreateVPC(); try { - CreateHostedZoneRequest createRequest = new CreateHostedZoneRequest + var createRequest = new CreateHostedZoneRequest { Name = ZONE_NAME, CallerReference = CALLER_REFERENCE, HostedZoneConfig = new HostedZoneConfig { Comment = COMMENT }, VPC = vpc1 }; - createdZoneId = UtilityMethods.WaitUntilSuccess(() => - Client.CreateHostedZone(createRequest).HostedZone.Id - ); - var hostedZoneInfo = Client.GetHostedZone(new GetHostedZoneRequest + await UtilityMethods.WaitUntilAsync(async () => + { + createdZoneId = (await Client.CreateHostedZoneAsync(createRequest)).HostedZone.Id; + }, maxWaitTime); + + var hostedZoneInfo = await Client.GetHostedZoneAsync(new GetHostedZoneRequest { Id = createdZoneId }); @@ -374,86 +295,86 @@ public void VPCTests() Assert.AreEqual(1, hostedZoneInfo.VPCs.Count); Assert.IsTrue(hostedZoneInfo.HostedZone.Config.PrivateZone.Value); - var changeInfo = Client.AssociateVPCWithHostedZone(new AssociateVPCWithHostedZoneRequest + var associateResponse = await Client.AssociateVPCWithHostedZoneAsync(new AssociateVPCWithHostedZoneRequest { VPC = vpc2, Comment = COMMENT, HostedZoneId = createdZoneId - }).ChangeInfo; + }); + var changeInfo = associateResponse.ChangeInfo; Assert.IsNotNull(changeInfo); Assert.IsNotNull(changeInfo.Comment); - assertValidChangeInfo(changeInfo); + AssertValidChangeInfo(changeInfo); - hostedZoneInfo = Client.GetHostedZone(new GetHostedZoneRequest + hostedZoneInfo = await Client.GetHostedZoneAsync(new GetHostedZoneRequest { Id = createdZoneId }); Assert.IsNotNull(hostedZoneInfo.VPCs); Assert.AreEqual(2, hostedZoneInfo.VPCs.Count); - changeInfo = Client.DisassociateVPCFromHostedZone(new DisassociateVPCFromHostedZoneRequest + var disassociateResponse = await Client.DisassociateVPCFromHostedZoneAsync(new DisassociateVPCFromHostedZoneRequest { HostedZoneId = createdZoneId, VPC = vpc2 - }).ChangeInfo; - assertValidChangeInfo(changeInfo); + }); + changeInfo = disassociateResponse.ChangeInfo; + AssertValidChangeInfo(changeInfo); - hostedZoneInfo = Client.GetHostedZone(new GetHostedZoneRequest + hostedZoneInfo = await Client.GetHostedZoneAsync(new GetHostedZoneRequest { Id = createdZoneId }); Assert.IsNotNull(hostedZoneInfo.VPCs); Assert.AreEqual(1, hostedZoneInfo.VPCs.Count); - changeInfo = Client.DeleteHostedZone(new DeleteHostedZoneRequest + var deleteResponse = await Client.DeleteHostedZoneAsync(new DeleteHostedZoneRequest { Id = createdZoneId - }).ChangeInfo; - assertValidChangeInfo(changeInfo); + }); + changeInfo = deleteResponse.ChangeInfo; + AssertValidChangeInfo(changeInfo); } finally { - DeleteVPC(vpc1); - DeleteVPC(vpc2); + await DeleteVPC(vpc1); + await DeleteVPC(vpc2); } } - // Deletes a VPC - private void DeleteVPC(VPC vpc) + private async Task DeleteVPC(VPC vpc) { using (var ec2 = new Amazon.EC2.AmazonEC2Client()) { - ec2.DeleteVpc(new Amazon.EC2.Model.DeleteVpcRequest + await ec2.DeleteVpcAsync(new Amazon.EC2.Model.DeleteVpcRequest { VpcId = vpc.VPCId }); } } - // Creates a VPC - private VPC CreateVPC() + private async Task CreateVPC() { var region = VPCRegion.FindValue(AWSConfigs.RegionEndpoint.SystemName); - - using(var ec2 = new Amazon.EC2.AmazonEC2Client()) + using (var ec2 = new Amazon.EC2.AmazonEC2Client()) { - var ec2Vpc = ec2.CreateVpc(new Amazon.EC2.Model.CreateVpcRequest + var createResponse = await ec2.CreateVpcAsync(new Amazon.EC2.Model.CreateVpcRequest { CidrBlock = "10.0.0.0/16", InstanceTenancy = Amazon.EC2.Tenancy.Default - }).Vpc; + }); return new VPC { VPCRegion = region, - VPCId = ec2Vpc.VpcId + VPCId = createResponse.Vpc.VpcId }; } } // Asserts that the specified HostedZone is valid and represents the same // HostedZone that we initially created at the very start of this test. - private void assertValidCreatedHostedZone(HostedZone hostedZone) + private void AssertValidCreatedHostedZone(HostedZone hostedZone) { Assert.AreEqual(ZONE_NAME, hostedZone.Name); Assert.IsNotNull(hostedZone.Id); @@ -461,7 +382,7 @@ private void assertValidCreatedHostedZone(HostedZone hostedZone) } // Asserts that the specified DelegationSet is valid. - private void assertValidDelegationSet(DelegationSet delegationSet) + private void AssertValidDelegationSet(DelegationSet delegationSet) { Assert.IsTrue(delegationSet.NameServers.Count > 0); foreach (string server in delegationSet.NameServers) @@ -471,7 +392,7 @@ private void assertValidDelegationSet(DelegationSet delegationSet) } // Asserts that the specified ChangeInfo is valid. - private void assertValidChangeInfo(ChangeInfo change) + private void AssertValidChangeInfo(ChangeInfo change) { Assert.IsNotNull(change.Id); Assert.IsNotNull(change.Status); diff --git a/sdk/test/Services/Route53Domains/IntegrationTests/AWSSDK.IntegrationTests.Route53Domains.NetFramework.csproj b/sdk/test/Services/Route53Domains/IntegrationTests/AWSSDK.IntegrationTests.Route53Domains.NetFramework.csproj deleted file mode 100644 index e5eb357829c7..000000000000 --- a/sdk/test/Services/Route53Domains/IntegrationTests/AWSSDK.IntegrationTests.Route53Domains.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.Route53Domains.NetFramework - AWSSDK.IntegrationTests.Route53Domains.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/Route53Domains/IntegrationTests/Config/462/App.config b/sdk/test/Services/Route53Domains/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/Route53Domains/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/Route53Domains/IntegrationTests/Route53Domains.cs b/sdk/test/Services/Route53Domains/IntegrationTests/Route53Domains.cs deleted file mode 100644 index 3ab9a09899b5..000000000000 --- a/sdk/test/Services/Route53Domains/IntegrationTests/Route53Domains.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using Amazon.Route53Domains; -using Amazon.Route53Domains.Model; -using AWSSDK_DotNet.IntegrationTests.Utils; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class Route53Domains : TestBase - { - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - [TestMethod] - [TestCategory("Route53Domains")] - public void CheckDomainAvailabilityTest() - { - var checkRequest = new CheckDomainAvailabilityRequest - { - DomainName = "mydomain1111111111111.com" - }; - var response = Client.CheckDomainAvailability(checkRequest); - Assert.AreEqual(DomainAvailability.AVAILABLE, response.Availability); - - checkRequest = new CheckDomainAvailabilityRequest - { - DomainName = "mydomain1111111111111.fake" - }; - AssertExtensions.ExpectException(() => Client.CheckDomainAvailability(checkRequest)); - - var domains = Client.ListDomains().Domains; - if (domains.Count > 0) - { - checkRequest.DomainName = domains[0].DomainName; - response = Client.CheckDomainAvailability(checkRequest); - Assert.AreEqual(DomainAvailability.UNAVAILABLE, response.Availability); - } - } - - [TestMethod] - [TestCategory("Route53Domains")] - public void TestTagging() - { - var domains = Client.ListDomains().Domains; - if (domains.Count > 0) - { - TestTagging(Client, domains[0].DomainName); - } - } - - private void TestTagging(AmazonRoute53DomainsClient client, string domain) - { - var existingTags = client.ListTagsForDomain(domain).TagList; - - client.UpdateTagsForDomain(domain, - new List -         { -             new Tag { Key = "tag1", Value = "42" }, -             new Tag { Key = "tag2", Value = "ALL" } -         }); - - var tags = client.ListTagsForDomain(domain).TagList; - var count = tags.Count; - Assert.AreEqual(2, count); - - client.DeleteTagsForDomain(domain, new List { "tag1" }); - - tags = client.ListTagsForDomain(domain).TagList; - count = tags.Count; - Assert.AreEqual(1, count); - - // Restore previous tags - if (existingTags.Count > 0) - client.UpdateTagsForDomain(domain, existingTags); - else - client.DeleteTagsForDomain(domain, new List { "tag2" }); - - tags = client.ListTagsForDomain(domain).TagList; - count = tags.Count; - Assert.AreEqual(existingTags.Count, count); - } - } -} diff --git a/sdk/test/Services/S3/IntegrationTests/KMSTests.cs b/sdk/test/Services/S3/IntegrationTests/KMSTests.cs index e3abb8d93a2f..d3d1fc9b41e4 100644 --- a/sdk/test/Services/S3/IntegrationTests/KMSTests.cs +++ b/sdk/test/Services/S3/IntegrationTests/KMSTests.cs @@ -1,21 +1,18 @@ -using System; -using System.Linq; -using System.IO; -using System.Text; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using AWSSDK_DotNet.IntegrationTests.Utils; - +using Amazon; +using Amazon.KeyManagementService; +using Amazon.Runtime; using Amazon.S3; using Amazon.S3.Model; -using Amazon.S3.Util; using Amazon.S3.Transfer; -using System.Security.Cryptography; -using System.Net; -using Amazon.Runtime; -using Amazon; -using System.Collections.Generic; +using Amazon.S3.Util; using Amazon.Util; +using AWSSDK_DotNet.IntegrationTests.Utils; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Collections.Generic; +using System.IO; +using System.Net; +using System.Text; namespace AWSSDK_DotNet.IntegrationTests.Tests.S3 { @@ -268,9 +265,10 @@ public void TestKmsDssePresignedUrls() [TestCategory("S3")] public void SpecificKeyTests() { - var keyId = KeyManagementService.Client.CreateKey(new Amazon.KeyManagementService.Model.CreateKeyRequest + var kms = new AmazonKeyManagementServiceClient(Client.Config.RegionEndpoint); + var keyId = kms.CreateKey(new Amazon.KeyManagementService.Model.CreateKeyRequest { - KeyUsage = Amazon.KeyManagementService.KeyUsageType.ENCRYPT_DECRYPT, + KeyUsage = KeyUsageType.ENCRYPT_DECRYPT, Description = ".NET SDK S3 Test Key" }).KeyMetadata.KeyId; diff --git a/sdk/test/Services/S3Control/IntegrationTests/PublicAccessBlockTests.cs b/sdk/test/Services/S3Control/IntegrationTests/PublicAccessBlockTests.cs index 2f5fec494fae..01ec9c164b8c 100644 --- a/sdk/test/Services/S3Control/IntegrationTests/PublicAccessBlockTests.cs +++ b/sdk/test/Services/S3Control/IntegrationTests/PublicAccessBlockTests.cs @@ -3,25 +3,25 @@ using Amazon.S3Control.Model; using Amazon.SecurityToken; using Amazon.SecurityToken.Model; -using Amazon.Runtime; +using Amazon.Util; using Microsoft.VisualStudio.TestTools.UnitTesting; using System; -using System.IO; -using Amazon.Util; +using System.Threading.Tasks; namespace AWSSDK_DotNet.IntegrationTests.Tests.S3Control { [TestClass] + [TestCategory("S3Control")] public class PublicAccessBlockTests : TestBase { private string accountId; - private AmazonS3ControlClient client; [TestInitialize] - public void Initialize() + public async Task Initialize() { - accountId = new AmazonSecurityTokenServiceClient().GetCallerIdentity(new GetCallerIdentityRequest()).Account; + var response = await new AmazonSecurityTokenServiceClient().GetCallerIdentityAsync(new GetCallerIdentityRequest()); + accountId = response.Account; client = new AmazonS3ControlClient(RegionEndpoint.USEast1); } @@ -32,45 +32,47 @@ public void TestCleanup() } [TestMethod] - [TestCategory("S3Control")] - public void TestPublicAccessBlock() + public async Task TestPublicAccessBlock() { - client.PutPublicAccessBlock(new PutPublicAccessBlockRequest + await client.PutPublicAccessBlockAsync(new PutPublicAccessBlockRequest { AccountId = accountId, - PublicAccessBlockConfiguration = new PublicAccessBlockConfiguration() + PublicAccessBlockConfiguration = new PublicAccessBlockConfiguration { BlockPublicPolicy = false } }); - var response = client.GetPublicAccessBlock(new GetPublicAccessBlockRequest() + + var response = await client.GetPublicAccessBlockAsync(new GetPublicAccessBlockRequest { AccountId = accountId }); + Assert.IsTrue(response.ResponseMetadata.Metadata.ContainsKey(HeaderKeys.XAmzId2Header)); Assert.IsFalse(response.PublicAccessBlockConfiguration.BlockPublicPolicy.Value); - client.DeletePublicAccessBlock(new DeletePublicAccessBlockRequest() + + await client.DeletePublicAccessBlockAsync(new DeletePublicAccessBlockRequest { AccountId = accountId }); } [TestMethod] - [TestCategory("S3Control")] - public void TestPublicAccessBlockException() + public async Task TestPublicAccessBlockException() { - var exception = Assert.ThrowsException(() => + var exception = await Assert.ThrowsExceptionAsync(async () => { - client.PutPublicAccessBlock(new PutPublicAccessBlockRequest + await client.PutPublicAccessBlockAsync(new PutPublicAccessBlockRequest { AccountId = "0000", - PublicAccessBlockConfiguration = new PublicAccessBlockConfiguration() + PublicAccessBlockConfiguration = new PublicAccessBlockConfiguration { BlockPublicPolicy = false } }); }); - Assert.IsFalse(String.IsNullOrEmpty(exception.AmazonId2)); + + Assert.IsFalse(string.IsNullOrEmpty(exception.AmazonId2)); } } } \ No newline at end of file diff --git a/sdk/test/Services/SQS/IntegrationTests/SQS.cs b/sdk/test/Services/SQS/IntegrationTests/SQS.cs index ea57c87e7fe2..47b7e6afd58c 100644 --- a/sdk/test/Services/SQS/IntegrationTests/SQS.cs +++ b/sdk/test/Services/SQS/IntegrationTests/SQS.cs @@ -1,22 +1,19 @@ +using Amazon; +using Amazon.SQS; +using Amazon.SQS.Model; +using Amazon.SQS.Util; +using Microsoft.VisualStudio.TestTools.UnitTesting; using System; -using System.Linq; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Text; -using System.Threading; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using Amazon.SQS; -using Amazon.SQS.Model; -using Amazon.SQS.Util; -using Amazon; +using System.Threading.Tasks; namespace AWSSDK_DotNet.IntegrationTests.Tests { - /// - /// Summary description for SQSIntegrationTest - /// [TestClass] + [TestCategory("SQS")] public class SQS : TestBase { private const string prefix = "TestQueue"; @@ -29,53 +26,57 @@ public static void Cleanup() } [TestInitialize] - public void TestInit() + public async Task TestInit() { - var result = Client.ListQueues(new ListQueuesRequest()); + var result = await Client.ListQueuesAsync(new ListQueuesRequest()); Assert.IsNotNull(result); + if (result.QueueUrls == null) + { Assert.IsFalse(AWSConfigs.InitializeCollections); + } else + { Assert.IsNotNull(result.QueueUrls); + } } [TestCleanup] - public void SQSCleanup() + public async Task SQSCleanup() { - var result = Client.ListQueues(new ListQueuesRequest()); - if (result.QueueUrls != null) + var result = await Client.ListQueuesAsync(new ListQueuesRequest()); + if (result.QueueUrls == null) + { + return; + } + + foreach (string queue in result.QueueUrls) { - foreach (string queue in result.QueueUrls) + if (queue.Contains("TestQueue")) { - Console.WriteLine("Queue: {0}", queue); - if (queue.Contains("TestQueue")) + try { - try - { - Client.DeleteQueue(new DeleteQueueRequest() { QueueUrl = queue }); - } - catch (Exception) - { - Console.Write("Failed to clean up queue {0}", queue); - } + await Client.DeleteQueueAsync(new DeleteQueueRequest { QueueUrl = queue }); + } + catch + { + Console.Write("Failed to clean up queue {0}", queue); } } } } [TestMethod] - [TestCategory("SQS")] - public void SQSDLQTest() + public async Task SQSDLQTest() { string mainQueueName = prefix + new Random().Next() + "MQ"; - string mainQueueURL = createQueueTest(mainQueueName); + string mainQueueURL = await CreateQueueTest(mainQueueName); string deadQueueName = prefix + new Random().Next() + "DLQ"; - string deadQueueURL = createQueueTest(deadQueueName); - - string deadQueueArn = getQueueArn(deadQueueURL); + string deadQueueURL = await CreateQueueTest(deadQueueName); + string deadQueueArn = await GetQueueArn(deadQueueURL); string redrivePolicy = string.Format(@"{{""maxReceiveCount"" : 5, ""deadLetterTargetArn"" : ""{0}""}}", deadQueueArn); - Client.SetQueueAttributes(new SetQueueAttributesRequest + await Client.SetQueueAttributesAsync(new SetQueueAttributesRequest { QueueUrl = mainQueueURL, Attributes = new Dictionary @@ -85,36 +86,38 @@ public void SQSDLQTest() }); // Wait a bit to make sure the attribute has fully propagated. - Thread.Sleep(1000); + await Task.Delay(1000); - var response = Client.ListDeadLetterSourceQueues(new ListDeadLetterSourceQueuesRequest + var response = await Client.ListDeadLetterSourceQueuesAsync(new ListDeadLetterSourceQueuesRequest { QueueUrl = deadQueueURL }); Assert.IsNotNull(response); Assert.IsNotNull(response.QueueUrls); Assert.AreEqual(1, response.QueueUrls.Count); + var metadata = response.ResponseMetadata; Assert.IsNotNull(metadata); Assert.IsNotNull(metadata.RequestId); } [TestMethod] - [TestCategory("SQS")] - public void SimpleSend() + public async Task SimpleSend() { int maxMessageLength = 20 * 1024; string queueName = prefix + new Random().Next(); - string queueURL; - queueURL = createQueueTest(queueName); + var queueURL = await CreateQueueTest(queueName); + StringBuilder sb = new StringBuilder("The quick brown fox jumped over the lazy dog"); string messageBody = sb.ToString(); if (messageBody.Length > maxMessageLength) + { messageBody = messageBody.Substring(0, maxMessageLength); + } - TestSendMessage(Client, queueURL, messageBody); - TestSendMessageBatch(Client, queueURL, messageBody); - TestReceiveMessage(Client, queueURL); + await TestSendMessage(Client, queueURL, messageBody); + await TestSendMessageBatch(Client, queueURL, messageBody); + await TestReceiveMessage(Client, queueURL); } static Dictionary messageAttributes = new Dictionary @@ -126,9 +129,9 @@ public void SimpleSend() { "lowercasestringattribute", new MessageAttributeValue { DataType = "String", StringValue = "lowercasestringattribute" } }, }; - private static void TestReceiveMessage(IAmazonSQS client, string queueURL) + private static async Task TestReceiveMessage(IAmazonSQS client, string queueURL) { - var receiveResponse = client.ReceiveMessage(new ReceiveMessageRequest { QueueUrl = queueURL }); + var receiveResponse = await client.ReceiveMessageAsync(new ReceiveMessageRequest { QueueUrl = queueURL }); var messages = receiveResponse.Messages; foreach (var message in messages) { @@ -136,7 +139,7 @@ private static void TestReceiveMessage(IAmazonSQS client, string queueURL) } } - private static void TestSendMessage(IAmazonSQS client, string queueURL, string messageBody) + private static async Task TestSendMessage(IAmazonSQS client, string queueURL, string messageBody) { var request = new SendMessageRequest { @@ -144,11 +147,12 @@ private static void TestSendMessage(IAmazonSQS client, string queueURL, string m QueueUrl = queueURL, MessageAttributes = messageAttributes }; - var response = client.SendMessage(request); + var response = await client.SendMessageAsync(request); ValidateMD5(request.MessageBody, response.MD5OfMessageBody); } - private static void TestSendMessageBatch(IAmazonSQS client, string queueUrl, string messageBody) + + private static async Task TestSendMessageBatch(IAmazonSQS client, string queueUrl, string messageBody) { var request = new SendMessageBatchRequest { @@ -161,100 +165,70 @@ private static void TestSendMessageBatch(IAmazonSQS client, string queueUrl, str } } }; - var response = client.SendMessageBatch(request); - + + var response = await client.SendMessageBatchAsync(request); ValidateMD5(request.Entries[0].MessageBody, response.Successful[0].MD5OfMessageBody); } - public static string Reverse(string s) - { - char[] charArray = s.ToCharArray(); - Array.Reverse(charArray); - return new string(charArray); - } - - private static string CalculateMD5(string message) - { - return Amazon.SQS.Internal.ValidationResponseHandler.CalculateMD5(message); - } private static void ValidateMD5(string message, string md5) { Amazon.SQS.Internal.ValidationResponseHandler.ValidateMD5(message, md5); } [TestMethod] - [TestCategory("SQS")] - public void TestGetQueueUrl() + public async Task TestGetQueueUrl() { - Client.ListQueues(new ListQueuesRequest()); - string queueName = "TestGetQueueUrl" + DateTime.UtcNow.Ticks; - CreateQueueResponse createResponse = Client.CreateQueue(new CreateQueueRequest() + var queueName = "TestGetQueueUrl" + DateTime.UtcNow.Ticks; + var createResponse = await Client.CreateQueueAsync(new CreateQueueRequest { QueueName = queueName }); + try { - GetQueueUrlRequest request = new GetQueueUrlRequest() { QueueName = queueName }; - GetQueueUrlResponse response = Client.GetQueueUrl(request); + var request = new GetQueueUrlRequest { QueueName = queueName }; + var response = await Client.GetQueueUrlAsync(request); Assert.AreEqual(createResponse.QueueUrl, response.QueueUrl); } finally { - Client.DeleteQueue(new DeleteQueueRequest() { QueueUrl = createResponse.QueueUrl }); + await Client.DeleteQueueAsync(new DeleteQueueRequest { QueueUrl = createResponse.QueueUrl }); } } - private string getQueueArn(string queueUrl) + private async Task GetQueueArn(string queueUrl) { - return Client.GetQueueAttributes(new GetQueueAttributesRequest + var getResponse = await Client.GetQueueAttributesAsync(new GetQueueAttributesRequest { AttributeNames = new List { "All" }, QueueUrl = queueUrl - }).QueueARN; + }); + + return getResponse.QueueARN; } - private void deleteQueueTest(string queueUrl) + private async Task CreateQueueTest(string name) { - var listResult = Client.ListQueues(new ListQueuesRequest() { QueueNamePrefix = prefix }); - int count = listResult.QueueUrls.Count; - - Client.DeleteQueue(new DeleteQueueRequest() { QueueUrl = queueUrl }); - for (int i = 0; i < 10; i++) + var result = await Client.CreateQueueAsync(new CreateQueueRequest { - listResult = Client.ListQueues(new ListQueuesRequest() { QueueNamePrefix = prefix }); - if (listResult.QueueUrls == null || count - 1 == listResult.QueueUrls.Count) + QueueName = name, + Attributes = new Dictionary { - return; + { SQSConstants.ATTRIBUTE_VISIBILITY_TIMEOUT, defaultTimeout } } - Console.WriteLine("Sleeping 10s while queue is being deleted"); - Thread.Sleep(10000); - } - } - - private string createQueueTest(string name) - { - var result = Client.CreateQueue( - new CreateQueueRequest() - { - QueueName = name, - Attributes = new Dictionary - { - {SQSConstants.ATTRIBUTE_VISIBILITY_TIMEOUT,defaultTimeout} - } - }); + }); Assert.IsNotNull(result); Assert.IsNotNull(result.QueueUrl); - var attrResults = Client.GetQueueAttributes(new GetQueueAttributesRequest() + var attrResults = await Client.GetQueueAttributesAsync(new GetQueueAttributesRequest { QueueUrl = result.QueueUrl, - AttributeNames = new List() { SQSConstants.ATTRIBUTE_ALL } + AttributeNames = new List { SQSConstants.ATTRIBUTE_ALL } }); // if a new attribute has been added, then it's necessary to also update // SQSConstants and the GetQueueAttributesResponse.Extensions Assert.AreEqual(12, attrResults.Attributes.Count); - Assert.AreEqual(int.Parse(defaultTimeout), int.Parse(attrResults.Attributes[SQSConstants.ATTRIBUTE_VISIBILITY_TIMEOUT])); Assert.AreEqual(false, attrResults.FifoQueue); Assert.AreEqual(false, attrResults.ContentBasedDeduplication.HasValue); @@ -262,49 +236,44 @@ private string createQueueTest(string name) for (int i = 0; i < 30; i++) { - var listResult = Client.ListQueues(new ListQueuesRequest() { QueueNamePrefix = prefix }); + var listResult = await Client.ListQueuesAsync(new ListQueuesRequest { QueueNamePrefix = prefix }); if (listResult.QueueUrls.FirstOrDefault(x => x == result.QueueUrl) != null) + { return result.QueueUrl; + } - Console.WriteLine("Sleeping 10s while queue is being created"); - Thread.Sleep(2000); + await Task.Delay(TimeSpan.FromSeconds(2)); } - Assert.Fail("Queue never created"); + Assert.Fail("Queue never created"); return "fail"; } [TestMethod] - [TestCategory("SQS")] - public void SQSFIFOTest() + public async Task SQSFIFOTest() { - string fifoQueueName = prefix + new Random().Next() + ".fifo"; - - using (var sqsClient = new AmazonSQSClient(RegionEndpoint.USEast2)) + var fifoQueueName = prefix + new Random().Next() + ".fifo"; + var result = await Client.CreateQueueAsync(new CreateQueueRequest { - var result = sqsClient.CreateQueue(new CreateQueueRequest() + QueueName = fifoQueueName, + Attributes = new Dictionary { - QueueName = fifoQueueName, - Attributes = new Dictionary - { - { SQSConstants.ATTRIBUTE_FIFO_QUEUE, "true" }, - { SQSConstants.ATTRIBUTE_CONTENT_BASED_DEDUPLICATION , "true" } - } - }); - - Assert.IsNotNull(result); - Assert.IsNotNull(result.QueueUrl); + { SQSConstants.ATTRIBUTE_FIFO_QUEUE, "true" }, + { SQSConstants.ATTRIBUTE_CONTENT_BASED_DEDUPLICATION , "true" } + } + }); - var attrResults = sqsClient.GetQueueAttributes(new GetQueueAttributesRequest() - { - QueueUrl = result.QueueUrl, - AttributeNames = new List() { SQSConstants.ATTRIBUTE_FIFO_QUEUE, SQSConstants.ATTRIBUTE_CONTENT_BASED_DEDUPLICATION } - }); + Assert.IsNotNull(result); + Assert.IsNotNull(result.QueueUrl); - Assert.AreEqual(true, attrResults.FifoQueue); + var attrResults = await Client.GetQueueAttributesAsync(new GetQueueAttributesRequest + { + QueueUrl = result.QueueUrl, + AttributeNames = new List { SQSConstants.ATTRIBUTE_FIFO_QUEUE, SQSConstants.ATTRIBUTE_CONTENT_BASED_DEDUPLICATION } + }); - Assert.AreEqual(true, attrResults.ContentBasedDeduplication); - } + Assert.AreEqual(true, attrResults.FifoQueue); + Assert.AreEqual(true, attrResults.ContentBasedDeduplication); } } } diff --git a/sdk/test/Services/SecurityToken/IntegrationTests/AWSSDK.IntegrationTests.SecurityToken.NetFramework.csproj b/sdk/test/Services/SecurityToken/IntegrationTests/AWSSDK.IntegrationTests.SecurityToken.NetFramework.csproj deleted file mode 100644 index 832ab98fb252..000000000000 --- a/sdk/test/Services/SecurityToken/IntegrationTests/AWSSDK.IntegrationTests.SecurityToken.NetFramework.csproj +++ /dev/null @@ -1,51 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.SecurityToken.NetFramework - AWSSDK.IntegrationTests.SecurityToken.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/SecurityToken/IntegrationTests/AssumeRole.cs b/sdk/test/Services/SecurityToken/IntegrationTests/AssumeRole.cs deleted file mode 100644 index 3e3c2470de52..000000000000 --- a/sdk/test/Services/SecurityToken/IntegrationTests/AssumeRole.cs +++ /dev/null @@ -1,160 +0,0 @@ -using System; -using System.Threading; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using Amazon.Runtime; -using Amazon.SecurityToken; -using Amazon.SecurityToken.Model; -using Amazon.IdentityManagement; -using Amazon.IdentityManagement.Model; - -using AWSSDK_DotNet.IntegrationTests.Utils; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class AssumeRoleTest : TestBase - { - string _now; - string _roleName; - string _userName; - Role _role; - User _user; - BasicAWSCredentials _userCredentials; - string _accessKeyId; - - [ClassCleanup] - public static void ClassCleanup() - { - BaseClean(); - } - - [TestInitialize] - public void Init() - { - _now = DateTime.UtcNow.ToFileTime().ToString(); - _roleName = "assume-role-" + _now; - _userName = "assume-user-" + _now; - - _role = Client.CreateRole(new CreateRoleRequest - { - RoleName = _roleName, - AssumeRolePolicyDocument = @"{ - ""Statement"": - [ - { - ""Principal"":{""AWS"":""{AccountId}""}, - ""Effect"":""Allow"", - ""Action"":[""sts:AssumeRole""] - } - ] -}".Replace("{AccountId}", UtilityMethods.AccountId) - }).Role; - - Client.PutRolePolicy(new PutRolePolicyRequest - { - RoleName = _role.RoleName, - PolicyName = "god-mode", - PolicyDocument = @"{ - ""Statement"" : [ - { - ""Effect"" : ""Allow"", - ""Action"" : ""*"", - ""Resource"" : ""*"" - } - ] -}" - }); - - _user = Client.CreateUser(new CreateUserRequest - { - UserName = _userName - }).User; - - Client.PutUserPolicy(new PutUserPolicyRequest - { - UserName = _user.UserName, - PolicyName = "assume-policy-1", - PolicyDocument = @"{ - ""Statement"":{ - ""Effect"":""Allow"", - ""Action"":""sts:AssumeRole"", - ""Resource"":""*"" - } - }" - }); - - var accessKey = Client.CreateAccessKey(new CreateAccessKeyRequest - { - UserName = _user.UserName - }).AccessKey; - - _accessKeyId = accessKey.AccessKeyId; - _userCredentials = new BasicAWSCredentials(accessKey.AccessKeyId, accessKey.SecretAccessKey); - } - - [TestCleanup] - public void Cleanup() - { - var rolePolicies = Client.ListRolePolicies(new ListRolePoliciesRequest { RoleName = _roleName }).PolicyNames; - foreach (var policy in rolePolicies) - { - Client.DeleteRolePolicy(new DeleteRolePolicyRequest - { - RoleName = _roleName, - PolicyName = policy - }); - } - Client.DeleteRole(new DeleteRoleRequest { RoleName = _roleName }); - - var userPolicies = Client.ListUserPolicies(new ListUserPoliciesRequest { UserName = _userName }).PolicyNames; - foreach (var policy in userPolicies) - { - Client.DeleteUserPolicy(new DeleteUserPolicyRequest - { - UserName = _userName, - PolicyName = policy - }); - } - Client.DeleteAccessKey(new DeleteAccessKeyRequest - { - UserName = _userName, - AccessKeyId = _accessKeyId - }); - Client.DeleteUser(new DeleteUserRequest { UserName = _userName }); - } - - [Ignore("Excluding tests that need IAM Write/Permissions management.")] - [TestMethod] - [TestCategory("SecurityToken")] - public void TestAssumeRole() - { - var clientId = Guid.NewGuid(); - var roleArn = _role.Arn; - const string sessionName = "NetUser"; - - // sleep for IAM data to propagate - Thread.Sleep(TimeSpan.FromSeconds(10)); - var sts = new AmazonSecurityTokenServiceClient(_userCredentials); - Thread.Sleep(TimeSpan.FromSeconds(60)); - var result = sts.AssumeRole(new AssumeRoleRequest - { - RoleArn = roleArn, - RoleSessionName = sessionName, - DurationSeconds = 3600, - ExternalId = clientId.ToString() - }); - - var credentials = result.Credentials; - - var sessionCredentials = new SessionAWSCredentials(credentials.AccessKeyId, credentials.SecretAccessKey, credentials.SessionToken); - var client = new AmazonIdentityManagementServiceClient(sessionCredentials); - var response = client.ListRoles(); - Assert.IsNotNull(response); - - client = new AmazonIdentityManagementServiceClient(credentials); - response = client.ListRoles(); - Assert.IsNotNull(response); - } - } -} diff --git a/sdk/test/Services/SecurityToken/IntegrationTests/Config/462/App.config b/sdk/test/Services/SecurityToken/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/SecurityToken/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/SecurityToken/IntegrationTests/GetFederationToken.cs b/sdk/test/Services/SecurityToken/IntegrationTests/GetFederationToken.cs deleted file mode 100644 index 6b7bb8fcc2f4..000000000000 --- a/sdk/test/Services/SecurityToken/IntegrationTests/GetFederationToken.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System; -using System.Threading; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using Amazon.SecurityToken; -using Amazon.SecurityToken.Model; - -using AWSSDK_DotNet.IntegrationTests.Utils; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - [TestCategory("RequiresIAMUser")] - public class GetFederationTokenTest : TestBase - { - - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - [TestMethod] - [TestCategory("SecurityToken")] - public void TestGetFederationToken() - { - var gftRequest = new GetFederationTokenRequest - { - Policy = @"{""Statement"":[{""Effect"":""Allow"",""Action"":""*"",""Resource"":""*""}]}", - Name = "BillyBob", - DurationSeconds = 3600 - }; - var gftResult = Client.GetFederationToken(gftRequest); - - Assert.IsNotNull(gftResult.Credentials.AccessKeyId); - Assert.IsNotNull(gftResult.Credentials.SecretAccessKey); - Assert.IsNotNull(gftResult.Credentials.SessionToken); - Assert.IsNotNull(gftResult.Credentials.Expiration); - - var time = DateTime.UtcNow; - var approximateExpires = time.AddHours(1); - var expiresAfter = approximateExpires.AddMinutes(-5); - var expiresBefore = approximateExpires.AddMinutes(5); - var expires = gftResult.Credentials.Expiration; - - Assert.IsTrue(expires > expiresAfter); - Assert.IsTrue(expires < expiresBefore); - - Assert.IsNotNull(gftResult.FederatedUser.FederatedUserId); - Assert.IsNotNull(gftResult.FederatedUser.Arn); - - Assert.IsTrue(gftResult.FederatedUser.FederatedUserId.EndsWith(gftRequest.Name, StringComparison.OrdinalIgnoreCase)); - Assert.IsTrue(gftResult.FederatedUser.Arn.EndsWith(gftRequest.Name, StringComparison.OrdinalIgnoreCase)); - } - - [TestMethod] - [TestCategory("SecurityToken")] - public void TestGetFederationTokenAsync() - { - var gftRequest = new GetFederationTokenRequest - { - Policy = @"{""Statement"":[{""Effect"":""Allow"",""Action"":""*"",""Resource"":""*""}]}", - Name = "BillyBob", - DurationSeconds = 3600 - }; - - GetFederationTokenResponse asyncResponse = null; - -#if ASYNC_AWAIT - var task = Client.GetFederationTokenAsync(gftRequest); - asyncResponse = task.Result; -#else - var asyncResult = Client.BeginGetFederationToken(gftRequest, - ar => - { - var client = ar.AsyncState as AmazonSecurityTokenServiceClient; - asyncResponse = client.EndGetFederationToken(ar); - } - , Client); - asyncResult.AsyncWaitHandle.WaitOne(); -#endif - - Thread.Sleep(TimeSpan.FromSeconds(5)); - Assert.IsNotNull(asyncResponse); - - var gftResult = asyncResponse; - Assert.IsNotNull(gftResult); - Assert.IsNotNull(gftResult.Credentials.AccessKeyId); - Assert.IsNotNull(gftResult.Credentials.SecretAccessKey); - Assert.IsNotNull(gftResult.Credentials.SessionToken); - Assert.IsNotNull(gftResult.Credentials.Expiration); - - var time = DateTime.UtcNow; - var approximateExpires = time.AddHours(1); - var expiresAfter = approximateExpires.AddMinutes(-5); - var expiresBefore = approximateExpires.AddMinutes(5); - var expires = gftResult.Credentials.Expiration; - - Assert.IsTrue(expires > expiresAfter); - Assert.IsTrue(expires < expiresBefore); - - Assert.IsNotNull(gftResult.FederatedUser.FederatedUserId); - Assert.IsNotNull(gftResult.FederatedUser.Arn); - - Assert.IsTrue(gftResult.FederatedUser.FederatedUserId.EndsWith(gftRequest.Name, StringComparison.OrdinalIgnoreCase)); - Assert.IsTrue(gftResult.FederatedUser.Arn.EndsWith(gftRequest.Name, StringComparison.OrdinalIgnoreCase)); - } - } -} diff --git a/sdk/test/Services/SecurityToken/IntegrationTests/GetSessionToken.cs b/sdk/test/Services/SecurityToken/IntegrationTests/GetSessionToken.cs deleted file mode 100644 index 8f9d705d7731..000000000000 --- a/sdk/test/Services/SecurityToken/IntegrationTests/GetSessionToken.cs +++ /dev/null @@ -1,122 +0,0 @@ -using System; -using System.Threading; -using Amazon; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using AWSSDK_DotNet.IntegrationTests.Utils; - -using Amazon.SecurityToken; -using Amazon.SecurityToken.Model; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - [TestCategory("RequiresIAMUser")] - public class GetSessionToken : TestBase - { - - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - [TestMethod] - [TestCategory("SecurityToken")] - public void TestGetSessionToken() - { - var gstRequest = new GetSessionTokenRequest() - { - DurationSeconds = 3600 - }; - - var gstResult = Client.GetSessionToken(gstRequest); - - Assert.IsNotNull(gstResult.Credentials.AccessKeyId); - Assert.IsNotNull(gstResult.Credentials.SecretAccessKey); - Assert.IsNotNull(gstResult.Credentials.SessionToken); - Assert.IsNotNull(gstResult.Credentials.Expiration); - - var time = DateTime.UtcNow; - var approximateExpires = time.AddHours(1); - var expiresAfter = approximateExpires.AddMinutes(-5); - var expiresBefore = approximateExpires.AddMinutes(5); - var expires = gstResult.Credentials.Expiration; - - Assert.IsTrue(expires > expiresAfter); - Assert.IsTrue(expires < expiresBefore); - } - - [TestMethod] - [TestCategory("SecurityToken")] - public void TestGetSessionTokenRegional() - { - var uswest2Client = new AmazonSecurityTokenServiceClient(RegionEndpoint.USWest2); - var gstRequest = new GetSessionTokenRequest() - { - DurationSeconds = 3600 - }; - - var gstResult = uswest2Client.GetSessionToken(gstRequest); - - Assert.IsNotNull(gstResult.Credentials.AccessKeyId); - Assert.IsNotNull(gstResult.Credentials.SecretAccessKey); - Assert.IsNotNull(gstResult.Credentials.SessionToken); - Assert.IsNotNull(gstResult.Credentials.Expiration); - - var time = DateTime.UtcNow; - var approximateExpires = time.AddHours(1); - var expiresAfter = approximateExpires.AddMinutes(-5); - var expiresBefore = approximateExpires.AddMinutes(5); - var expires = gstResult.Credentials.Expiration; - - Assert.IsTrue(expires > expiresAfter); - Assert.IsTrue(expires < expiresBefore); - } - - [TestMethod] - [TestCategory("SecurityToken")] - public void TestGetSessionTokenAsync() - { - var gstRequest = new GetSessionTokenRequest() - { - DurationSeconds = 3600 - }; - - GetSessionTokenResponse asyncResponse = null; - -#if ASYNC_AWAIT - var task = Client.GetSessionTokenAsync(gstRequest); - asyncResponse = task.Result; -#else - var asyncResult = Client.BeginGetSessionToken(gstRequest, - ar => - { - var client = ar.AsyncState as AmazonSecurityTokenServiceClient; - asyncResponse = client.EndGetSessionToken(ar); - } - , Client); - asyncResult.AsyncWaitHandle.WaitOne(); -#endif - - Thread.Sleep(TimeSpan.FromSeconds(5)); - Assert.IsNotNull(asyncResponse); - - var gstResult = asyncResponse; - Assert.IsNotNull(gstResult); - Assert.IsNotNull(gstResult.Credentials.AccessKeyId); - Assert.IsNotNull(gstResult.Credentials.SecretAccessKey); - Assert.IsNotNull(gstResult.Credentials.SessionToken); - Assert.IsNotNull(gstResult.Credentials.Expiration); - - var time = DateTime.UtcNow; - var approximateExpires = time.AddHours(1); - var expiresAfter = approximateExpires.AddMinutes(-5); - var expiresBefore = approximateExpires.AddMinutes(5); - var expires = gstResult.Credentials.Expiration; - - Assert.IsTrue(expires > expiresAfter); - Assert.IsTrue(expires < expiresBefore); - } - } -} \ No newline at end of file diff --git a/sdk/test/Services/SimpleDB/IntegrationTests/AWSSDK.IntegrationTests.SimpleDB.NetFramework.csproj b/sdk/test/Services/SimpleDB/IntegrationTests/AWSSDK.IntegrationTests.SimpleDB.NetFramework.csproj deleted file mode 100644 index 30d3d0f67b21..000000000000 --- a/sdk/test/Services/SimpleDB/IntegrationTests/AWSSDK.IntegrationTests.SimpleDB.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.SimpleDB.NetFramework - AWSSDK.IntegrationTests.SimpleDB.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/SimpleDB/IntegrationTests/Config/462/App.config b/sdk/test/Services/SimpleDB/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/SimpleDB/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/SimpleDB/IntegrationTests/SimpleDB.cs b/sdk/test/Services/SimpleDB/IntegrationTests/SimpleDB.cs deleted file mode 100644 index 540d53c254d0..000000000000 --- a/sdk/test/Services/SimpleDB/IntegrationTests/SimpleDB.cs +++ /dev/null @@ -1,391 +0,0 @@ -using System; -using System.Linq; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Text; -using System.Threading; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using AWSSDK_DotNet.IntegrationTests.Utils; - -using Amazon.SimpleDB; -using Amazon.SimpleDB.Model; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - /// - /// Integration tests for SimpleDB client. - /// - [TestClass] - public class SimpleDB : TestBase - { - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - // Name of the domain used for all the integration tests. - private static string domainName = "aws-net-sdk-domain-" + DateTime.UtcNow.Ticks; - - // All test data used in these integration tests. - private static List ALL_TEST_DATA = new List{ - new ReplaceableItem{ - Name= "foo", - Attributes= new List - { - new ReplaceableAttribute{Name="1",Value= "2"}, - new ReplaceableAttribute{Name="3",Value= "4"}, - new ReplaceableAttribute{Name="5",Value= "6"} - } - }, - new ReplaceableItem{ - Name="boo", - Attributes= new List - { - new ReplaceableAttribute{Name="X",Value= "Y"}, - new ReplaceableAttribute{Name="Z",Value= "Q"} - } - }, - new ReplaceableItem{ - Name= "baa", - Attributes= new List - { - new ReplaceableAttribute{Name="A'",Value= "B'"}, - new ReplaceableAttribute{Name="(C)", Value = "(D)"}, - new ReplaceableAttribute{Name="E",Value= "F"}} - }}; - - private ReplaceableItem FOO_ITEM = ALL_TEST_DATA[0]; - - private List ITEM_LIST = - new List { ALL_TEST_DATA[1], ALL_TEST_DATA[2] }; - - [TestCleanup] - public void TearDown() - { - try - { - DeleteDomain(domainName); - } - catch (AmazonSimpleDBException) { } - } - - - [TestMethod] - [TestCategory("SimpleDB")] - public void TestSimpleDBOperations() - { - TestCreateDomain(); - try - { - Thread.Sleep(5 * 1000); - - TestPutAttributes(); - TestPutAttributesWithCondition(); - TestBatchPutAttributes(); - - TestGetAttributes(); - TestListDomains(); - TestDomainMetadata(); - - TestSelect(); - TestDeleteAttributes(); - } - finally - { - TestDeleteDomain(); - } - } - - private void TestCreateDomain() - { - Assert.IsFalse(DoesDomainExist(domainName)); - CreateDomain(domainName); - - bool found = false; - for (int retries = 0; retries < 5 && !found; retries++) - { - Thread.Sleep(1000 * retries); - found = DoesDomainExist(domainName); - } - Assert.IsTrue(found); - } - - private void TestDeleteDomain() - { - DeleteDomain(domainName); - Assert.IsFalse(DoesDomainExist(domainName)); - } - - private void TestListDomains() - { - var listDomainsResult = Client.ListDomains(new ListDomainsRequest()); - List domainNames = listDomainsResult.DomainNames; - Assert.IsTrue(domainNames.Contains(domainName)); - } - - private void TestPutAttributes() - { - PutAttributesRequest request = new PutAttributesRequest() - { - DomainName = domainName, - ItemName = FOO_ITEM.Name, - Attributes = FOO_ITEM.Attributes - }; - Client.PutAttributes(request); - assertItemsStoredInDomain(Client, new List { FOO_ITEM }, domainName); - } - - private void TestPutAttributesWithCondition() - { - PutAttributesRequest request = new PutAttributesRequest() - { - DomainName = domainName, - ItemName = FOO_ITEM.Name, - Attributes = new List() { FOO_ITEM.Attributes[0] }, - Expected = new UpdateCondition() - { - Name = FOO_ITEM.Attributes[0].Name, - Exists = true, - Value = FOO_ITEM.Attributes[0].Value - } - }; - - request.Attributes[0].Replace = true; - request.Attributes[0].Value = "11"; - FOO_ITEM.Attributes[0].Value = "11"; - - Client.PutAttributes(request); - - assertItemsStoredInDomain(Client, new List { FOO_ITEM }, domainName); - } - - private void TestBatchPutAttributes() - { - BatchPutAttributesRequest request = new BatchPutAttributesRequest() - { - DomainName = domainName, - Items = ITEM_LIST - }; - Client.BatchPutAttributes(request); - assertItemsStoredInDomain(Client, ITEM_LIST, domainName); - } - - private void TestSelect() - { - SelectRequest request = new SelectRequest() - { - SelectExpression = "select * from `" + domainName + "`", - ConsistentRead = true - }; - var selectResult = Client.Select(request); - - AssertItemsPresent(ITEM_LIST, selectResult.Items); - AssertItemsPresent(new List { FOO_ITEM }, selectResult.Items); - } - - private void TestDomainMetadata() - { - System.Threading.Thread.Sleep(5 * 1000); - DomainMetadataRequest request = new DomainMetadataRequest() { DomainName = domainName }; - var domainMetadataResult = Client.DomainMetadata(request); - - int expectedItemCount = 0; - int expectedAttributeValueCount = 0; - int expectedAttributeNameCount = 0; - - foreach (ReplaceableItem item in ALL_TEST_DATA) - { - expectedItemCount++; - expectedAttributeNameCount += item.Attributes.Count; - expectedAttributeValueCount += item.Attributes.Count; - } - - Assert.AreEqual(expectedItemCount, domainMetadataResult.ItemCount.Value); - Assert.AreEqual(expectedAttributeNameCount, domainMetadataResult.AttributeNameCount.Value); - Assert.AreEqual(expectedAttributeValueCount, domainMetadataResult.AttributeValueCount.Value); - Assert.IsNotNull(domainMetadataResult.Timestamp); - } - - private void TestGetAttributes() - { - GetAttributesRequest request = new GetAttributesRequest() - { - DomainName = domainName, - ItemName = FOO_ITEM.Name, - AttributeNames = new List() { FOO_ITEM.Attributes[0].Name, FOO_ITEM.Attributes[1].Name }, - ConsistentRead = true - }; - - var getAttributesResult = Client.GetAttributes(request); - List attributes = getAttributesResult.Attributes; - Dictionary attributeValuesByName = ConvertAttributesToMap(attributes); - - Assert.AreEqual(2, attributeValuesByName.Count); - - List attrs = new List(); - attrs.Add(FOO_ITEM.Attributes[0]); - attrs.Add(FOO_ITEM.Attributes[1]); - - foreach (ReplaceableAttribute expectedAttribute in attrs) - { - string expectedAttributeName = expectedAttribute.Name; - Assert.IsTrue(attributeValuesByName.ContainsKey(expectedAttributeName)); - Assert.AreEqual(expectedAttribute.Value, attributeValuesByName[expectedAttributeName]); - } - } - - private void TestDeleteAttributes() - { - List attributeNames = new List(); - attributeNames.Add(FOO_ITEM.Attributes[0].Name); - attributeNames.Add(FOO_ITEM.Attributes[1].Name); - - List attributeList = new List(); - - foreach (string attributeName in attributeNames) - { - attributeList.Add(new Amazon.SimpleDB.Model.Attribute() { Name = attributeName }); - } - - Assert.IsTrue(DoAttributesExistForItem(Client, FOO_ITEM.Name, domainName, attributeNames)); - - DeleteAttributesRequest request = new DeleteAttributesRequest() - { - DomainName = domainName, - ItemName = FOO_ITEM.Name, - Attributes = attributeList - }; - - Client.DeleteAttributes(request); - Assert.IsFalse(DoAttributesExistForItem(Client, FOO_ITEM.Name, domainName, attributeNames)); - } - - bool DoesDomainExist(String domainName) - { - try - { - DomainMetadataRequest request = new DomainMetadataRequest() { DomainName = domainName }; - Client.DomainMetadata(request); - return true; - } - catch (AmazonSimpleDBException) - { - return false; - } - } - - void CreateDomain(String domainName) - { - CreateDomainRequest request = new CreateDomainRequest() { DomainName = domainName }; - Client.CreateDomain(request); - } - - bool DoAttributesExistForItem(IAmazonSimpleDB sdb, String itemName, String domainName, List attributeNames) - { - GetAttributesRequest request = new GetAttributesRequest() - { - DomainName = domainName, - AttributeNames = attributeNames, - ItemName = itemName, - ConsistentRead = true - }; - - var result = sdb.GetAttributes(request); - Dictionary attributeValuesByName = ConvertAttributesToMap(result.Attributes); - - foreach (string expectedAttributeName in attributeNames) - { - if (!attributeValuesByName.ContainsKey(expectedAttributeName)) - { - return false; - } - } - return true; - } - - Dictionary ConvertAttributesToMap(List attributeList) - { - Dictionary attributeValuesByName = new Dictionary(); - - if (attributeList != null) - { - foreach (Amazon.SimpleDB.Model.Attribute attribute in attributeList) - { - attributeValuesByName.Add(attribute.Name, attribute.Value); - } - } - return attributeValuesByName; - } - - static void DeleteDomain(String domainName) - { - DeleteDomainRequest request = new DeleteDomainRequest() - { - DomainName = domainName, - }; - Client.DeleteDomain(request); - } - - void assertItemsStoredInDomain(IAmazonSimpleDB sdb, List expectedItems, String domainName) - { - SelectRequest request = new SelectRequest() - { - SelectExpression = "select * from `" + domainName + "`", - ConsistentRead = true - }; - var selectResult = Client.Select(request); - AssertItemsPresent(expectedItems, selectResult.Items); - } - - void AssertItemsPresent(List expectedItems, List items) - { - Dictionary> expectedAttributesByItemName = ConvertReplaceableItemListToMap(expectedItems); - Dictionary> retrievedAttributesByItemName = ConvertItemListToMap(items); - - foreach (string expectedItemName in expectedAttributesByItemName.Keys) - { - Assert.IsTrue(retrievedAttributesByItemName.ContainsKey(expectedItemName)); - Dictionary expectedAttributes = expectedAttributesByItemName[expectedItemName]; - Dictionary retrievedAttributes = retrievedAttributesByItemName[expectedItemName]; - - foreach (string expectedAttributeName in expectedAttributes.Keys) - { - string expectedAttributeValue = expectedAttributes[expectedAttributeName]; - Assert.IsTrue(retrievedAttributes.ContainsKey(expectedAttributeName)); - Assert.AreEqual(expectedAttributeValue, retrievedAttributes[expectedAttributeName]); - } - - } - } - - private Dictionary> ConvertReplaceableItemListToMap(List items) - { - Dictionary> attributesByItemName = new Dictionary>(); - - foreach (ReplaceableItem item in items) - { - Dictionary attributeValuesByName = new Dictionary(); - foreach (ReplaceableAttribute attribute in item.Attributes) - { - attributeValuesByName.Add(attribute.Name, attribute.Value); - } - attributesByItemName.Add(item.Name, attributeValuesByName); - } - return attributesByItemName; - } - - private Dictionary> ConvertItemListToMap(List items) - { - Dictionary> attributesByItemName = new Dictionary>(); - foreach (Item item in items) - { - attributesByItemName.Add(item.Name, ConvertAttributesToMap(item.Attributes)); - } - - return attributesByItemName; - } - } -} diff --git a/sdk/test/Services/SimpleEmail/IntegrationTests/AWSSDK.IntegrationTests.SimpleEmail.NetFramework.csproj b/sdk/test/Services/SimpleEmail/IntegrationTests/AWSSDK.IntegrationTests.SimpleEmail.NetFramework.csproj deleted file mode 100644 index 6fcf7b07fb0e..000000000000 --- a/sdk/test/Services/SimpleEmail/IntegrationTests/AWSSDK.IntegrationTests.SimpleEmail.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.SimpleEmail.NetFramework - AWSSDK.IntegrationTests.SimpleEmail.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/SimpleEmail/IntegrationTests/Config/462/App.config b/sdk/test/Services/SimpleEmail/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/SimpleEmail/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/SimpleEmail/IntegrationTests/SimpleEmail.cs b/sdk/test/Services/SimpleEmail/IntegrationTests/SimpleEmail.cs deleted file mode 100644 index c8b6ecdeefa7..000000000000 --- a/sdk/test/Services/SimpleEmail/IntegrationTests/SimpleEmail.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using AWSSDK_DotNet.IntegrationTests.Utils; - -using Amazon.SimpleEmail; -using Amazon.SimpleEmail.Model; - - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class SimpleEmail : TestBase - { - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - // To run this test uncomment the TestMethod attribute and use - // valid email ids for sourceAddress and destinationAddress. - //[TestMethod] - [TestCategory("SimpleEmail")] - public void TestSendEmail() - { - // Replace these email with valid emails. - var sourceAddress = "bruce@example.com"; - var destinationAddress = "alice@example.com"; - - // verify email addresses, both source and destination - VerifyEmails(sourceAddress, destinationAddress); - - // send email - var sendEmailRequest = new SendEmailRequest - { - Source = sourceAddress, - Destination = new Destination - { - ToAddresses = new List { destinationAddress } - }, - Message = new Message - { - Subject = new Content("Re: Monday meeting"), - Body = new Body - { - Html = new Content(@"

Meeting on Monday


Monday's meeting to discuss intern projects
Let's start at 9:30am.") - } - } - }; - Client.SendEmail(sendEmailRequest); - } - - public static void VerifyEmails(params string[] emails) - { - // start verification process for all email addresses - foreach (var email in emails) - { - Client.VerifyEmailIdentity(new VerifyEmailIdentityRequest - { - EmailAddress = email - }); - } - - // wait until all are verified, maximum wait time of two minutes - bool allVerified = true; - DateTime latest = DateTime.UtcNow + TimeSpan.FromMinutes(2); - while(DateTime.UtcNow < latest) - { - // get verification status for all emails - var verificationAttributes = Client.GetIdentityVerificationAttributes(new GetIdentityVerificationAttributesRequest - { - Identities = new List(emails) - }).VerificationAttributes; - - // test verification status - allVerified = true; - foreach (var email in emails) - { - var attribute = verificationAttributes[email]; - if (attribute.VerificationStatus != VerificationStatus.Success) - allVerified = false; - } - - if (allVerified) - break; - - System.Threading.Thread.Sleep(TimeSpan.FromSeconds(15)); - } - - if (!allVerified) - throw new InvalidOperationException("Not all email addresses have been verified"); - } - } -} \ No newline at end of file diff --git a/sdk/test/Services/SimpleNotificationService/IntegrationTests/SNS.cs b/sdk/test/Services/SimpleNotificationService/IntegrationTests/SNS.cs index abe03cebba1d..3603149119e0 100644 --- a/sdk/test/Services/SimpleNotificationService/IntegrationTests/SNS.cs +++ b/sdk/test/Services/SimpleNotificationService/IntegrationTests/SNS.cs @@ -1,53 +1,46 @@ -using System; +using Amazon.Auth.AccessControlPolicy; +using Amazon.SimpleNotificationService; +using Amazon.SimpleNotificationService.Model; +using Amazon.SQS; +using Amazon.SQS.Model; +using AWSSDK_DotNet.IntegrationTests.Utils; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Text.Json; -using Amazon.Auth.AccessControlPolicy; -using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Threading; - -using AWSSDK_DotNet.IntegrationTests.Utils; - -using Amazon.SimpleNotificationService; -using Amazon.SimpleNotificationService.Model; -using Amazon.SQS; -using Amazon.SQS.Model; - +using System.Threading.Tasks; using SNSMessageAttributeValue = Amazon.SimpleNotificationService.Model.MessageAttributeValue; namespace AWSSDK_DotNet.IntegrationTests.Tests { [TestClass] + [TestCategory("SimpleNotificationService")] public class SNS : TestBase { - - static AmazonSQSClient sqsClient; + private static AmazonSQSClient sqsClient; [ClassInitialize] public static void ClassInitialize(TestContext testContext) { - sqsClient = new AmazonSQSClient(); + sqsClient = new AmazonSQSClient(Client.Config.RegionEndpoint); } [ClassCleanup] public static void Cleanup() { + sqsClient?.Dispose(); BaseClean(); - if (sqsClient != null) - { - sqsClient.Dispose(); - sqsClient = null; - } } [TestMethod] - [TestCategory("SimpleNotificationService")] - public void CRUDTopics() + public async Task CRUDTopics() { // list all topics - var allTopics = GetAllTopics(); + var allTopics = await GetAllTopics(); var currentTopicCount = allTopics.Count; // create new topic @@ -56,13 +49,13 @@ public void CRUDTopics() { Name = name }; - var createTopicResult = Client.CreateTopic(createTopicRequest); + var createTopicResult = await Client.CreateTopicAsync(createTopicRequest); var topicArn = createTopicResult.TopicArn; try { // verify there is a new topic - allTopics = GetAllTopics(); + allTopics = await GetAllTopics(); Assert.AreNotEqual(currentTopicCount, allTopics.Count); // set topic attribute @@ -72,121 +65,36 @@ public void CRUDTopics() AttributeName = "DisplayName", AttributeValue = "Test topic" }; - Client.SetTopicAttributes(setTopicAttributesRequest); + await Client.SetTopicAttributesAsync(setTopicAttributesRequest); // verify topic attributes var getTopicAttributesRequest = new GetTopicAttributesRequest { TopicArn = topicArn }; - var topicAttributes = - Client.GetTopicAttributes(getTopicAttributesRequest).Attributes; - Assert.AreEqual(setTopicAttributesRequest.AttributeValue, - topicAttributes[setTopicAttributesRequest.AttributeName]); - } - finally - { - // delete new topic - var deleteTopicRequest = new DeleteTopicRequest - { - TopicArn = topicArn - }; - Client.DeleteTopic(deleteTopicRequest); + var topicAttributes = (await Client.GetTopicAttributesAsync(getTopicAttributesRequest)).Attributes; + Assert.AreEqual( + setTopicAttributesRequest.AttributeValue, + topicAttributes[setTopicAttributesRequest.AttributeName] + ); - // verify the topic was deleted - allTopics = GetAllTopics(); - Assert.AreEqual(currentTopicCount, allTopics.Count); } - } - - // Constraints: - // to run this test, a valid email address must be supplied and - // the subscription confirmed within two minutes by default - //[TestMethod] - [TestCategory("SNS")] - public void SubscribeTopic() - { - const string emailAddress = "replaceme@example.com"; - var subscriptionWaitDelay = TimeSpan.FromMinutes(2); - - // create new topic - var name = "dotnetsdk" + DateTime.UtcNow.Ticks; - var createTopicRequest = new CreateTopicRequest - { - Name = name - }; - var createTopicResult = Client.CreateTopic(createTopicRequest); - var topicArn = createTopicResult.TopicArn; - - try + finally { - // subscribe an email address to the topic - var subscribeRequest = new SubscribeRequest + await Client.DeleteTopicAsync(new DeleteTopicRequest { - Protocol = "email", - Endpoint = emailAddress, TopicArn = topicArn - }; - Client.Subscribe(subscribeRequest); - - // wait until subscription has been confirmed, maximum wait time of two minutes - // by default - string subArn = null; - var latest = DateTime.UtcNow + subscriptionWaitDelay; - while (DateTime.UtcNow < latest) - { - // get subscriptions for topic - var listSubscriptionsRequest = new ListSubscriptionsByTopicRequest - { - TopicArn = topicArn - }; - var subs = Client.ListSubscriptionsByTopic(listSubscriptionsRequest).Subscriptions; - Assert.AreEqual(1, subs.Count); - - // test whether the subscription has been confirmed - var subscription = subs[0]; - if (!string.Equals(subscription.SubscriptionArn, "PendingConfirmation", StringComparison.Ordinal)) - { - subArn = subscription.SubscriptionArn; - break; - } - - // wait - Thread.Sleep(TimeSpan.FromSeconds(15)); - } - - // verify that the subscription was confirmed and the arn has been set - Assert.IsNotNull(subArn); - - // publish a message to the topic - Client.Publish(new PublishRequest - { - TopicArn = topicArn, - Subject = "Test subject", - Message = "Test message" }); - // delete the subscription - Client.Unsubscribe(new UnsubscribeRequest - { - SubscriptionArn = subArn - }); - } - finally - { - // delete the topic - var deleteTopicRequest = new DeleteTopicRequest - { - TopicArn = topicArn - }; - Client.DeleteTopic(deleteTopicRequest); + // verify the topic was deleted + allTopics = await GetAllTopics(); + Assert.IsFalse(allTopics.Any(t => t.TopicArn == topicArn)); } } [TestMethod] - [TestCategory("SimpleNotificationService")] - public void TestPublishAsJson() + public async Task TestPublishAsJson() { // create new topic var name = "dotnetsdk" + DateTime.UtcNow.Ticks; @@ -194,12 +102,13 @@ public void TestPublishAsJson() { Name = name }; - var createTopicResult = Client.CreateTopic(createTopicRequest); + + var createTopicResult = await Client.CreateTopicAsync(createTopicRequest); var topicArn = createTopicResult.TopicArn; try { - var pubRequest = new PublishRequest() + var pubRequest = new PublishRequest { TopicArn = topicArn, MessageStructure = "json", @@ -209,38 +118,37 @@ public void TestPublishAsJson() var gotException = true; try { - Client.Publish(pubRequest); + await Client.PublishAsync(pubRequest); gotException = false; } catch (AmazonSimpleNotificationServiceException e) { Assert.AreEqual("InvalidParameter", e.ErrorCode); } - Assert.IsTrue(gotException, "Failed to get exception about invalid JSON"); + Assert.IsTrue(gotException, "Failed to get exception about invalid JSON"); pubRequest.Message = "{\"default\" : \"Data\"}"; - Client.Publish(pubRequest); + await Client.PublishAsync(pubRequest); } finally { - Client.DeleteTopic(new DeleteTopicRequest { TopicArn = topicArn }); + await Client.DeleteTopicAsync(new DeleteTopicRequest { TopicArn = topicArn }); } } [TestMethod] - [TestCategory("SimpleNotificationService")] - public void IsMessageSignatureValidSHA1() + public async Task IsMessageSignatureValidSHA1() { string topicArn = null; string queueUrl = null; try { - topicArn = CreateTopic(); - queueUrl = CreateQueue(); + topicArn = await CreateTopic(); + queueUrl = await CreateQueue(); - SubscribeQueue(topicArn, queueUrl); - List messages = PublishToSNSAndReceiveMessages(GetPublishRequest(topicArn), topicArn, queueUrl); + await SubscribeQueue(topicArn, queueUrl); + List messages = await PublishToSNSAndReceiveMessages(GetPublishRequest(topicArn), queueUrl); Assert.AreEqual(1, messages.Count); var bodyJson = GetBodyJson(messages[0]); @@ -254,24 +162,27 @@ public void IsMessageSignatureValidSHA1() finally { if (topicArn != null) - Client.DeleteTopic(new DeleteTopicRequest { TopicArn = topicArn }); + { + await Client.DeleteTopicAsync(new DeleteTopicRequest { TopicArn = topicArn }); + } if (queueUrl != null) - sqsClient.DeleteQueue(new DeleteQueueRequest { QueueUrl = queueUrl }); + { + await sqsClient.DeleteQueueAsync(new DeleteQueueRequest { QueueUrl = queueUrl }); + } } } [TestMethod] - [TestCategory("SimpleNotificationService")] - public void IsMessageSignatureValidSHA256() + public async Task IsMessageSignatureValidSHA256() { string topicArn = null; string queueUrl = null; try { - topicArn = CreateTopic(); - queueUrl = CreateQueue(); + topicArn = await CreateTopic(); + queueUrl = await CreateQueue(); // set topic attribute var setTopicAttributesRequest = new SetTopicAttributesRequest @@ -280,10 +191,10 @@ public void IsMessageSignatureValidSHA256() AttributeName = "SignatureVersion", AttributeValue = "2" }; - Client.SetTopicAttributes(setTopicAttributesRequest); + await Client.SetTopicAttributesAsync(setTopicAttributesRequest); - SubscribeQueue(topicArn, queueUrl); - List messages = PublishToSNSAndReceiveMessages(GetPublishRequest(topicArn), topicArn, queueUrl); + await SubscribeQueue(topicArn, queueUrl); + List messages = await PublishToSNSAndReceiveMessages(GetPublishRequest(topicArn), queueUrl); Assert.AreEqual(1, messages.Count); var bodyJson = GetBodyJson(messages[0]); @@ -297,28 +208,31 @@ public void IsMessageSignatureValidSHA256() finally { if (topicArn != null) - Client.DeleteTopic(new DeleteTopicRequest { TopicArn = topicArn }); + { + await Client.DeleteTopicAsync(new DeleteTopicRequest { TopicArn = topicArn }); + } if (queueUrl != null) - sqsClient.DeleteQueue(new DeleteQueueRequest { QueueUrl = queueUrl }); + { + await sqsClient.DeleteQueueAsync(new DeleteQueueRequest { QueueUrl = queueUrl }); + } } } [TestMethod] - [TestCategory("SimpleNotificationService")] - public void TestQueueSubscription() + public async Task TestQueueSubscription() { string topicArn = null; string queueUrl = null; try { - topicArn = CreateTopic(); - queueUrl = CreateQueue(); + topicArn = await CreateTopic(); + queueUrl = await CreateQueue(); - var subscriptionArn = SubscribeQueue(topicArn, queueUrl); + var subscriptionArn = await SubscribeQueue(topicArn, queueUrl); var publishRequest = GetPublishRequest(topicArn); - List messages = PublishToSNSAndReceiveMessages(publishRequest, topicArn, queueUrl); + List messages = await PublishToSNSAndReceiveMessages(publishRequest, queueUrl); Assert.AreEqual(1, messages.Count); var message = messages[0]; @@ -349,36 +263,36 @@ public void TestQueueSubscription() : Convert.ToBase64String(value.BinaryValue.ToArray()), jsonValue); } - sqsClient.DeleteMessage(new DeleteMessageRequest + await sqsClient.DeleteMessageAsync(new DeleteMessageRequest { QueueUrl = queueUrl, ReceiptHandle = messages[0].ReceiptHandle }); // This will unsubscribe but leave the policy in place. - Client.Unsubscribe(new UnsubscribeRequest + await Client.UnsubscribeAsync(new UnsubscribeRequest { SubscriptionArn = subscriptionArn }); // Subscribe again to see if this affects the policy. - Client.SubscribeQueue(topicArn, sqsClient, queueUrl); + await Client.SubscribeQueueAsync(topicArn, sqsClient, queueUrl); - Client.Publish(new PublishRequest + await Client.PublishAsync(new PublishRequest { TopicArn = topicArn, Message = "Test Message again" }); - messages = sqsClient.ReceiveMessage(new ReceiveMessageRequest + messages = (await sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest { QueueUrl = queueUrl, WaitTimeSeconds = 20 - }).Messages; + })).Messages; Assert.AreEqual(1, messages.Count); - var getAttributeResponse = sqsClient.GetQueueAttributes(new GetQueueAttributesRequest + var getAttributeResponse = await sqsClient.GetQueueAttributesAsync(new GetQueueAttributesRequest { AttributeNames = new List { "All" }, QueueUrl = queueUrl @@ -390,80 +304,75 @@ public void TestQueueSubscription() finally { if (topicArn != null) - Client.DeleteTopic(new DeleteTopicRequest { TopicArn = topicArn }); + { + await Client.DeleteTopicAsync(new DeleteTopicRequest { TopicArn = topicArn }); + } if (queueUrl != null) - sqsClient.DeleteQueue(new DeleteQueueRequest { QueueUrl = queueUrl }); + { + await sqsClient.DeleteQueueAsync(new DeleteQueueRequest { QueueUrl = queueUrl }); + } } } [TestMethod] - [TestCategory("SimpleNotificationService")] - public void TestMultipleQueueSubscription() + public async Task TestMultipleQueueSubscription() { var topicArns = new List(); var topicName1 = "dotnetsdkTopic" + DateTime.UtcNow.Ticks; - topicArns.Add(Client.CreateTopic(topicName1).TopicArn); + topicArns.Add((await Client.CreateTopicAsync(topicName1)).TopicArn); var topicName2 = "dotnetsdkTopic" + DateTime.UtcNow.Ticks; - topicArns.Add(Client.CreateTopic(topicName2).TopicArn); + topicArns.Add((await Client.CreateTopicAsync(topicName2)).TopicArn); var queueName = "dotnetsdkQueue-" + DateTime.UtcNow.Ticks; - var queueUrl = sqsClient.CreateQueue(queueName).QueueUrl; + var queueUrl = (await sqsClient.CreateQueueAsync(queueName)).QueueUrl; try { - var subscriptionArns = Client.SubscribeQueueToTopics(topicArns, sqsClient, queueUrl).Values; - + var subscriptionArns = (await Client.SubscribeQueueToTopicsAsync(topicArns, sqsClient, queueUrl)).Values; Assert.AreEqual(2, subscriptionArns.Count); - Thread.Sleep(TimeSpan.FromSeconds(5)); - var attributes = sqsClient.GetQueueAttributes(queueUrl, new List { "All" }).Attributes; + var attributes = (await sqsClient.GetQueueAttributesAsync(queueUrl, new List { "All" })).Attributes; var policy = Policy.FromJson(attributes["Policy"]); - Assert.AreEqual(2, policy.Statements.Count); } finally { foreach (var topicArn in topicArns) { - Client.DeleteTopic(new DeleteTopicRequest { TopicArn = topicArn }); + await Client.DeleteTopicAsync(new DeleteTopicRequest { TopicArn = topicArn }); } - sqsClient.DeleteQueue(new DeleteQueueRequest { QueueUrl = queueUrl }); + + await sqsClient.DeleteQueueAsync(new DeleteQueueRequest { QueueUrl = queueUrl }); } } [TestMethod] - [TestCategory("SimpleNotificationService")] - public void FindTopic() + public async Task FindTopic() { - // create new topic var name = "dotnetsdk" + DateTime.UtcNow.Ticks; var createTopicRequest = new CreateTopicRequest { Name = name }; - var createTopicResult = Client.CreateTopic(createTopicRequest); + + var createTopicResult = await Client.CreateTopicAsync(createTopicRequest); var topicArn = createTopicResult.TopicArn; try { - // find the topic by name - var foundTopic = Client.FindTopic(name); - - // verify that the topic was fund + var foundTopic = await Client.FindTopicAsync(name); Assert.IsNotNull(foundTopic); } finally { - // delete the topic - var deleteTopicRequest = new DeleteTopicRequest + await Client.DeleteTopicAsync(new DeleteTopicRequest { TopicArn = topicArn - }; - Client.DeleteTopic(deleteTopicRequest); + }); } } @@ -478,14 +387,13 @@ private static string GetBodyJson(Message message) return bodyJson; } - private static List GetAllTopics() + private static async Task> GetAllTopics() { var allTopics = new List(); var listRequest = new ListTopicsRequest(); do { - var listResponse = Client.ListTopics(listRequest); - + var listResponse = await Client.ListTopicsAsync(listRequest); if (listResponse.Topics != null) { allTopics.AddRange(listResponse.Topics); @@ -493,7 +401,7 @@ private static List GetAllTopics() listRequest.NextToken = listResponse.NextToken; } while (!string.IsNullOrEmpty(listRequest.NextToken)); - return allTopics ?? new List(); + return allTopics; } private PublishRequest GetPublishRequest(string topicArn) @@ -510,42 +418,43 @@ private PublishRequest GetPublishRequest(string topicArn) { "Prime", new SNSMessageAttributeValue { StringValue = "31", DataType = "Number" } }, } }; - } - private List PublishToSNSAndReceiveMessages(PublishRequest publishRequest, string topicArn, string queueUrl) + private async Task> PublishToSNSAndReceiveMessages(PublishRequest publishRequest, string queueUrl) { - Client.Publish(publishRequest); + await Client.PublishAsync(publishRequest); - var messages = (sqsClient.ReceiveMessage(new ReceiveMessageRequest + var receiveResponse = await sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest { QueueUrl = queueUrl, WaitTimeSeconds = 20 - })).Messages; - return messages; + }); + + return receiveResponse.Messages; } - private string SubscribeQueue(string topicArn, string queueUrl) + private async Task SubscribeQueue(string topicArn, string queueUrl) { - var subscriptionARN = Client.SubscribeQueue(topicArn, sqsClient, queueUrl); + var subscriptionARN = await Client.SubscribeQueueAsync(topicArn, sqsClient, queueUrl); // Sleep to wait for the subscribe to complete. - Thread.Sleep(TimeSpan.FromSeconds(5)); + await Task.Delay(TimeSpan.FromSeconds(5)); return subscriptionARN; } - private string CreateQueue() + private async Task CreateQueue() { var queueName = UtilityMethods.GenerateName("TestQueueSubscription"); - var queueUrl = (sqsClient.CreateQueue(new CreateQueueRequest + var createResponse = await sqsClient.CreateQueueAsync(new CreateQueueRequest { QueueName = queueName - })).QueueUrl; - return queueUrl; + }); + + return createResponse.QueueUrl; } - private string CreateTopic() + private async Task CreateTopic() { // create new topic var topicName = UtilityMethods.GenerateName("TestQueueSubscription"); @@ -553,10 +462,9 @@ private string CreateTopic() { Name = topicName }; - var createTopicResult = Client.CreateTopic(createTopicRequest); - var topicArn = createTopicResult.TopicArn; - return topicArn; - } + var createTopicResult = await Client.CreateTopicAsync(createTopicRequest); + return createTopicResult.TopicArn; + } } } diff --git a/sdk/test/Services/SimpleSystemsManagement/IntegrationTests/AWSSDK.IntegrationTests.SimpleSystemsManagement.NetFramework.csproj b/sdk/test/Services/SimpleSystemsManagement/IntegrationTests/AWSSDK.IntegrationTests.SimpleSystemsManagement.NetFramework.csproj deleted file mode 100644 index 54a6542ea22b..000000000000 --- a/sdk/test/Services/SimpleSystemsManagement/IntegrationTests/AWSSDK.IntegrationTests.SimpleSystemsManagement.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.SimpleSystemsManagement.NetFramework - AWSSDK.IntegrationTests.SimpleSystemsManagement.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/SimpleSystemsManagement/IntegrationTests/Config/462/App.config b/sdk/test/Services/SimpleSystemsManagement/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/SimpleSystemsManagement/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/SimpleSystemsManagement/IntegrationTests/SimpleSystemsManagement.cs b/sdk/test/Services/SimpleSystemsManagement/IntegrationTests/SimpleSystemsManagement.cs deleted file mode 100644 index 6e9a6809f4f4..000000000000 --- a/sdk/test/Services/SimpleSystemsManagement/IntegrationTests/SimpleSystemsManagement.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using Amazon.SimpleSystemsManagement; -using Amazon.SimpleSystemsManagement.Model; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class SimpleSystemsManagement : TestBase - { - [TestMethod] - [TestCategory("SimpleSystemsManagement")] - public void TestListDocuments() - { - var response = Client.ListDocuments(); - Assert.IsNotNull(response); - - // if test a/c had some documents, iterate through - // to verify marshal - if (response.DocumentIdentifiers.Count > 0) - { - foreach (var d in response.DocumentIdentifiers) - { - Assert.IsFalse(string.IsNullOrEmpty(d.Name)); - } - } - } - } -} diff --git a/sdk/test/Services/SimpleWorkflow/IntegrationTests/AWSSDK.IntegrationTests.SimpleWorkflow.NetFramework.csproj b/sdk/test/Services/SimpleWorkflow/IntegrationTests/AWSSDK.IntegrationTests.SimpleWorkflow.NetFramework.csproj deleted file mode 100644 index 61db54777e0b..000000000000 --- a/sdk/test/Services/SimpleWorkflow/IntegrationTests/AWSSDK.IntegrationTests.SimpleWorkflow.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.SimpleWorkflow.NetFramework - AWSSDK.IntegrationTests.SimpleWorkflow.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/SimpleWorkflow/IntegrationTests/Config/462/App.config b/sdk/test/Services/SimpleWorkflow/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/SimpleWorkflow/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/SimpleWorkflow/IntegrationTests/SimpleWorkflow.cs b/sdk/test/Services/SimpleWorkflow/IntegrationTests/SimpleWorkflow.cs deleted file mode 100644 index 97a38798c7ce..000000000000 --- a/sdk/test/Services/SimpleWorkflow/IntegrationTests/SimpleWorkflow.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Amazon.SimpleWorkflow; -using Amazon.SimpleWorkflow.Model; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class SimpleWorkflow : TestBase - { - [TestMethod] - [TestCategory("SimpleWorkflow")] - public void SmokeTest() - { - var listDomainsRequest = new ListDomainsRequest - { - RegistrationStatus = RegistrationStatus.REGISTERED - }; - var listDomainsResponse = Client.ListDomains(listDomainsRequest); - Assert.AreEqual(listDomainsResponse.HttpStatusCode, System.Net.HttpStatusCode.OK); - } - } -} diff --git a/sdk/test/Services/Snowball/IntegrationTests/AWSSDK.IntegrationTests.Snowball.NetFramework.csproj b/sdk/test/Services/Snowball/IntegrationTests/AWSSDK.IntegrationTests.Snowball.NetFramework.csproj deleted file mode 100644 index 75f87e0e3ecf..000000000000 --- a/sdk/test/Services/Snowball/IntegrationTests/AWSSDK.IntegrationTests.Snowball.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.Snowball.NetFramework - AWSSDK.IntegrationTests.Snowball.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/Snowball/IntegrationTests/Config/462/App.config b/sdk/test/Services/Snowball/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/Snowball/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/Snowball/IntegrationTests/Snowball.cs b/sdk/test/Services/Snowball/IntegrationTests/Snowball.cs deleted file mode 100644 index a97f9ee8a60c..000000000000 --- a/sdk/test/Services/Snowball/IntegrationTests/Snowball.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using Amazon; -using Amazon.Snowball; -using Amazon.Snowball.Model; -using Amazon.Runtime; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class Snowball : TestBase - { - [TestMethod] - [TestCategory("Snowball")] - public void ListJobs() - { - var client = new AmazonSnowballClient(Amazon.RegionEndpoint.EUCentral1); - client.ListJobs(new ListJobsRequest()); - } - - [TestMethod] - [TestCategory("Snowball")] - public void GetSnowballUsage() - { - var client = new AmazonSnowballClient(Amazon.RegionEndpoint.EUCentral1); - var response = client.GetSnowballUsage(new GetSnowballUsageRequest()); - } - } -} diff --git a/sdk/test/Services/StorageGateway/IntegrationTests/AWSSDK.IntegrationTests.StorageGateway.NetFramework.csproj b/sdk/test/Services/StorageGateway/IntegrationTests/AWSSDK.IntegrationTests.StorageGateway.NetFramework.csproj deleted file mode 100644 index 5781bce7252b..000000000000 --- a/sdk/test/Services/StorageGateway/IntegrationTests/AWSSDK.IntegrationTests.StorageGateway.NetFramework.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net472 - $(DefineConstants);DEBUG;TRACE;BCL;ASYNC_AWAIT;LOCAL_FILE - portable - false - AWSSDK.IntegrationTests.StorageGateway.NetFramework - AWSSDK.IntegrationTests.StorageGateway.NetFramework - - false - false - false - false - false - false - false - false - true - CS1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sdk/test/Services/StorageGateway/IntegrationTests/Config/462/App.config b/sdk/test/Services/StorageGateway/IntegrationTests/Config/462/App.config deleted file mode 100644 index e42d0bcd4c11..000000000000 --- a/sdk/test/Services/StorageGateway/IntegrationTests/Config/462/App.config +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/test/Services/StorageGateway/IntegrationTests/StorageGateway.cs b/sdk/test/Services/StorageGateway/IntegrationTests/StorageGateway.cs deleted file mode 100644 index 3a20e9e5e68d..000000000000 --- a/sdk/test/Services/StorageGateway/IntegrationTests/StorageGateway.cs +++ /dev/null @@ -1,56 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using Amazon.StorageGateway; - -namespace AWSSDK_DotNet.IntegrationTests.Tests -{ - [TestClass] - public class StorageGateway : TestBase - { - - [ClassCleanup] - public static void Cleanup() - { - BaseClean(); - } - - [TestMethod] - [TestCategory("StorageGateway")] - public void TestListGateways() - { - var response = Client.ListGateways(); - - Assert.IsNotNull(response); - Assert.IsNotNull(response.Gateways); - - // test a/c may not have any gateways but if some are returned, make - // sure they marshalled ok - if (response.Gateways.Count > 0) - { - foreach (var gi in response.Gateways) - { - Assert.IsFalse(string.IsNullOrEmpty(gi.GatewayARN)); - } - } - } - - [TestMethod] - [TestCategory("StorageGateway")] - public void TestDescribeTapeArchives() - { - var response = Client.DescribeTapeArchives(); - Assert.IsNotNull(response); - Assert.IsNotNull(response.TapeArchives); - - // test a/c may not have any archives but if some are returned, make - // sure they marshalled ok - if (response.TapeArchives.Count > 0) - { - foreach (var ta in response.TapeArchives) - { - Assert.IsFalse(string.IsNullOrEmpty(ta.TapeARN)); - } - } - } - } -} diff --git a/sdk/test/Services/WAF/IntegrationTests/WAF.cs b/sdk/test/Services/WAF/IntegrationTests/WAF.cs index f1965dbcd7e7..7ea503385d99 100644 --- a/sdk/test/Services/WAF/IntegrationTests/WAF.cs +++ b/sdk/test/Services/WAF/IntegrationTests/WAF.cs @@ -1,20 +1,18 @@ -using System; -using System.Collections.Generic; +using Amazon.WAF; +using Amazon.WAF.Model; using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Collections.Generic; using System.Linq; -using AWSSDK_DotNet.IntegrationTests.Utils; - -using Amazon.WAF; -using Amazon.WAF.Model; -using Amazon; using System.Text; +using System.Threading.Tasks; namespace AWSSDK_DotNet.IntegrationTests.Tests { [TestClass] + [TestCategory("WAF")] public class WAF : TestBase { - [ClassCleanup] public static void Cleanup() { @@ -22,15 +20,13 @@ public static void Cleanup() } [TestMethod] - [TestCategory("WAF")] - public void TestByteMatchSet() + public async Task TestByteMatchSet() { - var token1 = Client.GetChangeToken().ChangeToken; - var token2 = Client.GetChangeToken().ChangeToken; + var token1 = (await Client.GetChangeTokenAsync()).ChangeToken; + var token2 = (await Client.GetChangeTokenAsync()).ChangeToken; Assert.AreEqual(token1, token2); - var tokenStatus = Client.GetChangeTokenStatus(token1).ChangeTokenStatus; - + var tokenStatus = (await Client.GetChangeTokenStatusAsync(token1)).ChangeTokenStatus; var setName = "BMS-net-test-" + DateTime.UtcNow.ToFileTime(); var tupleTargetString = "aws"; var tuple = new ByteMatchTuple @@ -47,21 +43,21 @@ public void TestByteMatchSet() Assert.IsNotNull(tuple.TargetStream); Assert.AreEqual(tupleTargetString, Encoding.UTF8.GetString(tuple.TargetStream.ToArray())); - var createResponse = Client.CreateByteMatchSet(setName, Client.GetChangeToken().ChangeToken); + var createResponse = await Client.CreateByteMatchSetAsync(setName, (await Client.GetChangeTokenAsync()).ChangeToken); var createdSet = createResponse.ByteMatchSet; var changeToken = createResponse.ChangeToken; - var sets = GetAllbyteMatchSets().ToList(); + var sets = (await GetAllbyteMatchSets()).ToList(); var foundSet = sets.SingleOrDefault(s => string.Equals(s.ByteMatchSetId, createdSet.ByteMatchSetId, StringComparison.Ordinal)); Assert.IsNotNull(foundSet); - var retrievedSet = Client.GetByteMatchSet(createdSet.ByteMatchSetId).ByteMatchSet; + var retrievedSet = (await Client.GetByteMatchSetAsync(createdSet.ByteMatchSetId)).ByteMatchSet; Assert.IsNotNull(retrievedSet); Assert.AreEqual(createdSet.ByteMatchSetId, retrievedSet.ByteMatchSetId); Assert.AreEqual(createdSet.Name, retrievedSet.Name); Assert.AreEqual(createdSet.ByteMatchTuples.Count, retrievedSet.ByteMatchTuples.Count); - Client.UpdateByteMatchSet( + await Client.UpdateByteMatchSetAsync( createdSet.ByteMatchSetId, new List { @@ -71,16 +67,17 @@ public void TestByteMatchSet() ByteMatchTuple = tuple } }, - Client.GetChangeToken().ChangeToken); + (await Client.GetChangeTokenAsync()).ChangeToken + ); - retrievedSet = Client.GetByteMatchSet(createdSet.ByteMatchSetId).ByteMatchSet; + retrievedSet = (await Client.GetByteMatchSetAsync(createdSet.ByteMatchSetId)).ByteMatchSet; Assert.IsNotNull(retrievedSet); Assert.AreEqual(createdSet.ByteMatchSetId, retrievedSet.ByteMatchSetId); Assert.AreEqual(createdSet.Name, retrievedSet.Name); Assert.AreEqual(1, retrievedSet.ByteMatchTuples.Count); Assert.AreEqual(tuple.TargetString, retrievedSet.ByteMatchTuples[0].TargetString); - Client.UpdateByteMatchSet( + await Client.UpdateByteMatchSetAsync( createdSet.ByteMatchSetId, new List { @@ -90,25 +87,31 @@ public void TestByteMatchSet() ByteMatchTuple = tuple } }, - Client.GetChangeToken().ChangeToken); + (await Client.GetChangeTokenAsync()).ChangeToken + ); - Client.DeleteByteMatchSet(createdSet.ByteMatchSetId, Client.GetChangeToken().ChangeToken); + await Client.DeleteByteMatchSetAsync(createdSet.ByteMatchSetId, (await Client.GetChangeTokenAsync()).ChangeToken); - sets = GetAllbyteMatchSets().ToList(); + sets = (await GetAllbyteMatchSets()).ToList(); foundSet = sets.SingleOrDefault(s => string.Equals(s.ByteMatchSetId, createdSet.ByteMatchSetId, StringComparison.Ordinal)); Assert.IsNull(foundSet); } - private static IEnumerable GetAllbyteMatchSets() + private static async Task> GetAllbyteMatchSets() { + var summaries = new List(); var request = new ListByteMatchSetsRequest { Limit = 1 }; do { - var response = Client.ListByteMatchSets(request); + var response = await Client.ListByteMatchSetsAsync(request); request.NextMarker = response.NextMarker; - foreach (var set in response.ByteMatchSets) - yield return set; + + if (response.ByteMatchSets != null) + { + summaries.AddRange(response.ByteMatchSets); + } } while (!string.IsNullOrEmpty(request.NextMarker)); + return summaries; } } }