//-----------------------------------------------------------------------
//
// Copyright (c) Outercurve Foundation. All rights reserved.
//
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.Test.OAuth {
using System;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OAuth;
using NUnit.Framework;
///
/// Tests for the class.
///
[TestFixture]
public class ServiceProviderDescriptionTests : TestBase {
///
/// A test for UserAuthorizationUri
///
[Test]
public void UserAuthorizationUriTest() {
var target = new ServiceProviderHostDescription();
var expected = new MessageReceivingEndpoint("http://localhost/authorization", HttpDeliveryMethods.GetRequest);
MessageReceivingEndpoint actual;
target.UserAuthorizationEndpoint = expected;
actual = target.UserAuthorizationEndpoint;
Assert.AreEqual(expected, actual);
target.UserAuthorizationEndpoint = null;
Assert.IsNull(target.UserAuthorizationEndpoint);
}
///
/// A test for RequestTokenUri
///
[Test]
public void RequestTokenUriTest() {
var target = new ServiceProviderHostDescription();
var expected = new MessageReceivingEndpoint("http://localhost/requesttoken", HttpDeliveryMethods.GetRequest);
MessageReceivingEndpoint actual;
target.RequestTokenEndpoint = expected;
actual = target.RequestTokenEndpoint;
Assert.AreEqual(expected, actual);
target.RequestTokenEndpoint = null;
Assert.IsNull(target.RequestTokenEndpoint);
}
///
/// Verifies that oauth parameters are not allowed in ,
/// per section OAuth 1.0 section 4.1.
///
[Test, ExpectedException(typeof(ArgumentException))]
public void RequestTokenUriWithOAuthParametersTest() {
var target = new ServiceProviderHostDescription();
target.RequestTokenEndpoint = new MessageReceivingEndpoint("http://localhost/requesttoken?oauth_token=something", HttpDeliveryMethods.GetRequest);
}
///
/// A test for AccessTokenUri
///
[Test]
public void AccessTokenUriTest() {
var target = new ServiceProviderHostDescription();
MessageReceivingEndpoint expected = new MessageReceivingEndpoint("http://localhost/accesstoken", HttpDeliveryMethods.GetRequest);
MessageReceivingEndpoint actual;
target.AccessTokenEndpoint = expected;
actual = target.AccessTokenEndpoint;
Assert.AreEqual(expected, actual);
target.AccessTokenEndpoint = null;
Assert.IsNull(target.AccessTokenEndpoint);
}
}
}