Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Commit 7d94334

Browse files
committed
fixes error and adds tests
1 parent 0d8bdce commit 7d94334

File tree

2 files changed

+76
-4
lines changed

2 files changed

+76
-4
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using Solid.Identity.Protocols.Saml2p;
2+
using Solid.Identity.Protocols.Saml2p.Models;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Text;
6+
using Xunit;
7+
8+
namespace Solid.Identity.Protocols.Sam2p.Tests
9+
{
10+
public class Saml2pStatusConversionTests
11+
{
12+
[Theory]
13+
[InlineData(SamlResponseStatus.Success, Saml2pConstants.Statuses.SuccessString)]
14+
[InlineData(SamlResponseStatus.Requester, Saml2pConstants.Statuses.RequesterString)]
15+
[InlineData(SamlResponseStatus.Responder, Saml2pConstants.Statuses.ResponderString)]
16+
[InlineData(SamlResponseStatus.VersionMismatch, Saml2pConstants.Statuses.VersionMismatchString)]
17+
[InlineData(SamlResponseStatus.AuthnFailed, Saml2pConstants.Statuses.AuthnFailedString)]
18+
[InlineData(SamlResponseStatus.InvalidAttrNameOrValue, Saml2pConstants.Statuses.InvalidAttrNameOrValueString)]
19+
[InlineData(SamlResponseStatus.InvalidNameIDPolicy, Saml2pConstants.Statuses.InvalidNameIDPolicyString)]
20+
[InlineData(SamlResponseStatus.NoAuthnContext, Saml2pConstants.Statuses.NoAuthnContextString)]
21+
[InlineData(SamlResponseStatus.NoAvailableIDP, Saml2pConstants.Statuses.NoAvailableIDPString)]
22+
[InlineData(SamlResponseStatus.NoPassive, Saml2pConstants.Statuses.NoPassiveString)]
23+
[InlineData(SamlResponseStatus.NoSupportedIDP, Saml2pConstants.Statuses.NoSupportedIDPString)]
24+
[InlineData(SamlResponseStatus.PartialLogout, Saml2pConstants.Statuses.PartialLogoutString)]
25+
[InlineData(SamlResponseStatus.ProxyCountExceeded, Saml2pConstants.Statuses.ProxyCountExceededString)]
26+
[InlineData(SamlResponseStatus.RequestDenied, Saml2pConstants.Statuses.RequestDeniedString)]
27+
[InlineData(SamlResponseStatus.RequestUnsupported, Saml2pConstants.Statuses.RequestUnsupportedString)]
28+
[InlineData(SamlResponseStatus.RequestVersionDeprecated, Saml2pConstants.Statuses.RequestVersionDeprecatedString)]
29+
[InlineData(SamlResponseStatus.RequestVersionTooHigh, Saml2pConstants.Statuses.RequestVersionTooHighString)]
30+
[InlineData(SamlResponseStatus.RequestVersionTooLow, Saml2pConstants.Statuses.RequestVersionTooLowString)]
31+
[InlineData(SamlResponseStatus.ResourceNotRecognized, Saml2pConstants.Statuses.ResourceNotRecognizedString)]
32+
[InlineData(SamlResponseStatus.TooManyResponses, Saml2pConstants.Statuses.TooManyResponsesString)]
33+
[InlineData(SamlResponseStatus.UnknownAttrProfile, Saml2pConstants.Statuses.UnknownAttrProfileString)]
34+
[InlineData(SamlResponseStatus.UnknownPrincipal, Saml2pConstants.Statuses.UnknownPrincipalString)]
35+
[InlineData(SamlResponseStatus.UnsupportedBinding, Saml2pConstants.Statuses.UnsupportedBindingString)]
36+
public void ShouldConvertToString(SamlResponseStatus status, string expected)
37+
{
38+
var str = status.ToStatusString();
39+
Assert.Equal(expected, str);
40+
}
41+
42+
[Theory]
43+
[InlineData(SamlResponseStatus.Success, Saml2pConstants.Statuses.SuccessString)]
44+
[InlineData(SamlResponseStatus.Requester, Saml2pConstants.Statuses.RequesterString)]
45+
[InlineData(SamlResponseStatus.Responder, Saml2pConstants.Statuses.ResponderString)]
46+
[InlineData(SamlResponseStatus.VersionMismatch, Saml2pConstants.Statuses.VersionMismatchString)]
47+
[InlineData(SamlResponseStatus.AuthnFailed, Saml2pConstants.Statuses.AuthnFailedString)]
48+
[InlineData(SamlResponseStatus.InvalidAttrNameOrValue, Saml2pConstants.Statuses.InvalidAttrNameOrValueString)]
49+
[InlineData(SamlResponseStatus.InvalidNameIDPolicy, Saml2pConstants.Statuses.InvalidNameIDPolicyString)]
50+
[InlineData(SamlResponseStatus.NoAuthnContext, Saml2pConstants.Statuses.NoAuthnContextString)]
51+
[InlineData(SamlResponseStatus.NoAvailableIDP, Saml2pConstants.Statuses.NoAvailableIDPString)]
52+
[InlineData(SamlResponseStatus.NoPassive, Saml2pConstants.Statuses.NoPassiveString)]
53+
[InlineData(SamlResponseStatus.NoSupportedIDP, Saml2pConstants.Statuses.NoSupportedIDPString)]
54+
[InlineData(SamlResponseStatus.PartialLogout, Saml2pConstants.Statuses.PartialLogoutString)]
55+
[InlineData(SamlResponseStatus.ProxyCountExceeded, Saml2pConstants.Statuses.ProxyCountExceededString)]
56+
[InlineData(SamlResponseStatus.RequestDenied, Saml2pConstants.Statuses.RequestDeniedString)]
57+
[InlineData(SamlResponseStatus.RequestUnsupported, Saml2pConstants.Statuses.RequestUnsupportedString)]
58+
[InlineData(SamlResponseStatus.RequestVersionDeprecated, Saml2pConstants.Statuses.RequestVersionDeprecatedString)]
59+
[InlineData(SamlResponseStatus.RequestVersionTooHigh, Saml2pConstants.Statuses.RequestVersionTooHighString)]
60+
[InlineData(SamlResponseStatus.RequestVersionTooLow, Saml2pConstants.Statuses.RequestVersionTooLowString)]
61+
[InlineData(SamlResponseStatus.ResourceNotRecognized, Saml2pConstants.Statuses.ResourceNotRecognizedString)]
62+
[InlineData(SamlResponseStatus.TooManyResponses, Saml2pConstants.Statuses.TooManyResponsesString)]
63+
[InlineData(SamlResponseStatus.UnknownAttrProfile, Saml2pConstants.Statuses.UnknownAttrProfileString)]
64+
[InlineData(SamlResponseStatus.UnknownPrincipal, Saml2pConstants.Statuses.UnknownPrincipalString)]
65+
[InlineData(SamlResponseStatus.UnsupportedBinding, Saml2pConstants.Statuses.UnsupportedBindingString)]
66+
public void ShouldConvertToUri(SamlResponseStatus status, string expected)
67+
{
68+
var uri = status.ToStatusUri();
69+
Assert.Equal(new Uri(expected), uri);
70+
}
71+
}
72+
}

src/Solid.Identity.Protocols.Saml2p/Saml2pConstants.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ public static class Statuses
4949
public const string UnsupportedBindingString = Namespaces.StatusNamespace + ":UnsupportedBinding";
5050

5151
public static readonly Uri Success = new Uri(SuccessString);
52-
public static readonly Uri Requester = new Uri(SuccessString);
53-
public static readonly Uri Responder = new Uri(SuccessString);
54-
public static readonly Uri VersionMismatch = new Uri(SuccessString);
55-
public static readonly Uri AuthnFailed = new Uri(SuccessString);
52+
public static readonly Uri Requester = new Uri(RequesterString);
53+
public static readonly Uri Responder = new Uri(ResponderString);
54+
public static readonly Uri VersionMismatch = new Uri(VersionMismatchString);
55+
public static readonly Uri AuthnFailed = new Uri(AuthnFailedString);
5656
public static readonly Uri InvalidAttrNameOrValue = new Uri(InvalidAttrNameOrValueString);
5757
public static readonly Uri InvalidNameIDPolicy = new Uri(InvalidNameIDPolicyString);
5858
public static readonly Uri NoAuthnContext = new Uri(NoAuthnContextString);

0 commit comments

Comments
 (0)