Exemplo n.º 1
0
    public void BuildConfiguration_ReadFromEnvironmentalAppSettings()

    {
        var sut = EswDevOpsSdk.BuildConfiguration(AssemblyDirectory, "ENV1");

        sut["KeyENV1AppSettings"].Should().BeEquivalentTo("ENV1AppSettingsValue");
    }
Exemplo n.º 2
0
    public async Task RemoveTests(OperationPhase operationPhase)
    {
        using (var scope = Fixture.Container.BeginLifetimeScope())
        {
            var cl            = scope.Resolve <HttpClient>();
            var azure         = scope.ResolveKeyed <IAzure>(EswDevOpsSdk.GetEnvironment());
            var resourceGroup = await EnsureResourceGroupExists(azure, TestResourceGroupName, Region.EuropeNorth);

            var scaleSet = await GetScaleSet(azure);
            await Prepare(azure, operationPhase, resourceGroup, scaleSet, IdentityName);

            var identity = await FindIdentity(azure, resourceGroup, IdentityName);

            var msi = CreateMangedIdentityAssignment();
            await cl.PostJsonToActor(Fixture.TestMiddlewareUri, "ManagedIdentity", "Remove", msi);

            var deletedIdentity = await FindIdentity(azure, resourceGroup, IdentityName);

            deletedIdentity.Should().BeNull($"identity {IdentityName} should be deleted.");
            if (identity != null)
            {
                var updatedScaleSet = await GetScaleSet(azure);

                if (updatedScaleSet.ManagedServiceIdentityType == ResourceIdentityType.SystemAssignedUserAssigned ||
                    updatedScaleSet.ManagedServiceIdentityType == ResourceIdentityType.UserAssigned)
                {
                    updatedScaleSet.UserAssignedManagedServiceIdentityIds.Should().NotBeNull();
                    updatedScaleSet.UserAssignedManagedServiceIdentityIds.Should().NotContain(identity.Id);
                }

                // TODO: if possible check whether the managed identity had been unassigned from the scale set before it has been deleted.
            }
        }
    }
Exemplo n.º 3
0
    public void BuildConfiguration_ReadFromCoreAppSettings()
    {
        Environment.SetEnvironmentVariable(EswDevOpsSdk.EnvironmentEnvVariable, "ENV1", EnvironmentVariableTarget.Process); //process level is fine here
        var sut = EswDevOpsSdk.BuildConfiguration(AssemblyDirectory);

        sut["KeyRootAppSettings"].Should().BeEquivalentTo("AppSettingsValue");
    }
Exemplo n.º 4
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.Register(c => EswDevOpsSdk.BuildConfiguration());
            builder.RegisterType <ClusterNotifier>().SingleInstance();
            builder.Register(c => new FabricClient());
            builder.Register <IBigBrother>(c =>
            {
                var config   = c.Resolve <IConfigurationRoot>();
                var bbInsKey = config["BBInstrumentationKey"];
                return(new BigBrother(bbInsKey, bbInsKey));
            })
            .SingleInstance();

            builder.Register(c => HttpPolicyExtensions.HandleTransientHttpError()
                             .WaitAndRetryAsync(new[]
            {
                //TODO: configure these timeouts and add jitter policy
                TimeSpan.FromSeconds(1),
                TimeSpan.FromSeconds(5),
                TimeSpan.FromSeconds(10)
            }))
            .As <IAsyncPolicy <HttpResponseMessage> >()
            .SingleInstance();

            builder.Register(c => new PolicyHttpMessageHandler(c.Resolve <IAsyncPolicy <HttpResponseMessage> >()))
            .SingleInstance();

            builder.Register(c => new HttpClient(c.Resolve <PolicyHttpMessageHandler>()))
            .SingleInstance();
        }
Exemplo n.º 5
0
        private string GetAccessToken(bool includeRealApiClaim = false)
        {
            var config = EswDevOpsSdk.BuildConfiguration();

            var generator = new TokenGenerator();

            var issuer = config["STSIssuer"];

            var claims = new List <Claim>
            {
                new Claim("client_id", "esw.toolingIntTestClient"),
                new Claim("sub", "blah"),
                new Claim("idp", "oidc-azure"),
                new Claim("Scope", "openid"),
                new Claim("Scope", "profile"),
                new Claim("Scope", "esw.toolingIntTest"),

                new Claim("amr", "external")
            };

            if (includeRealApiClaim)
            {
                claims.Add(new Claim("Scope", "esw.toolingInt"));
            }

            return(generator.CreateAccessToken($"{issuer}", new List <string>
            {
                $"{issuer}/resources",
                "esw.toolingIntTest"
            }, claims, 3600));
        }
Exemplo n.º 6
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.Register(c =>
            {
                var tokenProvider        = new AzureServiceTokenProvider();
                var tokenProviderAdapter = new AzureServiceTokenProviderAdapter(tokenProvider);
                return(new TokenCredentials(tokenProviderAdapter));
            });

            builder.Register(c =>
            {
                var tokenCredentials = c.Resolve <TokenCredentials>();

                var client = RestClient.Configure()
                             .WithEnvironment(AzureEnvironment.AzureGlobalCloud)
                             .WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)
                             .WithCredentials(new AzureCredentials(tokenCredentials, tokenCredentials, string.Empty,
                                                                   AzureEnvironment.AzureGlobalCloud))
                             .Build();

                return(Azure.Authenticate(client, string.Empty));
            });

            foreach (DeploymentEnvironment env in Enum.GetValues(typeof(DeploymentEnvironment)))
            {
                var subscriptionId = EswDevOpsSdk.GetSierraDeploymentSubscriptionId(env);
                builder.Register(c =>
                {
                    var authenticated = c.Resolve <Azure.IAuthenticated>();
                    return(authenticated.WithSubscription(subscriptionId));
                }).Keyed <IAzure>(env).InstancePerLifetimeScope();
            }
        }
Exemplo n.º 7
0
        private async Task <string> GetAccessToken(bool includeRealApiClaim = false)
        {
            var config = EswDevOpsSdk.BuildConfiguration();

            var generator = new TokenGenerator();

            var certificate = new X509Certificate2(Convert.FromBase64String(config["STSSigningCert"]), "");
            var issuer      = config["STSIssuer"];

            var claims = new List <Claim>
            {
                new Claim("client_id", "esw.toolingIntTestClient"),
                new Claim("sub", "blah"),
                new Claim("idp", "oidc-azure"),
                new Claim("Scope", "openid"),
                new Claim("Scope", "profile"),
                new Claim("Scope", "esw.toolingIntTest"),

                new Claim("amr", "external")
            };

            if (includeRealApiClaim)
            {
                claims.Add(new Claim("Scope", "esw.toolingInt"));
            }

            return(await generator.CreateAccessTokenAsync($"{issuer}", new List <string>
            {
                $"{issuer}/resources",
                "esw.toolingIntTest"
            }, certificate, 3600, claims));
        }
Exemplo n.º 8
0
    public async Task AddTest(bool resourceGroupExists)
    {
        using (var scope = Fixture.Container.BeginLifetimeScope())
        {
            var cl    = scope.Resolve <HttpClient>();
            var azure = scope.ResolveKeyed <IAzure>(EswDevOpsSdk.GetEnvironment());
            await PrepareResourceGroup(resourceGroupExists, azure);

            try
            {
                var rg            = TestResourceGroupRequest();
                var actorResponse = await cl.PostJsonToActor(Fixture.TestMiddlewareUri, "ResourceGroup", "Add", rg);

                actorResponse.Should().NotBeNull();
                actorResponse.ResourceId.Should().NotBeNullOrEmpty();
                actorResponse.State.Should().Be(EntityStateEnum.Created);

                await Task.Delay(TimeSpan.FromSeconds(5));

                var isResourceGroupCreated = await azure.ResourceGroups.ContainAsync(TestResourceGroupName);

                isResourceGroupCreated.Should()
                .BeTrue($"the resource {TestResourceGroupName} group should be created in the {azure.SubscriptionId} subscription, but the actor reported that it created {actorResponse.ResourceId}.");
                var createdResourceGroup = await azure.ResourceGroups.GetByNameAsync(TestResourceGroupName);

                createdResourceGroup.Should().NotBeNull();
                createdResourceGroup.Region.Should().Be(Fixture.TestRegion);
                actorResponse.ResourceId.Should().Be(createdResourceGroup.Id);
            }
            finally
            {
                await DeleteResourceGroup(azure, TestResourceGroupName);
            }
        }
    }
Exemplo n.º 9
0
    public void BuildConfiguration_NonTestMode()

    {
        var sut = EswDevOpsSdk.BuildConfiguration(AssemblyDirectory);

        sut["KeyTestAppSettings"].Should().BeNullOrEmpty();
    }
Exemplo n.º 10
0
    /// <summary>
    /// constructor logic
    ///
    /// it invokes the tenant api to create the tenant so that other tests dependent on this fixture do not have to concern with the set up
    /// </summary>
    public TenantL3TestFixture()
    {
        var builder = new ContainerBuilder();

        builder.RegisterModule(new CoreModule(true));
        builder.RegisterModule(new VstsModule());
        builder.Register(c => new SierraDbContext
        {
            ConnectionString = c.Resolve <IConfigurationRoot>()["SierraDbConnectionString"]
        });
        builder.Register(c =>
        {
            TestConfig = new TestConfig();
            var config = EswDevOpsSdk.BuildConfiguration(true);
            config.GetSection("TestConfig").Bind(TestConfig);
            return(TestConfig);
        });

        Container  = builder.Build();
        TestConfig = Container.Resolve <TestConfig>();
        EnsureTenantCreated().Wait(TenantApiTimeout);
        //load tenant into memory
        using (var scope = Container.BeginLifetimeScope())
        {
            var dbContext = scope.Resolve <SierraDbContext>();
            TenantUnderTest = dbContext.LoadCompleteTenantAsync(TenantCode).Result;
        }
    }
Exemplo n.º 11
0
        public void ForCIReturnWEOnly()
        {
            Environment.SetEnvironmentVariable(EswDevOpsSdk.DeploymentRegionEnvVariable, null, EnvironmentVariableTarget.User);
            Environment.SetEnvironmentVariable(EswDevOpsSdk.DeploymentRegionEnvVariable, null, EnvironmentVariableTarget.Process);
            Environment.SetEnvironmentVariable(EswDevOpsSdk.DeploymentRegionEnvVariable, null, EnvironmentVariableTarget.Machine);

            Environment.SetEnvironmentVariable(EswDevOpsSdk.DeploymentRegionEnvVariable, "West Europe", EnvironmentVariableTarget.Machine);

            EswDevOpsSdk.CreateDeploymentContext(DeploymentEnvironment.CI).PreferredRegions.Should().ContainInOrder("West Europe");
        }
Exemplo n.º 12
0
        public void ForAllProductionRegions(string regionValue, string[] expectedRegionHierarchy)
        {
            Environment.SetEnvironmentVariable(EswDevOpsSdk.DeploymentRegionEnvVariable, null, EnvironmentVariableTarget.User);
            Environment.SetEnvironmentVariable(EswDevOpsSdk.DeploymentRegionEnvVariable, null, EnvironmentVariableTarget.Process);
            Environment.SetEnvironmentVariable(EswDevOpsSdk.DeploymentRegionEnvVariable, null, EnvironmentVariableTarget.Machine);

            Environment.SetEnvironmentVariable(EswDevOpsSdk.DeploymentRegionEnvVariable, regionValue, EnvironmentVariableTarget.Machine);

            EswDevOpsSdk.CreateDeploymentContext().PreferredRegions.Should().ContainInOrder(expectedRegionHierarchy);
        }
Exemplo n.º 13
0
    public void GetSubscriptionId_works_for_known_environments()
    {
        var environmentNames = Enum.GetNames(typeof(DeploymentEnvironment));

        foreach (var environmentName in environmentNames)
        {
            Environment.SetEnvironmentVariable(EswDevOpsSdk.EnvironmentEnvVariable, environmentName, EnvironmentVariableTarget.Process);
            var subscriptionId = EswDevOpsSdk.GetSubscriptionId();
            subscriptionId.Should().NotBeNullOrEmpty();
        }
    }
Exemplo n.º 14
0
    public void GetDeploymentSubscriptionIdTest(DeploymentEnvironment environmentName, DeploymentEnvironment deploymentEnvironmentName, object resultEnvironmentSubscription)
    {
        Environment.SetEnvironmentVariable(EswDevOpsSdk.EnvironmentEnvVariable, environmentName.ToString(), EnvironmentVariableTarget.Process);
        var expectedSubscriptionId = resultEnvironmentSubscription as string == SierraIntegration
            ? EswDevOpsSdk.SierraIntegrationSubscriptionId
            : EswDevOpsSdk.GetSubscriptionId(deploymentEnvironmentName);

        var subscriptionId = EswDevOpsSdk.GetSierraDeploymentSubscriptionId(deploymentEnvironmentName);

        subscriptionId.Should().Be(expectedSubscriptionId);
    }
Exemplo n.º 15
0
    public void BuildConfiguration_EnvironmentOverwrites()
    {
        Environment.SetEnvironmentVariable("OPTION2", "fromEnv", EnvironmentVariableTarget.Process);
        Environment.SetEnvironmentVariable("OPTION5", "fromEnv", EnvironmentVariableTarget.Process);
        var sut = EswDevOpsSdk.BuildConfiguration(AssemblyDirectory, "ORDER");

        sut["Option1"].Should().BeEquivalentTo("fromOrderAppSetting");
        sut["Option2"].Should().BeEquivalentTo("fromEnv");
        sut["Option3"].Should().BeEquivalentTo("value3");
        sut["Option4"].Should().BeEquivalentTo("fromKV");
        sut["Option5"].Should().BeEquivalentTo("fromENV");
    }
Exemplo n.º 16
0
        protected override void Load(ContainerBuilder builder)
        {
            var config = EswDevOpsSdk.BuildConfiguration(TestMode);

            builder.RegisterInstance(config)
            .As <IConfigurationRoot>()
            .SingleInstance();

            builder.Register <IBigBrother>(c =>
            {
                var insKey = c.Resolve <IConfigurationRoot>()["BBInstrumentationKey"];
                return(new BigBrother(insKey, insKey));
            })
            .SingleInstance();
        }
Exemplo n.º 17
0
 public Startup(IHostingEnvironment env)
 {
     try
     {
         _configuration = EswDevOpsSdk.BuildConfiguration(env.ContentRootPath, env.EnvironmentName);
         var internalKey = _configuration["BBInstrumentationKey"];
         _bb = new BigBrother(internalKey, internalKey);
         _bb.UseEventSourceSink().ForExceptions();
     }
     catch (Exception e)
     {
         BigBrother.Write(e);
         throw;
     }
 }
Exemplo n.º 18
0
    public void GeEnvironmentTest(string envValue, DeploymentEnvironment env)
    {
        var prevEnv = Environment.GetEnvironmentVariable(EswDevOpsSdk.EnvironmentEnvVariable);

        Environment.SetEnvironmentVariable(EswDevOpsSdk.EnvironmentEnvVariable, envValue, EnvironmentVariableTarget.Process);
        try
        {
            var currentEnvironment = EswDevOpsSdk.GetEnvironment();
            currentEnvironment.Should().Be(env);
        }
        finally
        {
            Environment.SetEnvironmentVariable(EswDevOpsSdk.EnvironmentEnvVariable, prevEnv, EnvironmentVariableTarget.Process);
        }
    }
Exemplo n.º 19
0
    public ActorTestsFixture()
    {
        if (string.IsNullOrWhiteSpace(EswDevOpsSdk.GetEnvironmentName()))
        {
            var defaultTestExecutionEnvironment = DeploymentEnvironment.Development.ToString();
            System.Environment.SetEnvironmentVariable(EswDevOpsSdk.EnvironmentEnvVariable, defaultTestExecutionEnvironment);
            EswDevOpsSdk.GetEnvironmentName().Should().Be(defaultTestExecutionEnvironment);
        }

        var builder = new ContainerBuilder();

        builder.RegisterModule(new CoreModule(true));
        builder.RegisterModule(new VstsModule());
        builder.RegisterModule(new AzureManagementFluentModule());
        builder.Register(c => new SierraDbContext
        {
            ConnectionString = c.Resolve <IConfigurationRoot>()["SierraDbConnectionString"]
        });
        builder.Register(c => new HttpClient {
            Timeout = TimeSpan.FromSeconds(200)
        });

        builder.Register(c =>
        {
            var testConfig = new TestConfig();

            var config = EswDevOpsSdk.BuildConfiguration(true);
            config.GetSection("TestConfig").Bind(testConfig);

            TestMiddlewareUri = $"{testConfig.ApiUrl}test";
            TestRegion        = string.IsNullOrEmpty(testConfig.RegionName)
                ? Region.EuropeNorth
                : Region.Create(testConfig.RegionName);

            Environment = Enum.Parse <DeploymentEnvironment>(testConfig.Environment, true);

            DeploymentSubscriptionId = EswDevOpsSdk.SierraIntegrationSubscriptionId;

            return(testConfig);
        });

        Container = builder.Build();
        //trigger set up
        Container.Resolve <TestConfig>();
    }
Exemplo n.º 20
0
        /// <summary>
        /// Uses the desired default configurations.  Environment taken from EnvVariable "ENVIRONMENT" if not passed.
        /// Builds configuration sources in the following order:
        /// - 1. Environment variables
        /// - 2. Command line arguments
        /// - 3. Json file (appsettings.json, followed by appsettings.{env}.json)
        /// Note:
        /// - appsettings.{env}.json WILL override appsettings.json file settings.
        /// </summary>
        /// <param name="builder">The configuration builder to bind to.</param>
        /// <param name="appSettingsPath">The application settings path.</param>
        /// <param name="environment">Specify the environment - optional, as its loaded from the ENVIRONMENT env variable if not set here.</param>
        /// <returns>The configuration builder after config has been added.</returns>
        public static IConfigurationBuilder UseDefaultConfigs(this IConfigurationBuilder builder, string appSettingsPath = "appsettings.json", string environment = null)
        {
            builder.AddEnvironmentVariables()
            .AddCommandLine(Environment.GetCommandLineArgs())
            .AddJsonFile(appSettingsPath, true);

            var env = EswDevOpsSdk.GetEnvironmentName();

            if (!string.IsNullOrEmpty(environment))
            {
                env = environment;
            }

            if (!string.IsNullOrEmpty(env))
            {
                builder.AddJsonFile($"appsettings.{env}.json", true, true);
            }

            return(builder);
        }
Exemplo n.º 21
0
    public async Task AddTest(OperationPhase operationPhase)
    {
        using (var scope = Fixture.Container.BeginLifetimeScope())
        {
            var cl            = scope.Resolve <HttpClient>();
            var azure         = scope.ResolveKeyed <IAzure>(EswDevOpsSdk.GetEnvironment());
            var resourceGroup = await EnsureResourceGroupExists(azure, TestResourceGroupName, Region.EuropeNorth);

            var scaleSet = await GetScaleSet(azure);
            await Prepare(azure, operationPhase, resourceGroup, scaleSet, IdentityName);

            var msi           = CreateMangedIdentityAssignment();
            var actorResponse = await cl.PostJsonToActor(Fixture.TestMiddlewareUri, "ManagedIdentity", "Add", msi);

            actorResponse.Should().NotBeNull();
            actorResponse.IdentityId.Should().NotBeNullOrEmpty();
            actorResponse.State.Should().Be(EntityStateEnum.Created);

            var policy = Policy
                         .Handle <CloudException>()
                         .OrResult <IIdentity>(x => x == null)
                         .WaitAndRetryAsync(3, retryAttempt =>
                                            TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))
                                            );

            var capturedIdentity =
                await policy.ExecuteAndCaptureAsync(() => azure.Identities.GetByIdAsync(actorResponse.IdentityId));

            capturedIdentity.Result.Should().NotBeNull(
                $"the identity {actorResponse.IdentityId} should be created in {azure.SubscriptionId} subscription");
            capturedIdentity.Result.Name.Should().Be(msi.IdentityName);
            capturedIdentity.Result.ResourceGroupName.Should().Be(msi.ResourceGroupName);

            var modifiedScaleSet = await GetScaleSet(azure);

            var isAssigned = IsIdentityAssigned(modifiedScaleSet, capturedIdentity.Result);
            isAssigned.Should()
            .BeTrue($"the identity {capturedIdentity.Result.Id} should be assigned to the scale set {modifiedScaleSet.Id}");
        }
    }
Exemplo n.º 22
0
    public async Task RemoveTests(bool resourceGroupExists)
    {
        using (var scope = Fixture.Container.BeginLifetimeScope())
        {
            var cl    = scope.Resolve <HttpClient>();
            var azure = scope.ResolveKeyed <IAzure>(EswDevOpsSdk.GetEnvironment());
            await PrepareResourceGroup(resourceGroupExists, azure);

            try
            {
                await cl.PostJsonToActor(Fixture.TestMiddlewareUri, "ResourceGroup", "Remove", TestResourceGroupRequest());

                await Task.Delay(TimeSpan.FromSeconds(5));

                var exists = await azure.ResourceGroups.ContainAsync(TestResourceGroupName);

                exists.Should().BeFalse();
            }
            finally
            {
                await DeleteResourceGroup(azure, TestResourceGroupName);
            }
        }
    }
Exemplo n.º 23
0
        private async Task CustomizeNonRingPipeline(VstsReleaseDefinition model, ReleaseDefinition pipeline)
        {
            //load sf endpoints
            var connectionEndpoints =
                await _taskAgentHttpClient.GetServiceEndpointsAsync(_vstsConfiguration.VstsTargetProjectId);

            //set up source trigger
            var sourceTrigger = (ArtifactSourceTrigger)pipeline.Triggers.First();

            sourceTrigger.ArtifactAlias = model.BuildDefinition.ToString();

            var clonedEnvStages = new List <ReleaseDefinitionEnvironment>();

            var rank = 1;

            //relink to target build definition
            foreach (var e in pipeline.Environments)
            {
                if (!Enum.TryParse(e.Name, true, out DeploymentEnvironment sierraEnvironment))
                {
                    throw new Exception($"Release template #{pipeline.Id} contains unrecognized environment - {e.Name}");
                }

                if (model.SkipEnvironments != null && model.SkipEnvironments.Contains(sierraEnvironment))
                {
                    continue;
                }

                ReleaseDefinitionEnvironment predecessor = null;

                foreach (var r in EswDevOpsSdk.GetRegionSequence(sierraEnvironment, default))
                {
                    var regionEnv = e.DeepClone();
                    var phase     = regionEnv.DeployPhases.First();
                    var envInput  = (AgentDeploymentInput)phase.GetDeploymentInput();
                    envInput.ArtifactsDownloadInput.DownloadInputs.First().Alias = model.BuildDefinition.ToString();

                    regionEnv.Name = $"{e.Name} - {r}";
                    regionEnv.Rank = rank++;
                    regionEnv.Id   = regionEnv.Rank;
                    //link condition to predecessor (region)
                    if (predecessor != null)
                    {
                        regionEnv.Conditions = new List <Condition>(new[]
                        {
                            new Condition(predecessor.Name, ConditionType.EnvironmentState,
                                          "4" /*find the documentation for this value*/)
                        });
                    }

                    //re-point to correct SF instance
                    var sfDeployStep =
                        phase.WorkflowTasks.FirstOrDefault(t => t.TaskId == Guid.Parse(VstsSfDeployTaskId));

                    if (sfDeployStep == null)
                    {
                        throw new Exception(
                                  $"Release template #{pipeline.Id} does not contain expected Task {VstsSfDeployTaskId} for {e.Name} environment");
                    }

                    var expectedConnectionName =
                        $"esw-{r.ToRegionCode().ToLowerInvariant()}-fabric-{e.Name.ToLowerInvariant()}";

                    var sfConnection = connectionEndpoints.FirstOrDefault(c => c.Name == expectedConnectionName);
                    if (sfConnection == null)
                    {
                        throw new Exception(
                                  $"SF Endpoint {expectedConnectionName} not found in VSTS project {_vstsConfiguration.VstsTargetProjectId}");
                    }

                    sfDeployStep.Inputs[VstsSfDeployTaskConnectionNameInput] = sfConnection.Id.ToString();

                    //set region in manifest
                    var sfUpdaterStep =
                        phase.WorkflowTasks.FirstOrDefault(t => t.TaskId == Guid.Parse(VstsSfUpdateTaskId));

                    if (sfUpdaterStep == null)
                    {
                        throw new Exception(
                                  $"Release template {pipeline.Name} does not contain expected Task {VstsSfUpdateTaskId} for {e.Name} environment");
                    }

                    sfUpdaterStep.Inputs[VstsSfUpdateTaskRegionInput] = r.ToRegionName();

                    clonedEnvStages.Add(regionEnv);
                    predecessor = regionEnv;
                }
            }

            pipeline.Environments = clonedEnvStages;

            //set tenant specific variables
            pipeline.Variables["TenantCode"].Value = model.TenantCode;
            pipeline.Variables["PortNumber"].Value = "11111"; //TODO: link to port management
        }
Exemplo n.º 24
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="env">hosting environment</param>
 public Startup(IHostingEnvironment env)
 {
     _configuration = EswDevOpsSdk.BuildConfiguration(env.ContentRootPath, env.EnvironmentName);
     AppSettings    = _configuration.GetSection("App").Get <AppSettings>();
     _bb            = new BigBrother(AppSettings.Telemetry.InstrumentationKey, AppSettings.Telemetry.InternalKey);
 }
Exemplo n.º 25
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="env">hosting environment</param>
 public Startup(IHostingEnvironment env)
 {
     _configuration = EswDevOpsSdk.BuildConfiguration(env.ContentRootPath, env.EnvironmentName);
     _configuration.GetSection("Telemetry").Bind(_telemetrySettings);
     _bb = new BigBrother(_telemetrySettings.InstrumentationKey, _telemetrySettings.InternalKey);
 }
Exemplo n.º 26
0
    public void BuildConfiguration_MSIAuthenticationTest()
    {
        var sut = EswDevOpsSdk.BuildConfiguration(AssemblyDirectory, "CI");

        sut["keyVaultItem"].Should().Be("keyVaultItemValue");
    }
Exemplo n.º 27
0
    public void BuildConfiguration_ReadFromEnvironmentalVariable()
    {
        var sut = EswDevOpsSdk.BuildConfiguration(AssemblyDirectory);

        sut["PATH"].Should().NotBeNullOrEmpty();
    }
Exemplo n.º 28
0
    public void GetRegionSequence_ForAllEnvironments(DeploymentEnvironment env, DeploymentRegion source, DeploymentRegion[] expected)
    {
        var ret = EswDevOpsSdk.GetRegionSequence(env, source);

        ret.Should().ContainInOrder(expected).And.HaveCount(expected.Length);
    }