예제 #1
0
        /// <summary>
        /// Get task instance from the ApplicationData element of Sync add response
        /// </summary>
        /// <typeparam name="T">The generic type parameter</typeparam>
        /// <param name="applicationData">The data which contains information for task</param>
        /// <returns>The returned instance</returns>
        public static T DeserializeFromAddApplicationData <T>(Response.SyncCollectionsCollectionCommandsAddApplicationData applicationData)
        {
            T obj = Activator.CreateInstance <T>();

            if (applicationData.ItemsElementName.Length > 0)
            {
                for (int itemIndex = 0; itemIndex < applicationData.ItemsElementName.Length; itemIndex++)
                {
                    switch (applicationData.ItemsElementName[itemIndex])
                    {
                    case Response.ItemsChoiceType8.Categories:
                        break;

                    case Response.ItemsChoiceType8.Categories1:
                        break;

                    case Response.ItemsChoiceType8.Categories2:
                        break;

                    case Response.ItemsChoiceType8.Categories3:
                        break;

                    case Response.ItemsChoiceType8.Subject:
                        break;

                    case Response.ItemsChoiceType8.Subject1:
                        break;

                    case Response.ItemsChoiceType8.Subject2:
                        break;

                    case Response.ItemsChoiceType8.Recurrence:
                        break;

                    case Response.ItemsChoiceType8.Recurrence1:
                        Common.SetSpecifiedPropertyValueByName(obj, "Recurrence", applicationData.Items[itemIndex]);
                        break;

                    case Response.ItemsChoiceType8.Categories4:
                        Common.SetSpecifiedPropertyValueByName(obj, "Categories", applicationData.Items[itemIndex]);
                        break;

                    case Response.ItemsChoiceType8.Importance1:
                        Common.SetSpecifiedPropertyValueByName(obj, "Importance", applicationData.Items[itemIndex]);
                        break;

                    case Response.ItemsChoiceType8.Sensitivity1:
                        Common.SetSpecifiedPropertyValueByName(obj, "Sensitivity", applicationData.Items[itemIndex]);
                        break;

                    case Response.ItemsChoiceType8.Subject3:
                        Common.SetSpecifiedPropertyValueByName(obj, "Subject", applicationData.Items[itemIndex]);
                        break;

                    default:
                        Common.SetSpecifiedPropertyValueByName(obj, applicationData.ItemsElementName[itemIndex].ToString(), applicationData.Items[itemIndex]);
                        break;
                    }
                }
            }

            return(obj);
        }
        public void MSASCMD_S20_TC01_ValidateCert_Success()
        {
            #region Switch to User9 mail account, the inbox had received a S/MIME mail.

            this.SwitchUser(this.User9Information);

            #endregion

            #region Call method Sync to synchronize changes of Inbox folder in User9's mailbox between the client and the server, and get the body content of the email item.

            string emailSubject = Common.GetConfigurationPropertyValue("MIMEMailSubject", this.Site);

            Request.BodyPreference bodyPreference = new Request.BodyPreference
            {
                AllOrNone               = false,
                AllOrNoneSpecified      = true,
                TruncationSize          = 4294967295,
                TruncationSizeSpecified = true,
                Type = 4
            };

            Request.Options option = new Request.Options
            {
                Items            = new object[] { (byte)2, bodyPreference, (byte)8 },
                ItemsElementName = new Request.ItemsChoiceType1[]
                {
                    Request.ItemsChoiceType1.MIMESupport,
                    Request.ItemsChoiceType1.BodyPreference, Request.ItemsChoiceType1.MIMETruncation
                }
            };

            SyncResponse  syncResponse = this.CheckEmail(this.User9Information.InboxCollectionId, emailSubject, new Request.Options[] { option });
            Response.Body mailBody     = null;
            Response.SyncCollectionsCollectionCommandsAddApplicationData applicationData = TestSuiteBase.GetAddApplicationData(syncResponse, Response.ItemsChoiceType8.Subject1, emailSubject);
            for (int i = 0; i < applicationData.ItemsElementName.Length; i++)
            {
                if (applicationData.ItemsElementName[i] == Response.ItemsChoiceType8.Body)
                {
                    mailBody = applicationData.Items[i] as Response.Body;
                    break;
                }
            }

            Site.Assert.IsNotNull(mailBody, "The body of the received email should not be null.");

            string specifiedString = "MIME-Version: 1.0";
            string body            = mailBody.Data.Substring(
                mailBody.Data.IndexOf(specifiedString, StringComparison.CurrentCultureIgnoreCase) + specifiedString.Length);
            body = body.Replace("\r", string.Empty);
            body = body.Replace("\n", string.Empty);

            Request.ValidateCert validateCert = new Request.ValidateCert
            {
                CheckCrl     = "1",
                Certificates = new byte[][] { System.Text.Encoding.Default.GetBytes(body) }
            };

            ValidateCertRequest validateRequest = new ValidateCertRequest {
                RequestData = validateCert
            };

            ValidateCertResponse validateResponse = this.CMDAdapter.ValidateCert(validateRequest);

            XmlNodeList status = this.GetValidateCertStatusCode(validateResponse);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4474
            Site.CaptureRequirementIfAreEqual <string>(
                "1",
                status[0].InnerText,
                4474,
                @"[In Status(ValidateCert)] [When the scope is Global], [the cause of the status value 1 is] Server successfully completed command.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R5387
            Site.CaptureRequirementIfAreEqual <string>(
                "1",
                status[0].InnerText,
                5387,
                @"[In Status(ValidateCert)] A value of 1 indicates success.");
            #endregion
        }