fix(user fields): missing creationDate in details (#9250)

# Which Problems Are Solved

The `creationDate` property on user search V2 endpoint was missing

# How the Problems Are Solved

Added property in v2 `object.proto` and in the function creating the
details on each call

# Additional Changes
- none
# Additional Context
closes #8552

---------

Co-authored-by: Stefan Benz <46600784+stebenz@users.noreply.github.com>
This commit is contained in:
KevinRSI
2025-02-26 14:00:04 +01:00
committed by GitHub
parent 8f88c4cf5b
commit 70bddceda8
17 changed files with 113 additions and 17 deletions

View File

@@ -150,6 +150,7 @@ func TestServer_GetUserByID(t *testing.T) {
},
Details: &object.Details{
ChangeDate: timestamppb.Now(),
CreationDate: timestamppb.Now(),
ResourceOwner: orgResp.OrganizationId,
},
},
@@ -195,6 +196,7 @@ func TestServer_GetUserByID(t *testing.T) {
},
Details: &object.Details{
ChangeDate: timestamppb.Now(),
CreationDate: timestamppb.Now(),
ResourceOwner: orgResp.OrganizationId,
},
},
@@ -282,6 +284,7 @@ func TestServer_GetUserByID_Permission(t *testing.T) {
},
Details: &object.Details{
ChangeDate: timestamppb.Now(),
CreationDate: timestamppb.Now(),
ResourceOwner: newOrg.GetOrganizationId(),
},
},
@@ -320,6 +323,7 @@ func TestServer_GetUserByID_Permission(t *testing.T) {
},
Details: &object.Details{
ChangeDate: timestamppb.Now(),
CreationDate: timestamppb.Now(),
ResourceOwner: newOrg.GetOrganizationId(),
},
},
@@ -415,6 +419,8 @@ func createUser(ctx context.Context, orgID string, passwordChangeRequired bool)
phone := "+41" + gofakeit.Phone()
resp := Instance.CreateHumanUserVerified(ctx, orgID, username, phone)
info := userAttr{resp.GetUserId(), username, phone, nil, resp.GetDetails()}
// as the change date of the creation is the creation date
resp.Details.CreationDate = resp.GetDetails().GetChangeDate()
if passwordChangeRequired {
details := Instance.SetUserPassword(ctx, resp.GetUserId(), integration.UserPassword, true)
info.Changed = details.GetChangeDate()

View File

@@ -74,6 +74,7 @@ func Test_passkeyRegistrationDetailsToPb(t *testing.T) {
ObjectDetails: &domain.ObjectDetails{
Sequence: 22,
EventDate: time.Unix(3000, 22),
CreationDate: time.Unix(3000, 22),
ResourceOwner: "me",
},
ID: "123",
@@ -90,6 +91,7 @@ func Test_passkeyRegistrationDetailsToPb(t *testing.T) {
ObjectDetails: &domain.ObjectDetails{
Sequence: 22,
EventDate: time.Unix(3000, 22),
CreationDate: time.Unix(3000, 22),
ResourceOwner: "me",
},
ID: "123",
@@ -104,6 +106,10 @@ func Test_passkeyRegistrationDetailsToPb(t *testing.T) {
Seconds: 3000,
Nanos: 22,
},
CreationDate: &timestamppb.Timestamp{
Seconds: 3000,
Nanos: 22,
},
ResourceOwner: "me",
},
PasskeyId: "123",
@@ -150,6 +156,7 @@ func Test_passkeyDetailsToPb(t *testing.T) {
details: &domain.ObjectDetails{
Sequence: 22,
EventDate: time.Unix(3000, 22),
CreationDate: time.Unix(3000, 22),
ResourceOwner: "me",
},
err: nil,
@@ -161,6 +168,10 @@ func Test_passkeyDetailsToPb(t *testing.T) {
Seconds: 3000,
Nanos: 22,
},
CreationDate: &timestamppb.Timestamp{
Seconds: 3000,
Nanos: 22,
},
ResourceOwner: "me",
},
},
@@ -199,6 +210,7 @@ func Test_passkeyCodeDetailsToPb(t *testing.T) {
ObjectDetails: &domain.ObjectDetails{
Sequence: 22,
EventDate: time.Unix(3000, 22),
CreationDate: time.Unix(3000, 22),
ResourceOwner: "me",
},
CodeID: "123",
@@ -213,6 +225,10 @@ func Test_passkeyCodeDetailsToPb(t *testing.T) {
Seconds: 3000,
Nanos: 22,
},
CreationDate: &timestamppb.Timestamp{
Seconds: 3000,
Nanos: 22,
},
ResourceOwner: "me",
},
Code: &user.PasskeyRegistrationCode{

View File

@@ -21,6 +21,7 @@ func (s *Server) GetUserByID(ctx context.Context, req *user.GetUserByIDRequest)
return &user.GetUserByIDResponse{
Details: object.DomainToDetailsPb(&domain.ObjectDetails{
Sequence: resp.Sequence,
CreationDate: resp.CreationDate,
EventDate: resp.ChangeDate,
ResourceOwner: resp.ResourceOwner,
}),
@@ -58,6 +59,7 @@ func userToPb(userQ *query.User, assetPrefix string) *user.User {
Sequence: userQ.Sequence,
EventDate: userQ.ChangeDate,
ResourceOwner: userQ.ResourceOwner,
CreationDate: userQ.CreationDate,
}),
State: userStateToPb(userQ.State),
Username: userQ.Username,

View File

@@ -43,6 +43,7 @@ func Test_u2fRegistrationDetailsToPb(t *testing.T) {
ObjectDetails: &domain.ObjectDetails{
Sequence: 22,
EventDate: time.Unix(3000, 22),
CreationDate: time.Unix(3000, 22),
ResourceOwner: "me",
},
ID: "123",
@@ -59,6 +60,7 @@ func Test_u2fRegistrationDetailsToPb(t *testing.T) {
ObjectDetails: &domain.ObjectDetails{
Sequence: 22,
EventDate: time.Unix(3000, 22),
CreationDate: time.Unix(3000, 22),
ResourceOwner: "me",
},
ID: "123",
@@ -73,6 +75,10 @@ func Test_u2fRegistrationDetailsToPb(t *testing.T) {
Seconds: 3000,
Nanos: 22,
},
CreationDate: &timestamppb.Timestamp{
Seconds: 3000,
Nanos: 22,
},
ResourceOwner: "me",
},
U2FId: "123",

View File

@@ -74,6 +74,7 @@ func Test_passkeyRegistrationDetailsToPb(t *testing.T) {
ObjectDetails: &domain.ObjectDetails{
Sequence: 22,
EventDate: time.Unix(3000, 22),
CreationDate: time.Unix(3000, 22),
ResourceOwner: "me",
},
ID: "123",
@@ -90,6 +91,7 @@ func Test_passkeyRegistrationDetailsToPb(t *testing.T) {
ObjectDetails: &domain.ObjectDetails{
Sequence: 22,
EventDate: time.Unix(3000, 22),
CreationDate: time.Unix(3000, 22),
ResourceOwner: "me",
},
ID: "123",
@@ -100,6 +102,10 @@ func Test_passkeyRegistrationDetailsToPb(t *testing.T) {
want: &user.RegisterPasskeyResponse{
Details: &object.Details{
Sequence: 22,
CreationDate: &timestamppb.Timestamp{
Seconds: 3000,
Nanos: 22,
},
ChangeDate: &timestamppb.Timestamp{
Seconds: 3000,
Nanos: 22,
@@ -150,6 +156,7 @@ func Test_passkeyDetailsToPb(t *testing.T) {
details: &domain.ObjectDetails{
Sequence: 22,
EventDate: time.Unix(3000, 22),
CreationDate: time.Unix(3000, 22),
ResourceOwner: "me",
},
err: nil,
@@ -157,6 +164,10 @@ func Test_passkeyDetailsToPb(t *testing.T) {
want: &user.CreatePasskeyRegistrationLinkResponse{
Details: &object.Details{
Sequence: 22,
CreationDate: &timestamppb.Timestamp{
Seconds: 3000,
Nanos: 22,
},
ChangeDate: &timestamppb.Timestamp{
Seconds: 3000,
Nanos: 22,
@@ -199,6 +210,7 @@ func Test_passkeyCodeDetailsToPb(t *testing.T) {
ObjectDetails: &domain.ObjectDetails{
Sequence: 22,
EventDate: time.Unix(3000, 22),
CreationDate: time.Unix(3000, 22),
ResourceOwner: "me",
},
CodeID: "123",
@@ -209,6 +221,10 @@ func Test_passkeyCodeDetailsToPb(t *testing.T) {
want: &user.CreatePasskeyRegistrationLinkResponse{
Details: &object.Details{
Sequence: 22,
CreationDate: &timestamppb.Timestamp{
Seconds: 3000,
Nanos: 22,
},
ChangeDate: &timestamppb.Timestamp{
Seconds: 3000,
Nanos: 22,

View File

@@ -43,6 +43,7 @@ func Test_u2fRegistrationDetailsToPb(t *testing.T) {
ObjectDetails: &domain.ObjectDetails{
Sequence: 22,
EventDate: time.Unix(3000, 22),
CreationDate: time.Unix(3000, 22),
ResourceOwner: "me",
},
ID: "123",
@@ -59,6 +60,7 @@ func Test_u2fRegistrationDetailsToPb(t *testing.T) {
ObjectDetails: &domain.ObjectDetails{
Sequence: 22,
EventDate: time.Unix(3000, 22),
CreationDate: time.Unix(3000, 22),
ResourceOwner: "me",
},
ID: "123",
@@ -69,6 +71,10 @@ func Test_u2fRegistrationDetailsToPb(t *testing.T) {
want: &user.RegisterU2FResponse{
Details: &object.Details{
Sequence: 22,
CreationDate: &timestamppb.Timestamp{
Seconds: 3000,
Nanos: 22,
},
ChangeDate: &timestamppb.Timestamp{
Seconds: 3000,
Nanos: 22,