Skip to content

Commit

Permalink
Add robust testing and prune functionality (#1)
Browse files Browse the repository at this point in the history
This adds testing for the applications, authorization, scope, and token stores. It also fixes methods that were discovered to be broken during testing, and adds prune functionality for authorizations and tokens.
  • Loading branch information
stevenkuhn authored Oct 24, 2022
1 parent 7197766 commit dccc3cf
Show file tree
Hide file tree
Showing 41 changed files with 3,509 additions and 264 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ jobs:
path: artifacts

- name: Create release
env:
GitHub_Access_Token: ${{ secrets.GITHUB_TOKEN }}
GitHub_Repository: ${{ github.repository }}
run: ./build.sh --target PublishToGitHub --skip PublishArtifacts



run: >
./build.sh
--target PublishToGitHub
--skip PublishArtifacts
--github-access-token ${{ secrets.GITHUB_TOKEN }}
--github-repository ${{ github.repository }}
12 changes: 7 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ jobs:
path: ./artifacts
token: ${{ secrets.GITHUB_TOKEN }}

- name: Push assets to NuGet
env:
NuGet_Source: ${{ secrets.NUGET_SOURCE }}
NuGet_ApiKey: ${{ secrets.NUGET_APIKEY }}
run: ./build.sh --target PublishToNuGetFeed --skip PublishArtifacts
- name: Push assets to NuGet
run: >
./build.sh
--target PublishToNuGetFeed
--skip PublishArtifacts
--nuget-api-key ${{ secrets.NUGET_APIKEY }}
--nuget-source ${{ secrets.NUGET_SOURCE }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,6 @@ MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/

# VerifyTests files
*.received.*
6 changes: 4 additions & 2 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
},
"GitHubAccessToken": {
"type": "string",
"description": "GitHub access token used for creating a new or updating an existing release"
"description": "GitHub access token used for creating a new or updating an existing release",
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
},
"GitHubRepository": {
"type": "string",
Expand Down Expand Up @@ -57,7 +58,8 @@
},
"NuGetApiKey": {
"type": "string",
"description": "NuGet API key used to pushing the NuGet package"
"description": "NuGet API key used to pushing the NuGet package",
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
},
"NuGetSource": {
"type": "string",
Expand Down
26 changes: 26 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/build/bin/Debug/net6.0/Build.dll",
"args": [],
"cwd": "${workspaceFolder}/build",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}
41 changes: 41 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/build/Build.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/build/Build.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/build/Build.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
2 changes: 2 additions & 0 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Build : NukeBuild
readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;

[Parameter("GitHub access token used for creating a new or updating an existing release.")]
[Secret]
readonly string GitHubAccessToken;

[Parameter("GitHub repository owner and name used for creating a new or updating an existing release. For example: 'stevenkuhn/openiddict-litedb'.")]
Expand All @@ -16,6 +17,7 @@ class Build : NukeBuild
readonly string NuGetSource = "https://api.nuget.org/v3/index.json";

[Parameter("NuGet API key used to pushing the NuGet package.")]
[Secret]
readonly string NuGetApiKey;

[Solution] readonly Solution Solution;
Expand Down
5 changes: 5 additions & 0 deletions build/Build.v3.ncrunchproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ProjectConfiguration>
<Settings>
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely>
</Settings>
</ProjectConfiguration>
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public class OpenIddictLiteDBApplication
/// Gets or sets the localized display names associated with the current application.
/// </summary>
[BsonField("display_names")]
public virtual IReadOnlyDictionary<string, string>? DisplayNames { get; set; }
= ImmutableDictionary.Create<string, string>();
public virtual ImmutableDictionary<CultureInfo, string>? DisplayNames { get; set; }
= ImmutableDictionary.Create<CultureInfo, string>();

/// <summary>
/// Gets or sets the unique identifier associated with the current application.
Expand All @@ -70,35 +70,34 @@ public class OpenIddictLiteDBApplication
/// Gets or sets the permissions associated with the current application.
/// </summary>
[BsonField("permissions")]
public virtual IReadOnlyList<string>? Permissions { get; set; } = ImmutableList.Create<string>();
public virtual ImmutableArray<string>? Permissions { get; set; } = ImmutableArray.Create<string>();

/// <summary>
/// Gets or sets the logout callback URLs associated with the current application.
/// </summary>
[BsonField("post_logout_redirect_uris")]
public virtual IReadOnlyList<string>? PostLogoutRedirectUris { get; set; } = ImmutableList.Create<string>();
public virtual ImmutableArray<string>? PostLogoutRedirectUris { get; set; } = ImmutableArray.Create<string>();

/// <summary>
/// Gets or sets the additional properties associated with the current application.
/// </summary>
[BsonField("properties")]
public virtual IReadOnlyDictionary<string, JsonElement>? Properties { get; set; }
public virtual ImmutableDictionary<string, JsonElement>? Properties { get; set; }

/// <summary>
/// Gets or sets the callback URLs associated with the current application.
/// </summary>
[BsonField("redirect_uris")]
public virtual IReadOnlyList<string>? RedirectUris { get; set; } = ImmutableList.Create<string>();
public virtual ImmutableArray<string>? RedirectUris { get; set; } = ImmutableArray.Create<string>();

/// <summary>
/// Gets or sets the requirements associated with the current application.
/// </summary>
[BsonField("requirements")]
public virtual IReadOnlyList<string>? Requirements { get; set; } = ImmutableList.Create<string>();
public virtual ImmutableArray<string>? Requirements { get; set; } = ImmutableArray.Create<string>();

/// <summary>
/// Gets or sets the application type
/// associated with the current application.
/// Gets or sets the application type associated with the current application.
/// </summary>
[BsonField("type")]
public virtual string? Type { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class OpenIddictLiteDBAuthorization
/// Gets or sets the UTC creation date of the current authorization.
/// </summary>
[BsonField("creation_date")]
public virtual DateTime? CreationDate { get; set; }
public virtual DateTimeOffset? CreationDate { get; set; }

/// <summary>
/// Gets or sets the unique identifier associated with the current authorization.
Expand All @@ -49,13 +49,13 @@ public class OpenIddictLiteDBAuthorization
/// Gets or sets the additional properties associated with the current authorization.
/// </summary>
[BsonField("properties")]
public virtual IReadOnlyDictionary<string, JsonElement>? Properties { get; set; }
public virtual ImmutableDictionary<string, JsonElement>? Properties { get; set; }

/// <summary>
/// Gets or sets the scopes associated with the current authorization.
/// </summary>
[BsonField("scopes")]
public virtual IReadOnlyList<string>? Scopes { get; set; } = ImmutableList.Create<string>();
public virtual ImmutableArray<string>? Scopes { get; set; } = ImmutableArray.Create<string>();

/// <summary>
/// Gets or sets the status of the current authorization.
Expand Down
12 changes: 6 additions & 6 deletions src/Sknet.OpenIddict.LiteDB.Models/OpenIddictLiteDBScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public class OpenIddictLiteDBScope
/// Gets or sets the localized public descriptions associated with the current scope.
/// </summary>
[BsonField("descriptions")]
public virtual IReadOnlyDictionary<string, string>? Descriptions { get; set; }
= ImmutableDictionary.Create<string, string>();
public virtual ImmutableDictionary<CultureInfo, string>? Descriptions { get; set; }
= ImmutableDictionary.Create<CultureInfo, string>();

/// <summary>
/// Gets or sets the display name associated with the current scope.
Expand All @@ -50,8 +50,8 @@ public class OpenIddictLiteDBScope
/// Gets or sets the localized display names associated with the current scope.
/// </summary>
[BsonField("display_names")]
public virtual IReadOnlyDictionary<string, string>? DisplayNames { get; set; }
= ImmutableDictionary.Create<string, string>();
public virtual ImmutableDictionary<CultureInfo, string>? DisplayNames { get; set; }
= ImmutableDictionary.Create<CultureInfo, string>();

/// <summary>
/// Gets or sets the unique identifier associated with the current scope.
Expand All @@ -69,11 +69,11 @@ public class OpenIddictLiteDBScope
/// Gets or sets the additional properties associated with the current scope.
/// </summary>
[BsonField("properties")]
public virtual IReadOnlyDictionary<string, JsonElement>? Properties { get; set; }
public virtual ImmutableDictionary<string, JsonElement>? Properties { get; set; }

/// <summary>
/// Gets or sets the resources associated with the current scope.
/// </summary>
[BsonField("resources")]
public virtual IReadOnlyList<string>? Resources { get; set; } = ImmutableList.Create<string>();
public virtual ImmutableArray<string>? Resources { get; set; } = ImmutableArray.Create<string>();
}
8 changes: 4 additions & 4 deletions src/Sknet.OpenIddict.LiteDB.Models/OpenIddictLiteDBToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public class OpenIddictLiteDBToken
/// Gets or sets the UTC creation date of the current token.
/// </summary>
[BsonField("creation_date")]
public virtual DateTime? CreationDate { get; set; }
public virtual DateTimeOffset? CreationDate { get; set; }

/// <summary>
/// Gets or sets the UTC expiration date of the current token.
/// </summary>
[BsonField("expiration_date")]
public virtual DateTime? ExpirationDate { get; set; }
public virtual DateTimeOffset? ExpirationDate { get; set; }

/// <summary>
/// Gets or sets the unique identifier associated with the current token.
Expand All @@ -69,13 +69,13 @@ public class OpenIddictLiteDBToken
/// Gets or sets the additional properties associated with the current token.
/// </summary>
[BsonField("properties")]
public virtual IReadOnlyDictionary<string, JsonElement>? Properties { get; set; }
public virtual ImmutableDictionary<string, JsonElement>? Properties { get; set; }

/// <summary>
/// Gets or sets the UTC redemption date of the current token.
/// </summary>
[BsonField("redemption_date")]
public virtual DateTime? RedemptionDate { get; set; }
public virtual DateTimeOffset? RedemptionDate { get; set; }

/// <summary>
/// Gets or sets the reference identifier associated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<ItemGroup>
<PackageReference Include="LiteDB" Version="5.0.12" />
<PackageReference Include="System.Collections.Immutable" Version="6.0.0" />
<PackageReference Include="System.Text.Json" Version="6.0.5" />
<PackageReference Include="System.Text.Json" Version="6.0.6" />
</ItemGroup>

</Project>
3 changes: 2 additions & 1 deletion src/Sknet.OpenIddict.LiteDB.Models/Usings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
global using LiteDB;
global using System.Collections.Immutable;
global using System.Diagnostics;
global using System.Text.Json;
global using System.Globalization;
global using System.Text.Json;
2 changes: 1 addition & 1 deletion src/Sknet.OpenIddict.LiteDB/IOpenIddictLiteDBContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public interface IOpenIddictLiteDBContext
/// Gets the <see cref="ILiteDatabase"/>.
/// </summary>
/// <returns>
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the
/// A <see cref="ValueTask{ILiteDatabase}"/> that can be used to monitor the
/// asynchronous operation, whose result returns the LiteDB database.
/// </returns>
ValueTask<ILiteDatabase> GetDatabaseAsync(CancellationToken cancellationToken);
Expand Down
1 change: 0 additions & 1 deletion src/Sknet.OpenIddict.LiteDB/OpenIddictLiteDBExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
namespace Microsoft.Extensions.DependencyInjection;


/// <summary>
/// Exposes extensions allowing to register the OpenIddict LiteDB services.
/// </summary>
Expand Down
16 changes: 8 additions & 8 deletions src/Sknet.OpenIddict.LiteDB/OpenIddictLiteDBOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ namespace Sknet.OpenIddict.LiteDB;
public class OpenIddictLiteDBOptions
{
/// <summary>
/// Gets or sets the name of the applications collection (by default, openiddict.applications).
/// Gets or sets the name of the applications collection (by default, openiddict_applications).
/// </summary>
public string ApplicationsCollectionName { get; set; } = "openiddict.applications";
public string ApplicationsCollectionName { get; set; } = "openiddict_applications";

/// <summary>
/// Gets or sets the name of the authorizations collection (by default, openiddict.authorizations).
/// Gets or sets the name of the authorizations collection (by default, openiddict_authorizations).
/// </summary>
public string AuthorizationsCollectionName { get; set; } = "openiddict.authorizations";
public string AuthorizationsCollectionName { get; set; } = "openiddict_authorizations";

/// <summary>
/// Gets or sets the <see cref="ILiteDatabase"/> used by the OpenIddict stores.
Expand All @@ -37,12 +37,12 @@ public class OpenIddictLiteDBOptions
public ILiteDatabase? Database { get; set; }

/// <summary>
/// Gets or sets the name of the scopes collection (by default, openiddict.scopes).
/// Gets or sets the name of the scopes collection (by default, openiddict_scopes).
/// </summary>
public string ScopesCollectionName { get; set; } = "openiddict.scopes";
public string ScopesCollectionName { get; set; } = "openiddict_scopes";

/// <summary>
/// Gets or sets the name of the tokens collection (by default, openiddict.tokens).
/// Gets or sets the name of the tokens collection (by default, openiddict_tokens).
/// </summary>
public string TokensCollectionName { get; set; } = "openiddict.tokens";
public string TokensCollectionName { get; set; } = "openiddict_tokens";
}
Loading

0 comments on commit dccc3cf

Please sign in to comment.