Beispiel #1
0
 public IActionResult Create([FromBody] ProvisionRequest provisionRequest)
 {
     return(Json(new ProvisionResponse {
         Config = provisionRequest.Options,
         Id = provisionRequest.Uuid,
     }));
 }
Beispiel #2
0
        /// <summary>
        /// Call Provision command.
        /// </summary>
        /// <param name="policyKey">The policy key.</param>
        /// <param name="policyType">The format in which the policy settings are to be provided to the client device.</param>
        /// <param name="status">The status of the initial Provision command.</param>
        /// <returns>The response of Provision command.</returns>
        protected ProvisionResponse CallProvisionCommand(string policyKey, string policyType, string status)
        {
            // Create Provision command request.
            ProvisionRequest provisionRequest = Common.CreateProvisionRequest(null, new Request.ProvisionPolicies(), null);

            Request.ProvisionPoliciesPolicy policy = new Request.ProvisionPoliciesPolicy {
                PolicyType = policyType
            };

            // The format in which the policy settings are to be provided to the client device.
            if (!string.IsNullOrEmpty(policyKey))
            {
                policy.PolicyKey = policyKey;
                policy.Status    = status;
            }
            else if (Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site) == "14.1" ||
                     Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site) == "16.0")
            {
                // Configure the DeviceInformation.
                Request.DeviceInformation    deviceInfomation     = new Request.DeviceInformation();
                Request.DeviceInformationSet deviceInformationSet = new Request.DeviceInformationSet
                {
                    Model = "ASPROVTest"
                };
                deviceInfomation.Set = deviceInformationSet;
                provisionRequest.RequestData.DeviceInformation = deviceInfomation;
            }

            provisionRequest.RequestData.Policies.Policy = policy;

            // Call Provision command.
            ProvisionResponse provisionResponse = this.PROVAdapter.Provision(provisionRequest);

            return(provisionResponse);
        }
Beispiel #3
0
        public async Task Provision(ProvisionRequest request)
        {
            await Task.Yield();

            var subscriptionId = request.SubscriptionId;
            var accountId = request.AccountId;
            var authToken = request.AuthorizationToken;

            bool failure = false;
            request.Course.State = CourseState.Provisioning;
            context.UpdateCourse(request.Course);

            try
            {
                Regex alphaNumericWithPeriod = new Regex(@"[^a-z0-9\.-]", RegexOptions.IgnoreCase);
                //var groupName = String.Join(".", request.Course.Name, student.LastName, student.FirstName, student.MicrosoftId.Split('@').First());
                var groupName = String.Join(".", request.Course.Name, request.Course.Id.ToString());
                groupName = alphaNumericWithPeriod.Replace(groupName, String.Empty);

                var factory = new AzureFactory(subscriptionId, accountId.ToString(), authToken);
                var group = factory.Create<CreateResourceGroupFactory>().CreateGroup(groupName);
                var plan = factory.Create<CreateWebHostingPlanFactory>().CreateWebPlan(group, "Student-Web-Site");
                factory.Create<AssignUserToRoleFactory>().CreateAndAssignRoleForGroup(group, request.PrincipalOwnerId, "WebSite Contributor");

                foreach (var student in context.GetStudentsInCourse(request.Course))
                {
                    var webFactory = factory.Create<CreateWebSiteFactory>();
                    var site = webFactory.CreateWebSite(plan, group);
                    var publishProfile = webFactory.GetPublishingProfile(site, group);
                    context.AddWebSite(request.Course, student, new Models.WebSite()
                    {
                        WebSiteUri = new Uri("http://" + site.Properties.HostNames.First()),
                        FtpUri = new Uri(publishProfile.PublishUrl),
                        FtpUsername = publishProfile.UserName,
                        FtpPassword = publishProfile.UserPassword
                    });
                }
            }
            catch
            {
                failure = true;
                request.Course.State = CourseState.Failed;
                throw;
            }
            finally
            {
                if (!failure)
                {
                    request.Course.State = CourseState.Complete;
                }

                context.UpdateCourse(request.Course);
            }

        }
Beispiel #4
0
        public async Task Provision(ProvisionRequest request)
        {
            await Task.Yield();

            var subscriptionId = request.SubscriptionId;
            var accountId      = request.AccountId;
            var authToken      = request.AuthorizationToken;

            bool failure = false;

            request.Course.State = CourseState.Provisioning;
            context.UpdateCourse(request.Course);

            try
            {
                Regex alphaNumericWithPeriod = new Regex(@"[^a-z0-9\.-]", RegexOptions.IgnoreCase);
                //var groupName = String.Join(".", request.Course.Name, student.LastName, student.FirstName, student.MicrosoftId.Split('@').First());
                var groupName = String.Join(".", request.Course.Name, request.Course.Id.ToString());
                groupName = alphaNumericWithPeriod.Replace(groupName, String.Empty);

                var factory = new AzureFactory(subscriptionId, accountId.ToString(), authToken);
                var group   = factory.Create <CreateResourceGroupFactory>().CreateGroup(groupName);
                var plan    = factory.Create <CreateWebHostingPlanFactory>().CreateWebPlan(group, "Student-Web-Site");
                factory.Create <AssignUserToRoleFactory>().CreateAndAssignRoleForGroup(group, request.PrincipalOwnerId, "WebSite Contributor");

                foreach (var student in context.GetStudentsInCourse(request.Course))
                {
                    var webFactory     = factory.Create <CreateWebSiteFactory>();
                    var site           = webFactory.CreateWebSite(plan, group);
                    var publishProfile = webFactory.GetPublishingProfile(site, group);
                    context.AddWebSite(request.Course, student, new Models.WebSite()
                    {
                        WebSiteUri  = new Uri("http://" + site.Properties.HostNames.First()),
                        FtpUri      = new Uri(publishProfile.PublishUrl),
                        FtpUsername = publishProfile.UserName,
                        FtpPassword = publishProfile.UserPassword
                    });
                }
            }
            catch
            {
                failure = true;
                request.Course.State = CourseState.Failed;
                throw;
            }
            finally
            {
                if (!failure)
                {
                    request.Course.State = CourseState.Complete;
                }

                context.UpdateCourse(request.Course);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Request the security policy settings that the administrator sets from the server.
        /// </summary>
        /// <param name="provisionRequest">The request of Provision command.</param>
        /// <returns>The response of Provision command.</returns>
        public ProvisionResponse Provision(ProvisionRequest provisionRequest)
        {
            ProvisionResponse provisionResponse = this.activeSyncClient.Provision(provisionRequest);

            Site.Assert.IsNotNull(provisionResponse, "The Provision response returned from server should not be null.");

            // Verify adapter requirements about Provision.
            this.VerifyProvisionCommandRequirements(provisionResponse);
            this.VerifyWBXMLRequirements();
            return(provisionResponse);
        }
            public void ThrowsArgumentExceptionWhenPlanIdDoesNotExist()
            {
                var configuration   = Substitute.For <IConfiguration>();
                var databaseBuilder = Substitute.For <IDatabaseBuilder>();

                configuration.GetAppSetting(Arg.Any <string>()).Returns("dashboard");
                var service = new MsSqlCloudFoundryService(configuration, databaseBuilder);
                var request = new ProvisionRequest {
                    PlanId = Guid.NewGuid().ToString(), InstanceId = "instanceId"
                };

                var ex = Assert.Throws <ArgumentException>(() => service.Provision(request));

                Assert.Equal(string.Format("The plan id {0} does not exists", request.PlanId), ex.Message);
            }
            public void CallsDatabaseBuilderWithCorrectPlan()
            {
                var configuration   = Substitute.For <IConfiguration>();
                var databaseBuilder = Substitute.For <IDatabaseBuilder>();

                configuration.GetAppSetting(Arg.Any <string>()).Returns("dashboard");
                var service = new MsSqlCloudFoundryService(configuration, databaseBuilder);
                var request = new ProvisionRequest {
                    PlanId = MsSqlService.FreePlanId.ToString(), InstanceId = Guid.NewGuid().ToString()
                };

                service.Provision(request);

                databaseBuilder.Received().CreateDatabase(Arg.Is <string>(x => x == request.InstanceId), Arg.Is <Plan>(x => x.Id == request.PlanId));
            }
            public void ReturnsCorrectUrlForDashboard()
            {
                var configuration   = Substitute.For <IConfiguration>();
                var databaseBuilder = Substitute.For <IDatabaseBuilder>();

                configuration.GetAppSetting(Arg.Any <string>()).Returns("dashboard");
                var service = new MsSqlCloudFoundryService(configuration, databaseBuilder);
                var request = new ProvisionRequest {
                    PlanId = MsSqlService.FreePlanId.ToString(), InstanceId = Guid.NewGuid().ToString()
                };

                ProvisionResponse response = service.Provision(request);

                Assert.Equal("dashboard", response.Url);
            }
        /// <summary>
        /// Enables client devices to request the administrator's security policy settings on the server..
        /// </summary>
        /// <param name="request">A ProvisionRequest object that contains the request information.</param>
        /// <returns>Provision command response</returns>
        public ProvisionResponse Provision(ProvisionRequest request)
        {
            // When the value of the MS-ASProtocolVersion header is 14.0 or 12.1, the client MUST NOT send the setting:DeviceInformation element in any Provision command request.
            if (this.activeSyncClient.ActiveSyncProtocolVersion.Equals("140", StringComparison.OrdinalIgnoreCase) || this.activeSyncClient.ActiveSyncProtocolVersion.Equals("121", StringComparison.OrdinalIgnoreCase))
            {
                request.RequestData.DeviceInformation = null;
            }

            ProvisionResponse response = this.activeSyncClient.Provision(request);

            this.VerifyTransportRequirements();
            this.VerifyProvisionCommand(response);
            this.VerifyWBXMLCapture(CommandName.Provision, response);
            return(response);
        }
        public void MSASCMD_S21_TC14_CommonStatusCode_145()
        {
            Site.Assume.AreNotEqual <string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "This test case is not supported when the MS-ASProtocolVersion header is set to 12.1.. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region User calls Provision command to download policies from server
            // Calls Provision command to download policies
            ProvisionRequest  provisionRequest  = TestSuiteBase.GenerateDefaultProvisionRequest();
            ProvisionResponse provisionResponse = this.CMDAdapter.Provision(provisionRequest);


            // Get policyKey, policyType and statusCode from server response
            string policyKey = null;
            if (null != provisionResponse.ResponseData.Policies)
            {
                Response.ProvisionPoliciesPolicy policyInResponse = provisionResponse.ResponseData.Policies.Policy;
                if (policyInResponse != null)
                {
                    policyKey = policyInResponse.PolicyKey;
                }
            }

            string policyType = provisionResponse.ResponseData.Policies.Policy.PolicyType;
            Response.ProvisionPoliciesPolicyData data = provisionResponse.ResponseData.Policies.Policy.Data;
            byte statusCode = provisionResponse.ResponseData.Status;
            #endregion

            #region User calls Provision command to acknowledge policies.

            // Set acknowledgeStatus value to 1, means accept the policy.
            ProvisionRequest provisionAcknowledgeRequest = TestSuiteBase.GenerateDefaultProvisionRequest();
            provisionAcknowledgeRequest.RequestData.Policies.Policy.PolicyKey = policyKey;
            provisionAcknowledgeRequest.RequestData.Policies.Policy.Status    = "4";

            // Calls Provision command
            ProvisionResponse provisionAcknowledgeResponse = this.CMDAdapter.Provision(provisionAcknowledgeRequest);
            statusCode = provisionAcknowledgeResponse.ResponseData.Status;

            this.Site.CaptureRequirementIfAreEqual <byte>(
                145,
                statusCode,
                4917,
                @"[In Common Status Codes] When the protocol version is 14.0, 14.1 or 16.0,  [The meaning of the status value 145 is] The device claimed to be externally managed, but the server doesn't allow externally managed devices to sync.");
            #endregion
        }
        public void MSASCMD_S12_TC02_Provision_WithoutPolicyTypeElement()
        {
            #region User calls Provision command to download policies without policy type element in request.
            ProvisionRequest provisionRequest = TestSuiteBase.GenerateDefaultProvisionRequest();

            // Set the policy type Element value to null
            provisionRequest.RequestData.Policies.Policy.PolicyType = null;
            ProvisionResponse provisionResponse = this.CMDAdapter.Provision(provisionRequest);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R4989");

            // Verify MS-ASCMD requirement: MS-ASCMD_R4989
            Site.CaptureRequirementIfAreEqual <int>(
                2,
                provisionResponse.ResponseData.Status,
                4989,
                @"[In Downloading Policy Settings] If the provision:PolicyType element is not included in the initial Provision command request, the server responds with a provision:Status element value of 2.");
            #endregion
        }
        public IHttpActionResult Provision(string instanceId, [FromBody] ProvisionRequest request)
        {
            ICloudFoundryService service;

            if (!servicesCatalog.Services.TryGetValue(request.ServiceId, out service))
            {
                return(BadRequest("This broker does not support the requested service."));
            }

            request.InstanceId = instanceId;

            try
            {
                ProvisionResponse response = service.Provision(request);
                return(Content(HttpStatusCode.Created, response));
            }
            catch (InvalidOperationException)
            {
                return(Conflict());
            }
        }
Beispiel #13
0
        // POST api/Course/{name}/resources/provision
        public async Task <IHttpActionResult> Provision(int id)
        {
            ICourse course = null;

            if (!ModelState.IsValid || (course = db.GetCourse(id)) == null)
            {
                return(BadRequest(ModelState));
            }

            var request = new ProvisionRequest()
            {
                AccountId          = Guid.Parse(CloudConfigurationManager.GetSetting("ApplicationId")),
                SubscriptionId     = Guid.Parse(CloudConfigurationManager.GetSetting("SubscriptionId")),
                PrincipalOwnerId   = Guid.Parse(CloudConfigurationManager.GetSetting("PrincipalOwnerId")),
                AuthorizationToken = await db.GetToken(),
                Course             = course
            };

            TopicClient client = TopicClient.CreateFromConnectionString(CloudConfigurationManager.GetSetting("SBConnectionString"), CloudConfigurationManager.GetSetting("SBTopic"));

            client.Send(new BrokeredMessage(request));

            return(Ok());
        }
        public void MSASCMD_S21_TC03_CommonStatusCode_165()
        {
            Site.Assume.AreNotEqual <string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "Status value 165 is not returned when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");
            Site.Assume.AreNotEqual <string>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "Status value 165 is not returned when the MS-ASProtocolVersion header is set to 14.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region User calls Provision command without the DeviceInformation element

            ProvisionRequest provisionRequest = TestSuiteBase.GenerateDefaultProvisionRequest();
            provisionRequest.RequestData.DeviceInformation = null;

            ProvisionResponse provisionResponse = this.CMDAdapter.Provision(provisionRequest);

            #endregion

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R4954");

            // Verify MS-ASCMD requirement: MS-ASCMD_R4954
            Site.CaptureRequirementIfAreEqual <byte>(
                165,
                provisionResponse.ResponseData.Status,
                4954,
                @"[In Common Status Codes] [The meaning of the status value 165 is] The required DeviceInformation element (as specified in [MS-ASPROV] section 2.2.2.52) is missing in the Provision request.<99>");
        }
        public void MSASCMD_S12_TC01_Provision_DownloadPolicy()
        {
            #region User calls Provision command to download policies from server
            // Calls Provision command to download policies
            ProvisionRequest  provisionRequest  = TestSuiteBase.GenerateDefaultProvisionRequest();
            ProvisionResponse provisionResponse = this.CMDAdapter.Provision(provisionRequest);

            // Get policyKey, policyType and statusCode from server response
            string policyKey  = GetPolicyKeyFromResponse(provisionResponse);
            string policyType = provisionResponse.ResponseData.Policies.Policy.PolicyType;
            Response.ProvisionPoliciesPolicyData data = provisionResponse.ResponseData.Policies.Policy.Data;
            byte statusCode = provisionResponse.ResponseData.Status;
            #endregion

            #region Verify Requirements MS-ASCMD_R5026, MS-ASCMD_R4990, MS-ASCMD_R4992
            // If User calls Provision command to download policies successful, server will return policyKey, policyType, data and statusCode in response, then MS-ASCMD_R5026, MS-ASCMD_R4990, MS-ASCMD_R4992 are verified.
            // The policy settings with the format specified in PolicyType element, are contained in Data element of Provision command response.
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R5026");

            // Verify MS-ASCMD requirement: MS-ASCMD_R5026
            Site.CaptureRequirementIfIsTrue(
                policyKey != null && policyType != null && data != null && statusCode == 1,
                5026,
                @"[In Downloading Policy Settings] [Provision sequence for downloading policy settings, order 1:] The server responds with the policy type, policy key, data, and status code.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R4990");

            // Verify MS-ASCMD requirement: MS-ASCMD_R4990
            Site.CaptureRequirementIfIsTrue(
                policyKey != null && policyType != null && data != null,
                4990,
                @"[In Downloading Policy Settings] The server then responds with the provision:PolicyType, provision:PolicyKey (as specified in [MS-ASPROV] section 2.2.2.41), and provision:Data ([MS-ASPROV] section 2.2.2.23) elements.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R4992");

            // Verify MS-ASCMD requirement: MS-ASCMD_R4992
            Site.CaptureRequirementIfIsTrue(
                policyType != null && data != null,
                4992,
                @"[In Downloading Policy Settings] The policy settings, in the format specified in the provision:PolicyType element, are contained in the provision:Data element.");
            #endregion

            #region User calls Provision command to acknowledge policies.

            // Set acknowledgeStatus value to 1, means accept the policy.
            string           acknowledgeStatus           = "1";
            ProvisionRequest provisionAcknowledgeRequest = TestSuiteBase.GenerateDefaultProvisionRequest();
            provisionAcknowledgeRequest.RequestData.Policies.Policy.PolicyKey = policyKey;
            provisionAcknowledgeRequest.RequestData.Policies.Policy.Status    = acknowledgeStatus;

            // Calls Provision command
            ProvisionResponse provisionAcknowledgeResponse = this.CMDAdapter.Provision(provisionAcknowledgeRequest);

            // Get policyKey, policyType and status code from server response
            policyKey  = GetPolicyKeyFromResponse(provisionAcknowledgeResponse);
            policyType = provisionAcknowledgeResponse.ResponseData.Policies.Policy.PolicyType;
            statusCode = provisionAcknowledgeResponse.ResponseData.Policies.Policy.Status;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R5028");

            // Verify MS-ASCMD requirement: MS-ASCMD_R5028
            Site.CaptureRequirementIfIsTrue(
                policyKey != null && policyType != null && statusCode == 1,
                5028,
                @"[In Downloading Policy Settings] [Provision sequence for downloading policy settings, order 2:] The server responds with the policy type, policy key, and status code to indicate that the server recorded the client's acknowledgement.");
            #endregion
        }
Beispiel #16
0
 private async Task ProvisionSite(ProvisionRequest request)
 {
     var storage = new ScampAzureContext();
     var p = new SiteProvisioner(storage);
     await p.Provision(request);
 }
        public void MSASPROV_S02_TC01_RemoteWipe()
        {
            #region Apply a unique DeviceType.
            // Switch the user credential to User1 to get user information.
            this.SwitchUser(this.User1Information, true);

            // Apply the unique DeviceType.
            this.DeviceType = string.Format("{0}{1}", "ASPROV", DateTime.Now.ToString("mmssfff"));
            this.PROVAdapter.ApplyDeviceType(this.DeviceType);
            this.CurrentUserInformation.UserName   = this.User1Information.UserName;
            this.CurrentUserInformation.UserDomain = this.User1Information.UserDomain;

            #endregion

            #region Acknowledge the policy setting and set the device status on server to be wipe pending
            this.AcknowledgeSecurityPolicySettings();

            // Set the device status on server to be wipe pending.
            string userEmail = Common.GetMailAddress(this.User1Information.UserName, this.User1Information.UserDomain);

            bool dataWiped = PROVSUTControlAdapter.WipeData(this.SutComputerName, userEmail, this.User1Information.UserPassword, this.DeviceType);
            Site.Assert.IsTrue(dataWiped, "The data on the device with DeviceType {0} should be wiped successfully.", this.DeviceType);
            #endregion

            #region Perform an initial remote wipe
            // Send an empty Provision request to indicate a remote wipe operation on client.
            ProvisionRequest  emptyRequest      = new ProvisionRequest();
            ProvisionResponse provisionResponse = this.PROVAdapter.Provision(emptyRequest);

            Site.Assert.IsNotNull(provisionResponse, "If the Provision command executes successfully, the response from server should not be null.");
            Site.Assert.AreEqual <byte>(1, provisionResponse.ResponseData.Status, "The server should return status code 1 to indicate a success.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASPROV_R653");

            // Verify MS-ASPROV requirement: MS-ASPROV_R653
            // The RemoteWipe element is not null, so this requirement can be captured.
            Site.CaptureRequirementIfIsNotNull(
                provisionResponse.ResponseData.RemoteWipe,
                653,
                @"[In Responding to an Initial Request] The RemoteWipe MUST only be included if a remote wipe has been requested for the client.");
            #endregion

            #region Perform a failure remote wipe acknowledgment
            // Set the remote wipe status to 2 to indicate a remote wipe failure on client.
            ProvisionRequest wipeRequest = new ProvisionRequest
            {
                RequestData =
                {
                    RemoteWipe = new Microsoft.Protocols.TestSuites.Common.Request.ProvisionRemoteWipe
                    {
                        Status = "2"
                    }
                }
            };

            provisionResponse = this.PROVAdapter.Provision(wipeRequest);

            if (Common.IsRequirementEnabled(1042, this.Site))
            {
                this.Site.CaptureRequirementIfAreEqual <byte>(
                    1,
                    provisionResponse.ResponseData.Status,
                    1042,
                    @"[In Appendix A: Product Behavior]  If the client reports failure, the implementation does return a value of 2 in the Status element [and a remote wipe directive]. (<4> Section 3.2.5.1.2.2:  In Exchange 2007 and Exchange 2010, if the client reports failure, the server returns a value of 1 in the Status element.)");
            }

            if (Common.IsRequirementEnabled(1048, this.Site))
            {
                this.Site.CaptureRequirementIfAreEqual <byte>(
                    2,
                    provisionResponse.ResponseData.Status,
                    1048,
                    @"[In Appendix A: Product Behavior] If the client reports failure, the implementation does return a value of 2 in the Status element [and a remote wipe directive]. (Exchange 2013 and above follow this behavior.)");
            }

            // Send an empty Provision request to indicate a remote wipe operation on client.
            provisionResponse = this.PROVAdapter.Provision(emptyRequest);
            Site.Assert.AreEqual <byte>(1, provisionResponse.ResponseData.Status, "The server should return status code 1 to indicate a success.");

            if (Common.IsRequirementEnabled(702, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASPROV_R702");

                // Verify MS-ASPROV requirement: MS-ASPROV_R702
                // The RemoteWipe element is not null, so this requirement can be captured.
                Site.CaptureRequirementIfIsNotNull(
                    provisionResponse.ResponseData.RemoteWipe,
                    702,
                    @"[In Appendix B: Product Behavior] If the client reports failure, the implementation does return [a value of 2 in the Status element and] a remote wipe directive. (Exchange 2007 and above follow this behavior.)");
            }
            #endregion

            #region Perform a successful remote wipe acknowledgment
            // Set the remote wipe status to 1 to indicate a successful wipe on client.
            wipeRequest.RequestData.RemoteWipe.Status = "1";
            ProvisionResponse wipeResponse = this.PROVAdapter.Provision(wipeRequest);

            if (Common.IsRequirementEnabled(1041, this.Site))
            {
                this.Site.CaptureRequirementIfAreEqual <byte>(
                    1,
                    wipeResponse.ResponseData.Status,
                    1041,
                    @"[In Appendix A: Product Behavior] If the client reports success, the implementation does return a value of 1 in the Status element (section 2.2.2.53.2). (<3> Section 3.2.5.1.2.2:  In Exchange 2007 and Exchange 2010, if the client reports success, the server returns a value of 1 in the Status element and a remote wipe directive.)");
            }

            if (Common.IsRequirementEnabled(1047, this.Site))
            {
                this.Site.CaptureRequirementIfAreEqual <byte>(
                    1,
                    wipeResponse.ResponseData.Status,
                    1047,
                    @"[In Appendix A: Product Behavior] If the client reports success, the implementation does return a value of 1 in the Status element (section 2.2.2.53.2). (Exchange 2013 and above follow this behavior.)");
            }

            // Record the provision confirmation mail for user1 to the item collection of User1.
            string       confirmationMailSubject = "Remote Device Wipe Confirmation";
            CreatedItems inboxItemForUser1       = Common.RecordCreatedItem(this.User1Information.InboxCollectionId, confirmationMailSubject);
            this.User1Information.UserCreatedItems.Add(inboxItemForUser1);
            CreatedItems sentItemForUser1 = Common.RecordCreatedItem(this.User1Information.SentItemsCollectionId, confirmationMailSubject);
            this.User1Information.UserCreatedItems.Add(sentItemForUser1);
            #endregion

            #region Remove the device from server and perform another initial remote wipe
            // Remove the device from the mobile list after wipe operation is successful.
            bool deviceRemoved = PROVSUTControlAdapter.RemoveDevice(this.SutComputerName, userEmail, this.User1Information.UserPassword, this.DeviceType);
            Site.Assert.IsTrue(deviceRemoved, "The device with DeviceType {0} should be removed successfully.", this.DeviceType);

            // Send an empty Provision request when the client is not requested for a remote wipe.
            provisionResponse = this.PROVAdapter.Provision(emptyRequest);
            Site.Assert.AreEqual <byte>(1, provisionResponse.ResponseData.Status, "The server should return status code 1 to indicate a success.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASPROV_R654");

            // Verify MS-ASPROV requirement: MS-ASPROV_R654
            // The RemoteWipe element is null, so this requirement can be captured.
            Site.CaptureRequirementIfIsNull(
                provisionResponse.ResponseData.RemoteWipe,
                654,
                @"[In Responding to an Initial Request] Otherwise [if a remote wipe has not been requested for the client], it [RemoteWipe] MUST be omitted");
            #endregion
        }
        /// <summary>
        /// Generate a Provision request.
        /// </summary>
        /// <returns>Provision request.</returns>
        protected static ProvisionRequest GenerateDefaultProvisionRequest()
        {
            Request.ProvisionPoliciesPolicy policy = new Request.ProvisionPoliciesPolicy
            {
                PolicyType = @"MS-EAS-Provisioning-WBXML"
            };

            Request.ProvisionPolicies policies = new Request.ProvisionPolicies { Policy = policy };
            Request.Provision requestData = new Request.Provision
            {
                Policies = policies,
                DeviceInformation = TestSuiteBase.GenerateDeviceInformation(),
                RemoteWipe = null
            };

            ProvisionRequest provisionRequest = new ProvisionRequest { RequestData = requestData };

            return provisionRequest;
        }
        public void MSASPROV_S03_TC03_VerifyProvisionStatus2()
        {
            #region Create a Provision request with syntax error.
            ProvisionRequest provisionRequest      = Common.CreateProvisionRequest(null, new Request.ProvisionPolicies(), null);
            Request.ProvisionPoliciesPolicy policy = new Request.ProvisionPoliciesPolicy
            {
                PolicyType = "MS-EAS-Provisioning-WBXML"
            };

            // The format in which the policy settings are to be provided to the client device.
            if (Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site) == "14.1" ||
                Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site) == "16.0" ||
                Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site) == "16.1")
            {
                // Configure the DeviceInformation.
                Request.DeviceInformation    deviceInfomation     = new Request.DeviceInformation();
                Request.DeviceInformationSet deviceInformationSet = new Request.DeviceInformationSet
                {
                    Model = "ASPROVTest"
                };
                deviceInfomation.Set = deviceInformationSet;
                provisionRequest.RequestData.DeviceInformation = deviceInfomation;
            }

            provisionRequest.RequestData.Policies.Policy = policy;
            string requestBody = provisionRequest.GetRequestDataSerializedXML();
            requestBody = requestBody.Replace(@"<Policies>", string.Empty);
            requestBody = requestBody.Replace(@"</Policies>", string.Empty);
            #endregion

            #region Call Provision command and get the Status of response.
            ProvisionResponse provisionResponse = this.PROVAdapter.SendProvisionStringRequest(requestBody);
            byte provisionStatus = provisionResponse.ResponseData.Status;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASPROV_R395");

            // Verify MS-ASPROV requirement: MS-ASPROV_R395
            // The Status of Provision element is 2, so this requirement can be captured.
            Site.CaptureRequirementIfAreEqual <byte>(
                2,
                provisionStatus,
                395,
                @"[In Status (Provision)] Value 2 means Protocol error.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASPROV_R679");

            // Verify MS-ASPROV requirement: MS-ASPROV_R679
            // The Status of Provision element is 2, so this requirement can be captured.
            Site.CaptureRequirementIfAreEqual <byte>(
                2,
                provisionStatus,
                679,
                @"[In Provision Command Errors] [The meaning of status value] 2 [is] Protocol error.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASPROV_R450");

            // Verify MS-ASPROV requirement: MS-ASPROV_R450
            // The Status of Provision element is 2, so this requirement can be captured.
            Site.CaptureRequirementIfAreEqual <byte>(
                2,
                provisionStatus,
                450,
                @"[In Provision Command Errors] [The cause of status value 2 is] Syntax error in the Provision command request.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASPROV_R497");

            // Verify MS-ASPROV requirement: MS-ASPROV_R497
            // The Status of Provision element is 2, so this requirement can be captured.
            Site.CaptureRequirementIfAreEqual <byte>(
                2,
                provisionStatus,
                497,
                @"[In Provision Command Errors] [When the scope is Global], [the cause of status value 2 is] Syntax error in the Provision command request.");

            if (Common.IsRequirementEnabled(697, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASPROV_R697");

                // Verify MS-ASPROV requirement: MS-ASPROV_R697
                // Status 2 is returned when there is syntax error in the Provision command request, so this requirement can be captured.
                Site.CaptureRequirement(
                    697,
                    @"[In Appendix B: Product Behavior] If the level of compliance does not meet the server's requirements, the implementation does return an appropriate value in the Status (section 2.2.2.53.2) element. (Exchange 2007 and above follow this behavior.)");
            }
            #endregion
        }
Beispiel #20
0
 /// <summary>
 /// Create a ProvisionRequest instance using specified information
 /// </summary>
 /// <param name="deviceInformation">Specified the device information</param>
 /// <param name="policies">Specified the policies</param>
 /// <param name="remoteWipe">Specified the remoteWipe</param>
 /// <returns>A ProvisionRequest instance</returns>
 public static ProvisionRequest CreateProvisionRequest(Request.DeviceInformation deviceInformation, Request.ProvisionPolicies policies, Request.ProvisionRemoteWipe remoteWipe)
 {
     ProvisionRequest request = new ProvisionRequest();
     Request.Provision requestData = new Request.Provision
     {
         DeviceInformation = deviceInformation,
         Policies = policies,
         RemoteWipe = remoteWipe
     };
     request.RequestData = requestData;
     return request;
 }
Beispiel #21
0
        // POST api/Course/{name}/resources/provision
        public async Task<IHttpActionResult> Provision(int id)
        {
            ICourse course = null;

            if (!ModelState.IsValid || (course = db.GetCourse(id)) == null)
            {
                return BadRequest(ModelState);
            }

            var request = new ProvisionRequest()
            {
                AccountId = Guid.Parse(CloudConfigurationManager.GetSetting("ApplicationId")),
                SubscriptionId = Guid.Parse(CloudConfigurationManager.GetSetting("SubscriptionId")),
                PrincipalOwnerId = Guid.Parse(CloudConfigurationManager.GetSetting("PrincipalOwnerId")),
                AuthorizationToken = await db.GetToken(),
                Course = course
            };

            TopicClient client = TopicClient.CreateFromConnectionString(CloudConfigurationManager.GetSetting("SBConnectionString"), CloudConfigurationManager.GetSetting("SBTopic"));
            client.Send(new BrokeredMessage(request));

            return Ok();
        }
Beispiel #22
0
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body"></param>
        /// <returns>Task of ApiResponse (HerokuProvision)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <HerokuProvision> > HerokuResourcesPostAsyncWithHttpInfo(ProvisionRequest body)
        {
            // verify the required parameter 'body' is set
            if (body == null)
            {
                throw new ApiException(400, "Missing required parameter 'body' when calling HerokuApi->HerokuResourcesPost");
            }

            var    localVarPath         = "/heroku/resources";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new List <KeyValuePair <String, String> >();
            var    localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json;charset=utf-8"
            };
            String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/vnd.heroku-addons+json;version=3"
            };
            String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (body != null && body.GetType() != typeof(byte[]))
            {
                localVarPostBody = this.Configuration.ApiClient.Serialize(body); // http body (model) parameter
            }
            else
            {
                localVarPostBody = body; // byte array
            }


            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                            Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("HerokuResourcesPost", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <HerokuProvision>(localVarStatusCode,
                                                     localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                                     (HerokuProvision)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(HerokuProvision))));
        }
Beispiel #23
0
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body"></param>
        /// <returns>Task of HerokuProvision</returns>
        public async System.Threading.Tasks.Task <HerokuProvision> HerokuResourcesPostAsync(ProvisionRequest body)
        {
            ApiResponse <HerokuProvision> localVarResponse = await HerokuResourcesPostAsyncWithHttpInfo(body);

            return(localVarResponse.Data);
        }
Beispiel #24
0
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body"></param>
        /// <returns>HerokuProvision</returns>
        public HerokuProvision HerokuResourcesPost(ProvisionRequest body)
        {
            ApiResponse <HerokuProvision> localVarResponse = HerokuResourcesPostWithHttpInfo(body);

            return(localVarResponse.Data);
        }
        /// <summary>
        /// Request the security policy settings that the administrator sets from the server.
        /// </summary>
        /// <param name="provisionRequest">The request of Provision command.</param>
        /// <returns>The response of Provision command.</returns>
        public ProvisionResponse Provision(ProvisionRequest provisionRequest)
        {
            ProvisionResponse provisionResponse = this.activeSyncClient.Provision(provisionRequest);
            Site.Assert.IsNotNull(provisionResponse, "The Provision response returned from server should not be null.");

            // Verify adapter requirements about Provision.
            this.VerifyProvisionCommandRequirements(provisionResponse);
            this.VerifyWBXMLRequirements();
            return provisionResponse;
        }
        public void MSASPROV_S02_TC01_RemoteWipe()
        {
            #region Apply a unique DeviceType.
            // Switch the user credential to User1 to get user information.
            this.SwitchUser(this.User1Information, true);

            // Apply the unique DeviceType.
            this.DeviceType = string.Format("{0}{1}", "ASPROV", DateTime.Now.ToString("mmssfff"));
            this.PROVAdapter.ApplyDeviceType(this.DeviceType);
            this.CurrentUserInformation.UserName = this.User1Information.UserName;
            this.CurrentUserInformation.UserDomain = this.User1Information.UserDomain;

            #endregion

            #region Acknowledge the policy setting and set the device status on server to be wipe pending
            this.AcknowledgeSecurityPolicySettings();

            // Set the device status on server to be wipe pending.
            string userEmail = Common.GetMailAddress(this.User1Information.UserName, this.User1Information.UserDomain);

            bool dataWiped = PROVSUTControlAdapter.WipeData(this.SutComputerName, userEmail, this.User1Information.UserPassword, this.DeviceType);
            Site.Assert.IsTrue(dataWiped, "The data on the device with DeviceType {0} should be wiped successfully.", this.DeviceType);
            #endregion

            #region Perform an initial remote wipe
            // Send an empty Provision request to indicate a remote wipe operation on client.
            ProvisionRequest emptyRequest = new ProvisionRequest();
            ProvisionResponse provisionResponse = this.PROVAdapter.Provision(emptyRequest);

            Site.Assert.IsNotNull(provisionResponse, "If the Provision command executes successfully, the response from server should not be null.");
            Site.Assert.AreEqual<byte>(1, provisionResponse.ResponseData.Status, "The server should return status code 1 to indicate a success.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASPROV_R653");

            // Verify MS-ASPROV requirement: MS-ASPROV_R653
            // The RemoteWipe element is not null, so this requirement can be captured.
            Site.CaptureRequirementIfIsNotNull(
                provisionResponse.ResponseData.RemoteWipe,
                653,
                @"[In Responding to an Initial Request] The RemoteWipe MUST only be included if a remote wipe has been requested for the client.");
            #endregion

            #region Perform a failure remote wipe acknowledgment
            // Set the remote wipe status to 2 to indicate a remote wipe failure on client.
            ProvisionRequest wipeRequest = new ProvisionRequest
            {
                RequestData =
                {
                    RemoteWipe = new Microsoft.Protocols.TestSuites.Common.Request.ProvisionRemoteWipe
                    {
                        Status = "2"
                    }
                }
            };

            provisionResponse = this.PROVAdapter.Provision(wipeRequest);

            if (Common.IsRequirementEnabled(1042, this.Site))
            {
                this.Site.CaptureRequirementIfAreEqual<byte>(
                    1,
                    provisionResponse.ResponseData.Status,
                    1042,
                    @"[In Appendix A: Product Behavior]  If the client reports failure, the implementation does return a value of 2 in the Status element [and a remote wipe directive]. (<4> Section 3.2.5.1.2.2:  In Exchange 2007 and Exchange 2010, if the client reports failure, the server returns a value of 1 in the Status element.)");
            }

            if (Common.IsRequirementEnabled(1048, this.Site))
            {
                this.Site.CaptureRequirementIfAreEqual<byte>(
                2,
                provisionResponse.ResponseData.Status,
                1048,
                @"[In Appendix A: Product Behavior] If the client reports failure, the implementation does return a value of 2 in the Status element [and a remote wipe directive]. (Exchange 2013 and above follow this behavior.)");
            }

            // Send an empty Provision request to indicate a remote wipe operation on client.
            provisionResponse = this.PROVAdapter.Provision(emptyRequest);
            Site.Assert.AreEqual<byte>(1, provisionResponse.ResponseData.Status, "The server should return status code 1 to indicate a success.");

            if (Common.IsRequirementEnabled(702, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASPROV_R702");

                // Verify MS-ASPROV requirement: MS-ASPROV_R702
                // The RemoteWipe element is not null, so this requirement can be captured.
                Site.CaptureRequirementIfIsNotNull(
                    provisionResponse.ResponseData.RemoteWipe,
                    702,
                    @"[In Appendix B: Product Behavior] If the client reports failure, the implementation does return [a value of 2 in the Status element and] a remote wipe directive. (Exchange 2007 and above follow this behavior.)");
            }
            #endregion

            #region Perform a successful remote wipe acknowledgment
            // Set the remote wipe status to 1 to indicate a successful wipe on client.
            wipeRequest.RequestData.RemoteWipe.Status = "1";
            ProvisionResponse wipeResponse = this.PROVAdapter.Provision(wipeRequest);

            if (Common.IsRequirementEnabled(1041, this.Site))
            {
                this.Site.CaptureRequirementIfAreEqual<byte>(
                1,
                wipeResponse.ResponseData.Status,
                1041,
                @"[In Appendix A: Product Behavior] If the client reports success, the implementation does return a value of 1 in the Status element (section 2.2.2.53.2). (<3> Section 3.2.5.1.2.2:  In Exchange 2007 and Exchange 2010, if the client reports success, the server returns a value of 1 in the Status element and a remote wipe directive.)");
            }

            if (Common.IsRequirementEnabled(1047, this.Site))
            {
                this.Site.CaptureRequirementIfAreEqual<byte>(
                    1,
                    wipeResponse.ResponseData.Status,
                    1047,
                    @"[In Appendix A: Product Behavior] If the client reports success, the implementation does return a value of 1 in the Status element (section 2.2.2.53.2). (Exchange 2013 and above follow this behavior.)");
            }

            // Record the provision confirmation mail for user1 to the item collection of User1.
            string confirmationMailSubject = "Remote Device Wipe Confirmation";
            CreatedItems inboxItemForUser1 = Common.RecordCreatedItem(this.User1Information.InboxCollectionId, confirmationMailSubject);
            this.User1Information.UserCreatedItems.Add(inboxItemForUser1);
            CreatedItems sentItemForUser1 = Common.RecordCreatedItem(this.User1Information.SentItemsCollectionId, confirmationMailSubject);
            this.User1Information.UserCreatedItems.Add(sentItemForUser1);
            #endregion

            #region Remove the device from server and perform another initial remote wipe
            // Remove the device from the mobile list after wipe operation is successful.
            bool deviceRemoved = PROVSUTControlAdapter.RemoveDevice(this.SutComputerName, userEmail, this.User1Information.UserPassword, this.DeviceType);
            Site.Assert.IsTrue(deviceRemoved, "The device with DeviceType {0} should be removed successfully.", this.DeviceType);

            // Send an empty Provision request when the client is not requested for a remote wipe.
            provisionResponse = this.PROVAdapter.Provision(emptyRequest);
            Site.Assert.AreEqual<byte>(1, provisionResponse.ResponseData.Status, "The server should return status code 1 to indicate a success.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASPROV_R654");

            // Verify MS-ASPROV requirement: MS-ASPROV_R654
            // The RemoteWipe element is null, so this requirement can be captured.
            Site.CaptureRequirementIfIsNull(
                provisionResponse.ResponseData.RemoteWipe,
                654,
                @"[In Responding to an Initial Request] Otherwise [if a remote wipe has not been requested for the client], it [RemoteWipe] MUST be omitted");
            #endregion
        }
Beispiel #27
0
 private async Task ProvisionSite(ProvisionRequest request)
 {
     var storage = new ScampAzureContext();
     var p       = new SiteProvisioner(storage);
     await p.Provision(request);
 }
        public void MSASCMD_S12_TC03_Provision_Status144()
        {
            #region User calls Provision command to download policies from server
            // Calls Provision command to download policies
            ProvisionRequest  provisionRequest  = TestSuiteBase.GenerateDefaultProvisionRequest();
            ProvisionResponse provisionResponse = this.CMDAdapter.Provision(provisionRequest);
            Site.Assert.AreEqual(1, provisionResponse.ResponseData.Status, "If Provision operation executes successfully, server should return status 1");

            // Get policyKey
            string policyKey = GetPolicyKeyFromResponse(provisionResponse);
            #endregion

            #region User calls Provision command to acknowledge policies.
            // Set acknowledgeStatus value to 1, means accept the policy.
            string           acknowledgeStatus           = "1";
            ProvisionRequest provisionAcknowledgeRequest = TestSuiteBase.GenerateDefaultProvisionRequest();
            provisionAcknowledgeRequest.RequestData.Policies.Policy.PolicyKey = policyKey;
            provisionAcknowledgeRequest.RequestData.Policies.Policy.Status    = acknowledgeStatus;

            // Calls Provision command
            ProvisionResponse provisionAcknowledgeResponse = this.CMDAdapter.Provision(provisionAcknowledgeRequest);
            Site.Assert.AreEqual(1, provisionResponse.ResponseData.Status, "If Provision operation executes successfully, server should return status 1");

            // Get policyKey
            string finalPolicyKey = GetPolicyKeyFromResponse(provisionAcknowledgeResponse);
            #endregion

            #region Call FolderSync command with an invalid PolicyKey which is different from the one got from last step.
            this.CMDAdapter.ChangePolicyKey(finalPolicyKey.Substring(0, 1));
            this.RecordPolicyKeyChanged();

            if ("12.1" == Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site))
            {
                string httpErrorCode = null;
                try
                {
                    // Call FolderSync command
                    this.CMDAdapter.FolderSync(Common.CreateFolderSyncRequest("0"));
                }
                catch (WebException exception)
                {
                    httpErrorCode = Common.GetErrorCodeFromException(exception);
                }

                Site.Assert.AreEqual("449", httpErrorCode, "[In MS-ASPROV Appendix A: Product Behavior] <2> Section 3.1.5.1: When the MS-ASProtocolVersion header is set to 12.1, the server sends an HTTP 449 response to request a Provision command from the client.");
            }
            else
            {
                // Call FolderSync command
                FolderSyncResponse folderSyncResponse = this.CMDAdapter.FolderSync(Common.CreateFolderSyncRequest("0"));

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R4912");

                // Verify MS-ASCMD requirement: MS-ASCMD_R4912
                Site.CaptureRequirementIfAreEqual <int>(
                    144,
                    int.Parse(folderSyncResponse.ResponseData.Status),
                    4912,
                    @"[In Common Status Codes] [The meaning of the status value 144 is] The device's policy key is invalid.");
            }

            #endregion
        }
Beispiel #29
0
 /// <summary>
 /// Create an empty ProvisionRequest instance
 /// </summary>
 /// <returns>An empty ProvisionRequest instance</returns>
 public static ProvisionRequest CreateProvisionRequest()
 {
     ProvisionRequest request = new ProvisionRequest();
     Request.Provision requestData = new Request.Provision();
     request.RequestData = requestData;
     return request;
 }
        public void MSASPROV_S02_TC02_AccountOnlyRemoteWipe()
        {
            Site.Assume.AreEqual <string>("16.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The AccountOnlyRemoteWipe element is supported when the ActiveSyncProtocolVersion is 16.1.");

            #region Apply a unique DeviceType.
            // Switch the user credential to User1 to get user information.
            this.SwitchUser(this.User1Information, true);

            // Apply the unique DeviceType.
            this.DeviceType = string.Format("{0}{1}", "ASPROV", DateTime.Now.ToString("mmssfff"));
            this.PROVAdapter.ApplyDeviceType(this.DeviceType);
            this.CurrentUserInformation.UserName   = this.User1Information.UserName;
            this.CurrentUserInformation.UserDomain = this.User1Information.UserDomain;
            #endregion

            #region Acknowledge the policy setting and set the device status on server to be wipe pending
            this.AcknowledgeSecurityPolicySettings();

            // Set the device status on server to be wipe pending.
            string userEmail = Common.GetMailAddress(this.User1Information.UserName, this.User1Information.UserDomain);

            bool dataWiped = PROVSUTControlAdapter.AccountOnlyWipeData(this.SutComputerName, userEmail, this.User1Information.UserPassword, this.DeviceType);
            Site.Assert.IsTrue(dataWiped, "The data on the device with DeviceType {0} should be wiped successfully.", this.DeviceType);
            #endregion

            #region Perform an initial account only remote wipe
            // Send an empty Provision request to indicate an account only remote wipe operation on client.
            ProvisionRequest  emptyRequest      = new ProvisionRequest();
            ProvisionResponse provisionResponse = this.PROVAdapter.Provision(emptyRequest);

            Site.Assert.IsNotNull(provisionResponse, "If the Provision command executes successfully, the response from server should not be null.");
            Site.Assert.AreEqual <byte>(1, provisionResponse.ResponseData.Status, "The server should return status code 1 to indicate a success.");

            if (Common.IsRequirementEnabled(66613, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASPROV_R66613");

                // Verify MS-ASPROV requirement: MS-ASPROV_R66613
                // The AccountOnlyRemoteWipe element is not null, so this requirement can be captured.
                Site.CaptureRequirementIfIsNotNull(
                    provisionResponse.ResponseData.AccountOnlyRemoteWipe,
                    66613,
                    @"[In Appendix B: Product Behavior] The [RemoteWipe or] AccountOnlyRemoteWipe MUST only be included if [a remote wipe or] an account only remote wipe has been requested for the client. (Exchange 2019 follow this behavior.)");
            }
            #endregion

            #region Perform a failure account only remote wipe acknowledgment
            // Set the account only remote wipe status to 2 to indicate an account only remote wipe failure on client.
            ProvisionRequest wipeRequest = new ProvisionRequest
            {
                RequestData =
                {
                    AccountOnlyRemoteWipe = new Microsoft.Protocols.TestSuites.Common.Request.ProvisionAccountOnlyRemoteWipe
                    {
                        Status            = 2
                    }
                }
            };

            provisionResponse = this.PROVAdapter.Provision(wipeRequest);

            if (Common.IsRequirementEnabled(66610, this.Site))
            {
                this.Site.CaptureRequirementIfAreEqual <byte>(
                    2,
                    provisionResponse.ResponseData.Status,
                    66610,
                    @"[In Appendix B: Product Behavior]  If the client reports failure, the server SHOULD return a value of 2 in the Status element[ and an account only remote wipe directive]. (Exchange 2019 follow this behavior.)");
            }

            // Send an empty Provision request to indicate an account only remote wipe operation on client.
            provisionResponse = this.PROVAdapter.Provision(emptyRequest);
            Site.Assert.AreEqual <byte>(1, provisionResponse.ResponseData.Status, "The server should return status code 1 to indicate a success.");

            if (Common.IsRequirementEnabled(66611, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASPROV_R66611");

                // Verify MS-ASPROV requirement: MS-ASPROV_R66611
                // The AccountOnlyRemoteWipe element is not null, so this requirement can be captured.
                Site.CaptureRequirementIfIsNotNull(
                    provisionResponse.ResponseData.AccountOnlyRemoteWipe,
                    66611,
                    @"[In Appendix B: Product Behavior] If the client reports failure, the server SHOULD return [a value of 2 in the Status element and ]an account only remote wipe directive. (Exchange 2019 follow this behavior.)");
            }
            #endregion

            #region Perform a successful account only remote wipe acknowledgment
            // Set the account only remote wipe status to 1 to indicate a successful wipe on client.
            wipeRequest.RequestData.AccountOnlyRemoteWipe.Status = 1;
            ProvisionResponse wipeResponse = this.PROVAdapter.Provision(wipeRequest);

            if (Common.IsRequirementEnabled(66609, this.Site))
            {
                this.Site.CaptureRequirementIfAreEqual <byte>(
                    1,
                    wipeResponse.ResponseData.Status,
                    66609,
                    @"[In Appendix B: Product Behavior] If the client reports success, the server SHOULD return a value of 1 in the Status element (section 2.2.2.54.2). (Exchange 2019 follow this behavior.)");
            }

            // Record the provision confirmation mail for user1 to the item collection of User1.
            string       confirmationMailSubject = "Remote Device Wipe Confirmation";
            CreatedItems inboxItemForUser1       = Common.RecordCreatedItem(this.User1Information.InboxCollectionId, confirmationMailSubject);
            this.User1Information.UserCreatedItems.Add(inboxItemForUser1);
            CreatedItems sentItemForUser1 = Common.RecordCreatedItem(this.User1Information.SentItemsCollectionId, confirmationMailSubject);
            this.User1Information.UserCreatedItems.Add(sentItemForUser1);
            #endregion

            #region Remove the device from server and perform another initial account only remote wipe
            // Remove the device from the mobile list after wipe operation is successful.
            bool deviceRemoved = PROVSUTControlAdapter.RemoveDevice(this.SutComputerName, userEmail, this.User1Information.UserPassword, this.DeviceType);
            Site.Assert.IsTrue(deviceRemoved, "The device with DeviceType {0} should be removed successfully.", this.DeviceType);

            // Send an empty Provision request when the client is not requested for an account only remote wipe.
            provisionResponse = this.PROVAdapter.Provision(emptyRequest);
            Site.Assert.AreEqual <byte>(1, provisionResponse.ResponseData.Status, "The server should return status code 1 to indicate a success.");

            if (Common.IsRequirementEnabled(66615, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASPROV_R66615");

                // Verify MS-ASPROV requirement: MS-ASPROV_R66615
                // The AccountOnlyRemoteWipe element is null, so this requirement can be captured.
                Site.CaptureRequirementIfIsNull(
                    provisionResponse.ResponseData.AccountOnlyRemoteWipe,
                    66615,
                    @"[In Appendix B: Product Behavior] Otherwise [if an account only remote wipe has not been requested for the client], it [Account Only RemoteWipe] MUST be omitted. (Exchange 2019 follow this behavior.)");
            }
            #endregion
        }