-
Notifications
You must be signed in to change notification settings - Fork 15
Add GetEventLogAsync #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9c0e479
Added event log endpoint and starter test.
jrmccannon a6f95c3
correcting app name
jrmccannon 222d323
Merge branch 'main' into adding-events-endpoint
jrmccannon e0e1a24
Fixed test to validate endpoint serializes to model correctly.
jrmccannon 8db8939
Removed extra line.
jrmccannon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 System.ComponentModel.DataAnnotations; | ||
|
||
namespace Passwordless.Models; | ||
|
||
/// <summary> | ||
/// Request for getting the event logs for an application. | ||
/// </summary> | ||
public class GetEventLogRequest | ||
{ | ||
/// <summary> | ||
/// Page number for retrieving event log records. | ||
/// </summary> | ||
public int PageNumber { get; set; } | ||
|
||
/// <summary> | ||
/// This is the max number of results that will be returned. Must be between 1-1000. | ||
/// </summary> | ||
[Range(1, 1000)] | ||
public int? NumberOfResults { get; set; } | ||
} |
This file contains hidden or 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,60 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Passwordless.Models; | ||
|
||
/// <summary> | ||
/// Response from GetEventLog. Contains list of events for the application. | ||
/// </summary> | ||
public class GetEventLogResponse | ||
{ | ||
/// <summary> | ||
/// Name of application the events correspond to. | ||
/// </summary> | ||
public string TenantId { get; set; } = string.Empty; | ||
/// <summary> | ||
/// List of events for the application based on the request pagination parameters. This will always be sorted by PerformedAt in descending order. | ||
/// </summary> | ||
public IEnumerable<ApplicationEvent> Events { get; set; } = new List<ApplicationEvent>(); | ||
/// <summary> | ||
/// Total number of events for the application. | ||
/// </summary> | ||
public int TotalEventCount { get; set; } | ||
} | ||
|
||
/// <summary> | ||
/// An event that occured using Passwordless library. | ||
/// </summary> | ||
public class ApplicationEvent | ||
jrmccannon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
public Guid Id { get; set; } | ||
/// <summary> | ||
/// When the record was performed. This will be in UTC. | ||
/// </summary> | ||
public DateTime PerformedAt { get; set; } | ||
|
||
/// <summary> | ||
/// The type of event <see href="https://github.com/passwordless/passwordless-server/blob/main/src/Common/EventLog/Enums/EventType.cs" /> | ||
/// </summary> | ||
public string EventType { get; set; } = string.Empty; | ||
|
||
/// <summary> | ||
/// Description of the event | ||
/// </summary> | ||
public string Message { get; set; } = string.Empty; | ||
|
||
/// <summary> | ||
/// Severity of the event <see href="https://github.com/passwordless/passwordless-server/blob/main/src/Common/EventLog/Enums/Severity.cs"/> | ||
/// </summary> | ||
public string Severity { get; set; } = string.Empty; | ||
|
||
/// <summary> | ||
/// The target of the event. Can be in reference to a user or the application. | ||
/// </summary> | ||
public string Subject { get; set; } = string.Empty; | ||
|
||
/// <summary> | ||
/// Last 4 characters of the api key (public/secret) used to perform the event. | ||
/// </summary> | ||
public string ApiKeyId { get; set; } = string.Empty; | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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,27 @@ | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using Passwordless.Models; | ||
using Passwordless.Tests.Infra; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Passwordless.Tests; | ||
|
||
public class ApplicationEventLogsTests(TestApiFixture api, ITestOutputHelper testOutput) : ApiTestBase(api, testOutput) | ||
{ | ||
[Fact] | ||
public async Task I_can_view_application_event_logs_when_event_logs_are_enabled() | ||
{ | ||
// Arrange | ||
var applicationName = TestApi.GetAppName(); | ||
var passwordless = await Api.CreateClientAsync(applicationName); | ||
await Api.EnableEventLogsAsync(applicationName); | ||
|
||
// Act | ||
var response = await passwordless.GetEventLogAsync(new GetEventLogRequest { PageNumber = 1, NumberOfResults = 100 }); | ||
|
||
// Assert | ||
response.Should().NotBeNull(); | ||
response.TenantId.Should().Be(applicationName); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.