Esempio n. 1
0
func (cfg *AutoTeamCreator) createRandomTeam() (*model.Team, bool) {
	var teamEmail string
	var teamDisplayName string
	var teamName string
	if cfg.Fuzzy {
		teamEmail = utils.FuzzEmail()
		teamDisplayName = utils.FuzzName()
		teamName = utils.FuzzName()
	} else {
		teamEmail = utils.RandomEmail(cfg.EmailLength, cfg.EmailCharset)
		teamDisplayName = utils.RandomName(cfg.NameLength, cfg.NameCharset)
		teamName = utils.RandomName(cfg.NameLength, cfg.NameCharset) + model.NewId()
	}
	team := &model.Team{
		DisplayName: teamDisplayName,
		Name:        teamName,
		Email:       teamEmail,
		Type:        model.TEAM_OPEN,
	}

	result, err := cfg.client.CreateTeam(team)
	if err != nil {
		return nil, false
	}
	createdTeam := result.Data.(*model.Team)
	return createdTeam, true
}
Esempio n. 2
0
func (cfg *AutoUserCreator) createRandomUser() (*model.User, bool) {
	var userEmail string
	var userName string
	if cfg.Fuzzy {
		userEmail = utils.RandString(FUZZ_USER_EMAIL_PREFIX_LEN, utils.LOWERCASE) + "-" + utils.FuzzEmail()
		userName = utils.FuzzName()
	} else {
		userEmail = utils.RandomEmail(cfg.EmailLength, cfg.EmailCharset)
		userName = utils.RandomName(cfg.NameLength, cfg.NameCharset)
	}

	user := &model.User{
		TeamId:   cfg.teamID,
		Email:    userEmail,
		Nickname: userName,
		Password: USER_PASSWORD}

	result, err := cfg.client.CreateUser(user, "")
	if err != nil {
		return nil, false
	}
	// We need to cheat to verify the user's email
	store.Must(Srv.Store.User().VerifyEmail(result.Data.(*model.User).Id))
	return result.Data.(*model.User), true
}