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

41 lines
1.1 KiB

  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/modules/setting"
  11. "github.com/stretchr/testify/assert"
  12. )
  13. func TestSignup(t *testing.T) {
  14. prepareTestEnv(t)
  15. setting.Service.EnableCaptcha = false
  16. req, err := http.NewRequest("POST", "/user/sign_up",
  17. bytes.NewBufferString(url.Values{
  18. "user_name": []string{"exampleUser"},
  19. "email": []string{"exampleUser@example.com"},
  20. "password": []string{"examplePassword"},
  21. "retype": []string{"examplePassword"},
  22. }.Encode()),
  23. )
  24. assert.NoError(t, err)
  25. req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
  26. resp := MakeRequest(req)
  27. assert.EqualValues(t, http.StatusFound, resp.HeaderCode)
  28. // should be able to view new user's page
  29. req, err = http.NewRequest("GET", "/exampleUser", nil)
  30. assert.NoError(t, err)
  31. resp = MakeRequest(req)
  32. assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
  33. }