Пример #1
0
		internal static RoutingEntity GetRoutingEntity(IUniversalRoutingEntity ure)
		{
			if (null == ure)
				throw new ArgumentNullException("ure");

			RoutingEntity routingEntity = new RoutingEntity();

			routingEntity.PolicyType = ure.PolicyType.ToString();
			routingEntity.RoutingType = ure.RoutingType;

			if (ure.Items != null && ure.Items.Count > 0)
			{
				routingEntity.Items = new Workshare.PolicyContent.RoutingItem[ure.Items.Count];
				int index = 0;
				foreach (IRoutingItem item in ure.Items)
				{
					Workshare.PolicyContent.RoutingItem routingItem = new Workshare.PolicyContent.RoutingItem();
					routingItem.Content = item.Content;

					if (item.Properties != null && item.Properties.Count > 0)
					{
						routingItem.Properties = new CustomProperty[item.Properties.Count];
						int propIndex = 0;
						foreach( string key in item.Properties.Keys)
						{
							routingItem.Properties[propIndex++] = new CustomProperty(key, item.Properties[key]);
						}
					}

					routingEntity.Items[index++] = routingItem;
				}
			}

			return routingEntity;
		}
        public void TestGetDigest()
        {
            Request request = new Request();
            
            List<CustomProperty> props = new List<CustomProperty>();

            props.Add(new CustomProperty("Subject", "This is a subject"));
            
            RoutingEntity sourceRouting = new RoutingEntity();

            RoutingItem item = new RoutingItem();
            item.Content = "*****@*****.**";
            
            sourceRouting.Items = new RoutingItem[] {item};
            request.Source = sourceRouting;
            request.Properties = props.ToArray();

            string digest1 = new RequestDigestProvider().GetDigest(request);
            //change the request, get a different digest value.

            request.Source.Items[0].Content = "*****@*****.**";
            string digest2 = new RequestDigestProvider().GetDigest(request);
            Assert.AreNotEqual(digest1,digest2);

            request.Properties[0].Value = "Change the subject";
            string digest3 = new RequestDigestProvider().GetDigest(request);
            Assert.AreNotEqual(digest1,digest2);
            Assert.AreNotEqual(digest2, digest3);

            //Empty subject is OK
            request.Properties[0].Value = string.Empty;

            string digest4 = new RequestDigestProvider().GetDigest(request);
            Assert.AreNotEqual(digest1,digest4);
        }
        public void GetDigestRoutingItemIsCaseInsensitive()
        {
            Request request = new Request();

            List<CustomProperty> props = new List<CustomProperty>();

            props.Add(new CustomProperty("Subject", "This is a subject"));

            RoutingEntity sourceRouting = new RoutingEntity();

            RoutingItem item = new RoutingItem();
            item.Content = "*****@*****.**";
            sourceRouting.Items = new RoutingItem[] { item };
            request.Source = sourceRouting;
            request.Properties = props.ToArray();

            string digest1 = new RequestDigestProvider().GetDigest(request);

            request.Source.Items[0].Content = request.Source.Items[0].Content.ToUpperInvariant();

            string digest2 = new RequestDigestProvider().GetDigest(request);

            Assert.AreEqual(digest1,digest2);
        }
Пример #4
0
		public void TestRecipientAddressInX400Format()
		{
			using (WsActivationContext wsac = new WsActivationContext())
			using (OutlookEmailWrapper outlookEmailWrapper = new OutlookEmailWrapper(m_outlookSession))
			{
				string subject = "Test outlook proxy: TestRecipientAddressInX400Format";
				outlookEmailWrapper.Subject = subject;
				outlookEmailWrapper.ToRecipients = "BlackHole<*****@*****.**>";
				outlookEmailWrapper.BodyFormat = Outlook.OlBodyFormat.olFormatRichText;
				string rtfBody = "We have a body that looks like something";
				outlookEmailWrapper.Body = rtfBody;

				// We have to save the message in order to access all its contents :(
				outlookEmailWrapper.MailItem.Save();

				using (RedemptionMailProxy proxy = new RedemptionMailProxy(outlookEmailWrapper.MailItem))
				using (Email2Mime mailItem2Mime = new Email2Mime(proxy))
				using (Stream mimeStream = mailItem2Mime.ConvertToMimeStream())
				using (MimeProxy mimeProxy = new MimeProxy(mimeStream))
				{
					Email2Request email2Request = new Email2Request(mimeProxy);
					Request request = email2Request.Convert(RequestChannel.Outlook, false);

					outlookEmailWrapper.MailItem.Delete();

					// Now fake an X400 email address
					Workshare.PolicyContent.RoutingItem routingItem = request.Destination.Items[0];

					Workshare.PolicyContent.RoutingItem modifiedRoutingItem = new Workshare.PolicyContent.RoutingItem();
					modifiedRoutingItem.Content = "/O=WSDEV/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=BlackHole";

					System.Collections.Generic.List< CustomProperty> custProps = new System.Collections.Generic.List<CustomProperty>();
					foreach (CustomProperty prop in routingItem.Properties)
					{
						custProps.Add(prop);
					}

					custProps.Add(new CustomProperty(EmailProperties.ReadOnlyKey, bool.TrueString));

					modifiedRoutingItem.Properties = custProps.ToArray();

					request.Destination.Items = new Workshare.PolicyContent.RoutingItem[] { modifiedRoutingItem };

					// Now do a convert again with the modified uro
					email2Request.Convert(RequestChannel.Outlook, request, false);

					Assert.AreEqual(1, request.Destination.Items.Length);

					routingItem = request.Destination.Items[0];
					Assert.AreEqual("/O=WSDEV/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=BlackHole", routingItem.Content);
					Assert.AreEqual("BlackHole", GetPropertyValue(SMTPItemPropertyKeys.DisplayName, routingItem.Properties));
					Assert.AreEqual(AddressType.To,  GetPropertyValue(SMTPItemPropertyKeys.AddressType, routingItem.Properties));
					Assert.AreEqual(bool.TrueString, GetPropertyValue(EmailProperties.ReadOnlyKey, routingItem.Properties));
				}
			}
		}
Пример #5
0
		private void ProcessRecipient(Request request, IEmailRecipient recipient, string addressType)
		{
			Workshare.PolicyContent.RoutingItem routingItem = new Workshare.PolicyContent.RoutingItem();
			routingItem.Content = recipient.EmailAddress;

			CustomProperty displayName = new CustomProperty(SMTPItemPropertyKeys.DisplayName, recipient.Name.Trim());
			CustomProperty addressTypeProp = new CustomProperty(SMTPItemPropertyKeys.AddressType, addressType);
			CustomProperty internalFlag = new CustomProperty(SMTPItemPropertyKeys.Internal, recipient.Internal.ToString());
			CustomProperty modified = new CustomProperty(EmailProperties.ModifiedKey, bool.FalseString);

			routingItem.Properties = new CustomProperty[] { displayName, addressTypeProp, internalFlag, modified };

			AddReadOnlyAttribute(routingItem);

			AddOrReplaceDestinationRoutingItem(request, routingItem);
		}
Пример #6
0
		private void ProcessSender(Request request)
		{
			string senderAddress = m_emailProxy.Sender.EmailAddress;
			string senderName = m_emailProxy.Sender.Name;

			Workshare.PolicyContent.RoutingItem routingItem = new Workshare.PolicyContent.RoutingItem();
			routingItem.Content = senderAddress;

			CustomProperty displayName = new CustomProperty(SMTPItemPropertyKeys.DisplayName, senderName);
			CustomProperty addressType = new CustomProperty(SMTPItemPropertyKeys.AddressType, AddressType.From);
			CustomProperty internalFlag = new CustomProperty(SMTPItemPropertyKeys.Internal, m_emailProxy.Sender.Internal.ToString());

			routingItem.Properties = new CustomProperty[] { displayName, addressType, internalFlag };

			request.Source.Items = new Workshare.PolicyContent.RoutingItem[] { routingItem };
		}
        public void GetDigestMissingSubjectProperty()
        {
            Request request = new Request();

            request.Properties = new CustomProperty[0];//Invalid, this should cause the throw

            RoutingEntity sourceRouting = new RoutingEntity();
            sourceRouting.RoutingType = "Source";

            RoutingItem item = new RoutingItem();
            item.Content = "*****@*****.**";
            sourceRouting.Items = new RoutingItem[] { item };
            request.Source = sourceRouting;

            try
            {
                string digest = new RequestDigestProvider().GetDigest(request);
            }
            catch (ArgumentException)
            {
                Assert.IsTrue(true, "Expecting method to throw this ArgumentException");
                return;
            }

            Assert.Fail("Should have thrown the ArgumentException");
        }
        public void GetDigestEmptyRoutingItem()
        {
            Request request = new Request();

            List<CustomProperty> props = new List<CustomProperty>();

            props.Add(new CustomProperty("Subject", "This is a subject"));
            request.Properties = props.ToArray();

            RoutingEntity sourceRouting = new RoutingEntity();

            RoutingItem item = new RoutingItem();
            item.Content = string.Empty;  //Invalid, this should cause the throw
            sourceRouting.Items = new RoutingItem[] { item };
            request.Source = sourceRouting;
            request.Properties = props.ToArray();

            try
            {
                string digest = new RequestDigestProvider().GetDigest(request);
            }
            catch (ArgumentException)
            {
                Assert.IsTrue(true, "Expecting method to throw this ArgumentException");
                return;
            }

            Assert.Fail("Should have thrown the ArgumentException");
        }