mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-30 06:03:45 +01:00
modify code as travis ci required
This commit is contained in:
parent
a6fd1a5050
commit
45136996eb
@ -41,18 +41,19 @@ func (l *LogAPI) Get() {
|
||||
endTime := l.GetString("end_time")
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("Get parameters error--lines", err)
|
||||
log.Errorf("Get parameters error--lines, err: %v", err)
|
||||
l.CustomAbort(http.StatusBadRequest, "bad request of lines")
|
||||
log.e
|
||||
}
|
||||
if lines <= 0 {
|
||||
lines = 10
|
||||
}
|
||||
if len(startTime) <= 0 {
|
||||
log.Errorf("Get parameters error--startTime", startTime)
|
||||
log.Errorf("Get parameters error--startTime: %s", startTime)
|
||||
l.CustomAbort(http.StatusBadRequest, "bad request of startTime")
|
||||
}
|
||||
if len(endTime) <= 0 {
|
||||
log.Errorf("Get parameters error--endTime", endTime)
|
||||
log.Errorf("Get parameters error--endTime: %s", endTime)
|
||||
l.CustomAbort(http.StatusBadRequest, "bad request of endTime")
|
||||
}
|
||||
var logList []models.AccessLog
|
||||
|
@ -235,7 +235,6 @@ func (ua *UserAPI) ChangeProfile() {
|
||||
if !(ua.AuthMode == "db_auth" || ldapAdminUser) {
|
||||
ua.CustomAbort(http.StatusForbidden, "")
|
||||
}
|
||||
log.Debugf("request body", string(ua.Ctx.Input.RequestBody))
|
||||
if !ua.IsAdmin {
|
||||
if ua.userID != ua.currentUserID {
|
||||
log.Error("Guests can only change their own account.")
|
||||
@ -245,7 +244,7 @@ func (ua *UserAPI) ChangeProfile() {
|
||||
user := models.User{UserID: ua.userID}
|
||||
ua.DecodeJSONReq(&user)
|
||||
if err := dao.ChangeUserProfile(user); err != nil {
|
||||
log.Errorf("Failed to update user profile", err)
|
||||
log.Errorf("Failed to update user profile, error: %v", err)
|
||||
ua.CustomAbort(http.StatusInternalServerError, err.Error())
|
||||
}
|
||||
}
|
||||
|
@ -730,16 +730,16 @@ func TestChangeUserProfile(t *testing.T) {
|
||||
t.Errorf("user email does not update, expected: %s, acutal: %s", username+"@163.com", loginedUser.Email)
|
||||
}
|
||||
if loginedUser.Realname != "test" {
|
||||
t.Errorf("user realname does not update, expected: %s, acutal: %s", "test", loginedUser.Email)
|
||||
t.Errorf("user realname does not update, expected: %s, acutal: %s", "test", loginedUser.Realname)
|
||||
}
|
||||
if loginedUser.Comment != "Unit Test" {
|
||||
t.Errorf("user email does not update, expected: %s, acutal: %s", "Unit Test", loginedUser.Email)
|
||||
t.Errorf("user email does not update, expected: %s, acutal: %s", "Unit Test", loginedUser.Comment)
|
||||
}
|
||||
}
|
||||
func TestGetRecentLogs(t *testing.T) {
|
||||
logs, err := GetRecentLogs(10, "2016-05-13 00:00:00", time.Now().String())
|
||||
if err != nil {
|
||||
t.Errorf("error occured in getting recent logs", err)
|
||||
t.Errorf("error occured in getting recent logs, error: %v", err)
|
||||
}
|
||||
if len(logs) <= 0 {
|
||||
t.Errorf("get logs error, expected: %d, actual: %d", 1, len(logs))
|
||||
|
@ -235,12 +235,12 @@ func DeleteUser(userID int) error {
|
||||
func ChangeUserProfile(user models.User) error {
|
||||
err := commonValidate(user)
|
||||
if err != nil {
|
||||
log.Errorf("user check failed!", err)
|
||||
log.Errorf("user check failed! error: %v", err)
|
||||
return err
|
||||
}
|
||||
o := orm.NewOrm()
|
||||
if _, err = o.Update(&user, "Email", "Realname", "Comment"); err != nil {
|
||||
log.Errorf("update user failed", err)
|
||||
log.Errorf("update user failed, error: %v", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user