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.

39 lines
1.0 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/models"
  11. "github.com/stretchr/testify/assert"
  12. )
  13. func TestDeleteUser(t *testing.T) {
  14. prepareTestEnv(t)
  15. session := loginUser(t, "user1", "password")
  16. req := NewRequest(t, "GET", "/admin/users/8")
  17. resp := session.MakeRequest(t, req)
  18. assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
  19. doc, err := NewHtmlParser(resp.Body)
  20. assert.NoError(t, err)
  21. req = NewRequestBody(t, "POST", "/admin/users/8/delete",
  22. bytes.NewBufferString(url.Values{
  23. "_csrf": []string{doc.GetInputValueByName("_csrf")},
  24. }.Encode()))
  25. req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
  26. resp = session.MakeRequest(t, req)
  27. assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
  28. models.AssertNotExistsBean(t, &models.User{ID: 8})
  29. models.CheckConsistencyFor(t, &models.User{})
  30. }