A static class contains all helper methods used in test cases.
Ejemplo n.º 1
0
        /// <summary>
        /// Sync changes between client and server
        /// </summary>
        /// <param name="syncKey">The synchronization key returned by last request.</param>
        /// <param name="collectionId">Identify the folder as the collection being synchronized.</param>
        /// <param name="rightsManagementSupport">A boolean value specifies whether the server will decompress and decrypt rights-managed email messages before sending them to the client or not</param>
        /// <returns>Return change result</returns>
        protected DataStructures.SyncStore SyncChanges(string syncKey, string collectionId, bool rightsManagementSupport)
        {
            // Get changes from server use initial syncKey
            SyncRequest syncRequest = TestSuiteHelper.CreateSyncRequest(syncKey, collectionId, rightsManagementSupport);

            DataStructures.SyncStore syncResult = this.ASRMAdapter.Sync(syncRequest);

            return(syncResult);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Find an email with specific subject and folder.
        /// </summary>
        /// <param name="subject">The subject of the email item.</param>
        /// <param name="collectionId">Identify the folder as the collection being synchronized.</param>
        /// <param name="rightsManagementSupport">A boolean value specifies whether the server will decompress and decrypt rights-managed email messages before sending them to the client or not</param>
        /// <param name="isRetryNeeded">A boolean value specifies whether need retry.</param>
        /// <returns>Return change result</returns>
        protected DataStructures.Sync SyncEmail(string subject, string collectionId, bool?rightsManagementSupport, bool isRetryNeeded)
        {
            SyncRequest syncRequest = Common.CreateInitialSyncRequest(collectionId);

            DataStructures.SyncStore initSyncResult = this.ASRMAdapter.Sync(syncRequest);

            // Verify sync change result
            this.Site.Assert.AreEqual <byte>(1, initSyncResult.CollectionStatus, "If the Sync command executes successfully, the Status in response should be 1.");

            syncRequest = TestSuiteHelper.CreateSyncRequest(initSyncResult.SyncKey, collectionId, rightsManagementSupport);
            DataStructures.Sync sync = this.ASRMAdapter.SyncEmail(syncRequest, subject, isRetryNeeded);
            return(sync);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Delete the specified item.
        /// </summary>
        /// <param name="itemsToDelete">The collection of the items to delete.</param>
        private void DeleteCreatedItems(Collection <CreatedItems> itemsToDelete)
        {
            foreach (CreatedItems itemToDelete in itemsToDelete)
            {
                SyncRequest syncRequest = Common.CreateInitialSyncRequest(itemToDelete.CollectionId);
                DataStructures.SyncStore initSyncResult = this.ASRMAdapter.Sync(syncRequest);
                DataStructures.SyncStore result         = this.SyncChanges(initSyncResult.SyncKey, itemToDelete.CollectionId, false);
                int i = 0;
                if (result.AddElements != null)
                {
                    Request.SyncCollectionDelete[] deletes = new Request.SyncCollectionDelete[result.AddElements.Count];
                    foreach (DataStructures.Sync item in result.AddElements)
                    {
                        foreach (string subject in itemToDelete.ItemSubject)
                        {
                            if (item.Email.Subject.Equals(subject))
                            {
                                Request.SyncCollectionDelete delete = new Request.SyncCollectionDelete
                                {
                                    ServerId = item.ServerId
                                };
                                deletes[i] = delete;
                            }
                        }

                        i++;
                    }

                    Request.SyncCollection syncCollection = TestSuiteHelper.CreateSyncCollection(result.SyncKey, itemToDelete.CollectionId);
                    syncCollection.Commands = deletes;

                    syncRequest = Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
                    DataStructures.SyncStore deleteResult = this.ASRMAdapter.Sync(syncRequest);
                    this.Site.Assert.AreEqual <byte>(
                        1,
                        deleteResult.CollectionStatus,
                        "The value of 'Status' should be 1 which indicates the Sync command executes successfully.");
                }
            }
        }
        public void MSASRM_S01_TC01_Sync_RightsManagedEmailMessages()
        {
            this.CheckPreconditions();

            #region The client logs on User1's account, calls Settings command to get a templateID with all rights allowed.
            string templateID = this.GetTemplateID("MSASRM_AllRights_AllowedTemplate");
            #endregion

            #region The client logs on User1's account, calls SendMail command with the templateID to send a rights-managed e-mail message to User2, switches to User2, and calls FolderSync command.
            string subject = this.SendMailAndFolderSync(templateID, false, null);
            #endregion

            #region The client logs on User2's account, calls Sync command with RightsManagementSupport element set to true to synchronize changes of Inbox folder in User2's mailbox, and gets the decompressed and decrypted rights-managed e-mail message.
            Sync item = this.SyncEmail(subject, this.UserTwoInformation.InboxCollectionId, true, true);
            Site.Assert.IsNotNull(item, "The returned item should not be null.");
            Site.Assert.IsNull(item.Email.Attachments, "The Attachments element in expected rights-managed e-mail message should be null.");

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

            // Verify MS-ASRM requirement: MS-ASRM_R127
            // If the RightsManagementLicense element is not null, represents the message has IRM protection.
            Site.CaptureRequirementIfIsNotNull(
                item.Email.RightsManagementLicense,
                127,
                @"[In RightsManagementSupport] If the value of this element[RightsManagementSupport] is TRUE (1), the server will decompress rights-managed email messages before sending them to the client, as specified in section 3.2.4.3. ");

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

            // Verify MS-ASRM requirement: MS-ASRM_R347
            // If the RightsManagementLicense element is not null, represents the message has IRM protection.
            Site.CaptureRequirementIfIsNotNull(
                item.Email.RightsManagementLicense,
                347,
                @"[In RightsManagementSupport] If the value of this element[RightsManagementSupport] is TRUE (1), the server will decrypt rights-managed email messages before sending them to the client, as specified in section 3.2.4.3. ");

            XmlElement lastRawResponse   = (XmlElement)this.ASRMAdapter.LastRawResponseXml;
            string     contentExpiryDate = TestSuiteHelper.GetElementInnerText(lastRawResponse, "RightsManagementLicense", "ContentExpiryDate", subject);

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

            // Verify MS-ASRM requirement: MS-ASRM_R23
            Site.CaptureRequirementIfAreEqual <string>(
                "9999-12-30T23:59:59.999Z",
                contentExpiryDate,
                23,
                @"[In ContentExpiryDate] The ContentExpiryDate element is set to ""9999-12-30T23:59:59.999Z"" if the rights management license has no expiration date set.");
            #endregion

            #region The client logs on User2's account, calls Sync command with RightsManagementSupport element set to false to synchronize changes of Inbox folder in User2's mailbox, and gets the neither decompressed nor decrypted rights-managed e-mail message.
            item = this.SyncEmail(subject, this.UserTwoInformation.InboxCollectionId, false, true);
            Site.Assert.IsNotNull(item, "The returned item should not be null.");
            Site.Assert.IsNotNull(item.Email.Attachments, "The Attachments element in expected rights-managed e-mail message should not be null.");

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

            // Verify MS-ASRM requirement: MS-ASRM_R335
            // If the RightsManagementLicense element is null, represents the message has no IRM protection.
            Site.CaptureRequirementIfIsNull(
                item.Email.RightsManagementLicense,
                335,
                @"[In RightsManagementSupport] If the value is FALSE (0), the server will not decompress rights-managed email messages before sending them to the client. ");

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

            // Verify MS-ASRM requirement: MS-ASRM_R348
            // If the RightsManagementLicense element is null, represents the message has no IRM protection.
            Site.CaptureRequirementIfIsNull(
                item.Email.RightsManagementLicense,
                348,
                @"[In RightsManagementSupport] If the value is FALSE (0), the server will not decrypt rights-managed email messages before sending them to the client. ");

            #endregion

            #region The client logs on User2's account, calls Sync command without the RightsManagementSupport element in a request message to synchronize changes of Inbox folder in User2's mailbox, and gets the neither decompressed nor decrypted rights-managed e-mail message.
            item = this.SyncEmail(subject, this.UserTwoInformation.InboxCollectionId, null, true);
            Site.Assert.IsNotNull(item, "The returned item should not be null.");
            Site.Assert.IsNotNull(item.Email.Attachments, "The Attachments element in expected rights-managed e-mail message should not be null.");

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

            // Verify MS-ASRM requirement: MS-ASRM_R128
            // If the response contains RightsManagementLicense element as null, and Attachments element not null, just as the same response when RightsManagementSupport is set to false, this requirement can be verified.
            Site.CaptureRequirementIfIsNull(
                item.Email.RightsManagementLicense,
                128,
                @"[In RightsManagementSupport] If the RightsManagementSupport element is not included in a request message, a default value of FALSE is assumed.");
            #endregion
        }
Ejemplo n.º 5
0
        /// <summary>
        /// User1 sends mail to User2 and does FolderSync in User2's mailbox
        /// </summary>
        /// <param name="templateID">A string that identifies a particular rights policy template to be applied to the outgoing message.</param>
        /// <param name="saveInSentItems">A boolean that represent to save the sent item in SentItems folder or not.</param>
        /// <param name="copyToUserInformation">The UserInformation for the Cc element.</param>
        /// <returns>The subject of the sent message</returns>
        protected string SendMailAndFolderSync(string templateID, bool saveInSentItems, UserInformation copyToUserInformation)
        {
            #region User1 calls method SendMail to send MIME-formatted e-mail messages to User2
            string          subject = Common.GenerateResourceName(this.Site, "subject");
            string          content = "The content of the body.";
            SendMailRequest sendMailRequest;

            if (copyToUserInformation != null)
            {
                sendMailRequest = TestSuiteHelper.CreateSendMailRequest(Common.GetMailAddress(this.UserOneInformation.UserName, this.UserOneInformation.UserDomain), Common.GetMailAddress(this.UserTwoInformation.UserName, this.UserTwoInformation.UserDomain), Common.GetMailAddress(copyToUserInformation.UserName, copyToUserInformation.UserDomain), string.Empty, subject, content, templateID);
            }
            else
            {
                sendMailRequest = TestSuiteHelper.CreateSendMailRequest(Common.GetMailAddress(this.UserOneInformation.UserName, this.UserOneInformation.UserDomain), Common.GetMailAddress(this.UserTwoInformation.UserName, this.UserTwoInformation.UserDomain), string.Empty, string.Empty, subject, content, templateID);
            }

            if (saveInSentItems)
            {
                sendMailRequest.RequestData.SaveInSentItems = string.Empty;
            }

            SendMailResponse sendMailResponse = this.ASRMAdapter.SendMail(sendMailRequest);

            int counter    = 0;
            int waitTime   = int.Parse(Common.GetConfigurationPropertyValue("SSLWaitTime", this.Site));
            int upperBound = int.Parse(Common.GetConfigurationPropertyValue("SSLRetryCount", this.Site));

            if (Common.GetConfigurationPropertyValue("TransportType", this.Site)
                .Equals("HTTPS", StringComparison.CurrentCultureIgnoreCase))
            {
                while (!string.IsNullOrEmpty(sendMailResponse.ResponseDataXML) && counter < upperBound)
                {
                    // Await the SSL configuration take effect.
                    System.Threading.Thread.Sleep(waitTime);
                    sendMailResponse = this.ASRMAdapter.SendMail(sendMailRequest);
                    counter++;
                }
            }

            this.Site.Assert.AreEqual <string>(string.Empty, sendMailResponse.ResponseDataXML, "If the message is sent successfully, the server should return an empty response.");

            if (saveInSentItems)
            {
                AddCreatedItemToCollection(this.UserOneInformation, this.UserOneInformation.SentItemsCollectionId, subject);
            }
            #endregion

            #region Record Cc user name, folder collectionId and item subject that are used in case
            if (copyToUserInformation != null)
            {
                this.SwitchUser(copyToUserInformation, true);
                AddCreatedItemToCollection(copyToUserInformation, copyToUserInformation.InboxCollectionId, subject);
            }

            #endregion

            #region User2 calls method FolderSync to synchronize the collection hierarchy, returns folder collectionIds
            this.SwitchUser(this.UserTwoInformation, true);
            #endregion

            #region Record User2's user name, folder collectionId and item subject that are used in case
            AddCreatedItemToCollection(this.UserTwoInformation, this.UserTwoInformation.InboxCollectionId, subject);
            #endregion

            return(subject);
        }