From ff15d71efc840d088f4aef2fa66b2aec4f9e459e Mon Sep 17 00:00:00 2001 From: github-actions Date: Tue, 30 Mar 2021 15:44:25 +0200 Subject: [PATCH] fix: request on datetime closes #399 --- .../IdentityServerStores/CorsPolicyService.cs | 2 +- .../Extensions/GetRequestExtensions.cs | 9 +++++++++ .../AdminStores/AdminStoreTest.cs | 13 +++++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/IdentityServer/Aguacongas.IdentityServer.EntityFramework.Store/IdentityServerStores/CorsPolicyService.cs b/src/IdentityServer/Aguacongas.IdentityServer.EntityFramework.Store/IdentityServerStores/CorsPolicyService.cs index 76bee935e..35330bac0 100644 --- a/src/IdentityServer/Aguacongas.IdentityServer.EntityFramework.Store/IdentityServerStores/CorsPolicyService.cs +++ b/src/IdentityServer/Aguacongas.IdentityServer.EntityFramework.Store/IdentityServerStores/CorsPolicyService.cs @@ -10,7 +10,7 @@ namespace Aguacongas.IdentityServer.EntityFramework.Store /// /// implementation /// - /// + /// public class CorsPolicyService : ICorsPolicyService { private readonly ConfigurationDbContext _context; diff --git a/src/IdentityServer/Aguacongas.IdentityServer.RavenDb.Store/Extensions/GetRequestExtensions.cs b/src/IdentityServer/Aguacongas.IdentityServer.RavenDb.Store/Extensions/GetRequestExtensions.cs index b6677cc38..37167bfc2 100644 --- a/src/IdentityServer/Aguacongas.IdentityServer.RavenDb.Store/Extensions/GetRequestExtensions.cs +++ b/src/IdentityServer/Aguacongas.IdentityServer.RavenDb.Store/Extensions/GetRequestExtensions.cs @@ -201,6 +201,14 @@ public override TSource Visit(SingleValuePropertyAccessNode nodeIn) public override TSource Visit(ConstantNode nodeIn) { + if (nodeIn.Value is DateTime || nodeIn.Value is DateTimeOffset) + { + Builder.Append('\''); + Builder.Append(nodeIn.LiteralText); + Builder.Append('\''); + return null; + } + Builder.Append(nodeIn.LiteralText); return null; } @@ -261,6 +269,7 @@ public override TSource Visit(ConstantNode nodeIn) Parameters.Add($"'*{nodeIn.Value}*'"); return null; } + Parameters.Add(nodeIn.LiteralText); return null; } diff --git a/test/Aguacongas.IdentityServer.RavenDb.Store.Test/AdminStores/AdminStoreTest.cs b/test/Aguacongas.IdentityServer.RavenDb.Store.Test/AdminStores/AdminStoreTest.cs index 18ff42a16..4b5c6908a 100644 --- a/test/Aguacongas.IdentityServer.RavenDb.Store.Test/AdminStores/AdminStoreTest.cs +++ b/test/Aguacongas.IdentityServer.RavenDb.Store.Test/AdminStores/AdminStoreTest.cs @@ -48,7 +48,7 @@ await s1.StoreAsync(new ProtectResource var page = await sut.GetAsync(new PageRequest { - Filter = "Id eq 'test'", + Filter = $"{nameof(ProtectResource.Id)} eq 'test'", Skip = 0, Take = 10 }); @@ -57,7 +57,16 @@ await s1.StoreAsync(new ProtectResource page = await sut.GetAsync(new PageRequest { - Filter = "DisplayName eq 'no-test'", + Filter = $"{nameof(ProtectResource.DisplayName)} eq 'no-test'", + Skip = 0, + Take = 10 + }); + + Assert.Empty(page.Items); + + page = await sut.GetAsync(new PageRequest + { + Filter = $"{nameof(ProtectResource.CreatedAt)} eq {DateTime.UtcNow.ToString("o")}", Skip = 0, Take = 10 });