-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat(authN): Add to all DB entries 'Modified_by'... (#81) #230
base: main
Are you sure you want to change the base?
Conversation
Move 'CreatedAt', 'DeletedAt' and 'UpdatedAt' to common entity.Info struct Add 'CreatedBy' and 'UpdatedBy' to common entity.Info struct Signed-off-by: Michal Krzyz <[email protected]>
e084f8b
to
cb2f9c1
Compare
b4e30a8
to
024bc5b
Compare
Add metadata for user Add tests
94c222f
to
2cdfe8c
Compare
internal/e2e/metadata_test.go
Outdated
|
||
var () | ||
|
||
func createUser(port string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if we use this function in the user_query_test.go
too. I would remove the expect checks from the helper function here and only add it to the test that calls this helper function so that its not hidden when a test runs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure we should remove expect checks from helper function/test framework function. Usually common test functions are checking for invalid operation, raising assertions and stopping the test execution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh yes. Now I get it. You are right, It is not good idea to hide expects in test for user create, so I would like to keep this function (createUser with expects), but it will use another function which is named queryCreateUser (without expects).
internal/e2e/metadata_test.go
Outdated
Expect(err).Should(BeNil()) | ||
Expect(createdAt).Should(BeTemporally("~", time.Now().UTC(), 3*time.Second)) | ||
|
||
Expect(*user.Metadata.UpdatedBy).To(BeEmpty()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really check for BeEmpty()
? in the UpdatedBy
field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to highlight that UpdatedBy is not assigned when the object is created. In some solutions of such problems we see that modified/updated time is assigned by created time at creation of an object (eg. Linux File)
Add metadata for activity, IssueVariant and IssueRepository
Add metadata for component
Add metadata for componentInstance, componentVersion
2cdfe8c
to
b8d5d0a
Compare
Add metadata for evidence
Issue Metadata rename to IssueMetadata, because now metadata means data related to creation time, creation user, update time and update user Add Metadata for Issue
Add metadata for IssueMatch
Add Metadata for IssueMatchChange, Service and SupportGroup
@@ -23,6 +24,7 @@ type ActivityConnection implements Connection { | |||
type ActivityEdge implements Edge { | |||
node: Activity! | |||
cursor: String | |||
metadata: Metadata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why intended differently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--> looks like 8 spaces instead of 4
@@ -12,8 +12,10 @@ create table if not exists Component | |||
component_name varchar(256) not null, | |||
component_type varchar(256) not null, | |||
component_created_at timestamp default current_timestamp() not null, | |||
component_created_by varchar(256) null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think User
is misleading here. A component can be as well created by a scanner, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should be foreign key to a User object. Users have a type; for scanners it's TechnicalUserType
, so I don't think it's misleading
@@ -132,6 +132,7 @@ func (a *activityHandler) ListActivities(filter *entity.ActivityFilter, options | |||
} | |||
|
|||
func (a *activityHandler) CreateActivity(activity *entity.Activity) (*entity.Activity, error) { | |||
activity.CreatedBy = "Creator" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that's a placeholder. Based on the comment I made we need to decide if that should really be a freetext field or rather a foreign key reference to a User
CreatedAt: &createdAt, | ||
CreatedBy: &em.CreatedBy, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As commented this might need to be a sub-resolver for users?!
@@ -152,6 +153,7 @@ func (a *activityHandler) CreateActivity(activity *entity.Activity) (*entity.Act | |||
} | |||
|
|||
func (a *activityHandler) UpdateActivity(activity *entity.Activity) (*entity.Activity, error) { | |||
activity.UpdatedBy = "Updater" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also a placeholder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most queries don't include the createdBy
and updatedBy
fields. Do we want to add them?
@@ -10,8 +10,7 @@ type IssueVariant implements Node { | |||
issueRepository: IssueRepository | |||
issueId: String | |||
issue: Issue | |||
created_at: DateTime | |||
updated_at: DateTime | |||
metadata: Metadata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong indentation
@@ -105,6 +105,7 @@ func (cs *componentHandler) ListComponents(filter *entity.ComponentFilter, optio | |||
} | |||
|
|||
func (cs *componentHandler) CreateComponent(component *entity.Component) (*entity.Component, error) { | |||
component.CreatedBy = "Creator" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another placeholder
@@ -139,6 +140,7 @@ func (cs *componentHandler) CreateComponent(component *entity.Component) (*entit | |||
} | |||
|
|||
func (cs *componentHandler) UpdateComponent(component *entity.Component) (*entity.Component, error) { | |||
component.UpdatedBy = "Updater" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another placeholder
@@ -111,6 +111,7 @@ func (ci *componentInstanceHandler) ListComponentInstances(filter *entity.Compon | |||
} | |||
|
|||
func (ci *componentInstanceHandler) CreateComponentInstance(componentInstance *entity.ComponentInstance) (*entity.ComponentInstance, error) { | |||
componentInstance.CreatedBy = "Creator" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another placeholder
@@ -131,6 +132,7 @@ func (ci *componentInstanceHandler) CreateComponentInstance(componentInstance *e | |||
} | |||
|
|||
func (ci *componentInstanceHandler) UpdateComponentInstance(componentInstance *entity.ComponentInstance) (*entity.ComponentInstance, error) { | |||
componentInstance.UpdatedBy = "Updater" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another placeholder
@@ -109,6 +109,7 @@ func (cv *componentVersionHandler) ListComponentVersions(filter *entity.Componen | |||
} | |||
|
|||
func (cv *componentVersionHandler) CreateComponentVersion(componentVersion *entity.ComponentVersion) (*entity.ComponentVersion, error) { | |||
componentVersion.CreatedBy = "Creator" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another placeholder
@@ -129,6 +130,7 @@ func (cv *componentVersionHandler) CreateComponentVersion(componentVersion *enti | |||
} | |||
|
|||
func (cv *componentVersionHandler) UpdateComponentVersion(componentVersion *entity.ComponentVersion) (*entity.ComponentVersion, error) { | |||
componentVersion.UpdatedBy = "Updater" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another placeholder
@@ -104,6 +104,7 @@ func (e *evidenceHandler) ListEvidences(filter *entity.EvidenceFilter, options * | |||
} | |||
|
|||
func (e *evidenceHandler) CreateEvidence(evidence *entity.Evidence) (*entity.Evidence, error) { | |||
evidence.CreatedBy = "Creator" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another placeholder
@@ -122,6 +123,7 @@ func (e *evidenceHandler) CreateEvidence(evidence *entity.Evidence) (*entity.Evi | |||
} | |||
|
|||
func (e *evidenceHandler) UpdateEvidence(evidence *entity.Evidence) (*entity.Evidence, error) { | |||
evidence.UpdatedBy = "Updater" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another placeholder
internal/app/issue/issue_handler.go
Outdated
@@ -160,6 +160,7 @@ func (is *issueHandler) ListIssues(filter *entity.IssueFilter, options *entity.I | |||
} | |||
|
|||
func (is *issueHandler) CreateIssue(issue *entity.Issue) (*entity.Issue, error) { | |||
issue.CreatedBy = "Creator" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another placeholder
@@ -208,9 +211,11 @@ func (s *SqlDatabase) CreateActivity(activity *entity.Activity) (*entity.Activit | |||
|
|||
query := ` | |||
INSERT INTO Activity ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aren't we missing the updated_by field? This is also in the other db queries the case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to insert it during creation of an object? is it possible that updatedBy will be given when the object is created in database?
353848a
to
f4ce3e7
Compare
Move 'CreatedAt', 'DeletedAt' and 'UpdatedAt' to common entity.Info struct
Add 'CreatedBy' and 'UpdatedBy' to common entity.Info struct
Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change.
What type of PR is this? (check all applicable)
Related Tickets & Documents
Added tests?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Added to documentation?
Checklist