Exemple #1
0
        public void AzureMsalClientBadIdTest()
        {
            TestUtilities utils = DefaultUtilities();

            DeleteTokenCache();

            ProcessOutput results = utils.ExecuteTest((config) =>
            {
                config.AzureClientId = "test";
                return(config.ValidateAad());
            }, utils.Collector.Config);

            Assert.IsTrue(results.ToString().Contains("client_id_must_be_guid"), results.ToString());
            Assert.IsTrue(results.HasErrors(), results.ToString());
        }
Exemple #2
0
        public void AzureMsalUserAuthTest()
        {
            TestUtilities utils = DefaultUtilities();

            DeleteTokenCache();

            ProcessOutput results = utils.ExecuteTest((config) =>
            {
                config.AzureClientId              = null;
                config.AzureClientCertificate     = null;
                config.AzureResourceGroup         = null;
                config.AzureResourceGroupLocation = null;
                config.AzureSubscriptionId        = null;
                config.AzureTenantId              = null;

                return(config.ValidateAad());
            }, utils.Collector.Config);

            /* known cng error in .net core that test is running as and azure-az modules
             * fix is to use cert thumb as secret but cert may have to be real / from ca
             */
            Assert.IsFalse(results.HasErrors(), results.ToString());

            /*
             *  "StandardError": "13:Validate:exception: validate:exception:System.AggregateException: One or more errors occurred. (Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.)\r\n ---> System.TypeLoadException: Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.\r\n   at Microsoft.Identity.Client.Platforms.net45.NetDesktopCryptographyManager.CreateSha256HashBytes(
             */
        }
Exemple #3
0
 protected static void ValidateOutput(ProcessOutput output)
 {
     if (output.ExitCode != 0)
     {
         throw new TestInfrastructureException("Process exited in error " + output.ToString());
     }
 }
        public void AzureClientCertificateLocalFile()
        {
            TestUtilities        utils  = DefaultUtilities();
            ConfigurationOptions config = utils.ConfigurationOptions;

            utils.ConfigurationOptions.Validate();
            DeleteTokenCache();

            ProcessOutput results = utils.ExecuteTest((config) =>
            {
                AzureResourceManager arm = new AzureResourceManager(config);
                string certFile          = $"{TestUtilities.TempDir}\\{config.AzureClientSecret}.pfx";
                new CertificateUtilities().SaveCertificateToFile(_appCertificate, certFile);

                //config.AzureClientId = "";
                config.AzureClientCertificate = certFile;
                config.AzureKeyVault          = "";
                config.AzureClientSecret      = "";
                Assert.IsTrue(config.IsClientIdConfigured(), "test configuration invalid");
                return(config.ValidateAad());
            }, utils.Collector.Config);

            Assert.IsTrue(results.ExitBool);
            Assert.IsTrue(!results.HasErrors(), results.ToString());
        }
        public void DefaultSaveConfigurationTest()
        {
            TestUtilities utils = DefaultUtilities();

            File.Delete(utils.TempOptionsFile);

            ProcessOutput results = utils.ExecuteCollectSfData($"-save collectsfdata.options.json");

            Assert.IsTrue(results.HasErrors(), results.ToString());
            Assert.IsTrue(File.Exists(utils.TempOptionsFile));

            results = utils.ExecuteCollectSfData($"");

            Assert.IsTrue(results.HasErrors(), results.ToString());

            // should not start execution
            Assert.NotZero(results.ExitCode);
        }
        public void GatherTypeAnyTest()
        {
            TestUtilities utils = DefaultUtilities();

            utils.ConfigurationOptions.GatherType = FileTypesEnum.any.ToString();
            ProcessOutput results = utils.ExecuteTest();

            Assert.IsFalse(results.HasErrors(), results.ToString());
        }
Exemple #7
0
        public void AzureMsalClientTest()
        {
            TestUtilities utils   = DefaultUtilities();
            ProcessOutput results = utils.ExecuteTest((config) =>
            {
                return(config.ValidateAad());
            }, utils.Collector.Config);

            Assert.IsFalse(results.HasErrors(), results.ToString());
        }
        public void GatherTypeCounterTest()
        {
            TestUtilities utils = DefaultUtilities();

            utils.ConfigurationOptions.GatherType = FileTypesEnum.counter.ToString();

            ProcessOutput results = utils.ExecuteTest();

            Assert.IsFalse(results.HasErrors(), results.ToString());
            Assert.IsTrue(results.StandardOutput.Contains("total execution time in minutes"));
        }
Exemple #9
0
        public void KustoClusterValidUrlNoLocationTest()
        {
            TestUtilities utils = DefaultUtilities();

            utils.ConfigurationOptions.KustoCluster = "https://ingest-testcluster.kusto.windows.net/testdatabase";
            utils.ConfigurationOptions.KustoTable   = "test";

            ProcessOutput results = utils.ExecuteTest();

            Assert.IsFalse(results.HasErrors(), results.ToString());
        }
        public void ThreadsZeroConfigurationTest()
        {
            TestUtilities utils = DefaultUtilities();

            utils.ConfigurationOptions.Threads = 0;
            ProcessOutput results = utils.ExecuteTest();

            Assert.IsTrue(!results.HasErrors(), results.ToString());
            Assert.IsTrue(File.Exists(utils.TempOptionsFile));

            // should start execution
            Assert.Zero(results.ExitCode);
        }
Exemple #11
0
        public void AzureMsalDeviceAuthTest()
        {
            ProcessOutput results = DefaultUtilities().ExecuteTest(() =>
            {
                AzureResourceManager arm             = new AzureResourceManager();
                AzureResourceManager.MsalMessage    += AzureResourceManager_MsalMessage;
                AzureResourceManager.MsalDeviceCode += AzureResourceManager_MsalDeviceCode;

                bool result = arm.CreatePublicClient(true, true);
                AzureResourceManager.MsalMessage    -= AzureResourceManager_MsalMessage;
                AzureResourceManager.MsalDeviceCode -= AzureResourceManager_MsalDeviceCode;

                return(result);
            });

            Assert.IsFalse(results.HasErrors(), results.ToString());
        }
        public void AzureClientCertificateKeyVaultAppRegistration()
        {
            TestUtilities        utils  = DefaultUtilities();
            ConfigurationOptions config = utils.ConfigurationOptions;

            utils.ConfigurationOptions.Validate();
            DeleteTokenCache();

            ProcessOutput results = utils.ExecuteTest((config) =>
            {
                config.AzureClientCertificate = "";
                Assert.IsTrue(config.IsClientIdConfigured(), "test configuration invalid");
                return(config.ValidateAad());
            }, utils.Collector.Config);

            Assert.IsTrue(results.ExitBool);
            Assert.IsTrue(!results.HasErrors(), results.ToString());
        }
        public void ThreadsNullConfigurationTest()
        {
            TestUtilities utils = DefaultUtilities();

            utils.SaveTempOptions();

            string config = File.ReadAllText(utils.TempOptionsFile);

            config = Regex.Replace(config, "\"Threads\".+", "\"Threads\": null,", RegexOptions.IgnoreCase);
            File.WriteAllText(utils.TempOptionsFile, config);

            ProcessOutput results = utils.ExecuteCollectSfData($"-config {utils.TempOptionsFile}");

            Assert.IsTrue(!results.HasErrors(), results.ToString());
            Assert.IsTrue(File.Exists(utils.TempOptionsFile));

            // should start execution
            Assert.Zero(results.ExitCode);
        }
        public void DefaultConfigurationTest()
        {
            TestUtilities utils = DefaultUtilities();
            string        defaultOptionsFile = $"{TestUtilities.WorkingDir}\\collectsfdata.options.json";

            if (!File.Exists(defaultOptionsFile) & File.Exists(DefaultOptionsFile))
            {
                defaultOptionsFile = DefaultOptionsFile;
            }

            Assert.IsTrue(File.Exists(defaultOptionsFile));

            ProcessOutput results = utils.ExecuteCollectSfData(defaultOptionsFile);

            Assert.IsTrue(results.HasErrors(), results.ToString());

            // should not start execution
            Assert.NotZero(results.ExitCode);
        }
        public void AzureClientCertificateKeyVaultUserManagedIdentity()
        {
            TestUtilities        utils  = DefaultUtilities();
            ConfigurationOptions config = utils.ConfigurationOptions;

            utils.ConfigurationOptions.Validate();
            DeleteTokenCache();

            ProcessOutput results = utils.ExecuteTest((config) =>
            {
                //config.AzureClientId = "";
                Assert.IsTrue(config.IsClientIdConfigured(), "test configuration invalid");
                AzureResourceManager arm = new AzureResourceManager(config);

                Assert.IsTrue(arm.ClientIdentity.IsUserManagedIdentity, "arm.IsUserManagedIdentity not detected. test from azure vm with user managed identity enabled.");
                return(config.ValidateAad());
            }, utils.Collector.Config);

            Assert.IsTrue(results.ExitBool);
            Assert.IsTrue(!results.HasErrors(), results.ToString());
        }
        public void AzureClientCertificateX509withPassword()
        {
            TestUtilities        utils  = DefaultUtilities();
            ConfigurationOptions config = utils.ConfigurationOptions;

            utils.ConfigurationOptions.Validate();
            DeleteTokenCache();

            ProcessOutput results = utils.ExecuteTest((config) =>
            {
                CertificateUtilities certificateUtilities = new CertificateUtilities();
                certificateUtilities.SetSecurePassword(TestUtilities.TestProperties.testAdminPassword);

                config.ClientCertificate = certificateUtilities.GetClientCertificate(TestUtilities.TestProperties.AzureClientCertificate);// _appCertificate;
                config.AzureKeyVault     = "";
                Assert.IsTrue(config.IsClientIdConfigured(), "test configuration invalid");
                return(config.ValidateAad());
            }, utils.Collector.Config);

            Assert.IsTrue(results.ExitBool);
            Assert.IsTrue(!results.HasErrors(), results.ToString());
        }
Exemple #17
0
        public void CheckNativePortOpen(ProcessOutput output, string ip)
        {
            using (var ccmConnection = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
            {
                using (var cts = new CancellationTokenSource(5 * 60 * 1000))
                {
                    while (!cts.IsCancellationRequested)
                    {
                        try
                        {
                            ccmConnection.Connect(ip, 9042);
                            return;
                        }
                        catch
                        {
                            Thread.Sleep(5000);
                        }
                    }
                }
            }

            throw new TestInfrastructureException("Native Port check timed out. Output: " + Environment.NewLine + output.ToString());
        }
        public void GatherTypeNullTest()
        {
            TestUtilities utils = DefaultUtilities();

            utils.ConfigurationOptions.GatherType = null;

            ProcessOutput results = utils.ExecuteTest();

            Assert.IsTrue(results.StandardOutput.Contains("ValidateFileType:warning: invalid -type"), results.ToString());
            // should not start execution
            Assert.NotZero(results.ExitCode);
        }
 private static void ValidateOutput(ProcessOutput output)
 {
     if (output.ExitCode != 0)
     {
         throw new TestInfrastructureException(string.Format("Process exited in error {0}", output.ToString()));
     }
 }
Exemple #20
0
        internal static void Exec(string binariesDirectory, string dataDirectory, int port)
        {
            string pgControllerExecutablePath = $"{binariesDirectory}{Path.DirectorySeparatorChar}{PostgresDefaults.ServerControllerExecutable}";
            string arguments = $"start -D \"{dataDirectory}\" -s -o \"-i -p {port} -F \"";

            System.Diagnostics.Process serverStarterProcess = Process.ProcessController
                                                              .CreateProcess(pgControllerExecutablePath, arguments);

            ProcessOutput output = Process.ProcessController
                                   .StartAndWaitForReady(serverStarterProcess, ProcessTimeoutInSeconds, ProcessIdentifier, $"Postgres starting | port: {port}");

            if (output.ExitCode != 0)
            {
                throw new PostgresProcessFinishedWithErrorsException("Cannot start Postmaster." + output.ToString());
            }
        }