Skip to content

Commit

Permalink
Improved code coverage for tests.
Browse files Browse the repository at this point in the history
- Added separate test method for PendingAuthnRequest.TryRemove with null. Obviously no longer covered by other tests.
- Adjusted Saml2Response_GetRequestState_ThrowsOnResponseNotValid to not use GetClaims as it has other caching that shadows.
- Added separate test for inner exception ctor for Saml2ResponseFailedValidationException.
  • Loading branch information
AndersAbel committed Jan 16, 2015
1 parent a2d1567 commit 002dc54
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
10 changes: 10 additions & 0 deletions Kentor.AuthServices.Tests/Internal/PendingAuthnRequestsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,15 @@ public void PendingAuthnRequests_Remove_FalseOnRemovedTwice()
PendingAuthnRequests.TryRemove(id, out responseData).Should().BeTrue();
PendingAuthnRequests.TryRemove(id, out responseData).Should().BeFalse();
}

[TestMethod]
public void PendingAuthnRequest_TryRemove_NullGivesNull()
{
Saml2Id id = null;
StoredRequestState state;

PendingAuthnRequests.TryRemove(id, out state).Should().BeFalse();
state.Should().BeNull();
}
}
}
4 changes: 2 additions & 2 deletions Kentor.AuthServices.Tests/Saml2P/Saml2ResponseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ public void Saml2Response_GetClaims_SavesBootstrapContext()
}

[TestMethod]
public void Saml2Response_GetClaims_ThrowsOnResponseNotValid()
public void Saml2Response_GetRequestState_ThrowsOnResponseNotValid()
{
var response =
@"<?xml version=""1.0"" encoding=""UTF-8""?>
Expand All @@ -672,7 +672,7 @@ public void Saml2Response_GetClaims_ThrowsOnResponseNotValid()

var r = Saml2Response.Read(response);

Action a = () => r.GetClaims(Options.FromConfiguration);
Action a = () => r.GetRequestState(Options.FromConfiguration);

a.ShouldThrow<Saml2ResponseFailedValidationException>()
.WithMessage("Signature validation failed on SAML response or contained assertion.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,17 @@ public void Saml2ResponseFailedValidationExecption_StringCtor()

subject.Message.Should().Be(msg);
}

[TestMethod]
public void Saml2ResponseFailedValidationException_InnerExceptionCtor()
{
var msg = "Message!";
var innerException = new InvalidOperationException("InnerMessage!");

var subject = new Saml2ResponseFailedValidationException(msg, innerException);

subject.Message.Should().Be("Message!");
subject.InnerException.Message.Should().Be("InnerMessage!");
}
}
}

0 comments on commit 002dc54

Please sign in to comment.