本文整理汇总了C#中DotNetOpenAuth.Test.Mocks.TestDirectedMessage类的典型用法代码示例。如果您正苦于以下问题:C# TestDirectedMessage类的具体用法?C# TestDirectedMessage怎么用?C# TestDirectedMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestDirectedMessage类属于DotNetOpenAuth.Test.Mocks命名空间,在下文中一共展示了TestDirectedMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendIndirectMessage301Get
public void SendIndirectMessage301Get() {
TestDirectedMessage message = new TestDirectedMessage(MessageTransport.Indirect);
GetStandardTestMessage(FieldFill.CompleteBeforeBindings, message);
message.Recipient = new Uri("http://provider/path");
var expected = GetStandardTestFields(FieldFill.CompleteBeforeBindings);
OutgoingWebResponse response = this.Channel.PrepareResponse(message);
Assert.AreEqual(HttpStatusCode.Redirect, response.Status);
StringAssert.StartsWith("http://provider/path", response.Headers[HttpResponseHeader.Location]);
foreach (var pair in expected) {
string key = MessagingUtilities.EscapeUriDataStringRfc3986(pair.Key);
string value = MessagingUtilities.EscapeUriDataStringRfc3986(pair.Value);
string substring = string.Format("{0}={1}", key, value);
StringAssert.Contains(substring, response.Headers[HttpResponseHeader.Location]);
}
}
示例2: SendIndirectMessage301Get
public void SendIndirectMessage301Get() {
TestDirectedMessage message = new TestDirectedMessage(MessageTransport.Indirect);
GetStandardTestMessage(FieldFill.CompleteBeforeBindings, message);
message.Recipient = new Uri("http://provider/path");
var expected = GetStandardTestFields(FieldFill.CompleteBeforeBindings);
OutgoingWebResponse response = this.Channel.PrepareResponse(message);
Assert.AreEqual(HttpStatusCode.Redirect, response.Status);
Assert.AreEqual("text/html; charset=utf-8", response.Headers[HttpResponseHeader.ContentType]);
Assert.IsTrue(response.Body != null && response.Body.Length > 0); // a non-empty body helps get passed filters like WebSense
StringAssert.StartsWith("http://provider/path", response.Headers[HttpResponseHeader.Location]);
foreach (var pair in expected) {
string key = MessagingUtilities.EscapeUriDataStringRfc3986(pair.Key);
string value = MessagingUtilities.EscapeUriDataStringRfc3986(pair.Value);
string substring = string.Format("{0}={1}", key, value);
StringAssert.Contains(substring, response.Headers[HttpResponseHeader.Location]);
}
}
示例3: GetNewRequestMessage
public IDirectedProtocolMessage GetNewRequestMessage(MessageReceivingEndpoint recipient, IDictionary<string, string> fields) {
if (fields.ContainsKey("age")) {
if (this.signedMessages) {
if (this.expiringMessages) {
if (this.replayMessages) {
return new TestReplayProtectedMessage();
}
return new TestExpiringMessage();
}
return new TestSignedDirectedMessage();
}
var result = new TestDirectedMessage();
if (fields.ContainsKey("GetOnly")) {
result.HttpMethods = HttpDeliveryMethods.GetRequest;
}
return result;
}
return null;
}
示例4: SendInvalidMessageTransport
public void SendInvalidMessageTransport()
{
IProtocolMessage message = new TestDirectedMessage((MessageTransport)100);
this.Channel.PrepareResponse(message);
}
示例5: SendIndirectMessageFormPostNullFields
public void SendIndirectMessageFormPostNullFields()
{
TestBadChannel badChannel = new TestBadChannel(false);
var message = new TestDirectedMessage(MessageTransport.Indirect);
message.Recipient = new Uri("http://someserver");
badChannel.CreateFormPostResponse(message, null);
}
示例6: SendIndirectMessageFormPostEmptyRecipient
public void SendIndirectMessageFormPostEmptyRecipient()
{
TestBadChannel badChannel = new TestBadChannel(false);
var message = new TestDirectedMessage(MessageTransport.Indirect);
badChannel.CreateFormPostResponse(message, new Dictionary<string, string>());
}
示例7: SendIndirectMessageFormPost
public void SendIndirectMessageFormPost()
{
// We craft a very large message to force fallback to form POST.
// We'll also stick some HTML reserved characters in the string value
// to test proper character escaping.
var message = new TestDirectedMessage(MessageTransport.Indirect) {
Age = 15,
Name = "c<b" + new string('a', 10 * 1024),
Location = new Uri("http://host/path"),
Recipient = new Uri("http://provider/path"),
};
OutgoingWebResponse response = this.Channel.PrepareResponse(message);
Assert.AreEqual(HttpStatusCode.OK, response.Status, "A form redirect should be an HTTP successful response.");
Assert.IsNull(response.Headers[HttpResponseHeader.Location], "There should not be a redirection header in the response.");
string body = response.Body;
StringAssert.Contains(body, "<form ");
StringAssert.Contains(body, "action=\"http://provider/path\"");
StringAssert.Contains(body, "method=\"post\"");
StringAssert.Contains(body, "<input type=\"hidden\" name=\"age\" value=\"15\" />");
StringAssert.Contains(body, "<input type=\"hidden\" name=\"Location\" value=\"http://host/path\" />");
StringAssert.Contains(body, "<input type=\"hidden\" name=\"Name\" value=\"" + HttpUtility.HtmlEncode(message.Name) + "\" />");
StringAssert.Contains(body, ".submit()", "There should be some javascript to automate form submission.");
}
示例8: RequestUsingAuthorizationHeaderScattered
public void RequestUsingAuthorizationHeaderScattered() {
TestDirectedMessage request = new TestDirectedMessage(MessageTransport.Direct) {
Age = 15,
Name = "Andrew",
Location = new Uri("http://hostb/pathB"),
Recipient = new Uri("http://localtest"),
Timestamp = DateTime.UtcNow,
HttpMethods = HttpDeliveryMethods.AuthorizationHeaderRequest,
};
// ExtraData should appear in the form since this is a POST request,
// and only official message parts get a place in the Authorization header.
((IProtocolMessage)request).ExtraData["appearinform"] = "formish";
request.Recipient = new Uri("http://localhost/?appearinquery=queryish");
request.HttpMethods = HttpDeliveryMethods.AuthorizationHeaderRequest | HttpDeliveryMethods.PostRequest;
HttpWebRequest webRequest = this.channel.InitializeRequest(request);
Assert.IsNotNull(webRequest);
Assert.AreEqual("POST", webRequest.Method);
Assert.AreEqual(request.Recipient, webRequest.RequestUri);
var declaredParts = new Dictionary<string, string> {
{ "age", request.Age.ToString() },
{ "Name", request.Name },
{ "Location", request.Location.AbsoluteUri },
{ "Timestamp", XmlConvert.ToString(request.Timestamp, XmlDateTimeSerializationMode.Utc) },
};
Assert.AreEqual(CreateAuthorizationHeader(declaredParts), webRequest.Headers[HttpRequestHeader.Authorization]);
Assert.AreEqual("appearinform=formish", this.webRequestHandler.RequestEntityAsString);
}
示例9: RequestNullRecipient
public void RequestNullRecipient() {
IDirectedProtocolMessage message = new TestDirectedMessage(MessageTransport.Direct);
this.channel.Request(message);
}
示例10: RequestBadPreferredScheme
public async Task RequestBadPreferredScheme() {
TestDirectedMessage message = new TestDirectedMessage(MessageTransport.Direct);
message.Recipient = new Uri("http://localtest");
message.HttpMethods = HttpDeliveryMethods.None;
await this.channel.RequestAsync(message, CancellationToken.None);
}
示例11: RequestNullRecipient
public async Task RequestNullRecipient() {
IDirectedProtocolMessage message = new TestDirectedMessage(MessageTransport.Direct);
await this.channel.RequestAsync(message, CancellationToken.None);
}
示例12: SendDirectMessageResponse
public async Task SendDirectMessageResponse() {
IProtocolMessage message = new TestDirectedMessage {
Age = 15,
Name = "Andrew",
Location = new Uri("http://hostb/pathB"),
};
var response = await this.channel.PrepareResponseAsync(message);
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
Assert.AreEqual(Channel.HttpFormUrlEncodedContentType.MediaType, response.Content.Headers.ContentType.MediaType);
NameValueCollection body = HttpUtility.ParseQueryString(await response.Content.ReadAsStringAsync());
Assert.AreEqual("15", body["age"]);
Assert.AreEqual("Andrew", body["Name"]);
Assert.AreEqual("http://hostb/pathB", body["Location"]);
}
示例13: GetStandardTestMessage
internal static TestMessage GetStandardTestMessage(FieldFill fill) {
TestMessage message = new TestDirectedMessage();
GetStandardTestMessage(fill, message);
return message;
}
示例14: SendInvalidMessageTransport
public async Task SendInvalidMessageTransport() {
IProtocolMessage message = new TestDirectedMessage((MessageTransport)100);
await this.Channel.PrepareResponseAsync(message);
}
示例15: SendDirectedNoRecipientMessage
public async Task SendDirectedNoRecipientMessage() {
IProtocolMessage message = new TestDirectedMessage(MessageTransport.Indirect);
await this.Channel.PrepareResponseAsync(message);
}