Skip to content

Implement New Audience Validator Method in SAML2TokenHandler#2853

Closed
FuPingFranco wants to merge 1 commit intodevfrom
francofung/AddNewAudienceValidatorInSAML2TokenHandler
Closed

Implement New Audience Validator Method in SAML2TokenHandler#2853
FuPingFranco wants to merge 1 commit intodevfrom
francofung/AddNewAudienceValidatorInSAML2TokenHandler

Conversation

@FuPingFranco
Copy link
Contributor

Implement New Audience Validator Method in SAML2TokenHandler

Description

Adding new internal method to validate audience in SAML2TokenHandler

@FuPingFranco FuPingFranco requested a review from a team as a code owner September 27, 2024 20:40
First = true,
ExpectedException = ExpectedException.ArgumentNullException("IDX10000:"),
TestId = "TokenValidationParameters null",
TestId = "TokenValidationParameters_Null",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of setting TestId this way - could you do it like so new TokenTheoryData("TokenValidationParameters_Null")? TokenTheoryData already has a ctor that takes a TestId and doing so this way allows theoryData.CallContext.DebugId to be set.

#pragma warning disable 1591

// general
internal const string IDX10000 = "IDX10000: The parameter '{0}' cannot be a 'null' or an empty object. "; //Q: Should we just use one set of validation errors?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need new IDX???? codes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is just to use in the tests, we could simply import the LogMessages from the outer package, Tokens.

/// <summary>
/// A <see cref="SecurityTokenHandler"/> designed for creating and validating Saml2 Tokens. See: http://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf
/// </summary>
public partial class Saml2SecurityTokenHandler : SecurityTokenHandler
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be internal for now?

/// <remarks><see cref="Validators.ValidateAudience(IList{string}, SecurityToken, ValidationParameters, CallContext)"/> for additional details.</remarks>
internal static ValidationResult<string> ValidateAudience(IList<string> audiences, SecurityToken securityToken, ValidationParameters validationParameters, CallContext callContext)
{
return Validators.ValidateAudience(audiences, securityToken, validationParameters, callContext);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think that adding methods simply to call the delegates is a good idea. We can refactor the methods that call this to use the delegates directly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see this draft: #2855

{
get
{
return new TheoryData<AudienceValidationTheoryData>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FuPingFranco
Copy link
Contributor Author

Closing this PR in favor of a different agreed approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants