Skip to content

Commit

Permalink
feat(authN): Add to all DB entries 'Modified_by'... (#81)
Browse files Browse the repository at this point in the history
Add metadata for user
Add tests
  • Loading branch information
michalkrzyz committed Sep 25, 2024
1 parent cb2f9c1 commit 0b4fba0
Show file tree
Hide file tree
Showing 60 changed files with 12,774 additions and 4,129 deletions.
16,367 changes: 12,400 additions & 3,967 deletions internal/api/graphql/graph/generated.go

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion internal/api/graphql/graph/model/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func NewIssueMatchEntity(im *IssueMatchInput) entity.IssueMatch {
IssueId: issueId,
ComponentInstanceId: ciId,
UserId: userId,
Info: entity.Info{CreatedAt: createdAt},
Metadata: entity.Metadata{CreatedAt: createdAt},
}
}

Expand Down Expand Up @@ -315,11 +315,21 @@ func NewIssueVariantEntity(issueVariant *IssueVariantInput) entity.IssueVariant
}

func NewUser(user *entity.User) User {
createdAt := user.CreatedAt.String()
deletedAt := user.DeletedAt.String()
updatedAt := user.UpdatedAt.String()
return User{
ID: fmt.Sprintf("%d", user.Id),
UniqueUserID: &user.UniqueUserID,
Name: &user.Name,
Type: int(user.Type),
Metadata: &Metadata{
CreatedAt: &createdAt,
CreatedBy: &user.CreatedBy,
DeletedAt: &deletedAt,
UpdatedAt: &updatedAt,
UpdatedBy: &user.UpdatedBy,
},
}
}

Expand Down
12 changes: 9 additions & 3 deletions internal/api/graphql/graph/model/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions internal/api/graphql/graph/queryCollection/user/listUsers.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
# SPDX-License-Identifier: Apache-2.0

query ($filter: UserFilter, $first: Int, $after: String) {
Users (
filter: $filter,
first: $first,
after: $after
) {
totalCount
edges {
node {
id
name
type
metadata {
created_at
created_by
deleted_at
updated_at
updated_by
}
}
cursor
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,12 @@ mutation ($id: ID!, $input: UserInput!) {
uniqueUserId
type
name
metadata {
created_at
created_by
deleted_at
updated_at
updated_by
}
}
}
5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/activity.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/component.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/component_instance.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/component_version.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/evidence.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/issue.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/issue_match.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/issue_match_change.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/issue_repository.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/issue_variant.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/mutation.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/query.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/service_filter.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/support_group.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/user.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion internal/api/graphql/graph/schema/common.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,12 @@ type FilterItem {
displayName: String
filterName: String
values: [String]
}
}

type Metadata {
created_at: DateTime
created_by: String
deleted_at: DateTime
updated_at: DateTime
updated_by: String
}
1 change: 1 addition & 0 deletions internal/api/graphql/graph/schema/user.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type User implements Node {
name: String
supportGroups(filter: SupportGroupFilter, first: Int, after: String): SupportGroupConnection
services(filter: ServiceFilter, first: Int, after: String): ServiceConnection
metadata: Metadata
}

input UserInput {
Expand Down
2 changes: 2 additions & 0 deletions internal/app/user/user_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func (u *userHandler) ListUsers(filter *entity.UserFilter, options *entity.ListO
}

func (u *userHandler) CreateUser(user *entity.User) (*entity.User, error) {
user.CreatedBy = "Creator"
f := &entity.UserFilter{
UniqueUserID: []*string{&user.UniqueUserID},
}
Expand Down Expand Up @@ -136,6 +137,7 @@ func (u *userHandler) CreateUser(user *entity.User) (*entity.User, error) {
}

func (u *userHandler) UpdateUser(user *entity.User) (*entity.User, error) {
user.UpdatedBy = "Updater"
l := logrus.WithFields(logrus.Fields{
"event": UpdateUserEventName,
"object": user,
Expand Down
Loading

0 comments on commit 0b4fba0

Please sign in to comment.