Exemple #1
0
        public void ShouldBeEnabled(string accountType, string connectionEndpoint, ScriptSyntax syntax, bool expected)
        {
            var variables = new CalamariVariables
            {
                { SpecialVariables.Account.AccountType, accountType },
                { SpecialVariables.Action.ServiceFabric.ConnectionEndpoint, connectionEndpoint }
            };
            var target = new AzurePowerShellContext(variables);
            var actual = target.IsEnabled(syntax);

            actual.Should().Be(expected);
        }
Exemple #2
0
        public void CertificateRemovedAfterScriptExecution()
        {
            OctopusTestAzureSubscription.IgnoreIfCertificateNotInstalled();
            var powershellContext = new AzurePowerShellContext();
            var scriptEngine      = Substitute.For <IScriptEngine>();
            var commandLineRunner = Substitute.For <ICommandLineRunner>();

            var variables = new CalamariVariableDictionary();

            OctopusTestAzureSubscription.PopulateVariables(variables);

            using (var variablesFile = new TemporaryFile(Path.GetTempFileName()))
            {
                var expectedCertFile = Path.Combine(variablesFile.DirectoryPath, "azure_certificate.pfx");

                scriptEngine
                .When(engine => engine.Execute(Arg.Any <string>(), variables, commandLineRunner))
                .Do(callInfo => Assert.True(File.Exists(expectedCertFile)));

                powershellContext.ExecuteScript(scriptEngine, variablesFile.FilePath, variables, commandLineRunner);

                Assert.False(File.Exists(expectedCertFile));
            }
        }