public void TestFixtureSetup() { _outlookapp = new WsApplication(new MSOutlook.Application(), false); _oif = new OutlookIImplFactory(); _wsUtilities = _oif.CreateUtilities(); Disable(); }
public TaskPaneManager(WsApplication application, object thisAddinInstance) { Logger.LogInfo("Interactive Protect : TaskPaneManager loaded."); Globals.Application = application; Globals.Application.ItemSend += OnItemSend; Globals.ThisAddin = thisAddinInstance.ActLike<IThisAddinWrapper>(); }
public void ExecuteEncryptionTestScript(string scriptName, bool shouldSucceed) { try { ContentEncryptionManager.ClearPasswordCache(); string scriptPath = Path.Combine(TestFileDirectory, shouldSucceed ? "succeed" : "fail", scriptName); var passwordInfo = ParsePasswordInfo(scriptPath); using (RequestCreator rc = new RequestCreator()) { // Create a request based on the script file using (Request request = rc.CreateRequest(scriptPath)) { // Check attachments read into request correctly Assert.IsTrue(CheckAttachments(scriptPath, request), "CheckAttachments failed after initial request creation, script:" + scriptPath); IContentEncryptionUi ui = new MockContentEncryptionUi(passwordInfo, DecryptResult.Ok, DecryptionErrorAction.Cancel); using (var app = new WsApplication(new MSOutlook.Application(), false)) { using (Workshare.PolicyMarshaller.MailAttachmentTransform mat = new MailAttachmentTransform(Interop.Options.OptionApi.GetInt("LevelOfProcessingEmbeddedMessages"), app)) using (ContentEncryptionManager manager = new ContentEncryptionManager(mat.ExpandMSG, mat.PackMSG)) { // Check decryption Assert.AreEqual(shouldSucceed, manager.DecryptRequestAttachments(request, ui), "DecryptRequestAttachments response incorrect, script:" + scriptPath); if (shouldSucceed)// No point proceeding if we were expecting failure { EnforceResponse spoofResponse = new EnforceResponse(); spoofResponse.ModifiedRequest = request; // Now ensure we can re-encrypt it bool cancelSend = true; Assert.IsTrue(manager.ReencryptResponseAttachments(spoofResponse, out cancelSend), "ReencryptResponseAttachments failed, script:" + scriptPath); Assert.IsFalse(cancelSend, "cancelSend true, should be false, script:" + scriptPath); Assert.IsTrue(CheckAttachments(scriptPath, request), "CheckAttachments failed after re-encryption, script:" + scriptPath); // Ensure the encryption went OK CheckFilesEncrypted(passwordInfo, manager, spoofResponse); } } } } } } catch (Exception ex) { Assert.Fail(string.Format("Caught exception while executing: {0}. Exception: {1}", Path.GetFileName(scriptName), ex.Message)); throw; } finally { // Occasionally seeing a COM error when re-running tests, suspect its down to the Request writer not having cleaned up fully. GC.Collect(); GC.WaitForPendingFinalizers(); } }
public Request CreateRequest(string testXMLFilePath) { using (var outlookApp = new WsApplication(new Microsoft.Office.Interop.Outlook.Application(), false)) { using (var mailItem = outlookApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)) { int positionCount = 0; XmlReader reader = new XmlTextReader(testXMLFilePath); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: if (reader.Name.CompareTo("subject") == 0) { mailItem.Subject = reader.ReadElementContentAsString(); } else if (reader.Name.CompareTo("recipient") == 0) { mailItem.Recipients.Add(reader.ReadElementContentAsString()); } else if (reader.Name.CompareTo("attachment") == 0) { string fileName = reader.ReadElementContentAsString(); // We want the parent directory because the scripts live in \succeed and \fail below the folder containg the test files string testFilePath = Path.Combine(Directory.GetParent(Path.GetDirectoryName(testXMLFilePath)).FullName, fileName); if (!File.Exists(testFilePath)) { throw new Exception("Unable to find test file: " + fileName); } mailItem.Attachments.Add(testFilePath, Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, ++positionCount, fileName); } break; } } mailItem.Save(); // Now convert to to a request Request request = null; // Yes we are assuming the security has been disabled OK...but we're testing the decryption here, NOT the proxy/security code path _proxy = new OutlookMailProxy(mailItem); _email2Uro = new Email2Request(_proxy); request = _email2Uro.Convert(RequestChannel.Outlook, false); // Tidyup mailItem.Delete(); return request; } } }
public void Dispose() { if (_wsApplication != null) { _wsApplication.Dispose(); _wsApplication = null; } if (_property != null) { Marshal.ReleaseComObject(_property); _property = null; } }
public void Dispose() { if (_wsApplication != null) { _wsApplication.Dispose(); _wsApplication = null; } if (_account != null) { Marshal.ReleaseComObject(_account); _account = null; } }
public void TestFixtureTearDown() { if (_wsUtilities != null) { _wsUtilities.Cleanup(); _wsUtilities = null; } _oif = null; _outlookapp.Quit(); _outlookapp.Dispose(); _outlookapp = null; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); }
public void Initialise(WsApplication application) { _instance.Initialise(application); }
public void Dispose() { if (_wsPropertyAccessor != null) { _wsPropertyAccessor.Dispose(); _wsPropertyAccessor = null; } if (_wsApplication != null) { _wsApplication.Dispose(); _wsApplication = null; } if (_wsAddressEntryManager != null) { _wsAddressEntryManager.Dispose(); _wsAddressEntryManager = null; } if (_addressEntries != null) { _addressEntries.Dispose(); _addressEntries = null; } if (_addressEntry != null) { Marshal.ReleaseComObject(_addressEntry); _addressEntry = null; } }
public TaskPaneLoader(WsApplication application) { _wsApplication = application; Load(); }
public void Dispose() { if (_wsApplication != null) { _wsApplication.Dispose(); _wsApplication = null; } if (_wsAccounts != null) { for (int i = 0; i < _wsAccounts.Count; i++) _wsAccounts[i].Dispose(); _wsAccounts.Clear(); } if (_accounts != null) { Marshal.ReleaseComObject(_accounts); _accounts = null; } }
protected override void Dispose(bool disposing) { if (_item != null) { ((MailItem) (_item)).BeforeAttachmentRead -= OnBeforeAttachmentRead; ((MailItem) _item).AttachmentAdd -= OnAttachmentAdd; ((MailItem) _item).AttachmentRemove -= OnAttachmentRemove; ((MailItem) _item).BeforeCheckNames -= OnBeforeCheckNames; } if (_recipients != null) { _recipients.Dispose(); _recipients = null; } if (_wsAttachments != null) { _wsAttachments.Dispose(); _wsAttachments = null; } if (_wsInspector != null) { _wsInspector.Dispose(); _wsInspector = null; } if (_wsAccount != null) { _wsAccount.Dispose(); _wsAccount = null; } if (_wsApplication != null) { _wsApplication.Dispose(); _wsApplication = null; } if (_wsUserProperties != null) { _wsUserProperties.Dispose(); _wsUserProperties = null; } if (_wsPropertyAccessor != null) { _wsPropertyAccessor.Dispose(); _wsPropertyAccessor = null; } if (_wsSession != null) { _wsSession.Dispose(); _wsSession = null; } base.Dispose(disposing); }
public void Dispose() { if (_wsPropertyAccessor != null) { _wsPropertyAccessor.Dispose(); _wsPropertyAccessor = null; } if (_wsApplication != null) { _wsApplication.Dispose(); _wsApplication = null; } if (_attachment != null) { Marshal.ReleaseComObject(_attachment); _attachment = null; } }
public void Dispose() { if (_wsApplication != null) { _wsApplication.Dispose(); _wsApplication = null; } if (_wsAddressEntries != null) { for (int i = 0; i < _wsAddressEntries.Count; i++) _wsAddressEntries[i].Dispose(); _wsAddressEntries.Clear(); } if (_addressEntries != null) { Marshal.ReleaseComObject(_addressEntries); _addressEntries = null; } }