-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ODS-6276] 64 bit Education Organization ID Authorization Error Respo…
…nse Bug (#999)
- Loading branch information
1 parent
6dce58d
commit 0f10b6b
Showing
2 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
...tion/EdFi.Ods.Tests/EdFi.Ods.Security/Authorization/Repositories/EntityAuthorizerTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Licensed to the Ed-Fi Alliance under one or more agreements. | ||
// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. | ||
// See the LICENSE and NOTICES files in the project root for more information. | ||
|
||
using EdFi.Common.Extensions; | ||
using EdFi.Ods.Api.Security.Authorization; | ||
using EdFi.Ods.Api.Security.Authorization.Filtering; | ||
using EdFi.Ods.Api.Security.Authorization.Repositories; | ||
using EdFi.Ods.Common.Exceptions; | ||
using EdFi.Ods.Common.Infrastructure.Filtering; | ||
using EdFi.Ods.Common.Models.Domain; | ||
using EdFi.Ods.Common.Security.Authorization; | ||
using EdFi.Ods.Common.Security.Claims; | ||
using EdFi.TestFixture; | ||
using FakeItEasy; | ||
using NUnit.Framework; | ||
using Shouldly; | ||
using System.Threading; | ||
using Test.Common; | ||
|
||
namespace EdFi.Ods.Tests.EdFi.Ods.Api.Security.Authorization.Repositories | ||
{ | ||
[TestFixture] | ||
public class EntityAuthorizerTests | ||
{ | ||
public class When_authorizing_an_unauthorized_caller: ScenarioFor<EntityAuthorizer> | ||
{ | ||
private const long ExpectedClaimEndpointValue = long.MaxValue; | ||
|
||
/// <summary> | ||
/// Prepares the state of the scenario (creating stubs, test data, etc.). | ||
/// </summary> | ||
protected override void Arrange() | ||
{ | ||
A.CallTo( | ||
() => | ||
Given<IAuthorizationFilteringProvider>().GetAuthorizationFiltering( | ||
A<EdFiAuthorizationContext>._, A<AuthorizationBasisMetadata>._)) | ||
.Returns( | ||
new[] | ||
{ | ||
new AuthorizationStrategyFiltering | ||
{ | ||
Operator = FilterOperator.And, | ||
Filters = new[] | ||
{ | ||
new AuthorizationFilterContext | ||
{ | ||
ClaimEndpointValues = new object[] {ExpectedClaimEndpointValue} | ||
} | ||
} | ||
} | ||
}); | ||
|
||
A.CallTo( | ||
() => | ||
Given<IAuthorizationFilterDefinitionProvider>().GetFilterDefinition(A<string>._)) | ||
.Returns( | ||
new AuthorizationFilterDefinition( | ||
"FilterName", | ||
"FriendlyHqlConditionFormat", | ||
(_, _, _, _, _) => { }, | ||
(_, _, _, _, _, _) => { }, | ||
(_, _) => InstanceAuthorizationResult.NotPerformed())); | ||
} | ||
|
||
/// <summary> | ||
/// Executes the code to be exercised for the scenario. | ||
/// </summary> | ||
protected override void Act() | ||
{ | ||
SystemUnderTest.AuthorizeEntityAsync(A.Fake<AggregateRootWithCompositeKey>(), "Action", CancellationToken.None) | ||
.WaitSafely(); | ||
} | ||
|
||
[Assert] | ||
public void Should_throw_a_SecurityAuthorizationException() | ||
{ | ||
ActualException.ShouldBeOfType<SecurityAuthorizationException>(); | ||
} | ||
|
||
[Assert] | ||
public void Should_throw_a_SecurityAuthorizationException_indicating_the_caller_claim_endpoint_value() | ||
{ | ||
ActualException.ToString().ShouldContain(ExpectedClaimEndpointValue.ToString()); | ||
} | ||
} | ||
} | ||
} |