Skip to content
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

Back office events #24

Merged
merged 16 commits into from
Apr 16, 2019
Merged

Back office events #24

merged 16 commits into from
Apr 16, 2019

Conversation

bsoniam
Copy link
Contributor

@bsoniam bsoniam commented Apr 11, 2019

Store in the DB the following events:
API_ACCOUNT_CREATION
API_ACCOUNT_DELETION
GET_DETAILS
LOCK_ACCOUNT
UNLOCK_ACCOUNT
INIT_PASSWORD
& restructuring the event module and component

@bsoniam bsoniam requested a review from harture April 11, 2019 15:08
@coveralls
Copy link

coveralls commented Apr 11, 2019

Pull Request Test Coverage Report for Build 252

  • 187 of 187 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.6%) to 91.671%

Totals Coverage Status
Change from base Build 231: 0.6%
Covered Lines: 1618
Relevant Lines: 1765

💛 - Coveralls

pkg/event/component.go Outdated Show resolved Hide resolved
pkg/event/component.go Outdated Show resolved Hide resolved
pkg/management/component.go Outdated Show resolved Hide resolved

if err != nil {
return "", err
}

//store the API call into the DB
var event = make(map[string]string)
event["ct_event_type"] = "API_ACCOUNT_CREATION"
Copy link
Contributor

@fperot74 fperot74 Apr 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In component.go, we don't want to many business unrelated code in our functions. We should try to have the less "invasive" code as possible here. Could we create functions like :

var event map[string]string = events.CreateEventMap("API_ACCOUNT_CREATION")
events.AddEventValues("realm_name", realmName, "user_id", user.Id, "username", user.Username, "origin", "back-office", "audit-time", time.Now().UTC())

and somewhere else :

func CreateEventMap(apiName string /* and other generic parameters... */) map[string]string {
    event["ct_event_type"] = apiName
    event["origin"] = "back-office"
    event["audit_time"] = time.Now().UTC().Format("2006-01-02 15:04:05.000")
}
func AddEventValues(eventNfo map[string]string, values string...) {
    // can automatically ignore key/value when value is nil
}
func AddEventTime(eventNfo map[string]string, fieldName string, time time.Time) {
}

To illustrate what is worrying me, the initial DeleteUser function is only 2 lines long to do what it is aimed to but is more than 20 lines with code not related to user deletion.

@harture harture merged commit 34c1cf8 into master Apr 16, 2019
@harture harture deleted the back_office_events branch April 25, 2019 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants