-
Notifications
You must be signed in to change notification settings - Fork 20
[ADMINAPI-743] Claimset endpoint inconsistencies, fix to enable ODS/API v6 updates #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
80 changes: 80 additions & 0 deletions
80
...ation/EdFi.Ods.AdminApi.DBTests/ClaimSetEditorTests/GetAllClaimSetsQueryV6ServiceTests.cs
This file contains hidden or 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,80 @@ | ||
| // 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 System; | ||
| using System.Linq; | ||
| using EdFi.Ods.AdminApi.Infrastructure.Services.ClaimSetEditor; | ||
| using EdFi.Security.DataAccess.Models; | ||
| using NUnit.Framework; | ||
| using Shouldly; | ||
| using ClaimSetModel = EdFi.Security.DataAccess.Models.ClaimSet; | ||
|
|
||
| namespace EdFi.Ods.AdminApi.DBTests.ClaimSetEditorTests; | ||
|
|
||
| [TestFixture] | ||
| public class GetAllClaimSetsQueryV6ServiceTests : SecurityDataTestBase | ||
| { | ||
| public GetAllClaimSetsQueryV6ServiceTests() | ||
| { | ||
| SeedSecurityContextOnFixtureSetup = true; | ||
| } | ||
|
|
||
| [Test] | ||
| public void Should_Retrieve_ClaimSetNames() | ||
| { | ||
| var application = new Application | ||
| { | ||
| ApplicationName = $"Test Application {DateTime.Now:O}" | ||
| }; | ||
| Save(application); | ||
|
|
||
| var claimSet1 = GetClaimSet(application); | ||
| var claimSet2 = GetClaimSet(application); | ||
| Save(claimSet1, claimSet2); | ||
|
|
||
| var claimSetNames = Transaction<string[]>(securityContext => | ||
| { | ||
| var query = new GetAllClaimSetsQueryV6Service(securityContext); | ||
| return query.Execute().Select(x => x.Name).ToArray(); | ||
| }); | ||
|
|
||
| claimSetNames.ShouldContain(claimSet1.ClaimSetName); | ||
| claimSetNames.ShouldContain(claimSet2.ClaimSetName); | ||
| } | ||
|
|
||
| [Test] | ||
| public void Should_Retrieve_EdfiPreset_ClaimSet() | ||
| { | ||
| var application = new Application | ||
| { | ||
| ApplicationName = $"Test Application {DateTime.Now:O}" | ||
| }; | ||
| Save(application); | ||
|
|
||
| var claimSet1 = GetClaimSet(application, true); | ||
| var claimSet2 = GetClaimSet(application); | ||
| Save(claimSet1, claimSet2); | ||
|
|
||
| var claimSets = Transaction(securityContext => | ||
| { | ||
| var query = new GetAllClaimSetsQueryV6Service(securityContext); | ||
| return query.Execute().ToArray(); | ||
| }); | ||
|
|
||
| var edfiPresetClaimSet = claimSets.Where( x=> x.Name.Equals(claimSet1.ClaimSetName) && x.IsEditable == false).ToList(); | ||
| edfiPresetClaimSet.Count().ShouldBe(1); | ||
| } | ||
|
|
||
| private static int _claimSetId = 0; | ||
| private static ClaimSetModel GetClaimSet(Application application, bool IsEdfiPreset = false) | ||
| { | ||
| return new ClaimSetModel | ||
| { | ||
| Application = application, | ||
| ClaimSetName = $"Test Claim Set {_claimSetId++} - {DateTime.Now:O}", | ||
| IsEdfiPreset= IsEdfiPreset | ||
| }; | ||
| } | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
41 changes: 41 additions & 0 deletions
41
Application/EdFi.Ods.AdminApi/Infrastructure/Services/ClaimSetEditor/GetAllClaimSetsQuery.cs
This file contains hidden or 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,41 @@ | ||
| // 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 ClaimSet = EdFi.Ods.AdminApi.Infrastructure.ClaimSetEditor.ClaimSet; | ||
|
|
||
| namespace EdFi.Ods.AdminApi.Infrastructure.Services.ClaimSetEditor; | ||
|
|
||
| public interface IGetAllClaimSetsQuery | ||
| { | ||
| IReadOnlyList<ClaimSet> Execute(); | ||
| } | ||
|
|
||
| public class GetAllClaimSetsQuery : IGetAllClaimSetsQuery | ||
| { | ||
| private readonly IOdsSecurityModelVersionResolver _resolver; | ||
| private readonly GetAllClaimSetsQueryV53Service _v53Service; | ||
| private readonly GetAllClaimSetsQueryV6Service _v6Service; | ||
|
|
||
| public GetAllClaimSetsQuery(IOdsSecurityModelVersionResolver resolver, | ||
| GetAllClaimSetsQueryV53Service v53Service, | ||
| GetAllClaimSetsQueryV6Service v6Service) | ||
| { | ||
| _resolver = resolver; | ||
| _v53Service = v53Service; | ||
| _v6Service = v6Service; | ||
| } | ||
|
|
||
| public IReadOnlyList<ClaimSet> Execute() | ||
| { | ||
| var securityModel = _resolver.DetermineSecurityModel(); | ||
|
|
||
| return securityModel switch | ||
| { | ||
| EdFiOdsSecurityModelCompatibility.ThreeThroughFive or EdFiOdsSecurityModelCompatibility.FiveThreeCqe => _v53Service.Execute(), | ||
| EdFiOdsSecurityModelCompatibility.Six => _v6Service.Execute(), | ||
| _ => throw new EdFiOdsSecurityModelCompatibilityException(securityModel), | ||
| }; | ||
| } | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.