summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Test
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2013-03-26 12:52:06 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2013-03-26 12:52:06 -0700
commitb9ae2ab289e2b9708ea3cce055ac484b00246a8a (patch)
tree28ef380a84c743075cbddf3417556e1d1bb37f49 /src/DotNetOpenAuth.Test
parent3d37ff45cab6838d80b22e6b782a0b9b4c2f4aeb (diff)
downloadDotNetOpenAuth-b9ae2ab289e2b9708ea3cce055ac484b00246a8a.zip
DotNetOpenAuth-b9ae2ab289e2b9708ea3cce055ac484b00246a8a.tar.gz
DotNetOpenAuth-b9ae2ab289e2b9708ea3cce055ac484b00246a8a.tar.bz2
Lots of StyleCop fixes.
Diffstat (limited to 'src/DotNetOpenAuth.Test')
-rw-r--r--src/DotNetOpenAuth.Test/Messaging/MessagingTestBase.cs62
-rw-r--r--src/DotNetOpenAuth.Test/MockingHostFactories.cs6
-rw-r--r--src/DotNetOpenAuth.Test/OAuth2/WebServerClientAuthorizeTests.cs6
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/ChannelElements/ExtensionsBindingElementTests.cs5
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/NonIdentityTests.cs3
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs132
-rw-r--r--src/DotNetOpenAuth.Test/Settings.StyleCop22
-rw-r--r--src/DotNetOpenAuth.Test/TestBase.cs5
8 files changed, 128 insertions, 113 deletions
diff --git a/src/DotNetOpenAuth.Test/Messaging/MessagingTestBase.cs b/src/DotNetOpenAuth.Test/Messaging/MessagingTestBase.cs
index 7903e89..f97e795 100644
--- a/src/DotNetOpenAuth.Test/Messaging/MessagingTestBase.cs
+++ b/src/DotNetOpenAuth.Test/Messaging/MessagingTestBase.cs
@@ -73,37 +73,6 @@ namespace DotNetOpenAuth.Test {
return result;
}
- internal Channel CreateChannel(MessageProtections capabilityAndRecognition) {
- return this.CreateChannel(capabilityAndRecognition, capabilityAndRecognition);
- }
-
- internal Channel CreateChannel(MessageProtections capability, MessageProtections recognition) {
- var bindingElements = new List<IChannelBindingElement>();
- if (capability >= MessageProtections.TamperProtection) {
- bindingElements.Add(new MockSigningBindingElement());
- }
- if (capability >= MessageProtections.Expiration) {
- bindingElements.Add(new StandardExpirationBindingElement());
- }
- if (capability >= MessageProtections.ReplayProtection) {
- bindingElements.Add(new MockReplayProtectionBindingElement());
- }
-
- bool signing = false, expiration = false, replay = false;
- if (recognition >= MessageProtections.TamperProtection) {
- signing = true;
- }
- if (recognition >= MessageProtections.Expiration) {
- expiration = true;
- }
- if (recognition >= MessageProtections.ReplayProtection) {
- replay = true;
- }
-
- var typeProvider = new TestMessageFactory(signing, expiration, replay);
- return new TestChannel(typeProvider, bindingElements.ToArray(), this.HostFactories);
- }
-
internal static IDictionary<string, string> GetStandardTestFields(FieldFill fill) {
TestMessage expectedMessage = GetStandardTestMessage(fill);
@@ -145,6 +114,37 @@ namespace DotNetOpenAuth.Test {
}
}
+ internal Channel CreateChannel(MessageProtections capabilityAndRecognition) {
+ return this.CreateChannel(capabilityAndRecognition, capabilityAndRecognition);
+ }
+
+ internal Channel CreateChannel(MessageProtections capability, MessageProtections recognition) {
+ var bindingElements = new List<IChannelBindingElement>();
+ if (capability >= MessageProtections.TamperProtection) {
+ bindingElements.Add(new MockSigningBindingElement());
+ }
+ if (capability >= MessageProtections.Expiration) {
+ bindingElements.Add(new StandardExpirationBindingElement());
+ }
+ if (capability >= MessageProtections.ReplayProtection) {
+ bindingElements.Add(new MockReplayProtectionBindingElement());
+ }
+
+ bool signing = false, expiration = false, replay = false;
+ if (recognition >= MessageProtections.TamperProtection) {
+ signing = true;
+ }
+ if (recognition >= MessageProtections.Expiration) {
+ expiration = true;
+ }
+ if (recognition >= MessageProtections.ReplayProtection) {
+ replay = true;
+ }
+
+ var typeProvider = new TestMessageFactory(signing, expiration, replay);
+ return new TestChannel(typeProvider, bindingElements.ToArray(), this.HostFactories);
+ }
+
internal async Task ParameterizedReceiveTestAsync(HttpMethod method) {
var fields = GetStandardTestFields(FieldFill.CompleteBeforeBindings);
TestMessage expectedMessage = GetStandardTestMessage(FieldFill.CompleteBeforeBindings);
diff --git a/src/DotNetOpenAuth.Test/MockingHostFactories.cs b/src/DotNetOpenAuth.Test/MockingHostFactories.cs
index b8cbeb0..93579ad 100644
--- a/src/DotNetOpenAuth.Test/MockingHostFactories.cs
+++ b/src/DotNetOpenAuth.Test/MockingHostFactories.cs
@@ -5,17 +5,15 @@
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.Test {
+ using System;
using System.Collections.Generic;
+ using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
- using System.Linq;
-
using DotNetOpenAuth.OpenId;
-
using Validation;
- using System;
internal class MockingHostFactories : IHostFactories {
public MockingHostFactories(Dictionary<Uri, Func<HttpRequestMessage, Task<HttpResponseMessage>>> handlers = null) {
diff --git a/src/DotNetOpenAuth.Test/OAuth2/WebServerClientAuthorizeTests.cs b/src/DotNetOpenAuth.Test/OAuth2/WebServerClientAuthorizeTests.cs
index 433cbf3..f395e38 100644
--- a/src/DotNetOpenAuth.Test/OAuth2/WebServerClientAuthorizeTests.cs
+++ b/src/DotNetOpenAuth.Test/OAuth2/WebServerClientAuthorizeTests.cs
@@ -118,9 +118,9 @@ namespace DotNetOpenAuth.Test.OAuth2 {
authServer.Setup(
a => a.CheckAuthorizeClientCredentialsGrant(It.Is<IAccessTokenRequest>(d => d.ClientIdentifier == ClientId && MessagingUtilities.AreEquivalent(d.Scope, TestScopes))))
.Returns<IAccessTokenRequest>(req => {
- var response = new AutomatedAuthorizationCheckResponse(req, true);
- response.ApprovedScope.ResetContents(approvedScopes);
- return response;
+ var response = new AutomatedAuthorizationCheckResponse(req, true);
+ response.ApprovedScope.ResetContents(approvedScopes);
+ return response;
});
Handle(AuthorizationServerDescription.TokenEndpoint).By(
async (req, ct) => {
diff --git a/src/DotNetOpenAuth.Test/OpenId/ChannelElements/ExtensionsBindingElementTests.cs b/src/DotNetOpenAuth.Test/OpenId/ChannelElements/ExtensionsBindingElementTests.cs
index 1a1307d..ca0e4b4 100644
--- a/src/DotNetOpenAuth.Test/OpenId/ChannelElements/ExtensionsBindingElementTests.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/ChannelElements/ExtensionsBindingElementTests.cs
@@ -124,7 +124,6 @@ namespace DotNetOpenAuth.Test.OpenId.ChannelElements {
var opStore = new StandardProviderApplicationStore();
int rpStep = 0;
-
Handle(RPUri).By(
async req => {
var rp = new OpenIdRelyingParty(new StandardRelyingPartyApplicationStore(), this.HostFactories);
@@ -157,7 +156,7 @@ namespace DotNetOpenAuth.Test.OpenId.ChannelElements {
{
var op = new OpenIdProvider(opStore, this.HostFactories);
RegisterMockExtension(op.Channel);
- var redirectingResponse = await op.Channel.PrepareResponseAsync(CreateResponseWithExtensions(protocol));
+ var redirectingResponse = await op.Channel.PrepareResponseAsync(this.CreateResponseWithExtensions(protocol));
using (var httpClient = this.HostFactories.CreateHttpClient()) {
using (var response = await httpClient.GetAsync(redirectingResponse.Headers.Location)) {
response.EnsureSuccessStatusCode();
@@ -165,7 +164,7 @@ namespace DotNetOpenAuth.Test.OpenId.ChannelElements {
}
op.SecuritySettings.SignOutgoingExtensions = false;
- redirectingResponse = await op.Channel.PrepareResponseAsync(CreateResponseWithExtensions(protocol));
+ redirectingResponse = await op.Channel.PrepareResponseAsync(this.CreateResponseWithExtensions(protocol));
using (var httpClient = this.HostFactories.CreateHttpClient()) {
using (var response = await httpClient.GetAsync(redirectingResponse.Headers.Location)) {
response.EnsureSuccessStatusCode();
diff --git a/src/DotNetOpenAuth.Test/OpenId/NonIdentityTests.cs b/src/DotNetOpenAuth.Test/OpenId/NonIdentityTests.cs
index 11463c7..2e2a960 100644
--- a/src/DotNetOpenAuth.Test/OpenId/NonIdentityTests.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/NonIdentityTests.cs
@@ -6,17 +6,16 @@
namespace DotNetOpenAuth.Test.OpenId {
using System;
+ using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
-
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OpenId;
using DotNetOpenAuth.OpenId.Messages;
using DotNetOpenAuth.OpenId.Provider;
using DotNetOpenAuth.OpenId.RelyingParty;
using NUnit.Framework;
- using System.Net;
[TestFixture]
public class NonIdentityTests : OpenIdTestBase {
diff --git a/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs b/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs
index ea2867c..9872b01 100644
--- a/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/OpenIdTestBase.cs
@@ -196,72 +196,6 @@ namespace DotNetOpenAuth.Test.OpenId {
var rp = this.CreateRelyingParty(true);
return rp.DiscoverAsync(identifier, cancellationToken);
}
-
- protected Realm GetMockRealm(bool useSsl) {
- var rpDescription = new RelyingPartyEndpointDescription(useSsl ? RPUriSsl : RPUri, new string[] { Protocol.V20.RPReturnToTypeURI });
- return new MockRealm(useSsl ? RPRealmUriSsl : RPRealmUri, rpDescription);
- }
-
- protected Identifier GetMockIdentifier(ProtocolVersion providerVersion) {
- return this.GetMockIdentifier(providerVersion, false);
- }
-
- protected Identifier GetMockIdentifier(ProtocolVersion providerVersion, bool useSsl) {
- return this.GetMockIdentifier(providerVersion, useSsl, false);
- }
-
- protected Identifier GetMockIdentifier(ProtocolVersion providerVersion, bool useSsl, bool delegating) {
- var se = GetServiceEndpoint(0, providerVersion, 10, useSsl, delegating);
- this.RegisterMockXrdsResponse(se);
- return se.ClaimedIdentifier;
- }
-
- protected Identifier GetMockDualIdentifier() {
- Protocol protocol = Protocol.Default;
- var opDesc = new ProviderEndpointDescription(OPUri, protocol.Version);
- var dualResults = new IdentifierDiscoveryResult[] {
- IdentifierDiscoveryResult.CreateForClaimedIdentifier(VanityUri.AbsoluteUri, OPLocalIdentifiers[0], opDesc, 10, 10),
- IdentifierDiscoveryResult.CreateForProviderIdentifier(protocol.ClaimedIdentifierForOPIdentifier, opDesc, 20, 20),
- };
-
- this.RegisterMockXrdsResponse(VanityUri, dualResults);
- return VanityUri;
- }
-
- /// <summary>
- /// Creates a standard <see cref="OpenIdRelyingParty"/> instance for general testing.
- /// </summary>
- /// <returns>The new instance.</returns>
- protected OpenIdRelyingParty CreateRelyingParty() {
- return this.CreateRelyingParty(false);
- }
-
- /// <summary>
- /// Creates a standard <see cref="OpenIdRelyingParty"/> instance for general testing.
- /// </summary>
- /// <param name="stateless">if set to <c>true</c> a stateless RP is created.</param>
- /// <returns>The new instance.</returns>
- protected OpenIdRelyingParty CreateRelyingParty(bool stateless) {
- var rp = new OpenIdRelyingParty(stateless ? null : new StandardRelyingPartyApplicationStore(), this.HostFactories);
- return rp;
- }
-
- /// <summary>
- /// Creates a standard <see cref="OpenIdProvider"/> instance for general testing.
- /// </summary>
- /// <returns>The new instance.</returns>
- protected OpenIdProvider CreateProvider() {
- var op = new OpenIdProvider(new StandardProviderApplicationStore(), this.HostFactories);
- return op;
- }
-
- protected internal void HandleProvider(Func<OpenIdProvider, HttpRequestMessage, Task<HttpResponseMessage>> provider) {
- var op = this.CreateProvider();
- this.Handle(OPUri).By(async req => {
- return await provider(op, req);
- });
- }
-
/// <summary>
/// Simulates an extension request and response.
/// </summary>
@@ -335,5 +269,71 @@ namespace DotNetOpenAuth.Test.OpenId {
CollectionAssert<IOpenIdMessageExtension>.AreEquivalentByEquality(responses.ToArray(), receivedResponses.ToArray());
}
}
+
+ protected internal void HandleProvider(Func<OpenIdProvider, HttpRequestMessage, Task<HttpResponseMessage>> provider) {
+ var op = this.CreateProvider();
+ this.Handle(OPUri).By(async req => {
+ return await provider(op, req);
+ });
+ }
+
+ protected Realm GetMockRealm(bool useSsl) {
+ var rpDescription = new RelyingPartyEndpointDescription(useSsl ? RPUriSsl : RPUri, new string[] { Protocol.V20.RPReturnToTypeURI });
+ return new MockRealm(useSsl ? RPRealmUriSsl : RPRealmUri, rpDescription);
+ }
+
+ protected Identifier GetMockIdentifier(ProtocolVersion providerVersion) {
+ return this.GetMockIdentifier(providerVersion, false);
+ }
+
+ protected Identifier GetMockIdentifier(ProtocolVersion providerVersion, bool useSsl) {
+ return this.GetMockIdentifier(providerVersion, useSsl, false);
+ }
+
+ protected Identifier GetMockIdentifier(ProtocolVersion providerVersion, bool useSsl, bool delegating) {
+ var se = GetServiceEndpoint(0, providerVersion, 10, useSsl, delegating);
+ this.RegisterMockXrdsResponse(se);
+ return se.ClaimedIdentifier;
+ }
+
+ protected Identifier GetMockDualIdentifier() {
+ Protocol protocol = Protocol.Default;
+ var opDesc = new ProviderEndpointDescription(OPUri, protocol.Version);
+ var dualResults = new IdentifierDiscoveryResult[] {
+ IdentifierDiscoveryResult.CreateForClaimedIdentifier(VanityUri.AbsoluteUri, OPLocalIdentifiers[0], opDesc, 10, 10),
+ IdentifierDiscoveryResult.CreateForProviderIdentifier(protocol.ClaimedIdentifierForOPIdentifier, opDesc, 20, 20),
+ };
+
+ this.RegisterMockXrdsResponse(VanityUri, dualResults);
+ return VanityUri;
+ }
+
+ /// <summary>
+ /// Creates a standard <see cref="OpenIdRelyingParty"/> instance for general testing.
+ /// </summary>
+ /// <returns>The new instance.</returns>
+ protected OpenIdRelyingParty CreateRelyingParty() {
+ return this.CreateRelyingParty(false);
+ }
+
+ /// <summary>
+ /// Creates a standard <see cref="OpenIdRelyingParty"/> instance for general testing.
+ /// </summary>
+ /// <param name="stateless">if set to <c>true</c> a stateless RP is created.</param>
+ /// <returns>The new instance.</returns>
+ protected OpenIdRelyingParty CreateRelyingParty(bool stateless) {
+ var rp = new OpenIdRelyingParty(stateless ? null : new StandardRelyingPartyApplicationStore(), this.HostFactories);
+ return rp;
+ }
+
+ /// <summary>
+ /// Creates a standard <see cref="OpenIdProvider"/> instance for general testing.
+ /// </summary>
+ /// <returns>The new instance.</returns>
+ protected OpenIdProvider CreateProvider() {
+ var op = new OpenIdProvider(new StandardProviderApplicationStore(), this.HostFactories);
+ return op;
+ }
+
}
}
diff --git a/src/DotNetOpenAuth.Test/Settings.StyleCop b/src/DotNetOpenAuth.Test/Settings.StyleCop
index 2e6f7e3..621fc43 100644
--- a/src/DotNetOpenAuth.Test/Settings.StyleCop
+++ b/src/DotNetOpenAuth.Test/Settings.StyleCop
@@ -1,4 +1,4 @@
-<StyleCopSettings Version="4.3">
+<StyleCopSettings Version="105">
<Analyzers>
<Analyzer AnalyzerId="StyleCop.CSharp.DocumentationRules">
<Rules>
@@ -12,6 +12,21 @@
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
+ <Rule Name="ElementReturnValueMustBeDocumented">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ <Rule Name="ElementParametersMustBeDocumented">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ <Rule Name="ElementParameterDocumentationMustMatchElementParameters">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
@@ -22,6 +37,11 @@
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
+ <Rule Name="OpeningCurlyBracketsMustNotBePrecededByBlankLine">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
diff --git a/src/DotNetOpenAuth.Test/TestBase.cs b/src/DotNetOpenAuth.Test/TestBase.cs
index 4758b7d..470fcf6 100644
--- a/src/DotNetOpenAuth.Test/TestBase.cs
+++ b/src/DotNetOpenAuth.Test/TestBase.cs
@@ -19,9 +19,8 @@ namespace DotNetOpenAuth.Test {
using DotNetOpenAuth.OpenId.RelyingParty;
using DotNetOpenAuth.Test.Performance;
using log4net;
- using NUnit.Framework;
-
using log4net.Config;
+ using NUnit.Framework;
/// <summary>
/// The base class that all test classes inherit from.
@@ -55,7 +54,7 @@ namespace DotNetOpenAuth.Test {
get { return this.messageDescriptions; }
}
- internal MockingHostFactories HostFactories;
+ internal MockingHostFactories HostFactories { get; set; }
/// <summary>
/// The TestInitialize method for the test cases.