diff --git a/Kentor.AuthServices.Tests/App.config b/Kentor.AuthServices.Tests/App.config
index ecc90053b..25af60dfe 100644
--- a/Kentor.AuthServices.Tests/App.config
+++ b/Kentor.AuthServices.Tests/App.config
@@ -5,7 +5,9 @@
-
+
@@ -41,6 +43,18 @@
+
+
+
+
+
+
diff --git a/Kentor.AuthServices.Tests/IdentityProviderTests.cs b/Kentor.AuthServices.Tests/IdentityProviderTests.cs
index 3237adf3c..30ad8e958 100644
--- a/Kentor.AuthServices.Tests/IdentityProviderTests.cs
+++ b/Kentor.AuthServices.Tests/IdentityProviderTests.cs
@@ -87,6 +87,7 @@ public void IdentityProvider_CreateAuthenticateRequest_BasicInfo()
subject.ShouldBeEquivalentTo(expected, opt => opt
.Excluding(au => au.Id)
+ .Excluding(au=>au.SigningAlgorithm)
.Excluding(au => au.RelayState));
subject.RelayState.Should().HaveLength(56);
@@ -113,6 +114,7 @@ public void IdentityProvider_CreateAuthenticateRequest_PublicOrigin()
subject.ShouldBeEquivalentTo(expected, opt => opt
.Excluding(au => au.Id)
+ .Excluding(au => au.SigningAlgorithm)
.Excluding(au => au.RelayState));
}
@@ -137,6 +139,7 @@ public void IdentityProvider_CreateAuthenticateRequest_NoAttributeIndex()
subject.ShouldBeEquivalentTo(expected, opt => opt
.Excluding(au => au.Id)
+ .Excluding(au => au.SigningAlgorithm)
.Excluding(au => au.RelayState));
}
diff --git a/Kentor.AuthServices.Tests/Owin/KentorAuthServicesAuthenticationMiddlewareTests.cs b/Kentor.AuthServices.Tests/Owin/KentorAuthServicesAuthenticationMiddlewareTests.cs
index de04bd960..85162288f 100644
--- a/Kentor.AuthServices.Tests/Owin/KentorAuthServicesAuthenticationMiddlewareTests.cs
+++ b/Kentor.AuthServices.Tests/Owin/KentorAuthServicesAuthenticationMiddlewareTests.cs
@@ -204,6 +204,43 @@ public async Task KentorAuthServicesAuthenticationMiddleware_CreatesPostOnAuthCh
}
}
+
+ [TestMethod]
+ public async Task KentorAuthServicesAuthenticationMiddleware_CreatesSignedPostOnAuthChallenge()
+ {
+ var middleware = new KentorAuthServicesAuthenticationMiddleware(
+ new StubOwinMiddleware(401, new AuthenticationResponseChallenge(
+ new string[] { "KentorAuthServices" }, new AuthenticationProperties(
+ new Dictionary()
+ {
+ { "idp", "https://idp4.example.com" }
+ }))),
+ CreateAppBuilder(),
+ new KentorAuthServicesAuthenticationOptions(true)
+ );
+
+ var context = OwinTestHelpers.CreateOwinContext();
+
+ await middleware.Invoke(context);
+
+ context.Response.StatusCode.Should().Be(200);
+ context.Response.Body.Seek(0, SeekOrigin.Begin);
+
+ // Fix to #295, where content length is incorrectly set to 0 by the
+ // next middleware. It appears as it works if the content length is
+ // simply removed. See discussion in GitHub issue #295.
+ context.Response.ContentLength.Should().NotHaveValue();
+
+ using (var reader = new StreamReader(context.Response.Body))
+ {
+ string bodyContent = reader.ReadToEnd();
+
+ // Checking some random stuff in body to make sure it looks like a SAML Post.
+ bodyContent.Should().Contain("