blob: d5de6b2125628b5f833205b16b6335538e2af605 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
//-----------------------------------------------------------------------
// <copyright file="DirectErrorResponseTests.cs" company="Outercurve Foundation">
// Copyright (c) Outercurve Foundation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.Test.OpenId.Messages {
using System;
using System.Net;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OpenId;
using DotNetOpenAuth.OpenId.Messages;
using NUnit.Framework;
[TestFixture]
public class DirectErrorResponseTests : OpenIdTestBase {
private DirectErrorResponse response;
[SetUp]
public override void SetUp() {
base.SetUp();
var request = new AssociateUnencryptedRequest(Protocol.V20.Version, new Uri("http://host"));
this.response = new DirectErrorResponse(request.Version, request);
}
[Test]
public void ParameterNames() {
this.response.ErrorMessage = "Some Error";
this.response.Contact = "Andrew Arnott";
this.response.Reference = "http://blog.nerdbank.net/";
MessageSerializer serializer = MessageSerializer.Get(this.response.GetType());
var fields = this.MessageDescriptions.GetAccessor(this.response).Serialize();
Assert.AreEqual(Protocol.OpenId2Namespace, fields["ns"]);
Assert.AreEqual("Some Error", fields["error"]);
Assert.AreEqual("Andrew Arnott", fields["contact"]);
Assert.AreEqual("http://blog.nerdbank.net/", fields["reference"]);
}
/// <summary>
/// Verifies that error messages are created as HTTP 400 errors,
/// per OpenID 2.0 section 5.1.2.2.
/// </summary>
[Test]
public void ErrorMessagesAsHttp400() {
var httpStatusMessage = (IHttpDirectResponse)this.response;
Assert.AreEqual(HttpStatusCode.BadRequest, httpStatusMessage.HttpStatusCode);
}
}
}
|