You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

signup_test.go 1.1 kB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright 2017 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package integrations
  5. import (
  6. "bytes"
  7. "net/http"
  8. "net/url"
  9. "testing"
  10. "code.gitea.io/gitea/models"
  11. "code.gitea.io/gitea/modules/setting"
  12. "github.com/stretchr/testify/assert"
  13. )
  14. func TestSignup(t *testing.T) {
  15. assert.NoError(t, models.LoadFixtures())
  16. setting.Service.EnableCaptcha = false
  17. req, err := http.NewRequest("POST", "/user/sign_up",
  18. bytes.NewBufferString(url.Values{
  19. "user_name": []string{"exampleUser"},
  20. "email": []string{"exampleUser@example.com"},
  21. "password": []string{"examplePassword"},
  22. "retype": []string{"examplePassword"},
  23. }.Encode()),
  24. )
  25. assert.NoError(t, err)
  26. req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
  27. resp := MakeRequest(req)
  28. assert.EqualValues(t, http.StatusFound, resp.HeaderCode)
  29. // should be able to view new user's page
  30. req, err = http.NewRequest("GET", "/exampleUser", nil)
  31. assert.NoError(t, err)
  32. resp = MakeRequest(req)
  33. assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
  34. }