Skip to content

Commit

Permalink
Remove GetRecursivelyReferencedUsedFragments
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane32 committed Aug 13, 2024
1 parent bf0cd69 commit 47ff469
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 105 deletions.
3 changes: 3 additions & 0 deletions docs/migration/migration8.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
in the response prefer the same status code. For practical purposes, this means that the included
errors triggered by the authorization validation rule will now return 401 or 403 when appropriate.
- The `SelectResponseContentType` method now returns a `MediaTypeHeaderValue` instead of a string.
- The `AuthorizationVisitorBase.GetRecursivelyReferencedUsedFragments` method has been removed as
`ValidationContext` now provides a overload to `GetRecursivelyReferencedFragments` which will only
return fragments in use by the specified operation.

## Other changes

Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion src/Transports.AspNetCore/AuthorizationVisitorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public AuthorizationVisitorBase(ValidationContext context)
{
if (context == null)
throw new ArgumentNullException(nameof(context));
_fragmentDefinitionsToCheck = GetRecursivelyReferencedUsedFragments(context);
_fragmentDefinitionsToCheck = context.GetRecursivelyReferencedFragments(context.Operation, true);
}

private bool _checkTree; // used to skip processing fragments or operations that do not apply
Expand Down
5 changes: 3 additions & 2 deletions tests/Transports.AspNetCore.Tests/AuthorizationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,9 @@ private void Apply(IMetadataWriter obj, Mode mode)
public void Constructors()
{
Should.Throw<ArgumentNullException>(() => new AuthorizationVisitor(null!, _principal, Mock.Of<IAuthorizationService>()));
Should.Throw<ArgumentNullException>(() => new AuthorizationVisitor(new ValidationContext(), null!, Mock.Of<IAuthorizationService>()));
Should.Throw<ArgumentNullException>(() => new AuthorizationVisitor(new ValidationContext(), _principal, null!));
var context = new ValidationContext() { Operation = new(new([])), Document = new([]) };
Should.Throw<ArgumentNullException>(() => new AuthorizationVisitor(context, null!, Mock.Of<IAuthorizationService>()));
Should.Throw<ArgumentNullException>(() => new AuthorizationVisitor(context, _principal, null!));
}

[Theory]
Expand Down

0 comments on commit 47ff469

Please sign in to comment.