code cleanup
This commit is contained in:
parent
8fdd56d33a
commit
847557318f
4 changed files with 17 additions and 14 deletions
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
|
|
@ -24,5 +24,7 @@
|
|||
],
|
||||
"cSpell.reportUnknownWords": true,
|
||||
"cSpell.language": "fr,en",
|
||||
"makefile.configureOnOpen": false
|
||||
"makefile.configureOnOpen": false,
|
||||
"search.useGlobalIgnoreFiles": true,
|
||||
"search.useParentIgnoreFiles": true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace Yavsc
|
|||
{
|
||||
foreach (var reserved in ReservedIdentityScopeNames)
|
||||
{
|
||||
Assert.DoesNotContain(reserved, Constants.BuildInApiScopes);
|
||||
Assert.DoesNotContain(reserved, Org.Constants.BuildInApiScopes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ namespace Yavsc
|
|||
{
|
||||
foreach (var reserved in ReservedIdentityScopeNames)
|
||||
{
|
||||
foreach (var spec in Constants.ApiResourcesScopes)
|
||||
foreach (var spec in Org.Constants.ApiResourcesScopes)
|
||||
{
|
||||
Assert.NotEqual(reserved, spec.ScopeName);
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ namespace Yavsc
|
|||
// Same ScopeName appearing twice would mean two ApiScopes
|
||||
// (and two ApiResourceScopes rows) trying to claim the same
|
||||
// name — IdentityServer8 would reject that on startup.
|
||||
var scopeNames = Constants.ApiResourcesScopes
|
||||
var scopeNames = Org.Constants.ApiResourcesScopes
|
||||
.Select(s => s.ScopeName)
|
||||
.ToList();
|
||||
Assert.Equal(scopeNames.Count, scopeNames.Distinct().Count());
|
||||
|
|
@ -67,7 +67,7 @@ namespace Yavsc
|
|||
// Same ResourceName appearing twice would mean two
|
||||
// ApiResources rows with the same Name — the EF seed would
|
||||
// crash on the unique index.
|
||||
var resourceNames = Constants.ApiResourcesScopes
|
||||
var resourceNames = Org.Constants.ApiResourcesScopes
|
||||
.Select(s => s.ResourceName)
|
||||
.ToList();
|
||||
Assert.Equal(resourceNames.Count, resourceNames.Distinct().Count());
|
||||
|
|
@ -79,7 +79,7 @@ namespace Yavsc
|
|||
// An empty ScopeName or ResourceName silently produces an
|
||||
// ApiScope / ApiResource row with no key, which breaks the
|
||||
// scope validator's string-based lookup later on.
|
||||
foreach (var spec in Constants.ApiResourcesScopes)
|
||||
foreach (var spec in Org.Constants.ApiResourcesScopes)
|
||||
{
|
||||
Assert.False(string.IsNullOrWhiteSpace(spec.ScopeName),
|
||||
$"ScopeName must be set (got '{spec.ScopeName}')");
|
||||
|
|
@ -95,7 +95,7 @@ namespace Yavsc
|
|||
{
|
||||
// Belt and braces: if someone ever wipes the list thinking
|
||||
// it's stale, this test forces them to be explicit about it.
|
||||
Assert.NotEmpty(Constants.ApiResourcesScopes);
|
||||
Assert.NotEmpty(Org.Constants.ApiResourcesScopes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
|
||||
namespace Yavsc.Org;
|
||||
|
||||
using IdentityServer8.EntityFramework.Entities;
|
||||
|
||||
|
|
|
|||
|
|
@ -534,7 +534,7 @@ public static class HostingExtensions
|
|||
{
|
||||
return (context, _) =>
|
||||
{
|
||||
foreach (String scope in Constants.BuildInApiScopes)
|
||||
foreach (String scope in Org.Constants.BuildInApiScopes)
|
||||
{
|
||||
var existentScope = context.Set<IdentityServer8.EntityFramework.Entities.ApiScope>().FirstOrDefault(b => b.Name == scope);
|
||||
if (existentScope == null)
|
||||
|
|
@ -575,7 +575,7 @@ public static class HostingExtensions
|
|||
// access to a downstream resource). Clients like PostIt that
|
||||
// request one of these scopes were rejected with "invalid_scope"
|
||||
// at the token endpoint. Keep this in ApiScopes.
|
||||
foreach (var scopeSpec in Constants.ApiResourcesScopes)
|
||||
foreach (var scopeSpec in Org.Constants.ApiResourcesScopes)
|
||||
{
|
||||
if (!apiScopes.Any(s => s.Name == scopeSpec.ScopeName))
|
||||
{
|
||||
|
|
@ -613,7 +613,7 @@ public static class HostingExtensions
|
|||
var apiResourceScopes = context.Set<IdentityServer8.EntityFramework.Entities.ApiResourceScope>();
|
||||
|
||||
// Make sure every resource row referenced by the spec exists.
|
||||
foreach (var resourceGroup in Constants.ApiResourcesScopes
|
||||
foreach (var resourceGroup in Org.Constants.ApiResourcesScopes
|
||||
.GroupBy(s => s.ResourceName))
|
||||
{
|
||||
var spec = resourceGroup.First();
|
||||
|
|
@ -646,7 +646,7 @@ public static class HostingExtensions
|
|||
// local list before letting EF try to translate the Where into
|
||||
// SQL — otherwise EF throws "The LINQ expression … could not be
|
||||
// translated" at runtime.
|
||||
var wantedResourceNames = Constants.ApiResourcesScopes
|
||||
var wantedResourceNames = Org.Constants.ApiResourcesScopes
|
||||
.Select(s => s.ResourceName)
|
||||
.ToHashSet();
|
||||
|
||||
|
|
@ -654,7 +654,7 @@ public static class HostingExtensions
|
|||
.Where(r => wantedResourceNames.Contains(r.Name))
|
||||
.ToDictionary(r => r.Name);
|
||||
|
||||
foreach (var scopeSpec in Constants.ApiResourcesScopes)
|
||||
foreach (var scopeSpec in Org.Constants.ApiResourcesScopes)
|
||||
{
|
||||
if (!resourceByName.TryGetValue(scopeSpec.ResourceName, out var resource))
|
||||
continue;
|
||||
|
|
@ -665,7 +665,7 @@ public static class HostingExtensions
|
|||
if (alreadyLinked)
|
||||
continue;
|
||||
|
||||
apiResourceScopes.Add(new IdentityServer8.EntityFramework.Entities.ApiResourceScope
|
||||
apiResourceScopes.Add(new ApiResourceScope
|
||||
{
|
||||
ApiResource = resource,
|
||||
ApiResourceId = resource.Id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue