public void TestSendReport_BadDateFormat()
        {
            var report = new Model.SendReportBody
            {
                JobId               = Guid.NewGuid(),
                StartTime           = "NOW",
                EndTime             = "THEN",
                OperationType       = "FOO",
                ReportFormatVersion = "BAR",
            };

            var config = BuildConfig();

            using (var client = new DscPullClient(config))
            {
                client.DisableReportAdditionalData = _testConfig.adjust_for_wmf_50;
                TugAssert.ThrowsExceptionWhen <AggregateException>(
                    condition: (ex) =>
                    ex.InnerException is HttpRequestException &&
                    ex.InnerException.Message.Contains(
                        "Response status code does not indicate success: 500 (Internal Server Error)"),
                    action: () =>
                    client.SendReport(report).Wait(),
                    message:
                    "Throws HTTP exception for internal server error (500)");
            }
        }
Exemple #2
0
        public void TestGetDscAction_BadContent_StatusItem()
        {
            var config = BuildConfig();

            using (var client = new DscPullClient(config))
            {
                // Construct our own status item collection
                var statusItems = new[] { new Model.ClientStatusItem() };
                statusItems[0].ChecksumAlgorithm = "SHA-256";
                statusItems[0].Checksum          = "";
                statusItems[0].ConfigurationName = config.ConfigurationNames.First();
                // Inject one unexpected property
                statusItems[0]["foo"] = "bar";

                client.RegisterDscAgent().Wait();

                TugAssert.ThrowsExceptionWhen <AggregateException>(
                    condition: (ex) =>
                    ex.InnerException is HttpRequestException &&
                    ex.InnerException.Message.Contains(
                        "Response status code does not indicate success: 400 (Bad Request)"),
                    action: () =>
                    client.GetDscAction(statusItems).Wait(),
                    message:
                    "Throws HTTP exception for bad request (400)");
            }
        }
Exemple #3
0
        public void TestRegisterDscAgent_BadCert_FieldOrder()
        {
            var config = BuildConfig(newAgentId: true);

            // Force bad/unexpected cert info
            var badCert = new BadFieldOrderCertInfo(config.CertificateInformation);

            config.CertificateInformation = badCert;

            using (var client = new DscPullClient(config))
            {
                TugAssert.ThrowsExceptionWhen <AggregateException>(
                    condition: (ex) =>
                    ex.InnerException is HttpRequestException
                    // We test for one of two possible error codes, either
                    // 401 which is returned from Classic DSC Pull Server or
                    // 400 which is returned from Tug Server which could not
                    // easily or practically reproduce the same error condition
                    && (ex.InnerException.Message.Contains(
                            "Response status code does not indicate success: 401 (Unauthorized)") ||
                        ex.InnerException.Message.Contains(
                            "Response status code does not indicate success: 400 (Bad Request)")),
                    action: () =>
                    client.RegisterDscAgent().Wait(),
                    message:
                    "Throws HTTP exception for unauthorized (401)");
            }
        }
        public void TestRegisterDscAgent_BadContent_CertInfo()
        {
            var c = BuildConfig();

            c.CertificateInformation["foo"] = "bar";

            TugAssert.ThrowsExceptionWhen <AggregateException>(
                condition: (ex) =>
                ex.InnerException is HttpRequestException &&
                ex.InnerException.Message.Contains(
                    "Response status code does not indicate success: 400 (Bad Request)"),
                action: () =>
                BuildClient(c).RegisterDscAgent().Wait(),
                message:
                "Throws HTTP exception for unauthorized (401)");
        }
        public void TestSendReport_BadMissingJobId()
        {
            var config = BuildConfig();

            using (var client = new DscPullClient(config))
            {
                client.DisableReportAdditionalData = _testConfig.adjust_for_wmf_50;
                TugAssert.ThrowsExceptionWhen <AggregateException>(
                    condition: (ex) =>
                    ex.InnerException is HttpRequestException &&
                    ex.InnerException.Message.Contains(
                        "Response status code does not indicate success: 400 (Bad Request)"),
                    action: () =>
                    client.SendReport(new BadSendReportBody()).Wait(),
                    message:
                    "Throws HTTP exception for bad request (400)");
            }
        }
Exemple #6
0
        public void TestRegisterDscAgent_BadRegKey()
        {
            var config = BuildConfig(newAgentId: true);

            // Force a bad RegKey
            config.ConfigurationRepositoryServer.RegistrationKey = Guid.NewGuid().ToString();

            using (var client = new DscPullClient(config))
            {
                TugAssert.ThrowsExceptionWhen <AggregateException>(
                    condition: (ex) =>
                    ex.InnerException is HttpRequestException &&
                    ex.InnerException.Message.Contains(
                        "Response status code does not indicate success: 401 (Unauthorized)"),
                    action: () =>
                    client.RegisterDscAgent().Wait(),
                    message:
                    "Throws HTTP exception for unauthorized (401)");
            }
        }
Exemple #7
0
        public void TestRegisterDscAgent_BadContent_CertInfo()
        {
            var config = BuildConfig(newAgentId: true);

            // Add an unexpected property
            config.CertificateInformation["foo"] = "bar";

            using (var client = new DscPullClient(config))
            {
                TugAssert.ThrowsExceptionWhen <AggregateException>(
                    condition: (ex) =>
                    ex.InnerException is HttpRequestException &&
                    ex.InnerException.Message.Contains(
                        "Response status code does not indicate success: 400 (Bad Request)"),
                    action: () =>
                    client.RegisterDscAgent().Wait(),
                    message:
                    "Throws HTTP exception for bad request (400)");
            }
        }
Exemple #8
0
        public void TestRegisterDscAgent_BadCert_NewField()
        {
            var config = BuildConfig(newAgentId: true);

            // Force bad/unexpected cert info
            var badCert = new BadNewFieldCertInfo(config.CertificateInformation);

            config.CertificateInformation = badCert;

            using (var client = new DscPullClient(config))
            {
                TugAssert.ThrowsExceptionWhen <AggregateException>(
                    condition: (ex) =>
                    ex.InnerException is HttpRequestException &&
                    ex.InnerException.Message.Contains(
                        "Response status code does not indicate success: 400 (Bad Request)"),
                    action: () =>
                    client.RegisterDscAgent().Wait(),
                    message:
                    "Throws HTTP exception for unauthorized (401)");
            }
        }