public void ThreadsOneConfigurationTest()
        {
            TestUtilities utils = DefaultUtilities();

            utils.ConfigurationOptions.Threads = 1;

            ProcessOutput results = utils.ExecuteTest();

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

            // should start execution
            Assert.Zero(results.ExitCode);
        }
예제 #2
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());
        }
예제 #3
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());
        }