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"]
|
new_roles := props["new_roles"]
|
||||||
if model.IsValidRoles(new_roles) {
|
if !model.IsValidRoles(new_roles) {
|
||||||
c.SetInvalidParam("updateRoles", "new_roles")
|
c.SetInvalidParam("updateRoles", "new_roles")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,6 +257,12 @@ func cmdResetPassword() {
|
|||||||
os.Exit(1)
|
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 := &api.Context{}
|
||||||
c.RequestId = model.NewId()
|
c.RequestId = model.NewId()
|
||||||
c.IpAddress = "cmd_line"
|
c.IpAddress = "cmd_line"
|
||||||
|
|||||||
@@ -106,8 +106,8 @@ var tReservedDomains = []struct {
|
|||||||
}{
|
}{
|
||||||
{"test-hello", true},
|
{"test-hello", true},
|
||||||
{"test", true},
|
{"test", true},
|
||||||
{"admin", true},
|
//{"admin", true},
|
||||||
{"Admin-punch", true},
|
//{"Admin-punch", true},
|
||||||
{"spin-punch-admin", false},
|
{"spin-punch-admin", false},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -199,6 +199,15 @@ func TestRoles(t *testing.T) {
|
|||||||
t.Fatal()
|
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{
|
var reservedName = []string{
|
||||||
"www",
|
"www",
|
||||||
"web",
|
"web",
|
||||||
"admin",
|
//"admin",
|
||||||
"support",
|
"support",
|
||||||
"notify",
|
"notify",
|
||||||
"test",
|
"test",
|
||||||
|
|||||||
@@ -35,10 +35,6 @@ func (s SqlTeamStore) CreateIndexesIfNotExists() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlTeamStore) Save(team *model.Team) StoreChannel {
|
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)
|
storeChannel := make(StoreChannel)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
@@ -54,13 +50,11 @@ func (s SqlTeamStore) SaveWithValidate(team *model.Team, validate bool) StoreCha
|
|||||||
|
|
||||||
team.PreSave()
|
team.PreSave()
|
||||||
|
|
||||||
if validate {
|
|
||||||
if result.Err = team.IsValid(); result.Err != nil {
|
if result.Err = team.IsValid(); result.Err != nil {
|
||||||
storeChannel <- result
|
storeChannel <- result
|
||||||
close(storeChannel)
|
close(storeChannel)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if err := s.GetMaster().Insert(team); err != nil {
|
if err := s.GetMaster().Insert(team); err != nil {
|
||||||
if IsUniqueConstraintError(err.Error(), "Name", "teams_name_key") {
|
if IsUniqueConstraintError(err.Error(), "Name", "teams_name_key") {
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ type Store interface {
|
|||||||
|
|
||||||
type TeamStore interface {
|
type TeamStore interface {
|
||||||
Save(team *model.Team) StoreChannel
|
Save(team *model.Team) StoreChannel
|
||||||
SaveWithValidate(team *model.Team, validate bool) StoreChannel
|
|
||||||
Update(team *model.Team) StoreChannel
|
Update(team *model.Team) StoreChannel
|
||||||
UpdateDisplayName(name string, teamId string) StoreChannel
|
UpdateDisplayName(name string, teamId string) StoreChannel
|
||||||
Get(id string) StoreChannel
|
Get(id string) StoreChannel
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// See License.txt for license information.
|
// See License.txt for license information.
|
||||||
|
|
||||||
export function setupAdminConsolePage() {
|
export function setupAdminConsolePage() {
|
||||||
console.log('setting up admin page');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
global.window.setup_admin_console_page = setupAdminConsolePage;
|
global.window.setup_admin_console_page = setupAdminConsolePage;
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user