Example #1
0
        public async Task ServerDeploymentSourceIsReadableByRecipe()
        {
            // Arrange
            var recipeFile = "Recipe.json";

            var expectedSettings        = CreateSettings("https://deploy.localhost", TokenFormat.JsonWebToken, true);
            var deployServerServiceMock = CreateServerServiceWithSettingsMock(expectedSettings);

            var actualSettings          = CreateSettings("https://recipe.localhost", TokenFormat.DataProtection, false);
            var recipeServerServiceMock = CreateServerServiceWithSettingsMock(actualSettings);

            var settingsProperties = typeof(OpenIdServerSettings)
                                     .GetProperties();

            foreach (var property in settingsProperties)
            {
                Assert.NotEqual(
                    property.GetValue(expectedSettings),
                    property.GetValue(actualSettings));
            }

            var fileBuilder = new MemoryFileBuilder();
            var descriptor  = new RecipeDescriptor();
            var result      = new DeploymentPlanResult(fileBuilder, descriptor);

            var deploymentSource = new OpenIdServerDeploymentSource(deployServerServiceMock.Object);

            // Act
            await deploymentSource.ProcessDeploymentStepAsync(new OpenIdServerDeploymentStep(), result);

            await result.FinalizeAsync();

            var deploy = JObject.Parse(
                fileBuilder.GetFileContents(
                    recipeFile,
                    Encoding.UTF8));

            var recipeContext = new RecipeExecutionContext
            {
                RecipeDescriptor = descriptor,
                Name             = deploy.Property("steps").Value.First.Value <string>("name"),
                Step             = (JObject)deploy.Property("steps").Value.First,
            };

            var recipeStep = new OpenIdServerSettingsStep(recipeServerServiceMock.Object);
            await recipeStep.ExecuteAsync(recipeContext);

            // Assert
            foreach (var property in settingsProperties)
            {
                Assert.Equal(
                    property.GetValue(expectedSettings),
                    property.GetValue(actualSettings));
            }
        }
        public async Task ExecuteDeploymentPlanAsync(DeploymentPlan deploymentPlan, DeploymentPlanResult result)
        {
            foreach (var step in deploymentPlan.DeploymentSteps)
            {
                foreach (var source in _deploymentSources)
                {
                    await source.ProcessDeploymentStepAsync(step, result);
                }
            }

            await result.FinalizeAsync();
        }