public void SetUp()
        {
            AWSCredentials credentials = AmbientCredentials.GetCredentials();

            Ec2Client = AWSClientFactory.CreateAmazonEC2Client(credentials);
            Service   = new SecurityGroupService(Ec2Client);
        }
예제 #2
0
        public async Task DescribeSecurityGroupAsync_when_any_exist_should_describe_security_groups()
        {
            // Arrange
            var client = new EnvironmentVariables().CloudComputeClient();
            ISecurityGroupService classUnderTest = new SecurityGroupService(client);

            // Act
            var response = await classUnderTest.DescribeSecurityGroupsAsync();

            // Assert
            Assert.IsTrue(response.SecurityGroups.Count >= 1);
        }
예제 #3
0
        public void SetUp()
        {
            AWSCredentials credentials = AmbientCredentials.GetCredentials();

            Ec2Client            = AWSClientFactory.CreateAmazonEC2Client(credentials);
            SecurityGroupService = new SecurityGroupService(Ec2Client);

            Creator = new DefaultSecurityGroupCreator(SecurityGroupService)
            {
                SecurityGroupName = _testSecurityGroupName
            };
        }
예제 #4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();

            // appsettings.json
            var awsAccessKeyId     = Configuration.GetSection("AwsAccessKeyId").Value;
            var awsSecretAccessKey = Configuration.GetSection("AwsSecretAccessKey").Value;
            var keyService         = new KeyService(awsAccessKeyId, awsSecretAccessKey);

            // Amazon clients
            // `keyService` can be used to pass `AwsAccessKeyId` and `AwsSecretAccessKey`
            var cloudComputeClient      = new AmazonEC2Client();
            var containerServiceClient  = new AmazonECSClient();
            var containerRegistryClient = new AmazonECRClient();

            services.AddSingleton <IKeyService>(keyService);
            services.AddSingleton <IAmazonEC2>(cloudComputeClient);
            services.AddSingleton <IAmazonECS>(containerServiceClient);
            services.AddSingleton <IAmazonECR>(containerRegistryClient);

            // AwsAdmin.Application Services
            var vpcService             = new VpcService(cloudComputeClient);
            var subnetService          = new SubnetService(cloudComputeClient);
            var routeTableService      = new RouteTableService(cloudComputeClient);
            var internetGatewayService = new InternetGatewayService(cloudComputeClient);
            var dhcpOptionsSetService  = new DhcpOptionsSetService(cloudComputeClient);
            var networkAclsService     = new NetworkAclsService(cloudComputeClient);
            var securityGroupService   = new SecurityGroupService(cloudComputeClient);

            services.AddSingleton <IVpcService>(vpcService);
            services.AddSingleton <ISubnetService>(subnetService);
            services.AddSingleton <IRouteTableService>(routeTableService);
            services.AddSingleton <IInternetGatewayService>(internetGatewayService);
            services.AddSingleton <IDhcpOptionsSetService>(dhcpOptionsSetService);
            services.AddSingleton <INetworkAclsService>(networkAclsService);
            services.AddSingleton <ISecurityGroupService>(securityGroupService);

            // Mappers
            services.AddSingleton <IDescribeVpcMapper, DescribeVpcMapper>();
            services.AddSingleton <IDescribeSubnetMapper, DescribeSubnetMapper>();
            services.AddSingleton <IDescribeRouteTableMapper, DescribeRouteTableMapper>();
            services.AddSingleton <IDhcpOptionsSetsMapper, DhcpOptionsSetsMapper>();
            services.AddSingleton <IInternetGatewayMapper, InternetGatewayMapper>();
            services.AddSingleton <INetworkAclsMapper, NetworkAclsMapper>();
            services.AddSingleton <ISecurityGroupMapper, SecurityGroupMapper>();
        }
 public void SetUp()
 {
     Ec2Mock = new Mock <IAmazonEC2>();
     SecurityGroupService = new SecurityGroupService(Ec2Mock.Object);
 }