Skip to content

Commit e63d438

Browse files
committed
Fixed ClaimHelper UTC conversion.
1 parent 0eb6207 commit e63d438

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12-
- Added volumes to Docker Compose.
12+
- Volumes to Docker Compose.
13+
14+
### Fixed
15+
16+
- ClaimHelper UTC conversion.
1317

1418
## [1.20.0] - 2024-11-19
1519

src/Logitar.Security/Claims/ClaimHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static class ClaimHelper
1313
/// <returns>The created claim.</returns>
1414
public static Claim Create(string name, DateTime moment)
1515
{
16-
string value = new DateTimeOffset(moment.ToUniversalTime()).ToUnixTimeSeconds().ToString();
16+
string value = new DateTimeOffset(moment.AsUniversalTime()).ToUnixTimeSeconds().ToString();
1717

1818
return new Claim(name, value, ClaimValueTypes.Integer64);
1919
}

src/Logitar.Security/Logitar.Security.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
3535
</PropertyGroup>
3636

37+
<ItemGroup>
38+
<ProjectReference Include="..\Logitar\Logitar.csproj" />
39+
</ItemGroup>
40+
3741
<ItemGroup>
3842
<None Update="LICENSE">
3943
<Pack>True</Pack>

tests/Logitar.Security.UnitTests/Claims/ClaimHelperTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public void It_should_create_the_correct_claim_from_a_date_and_time()
1515
Assert.Equal(value, local.Value);
1616
Assert.Equal(ClaimValueTypes.Integer64, local.ValueType);
1717

18-
Claim utc = ClaimHelper.Create(name, moment.ToUniversalTime());
18+
Claim utc = ClaimHelper.Create(name, moment.AsUniversalTime());
1919
Assert.Equal(local.Type, utc.Type);
2020
Assert.Equal(local.Value, utc.Value);
2121
Assert.Equal(local.ValueType, utc.ValueType);
@@ -30,7 +30,7 @@ public void It_should_create_the_correct_claim_from_an_unspecified_kind_date_and
3030
Claim claim = ClaimHelper.Create(Rfc7519ClaimNames.ExpirationTime, unspecified);
3131
DateTime value = ClaimHelper.ExtractDateTime(claim);
3232
Assert.Equal(DateTimeKind.Utc, value.Kind);
33-
Assert.Equal(ToUnixTimeSeconds(local), ToUnixTimeSeconds(value));
33+
Assert.Equal(ToUnixTimeSeconds(unspecified.AsUniversalTime()), ToUnixTimeSeconds(value));
3434
}
3535

3636
[Fact(DisplayName = "It should extract the correct date and time from a claim.")]

0 commit comments

Comments
 (0)