Clean up line lengths

- All tests pass.
parent 7a1c12cc
......@@ -53,7 +53,8 @@ func BasicAuthAndRunHandler(mw MultiWriter, r *http.Request, b BasicAuthShim) {
return
}
if err = bcrypt.CompareHashAndPassword([]byte(user.BcryptPassword), []byte(pass)); err != nil {
if err = bcrypt.CompareHashAndPassword([]byte(user.BcryptPassword),
[]byte(pass)); err != nil {
log.Printf("Login failure, CompareHashAndPassword: %s - %v", login, err)
UnauthorizedResp(mw, r)
} else {
......
......@@ -28,13 +28,15 @@ func main() {
flag.Parse()
if *ver {
fmt.Printf("go-resteasy commit: %s\nBuilt with: %s\n", vercommit, runtime.Version())
fmt.Printf("go-resteasy commit: %s\nBuilt with: %s\n", vercommit,
runtime.Version())
os.Exit(0)
}
InitPgConn()
// For the specifics of rooted path and subtree matching, see: https://golang.org/pkg/net/http/#ServeMux
// For the specifics of rooted path and subtree matching, see:
// https://golang.org/pkg/net/http/#ServeMux
smux := http.NewServeMux()
smux.Handle("/", RootNotFoundHandler())
smux.Handle("/auth", http.StripPrefix("/auth", AuthPathHandler()))
......
......@@ -28,8 +28,8 @@ func (ak *AccessKey) Create() error {
func GetAccessKeysByUserId(uid string) ([]AccessKey, error) {
var keys []AccessKey
rows, err := pg.Query("SELECT key, expires_at FROM access_keys WHERE user_id = $1 "+
"AND expires_at > now()", uid)
rows, err := pg.Query("SELECT key, expires_at FROM access_keys "+
"WHERE user_id = $1 AND expires_at > now()", uid)
if err != nil {
return keys, err
}
......
......@@ -52,7 +52,8 @@ func (j *Job) Create() error {
return nil
}
// Update updates a job in-place with a full resource representation from an already-validated source.
// Update updates a job in-place with a full resource representation from an
// already-validated source.
func (j *Job) Update() error {
if _, err := pg.Exec("UPDATE jobs SET user_id = $1, started_at = $2, "+
"completed_at = $3 WHERE id = $4", j.UserId, j.StartedAt, j.CompletedAt,
......
......@@ -12,7 +12,8 @@ func TestJobsValidateMissingUserId(t *testing.T) {
j.UserId = nil
if err := j.Validate(); err != nil && err.Error() != JobReqUserId {
t.Errorf("\nRan: Job.Validate(%#v)\nExpected: %v\nGot: %v", j, JobReqUserId, err.Error())
t.Errorf("\nRan: Job.Validate(%#v)\nExpected: %v\nGot: %v", j,
JobReqUserId, err.Error())
}
}
......
......@@ -90,7 +90,8 @@ func (u *User) PopulateLinks() {
// Create creates a new User from an already-validated source.
func (u *User) Create() error {
bcrypt_pass, err := bcrypt.GenerateFromPassword([]byte(*u.Password), bcrypt.DefaultCost)
bcrypt_pass, err := bcrypt.GenerateFromPassword([]byte(*u.Password),
bcrypt.DefaultCost)
if err != nil {
return err
}
......@@ -109,7 +110,8 @@ func (u *User) Create() error {
return nil
}
// Update updates a user in-place with a full resource representation from an already-validated source.
// Update updates a user in-place with a full resource representation from an
// already-validated source.
func (u *User) Update() error {
if u.Password != nil {
if bcrypt_pass, err := bcrypt.GenerateFromPassword([]byte(*u.Password),
......
......@@ -11,8 +11,8 @@ func DefaultUser() User {
func DefaultUserWithPass() User {
ut := "user"
pass := "mypass"
return User{UserType: &ut, FirstName: "First", LastName: "Last", Email: "email@example.com",
Login: "flast", Password: &pass}
return User{UserType: &ut, FirstName: "First", LastName: "Last",
Email: "email@example.com", Login: "flast", Password: &pass}
}
func TestUsersValidateMissingUserTypeId(t *testing.T) {
......@@ -20,7 +20,8 @@ func TestUsersValidateMissingUserTypeId(t *testing.T) {
u.UserType = nil
if err := u.Validate(); err != nil && err.Error() != UserReqUserTypeId {
t.Errorf("\nRan: User.Validate(%#v)\nExpected: %v\nGot: %v", u, UserReqUserTypeId, err.Error())
t.Errorf("\nRan: User.Validate(%#v)\nExpected: %v\nGot: %v", u,
UserReqUserTypeId, err.Error())
}
}
......@@ -29,7 +30,8 @@ func TestUsersValidateMissingFirstName(t *testing.T) {
u.FirstName = ""
if err := u.Validate(); err != nil && err.Error() != UserReqFirstName {
t.Errorf("\nRan: User.Validate(%#v)\nExpected: %v\nGot: %v", u, UserReqFirstName, err.Error())
t.Errorf("\nRan: User.Validate(%#v)\nExpected: %v\nGot: %v", u,
UserReqFirstName, err.Error())
}
}
......@@ -38,7 +40,8 @@ func TestUsersValidateMissingLastName(t *testing.T) {
u.LastName = ""
if err := u.Validate(); err != nil && err.Error() != UserReqLastName {
t.Errorf("\nRan: User.Validate(%#v)\nExpected: %v\nGot: %v", u, UserReqLastName, err.Error())
t.Errorf("\nRan: User.Validate(%#v)\nExpected: %v\nGot: %v", u,
UserReqLastName, err.Error())
}
}
......@@ -47,7 +50,8 @@ func TestUsersValidateMissingEmail(t *testing.T) {
u.Email = ""
if err := u.Validate(); err != nil && err.Error() != UserReqEmail {
t.Errorf("\nRan: User.Validate(%#v)\nExpected: %v\nGot: %v", u, UserReqEmail, err.Error())
t.Errorf("\nRan: User.Validate(%#v)\nExpected: %v\nGot: %v", u,
UserReqEmail, err.Error())
}
}
......@@ -56,7 +60,8 @@ func TestUsersValidateMissingLogin(t *testing.T) {
u.Login = ""
if err := u.Validate(); err != nil && err.Error() != UserReqLogin {
t.Errorf("\nRan: User.Validate(%#v)\nExpected: %v\nGot: %v", u, UserReqLogin, err.Error())
t.Errorf("\nRan: User.Validate(%#v)\nExpected: %v\nGot: %v", u,
UserReqLogin, err.Error())
}
}
......@@ -65,7 +70,8 @@ func TestUsersValidateMissingPasswordBcrypt(t *testing.T) {
u.BcryptPassword = ""
if err := u.Validate(); err != nil && err.Error() != UserReqPassword {
t.Errorf("\nRan: User.Validate(%#v)\nExpected: %v\nGot: %v", u, UserReqPassword, err.Error())
t.Errorf("\nRan: User.Validate(%#v)\nExpected: %v\nGot: %v", u,
UserReqPassword, err.Error())
}
}
......@@ -73,7 +79,8 @@ func TestUsersValidatePassingPassword(t *testing.T) {
u := DefaultUserWithPass()
if err := u.Validate(); err != nil {
t.Errorf("\nRan: User.Validate(%#v)\nExpected: %v\nGot: %v", u, nil, err.Error())
t.Errorf("\nRan: User.Validate(%#v)\nExpected: %v\nGot: %v", u, nil,
err.Error())
}
}
......@@ -81,6 +88,7 @@ func TestUsersValidatePassingBcrypt(t *testing.T) {
u := DefaultUser()
if err := u.Validate(); err != nil {
t.Errorf("\nRan: User.Validate(%#v)\nExpected: %v\nGot: %v", u, nil, err.Error())
t.Errorf("\nRan: User.Validate(%#v)\nExpected: %v\nGot: %v", u, nil,
err.Error())
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment