Adding unit tests for cmd line
Этот коммит содержится в:
@@ -925,7 +925,7 @@ func updateRoles(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
new_roles := props["new_roles"]
|
||||
if model.IsValidRoles(new_roles) {
|
||||
if !model.IsValidRoles(new_roles) {
|
||||
c.SetInvalidParam("updateRoles", "new_roles")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -257,6 +257,12 @@ func cmdResetPassword() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if len(flagPassword) < 5 {
|
||||
fmt.Fprintln(os.Stderr, "flag invalid argument needs to be more than 4 characters: -password")
|
||||
flag.Usage()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
c := &api.Context{}
|
||||
c.RequestId = model.NewId()
|
||||
c.IpAddress = "cmd_line"
|
||||
|
||||
@@ -106,8 +106,8 @@ var tReservedDomains = []struct {
|
||||
}{
|
||||
{"test-hello", true},
|
||||
{"test", true},
|
||||
{"admin", true},
|
||||
{"Admin-punch", true},
|
||||
//{"admin", true},
|
||||
//{"Admin-punch", true},
|
||||
{"spin-punch-admin", false},
|
||||
}
|
||||
|
||||
|
||||
@@ -199,6 +199,15 @@ func TestRoles(t *testing.T) {
|
||||
t.Fatal()
|
||||
}
|
||||
|
||||
//IsInRole
|
||||
if IsValidRoles("junk") {
|
||||
t.Fatal()
|
||||
}
|
||||
|
||||
if IsInRole("system_admin junk", "admin") {
|
||||
t.Fatal()
|
||||
}
|
||||
|
||||
if !IsInRole("system_admin junk", "system_admin") {
|
||||
t.Fatal()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ func IsValidEmail(email string) bool {
|
||||
var reservedName = []string{
|
||||
"www",
|
||||
"web",
|
||||
"admin",
|
||||
//"admin",
|
||||
"support",
|
||||
"notify",
|
||||
"test",
|
||||
|
||||
@@ -35,10 +35,6 @@ func (s SqlTeamStore) CreateIndexesIfNotExists() {
|
||||
}
|
||||
|
||||
func (s SqlTeamStore) Save(team *model.Team) StoreChannel {
|
||||
return s.SaveWithValidate(team, true)
|
||||
}
|
||||
|
||||
func (s SqlTeamStore) SaveWithValidate(team *model.Team, validate bool) StoreChannel {
|
||||
storeChannel := make(StoreChannel)
|
||||
|
||||
go func() {
|
||||
@@ -54,12 +50,10 @@ func (s SqlTeamStore) SaveWithValidate(team *model.Team, validate bool) StoreCha
|
||||
|
||||
team.PreSave()
|
||||
|
||||
if validate {
|
||||
if result.Err = team.IsValid(); result.Err != nil {
|
||||
storeChannel <- result
|
||||
close(storeChannel)
|
||||
return
|
||||
}
|
||||
if result.Err = team.IsValid(); result.Err != nil {
|
||||
storeChannel <- result
|
||||
close(storeChannel)
|
||||
return
|
||||
}
|
||||
|
||||
if err := s.GetMaster().Insert(team); err != nil {
|
||||
|
||||
@@ -39,7 +39,6 @@ type Store interface {
|
||||
|
||||
type TeamStore interface {
|
||||
Save(team *model.Team) StoreChannel
|
||||
SaveWithValidate(team *model.Team, validate bool) StoreChannel
|
||||
Update(team *model.Team) StoreChannel
|
||||
UpdateDisplayName(name string, teamId string) StoreChannel
|
||||
Get(id string) StoreChannel
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// See License.txt for license information.
|
||||
|
||||
export function setupAdminConsolePage() {
|
||||
console.log('setting up admin page');
|
||||
|
||||
}
|
||||
|
||||
global.window.setup_admin_console_page = setupAdminConsolePage;
|
||||
|
||||
Ссылка в новой задаче
Block a user