internal void ParameterizedReceiveProtectedTest(DateTime?utcCreatedDate, bool invalidSignature) { TestMessage expectedMessage = GetStandardTestMessage(FieldFill.CompleteBeforeBindings); var fields = GetStandardTestFields(FieldFill.CompleteBeforeBindings); fields.Add("Signature", invalidSignature ? "badsig" : MockSigningBindingElement.MessageSignature); fields.Add("Nonce", "someNonce"); if (utcCreatedDate.HasValue) { utcCreatedDate = DateTime.Parse(utcCreatedDate.Value.ToUniversalTime().ToString()); // round off the milliseconds so comparisons work later fields.Add("created_on", XmlConvert.ToString(utcCreatedDate.Value, XmlDateTimeSerializationMode.Utc)); } IProtocolMessage requestMessage = this.Channel.ReadFromRequest(CreateHttpRequestInfo("GET", fields)); Assert.IsNotNull(requestMessage); Assert.IsInstanceOf <TestSignedDirectedMessage>(requestMessage); TestSignedDirectedMessage actualMessage = (TestSignedDirectedMessage)requestMessage; Assert.AreEqual(expectedMessage.Age, actualMessage.Age); Assert.AreEqual(expectedMessage.Name, actualMessage.Name); Assert.AreEqual(expectedMessage.Location, actualMessage.Location); if (utcCreatedDate.HasValue) { IExpiringProtocolMessage expiringMessage = (IExpiringProtocolMessage)requestMessage; Assert.AreEqual(utcCreatedDate.Value, expiringMessage.UtcCreationDate); } }
public async Task InsufficientlyProtectedMessageSent() { var message = new TestSignedDirectedMessage(MessageTransport.Direct); message.Recipient = new Uri("http://localtest"); await this.Channel.PrepareResponseAsync(message); }
public void SingleResponseMessageType() { this.factory.AddMessageTypes(new MessageDescription[] { MessageDescriptions.Get(typeof(DirectResponseMessageMock), V1) }); var fields = new Dictionary <string, string> { { "random", "bits" }, }; IDirectedProtocolMessage request = new RequestMessageMock(receiver.Location, V1); Assert.IsNull(this.factory.GetNewResponseMessage(request, fields)); fields["Age"] = "18"; IDirectResponseProtocolMessage response = this.factory.GetNewResponseMessage(request, fields); Assert.IsInstanceOf <DirectResponseMessageMock>(response); Assert.AreSame(request, response.OriginatingRequest); // Verify that we can instantiate a response with a derived-type of an expected request message. request = new TestSignedDirectedMessage(); response = this.factory.GetNewResponseMessage(request, fields); Assert.IsInstanceOf <DirectResponseMessageMock>(response); Assert.AreSame(request, response.OriginatingRequest); }