-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MM-61910] refactor: log users by email (#873)
* refactor: log users by email * chore: move comment to proper location * chore: revert strings.Replace for the username
- Loading branch information
Showing
2 changed files
with
16 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -492,17 +492,13 @@ func getUserCredentials(usersFilePath string, _ *loadtest.Config) ([]user, error | |
} | ||
email := split[0] | ||
password := split[1] | ||
// Quick and dirty hack to extract username from email. | ||
// This is not terribly important to be correct. | ||
username := strings.Split(email, "@")[0] | ||
username = strings.Replace(username, "+", "-", -1) | ||
authService := userentity.AuthenticationTypeMattermost | ||
|
||
// Check if the user has a custom authentication type. Custom authentication types are | ||
// specified by prepending the email with the authentication type followed by a colon. | ||
// Example: "openid:[email protected]" | ||
if strings.Contains(username, ":") { | ||
split := strings.Split(username, ":") | ||
if strings.Contains(email, ":") { | ||
split := strings.Split(email, ":") | ||
if len(split) != 2 { | ||
return nil, fmt.Errorf("invalid custom authentication found in %q", email) | ||
} | ||
|
@@ -515,10 +511,19 @@ func getUserCredentials(usersFilePath string, _ *loadtest.Config) ([]user, error | |
return nil, fmt.Errorf("invalid custom authentication type %q", authService) | ||
} | ||
|
||
username = split[1] | ||
email = strings.Replace(email, authService+":", "", 1) | ||
} | ||
|
||
emailParts := strings.Split(email, "@") | ||
if len(emailParts) != 2 { | ||
return nil, fmt.Errorf("invalid email %q", email) | ||
} | ||
|
||
// Quick and dirty hack to extract username from email. | ||
// This is not terribly important to be correct. | ||
username := emailParts[0] | ||
username = strings.Replace(username, "+", "-", -1) | ||
|
||
users = append(users, user{ | ||
email: email, | ||
username: username, | ||
|
This file contains 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