-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
143 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
24 changes: 24 additions & 0 deletions
24
tests/Logitar.Identity.Domain.UnitTests/ApiKeys/Events/ApiKeyUpdatedEventTests.cs
This file contains 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,24 @@ | ||
using Bogus; | ||
|
||
namespace Logitar.Identity.Domain.ApiKeys.Events; | ||
|
||
[Trait(Traits.Category, Categories.Unit)] | ||
public class ApiKeyUpdatedEventTests | ||
{ | ||
private readonly Faker _faker = new(); | ||
|
||
[Fact(DisplayName = "It should be serializable and deserializable.")] | ||
public void It_should_be_serializable_and_deserializable() | ||
{ | ||
ApiKeyUpdatedEvent @event = new(); | ||
@event.CustomAttributes.Add("Owner", _faker.Person.UserName); | ||
@event.CustomAttributes.Add("SubSystem", "Identity"); | ||
|
||
string json = JsonSerializer.Serialize(@event); | ||
Assert.DoesNotContain("haschanges", json.ToLower()); | ||
|
||
ApiKeyUpdatedEvent? deserialized = JsonSerializer.Deserialize<ApiKeyUpdatedEvent>(json); | ||
Assert.NotNull(deserialized); | ||
Assert.Equal(@event.CustomAttributes, deserialized.CustomAttributes); | ||
} | ||
} |
This file contains 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
20 changes: 20 additions & 0 deletions
20
tests/Logitar.Identity.Domain.UnitTests/Passwords/Events/OneTimePasswordUpdatedEventTests.cs
This file contains 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,20 @@ | ||
namespace Logitar.Identity.Domain.Passwords.Events; | ||
|
||
[Trait(Traits.Category, Categories.Unit)] | ||
public class OneTimePasswordUpdatedEventTests | ||
{ | ||
[Fact(DisplayName = "It should be serializable and deserializable.")] | ||
public void It_should_be_serializable_and_deserializable() | ||
{ | ||
OneTimePasswordUpdatedEvent @event = new(); | ||
@event.CustomAttributes.Add("Purpose", "reset_password"); | ||
@event.CustomAttributes.Add("UserId", Guid.NewGuid().ToString()); | ||
|
||
string json = JsonSerializer.Serialize(@event); | ||
Assert.DoesNotContain("haschanges", json.ToLower()); | ||
|
||
OneTimePasswordUpdatedEvent? deserialized = JsonSerializer.Deserialize<OneTimePasswordUpdatedEvent>(json); | ||
Assert.NotNull(deserialized); | ||
Assert.Equal(@event.CustomAttributes, deserialized.CustomAttributes); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
tests/Logitar.Identity.Domain.UnitTests/Roles/Events/RoleUpdatedEventTests.cs
This file contains 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,20 @@ | ||
namespace Logitar.Identity.Domain.Roles.Events; | ||
|
||
[Trait(Traits.Category, Categories.Unit)] | ||
public class RoleUpdatedEventTests | ||
{ | ||
[Fact(DisplayName = "It should be serializable and deserializable.")] | ||
public void It_should_be_serializable_and_deserializable() | ||
{ | ||
RoleUpdatedEvent @event = new(); | ||
@event.CustomAttributes.Add("manage_users", bool.FalseString); | ||
@event.CustomAttributes.Add("configuration", bool.TrueString); | ||
|
||
string json = JsonSerializer.Serialize(@event); | ||
Assert.DoesNotContain("haschanges", json.ToLower()); | ||
|
||
RoleUpdatedEvent? deserialized = JsonSerializer.Deserialize<RoleUpdatedEvent>(json); | ||
Assert.NotNull(deserialized); | ||
Assert.Equal(@event.CustomAttributes, deserialized.CustomAttributes); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
tests/Logitar.Identity.Domain.UnitTests/Sessions/Events/SessionUpdatedEventTests.cs
This file contains 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,24 @@ | ||
using Bogus; | ||
|
||
namespace Logitar.Identity.Domain.Sessions.Events; | ||
|
||
[Trait(Traits.Category, Categories.Unit)] | ||
public class SessionUpdatedEventTests | ||
{ | ||
private readonly Faker _faker = new(); | ||
|
||
[Fact(DisplayName = "It should be serializable and deserializable.")] | ||
public void It_should_be_serializable_and_deserializable() | ||
{ | ||
SessionUpdatedEvent @event = new(); | ||
@event.CustomAttributes.Add("AdditionalInformation", $@"{{""User-Agent"":""{_faker.Internet.UserAgent()}""}}"); | ||
@event.CustomAttributes.Add("IpAddress", _faker.Internet.Ip()); | ||
|
||
string json = JsonSerializer.Serialize(@event); | ||
Assert.DoesNotContain("haschanges", json.ToLower()); | ||
|
||
SessionUpdatedEvent? deserialized = JsonSerializer.Deserialize<SessionUpdatedEvent>(json); | ||
Assert.NotNull(deserialized); | ||
Assert.Equal(@event.CustomAttributes, deserialized.CustomAttributes); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
tests/Logitar.Identity.Domain.UnitTests/Users/Events/UserUpdatedEventTests.cs
This file contains 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,24 @@ | ||
using Bogus; | ||
|
||
namespace Logitar.Identity.Domain.Users.Events; | ||
|
||
[Trait(Traits.Category, Categories.Unit)] | ||
public class UserUpdatedEventTests | ||
{ | ||
private readonly Faker _faker = new(); | ||
|
||
[Fact(DisplayName = "It should be serializable and deserializable.")] | ||
public void It_should_be_serializable_and_deserializable() | ||
{ | ||
UserUpdatedEvent @event = new(); | ||
@event.CustomAttributes.Add("HealthInsuranceNumber", _faker.Person.BuildHealthInsuranceNumber()); | ||
@event.CustomAttributes.Add("JobTitle", "Sales Manager"); | ||
|
||
string json = JsonSerializer.Serialize(@event); | ||
Assert.DoesNotContain("haschanges", json.ToLower()); | ||
|
||
UserUpdatedEvent? deserialized = JsonSerializer.Deserialize<UserUpdatedEvent>(json); | ||
Assert.NotNull(deserialized); | ||
Assert.Equal(@event.CustomAttributes, deserialized.CustomAttributes); | ||
} | ||
} |
This file contains 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,20 @@ | ||
using Bogus; | ||
|
||
namespace Logitar.Identity; | ||
|
||
public static class PersonExtensions | ||
{ | ||
private static readonly Random _random = new(); | ||
|
||
public static string BuildHealthInsuranceNumber(this Person person) | ||
{ | ||
StringBuilder hin = new(); | ||
hin.Append(person.LastName[..3].ToUpper()); | ||
hin.Append(person.FirstName[..1].ToUpper()); | ||
hin.Append(person.DateOfBirth.Year % 100); | ||
hin.Append(person.DateOfBirth.Month.ToString("00")); | ||
hin.Append(person.DateOfBirth.Day.ToString("00")); | ||
hin.Append(_random.Next(0, 99).ToString("00")); | ||
return hin.ToString(); | ||
} | ||
} |