mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-10-21 21:03:22 +00:00
initial public commit
This commit is contained in:
173
pkg/handler/testing/team_test.go
Normal file
173
pkg/handler/testing/team_test.go
Normal file
@@ -0,0 +1,173 @@
|
||||
package testing
|
||||
|
||||
import (
|
||||
//"net/http"
|
||||
//"net/http/httptest"
|
||||
//"net/url"
|
||||
"testing"
|
||||
|
||||
//"github.com/drone/drone/database"
|
||||
. "github.com/drone/drone/database/testing"
|
||||
//"github.com/drone/drone/handler"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
)
|
||||
|
||||
func TestTeamProfilePage(t *testing.T) {
|
||||
// seed the database with values
|
||||
Setup()
|
||||
defer Teardown()
|
||||
|
||||
// dummy request
|
||||
//req := http.Request{}
|
||||
//req.Form = url.Values{}
|
||||
|
||||
Convey("Team Profile Page", t, func() {
|
||||
Convey("View Profile Information", func() {
|
||||
|
||||
SkipConvey("Email Address is correct", func() {
|
||||
|
||||
})
|
||||
SkipConvey("Team Name is correct", func() {
|
||||
|
||||
})
|
||||
SkipConvey("GitHub Login is correct", func() {
|
||||
|
||||
})
|
||||
SkipConvey("Bitbucket Login is correct", func() {
|
||||
|
||||
})
|
||||
})
|
||||
Convey("Update Email Address", func() {
|
||||
SkipConvey("With a Valid Email Address", func() {
|
||||
|
||||
})
|
||||
SkipConvey("With an Invalid Email Address", func() {
|
||||
|
||||
})
|
||||
SkipConvey("With an Empty Email Address", func() {
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
Convey("Update Team Name", func() {
|
||||
SkipConvey("With a Valid Name", func() {
|
||||
|
||||
})
|
||||
SkipConvey("With an Invalid Name", func() {
|
||||
|
||||
})
|
||||
SkipConvey("With an Empty Name", func() {
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
Convey("Delete the Team", func() {
|
||||
SkipConvey("Providing an Invalid Password", func() {
|
||||
|
||||
})
|
||||
SkipConvey("Providing a Valid Password", func() {
|
||||
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func TestTeamMembersPage(t *testing.T) {
|
||||
// seed the database with values
|
||||
Setup()
|
||||
defer Teardown()
|
||||
|
||||
// dummy request
|
||||
//req := http.Request{}
|
||||
//req.Form = url.Values{}
|
||||
|
||||
Convey("Team Members Page", t, func() {
|
||||
SkipConvey("View List of Team Members", func() {
|
||||
|
||||
})
|
||||
SkipConvey("Add a New Team Member", func() {
|
||||
|
||||
})
|
||||
|
||||
Convey("Edit a Team Member", func() {
|
||||
SkipConvey("Modify the Role", func() {
|
||||
|
||||
})
|
||||
SkipConvey("Change to an Invalid Role", func() {
|
||||
|
||||
})
|
||||
SkipConvey("Change from Owner to Read", func() {
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
Convey("Delete a Team Member", func() {
|
||||
SkipConvey("Delete a Read-only Member", func() {
|
||||
|
||||
})
|
||||
SkipConvey("Delete the Last Member", func() {
|
||||
|
||||
})
|
||||
SkipConvey("Delete the Owner", func() {
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
Convey("Accept Membership", func() {
|
||||
SkipConvey("Valid Invitation", func() {
|
||||
|
||||
})
|
||||
SkipConvey("Expired Invitation", func() {
|
||||
|
||||
})
|
||||
SkipConvey("Invalid or Forged Invitation", func() {
|
||||
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func TestDashboardPage(t *testing.T) {
|
||||
// seed the database with values
|
||||
Setup()
|
||||
defer Teardown()
|
||||
|
||||
// dummy request
|
||||
//req := http.Request{}
|
||||
//req.Form = url.Values{}
|
||||
|
||||
SkipConvey("Team Dashboard", t, func() {
|
||||
|
||||
})
|
||||
|
||||
SkipConvey("User Dashboard", t, func() {
|
||||
|
||||
})
|
||||
|
||||
SkipConvey("Repo Dashboard", t, func() {
|
||||
|
||||
})
|
||||
|
||||
SkipConvey("Repo Settings", t, func() {
|
||||
|
||||
})
|
||||
|
||||
SkipConvey("Commit Dashboard", t, func() {
|
||||
|
||||
})
|
||||
|
||||
Convey("User Account", t, func() {
|
||||
SkipConvey("Login", func() {
|
||||
|
||||
})
|
||||
SkipConvey("Logout", func() {
|
||||
|
||||
})
|
||||
SkipConvey("Register", func() {
|
||||
|
||||
})
|
||||
SkipConvey("Sign Up", func() {
|
||||
|
||||
})
|
||||
})
|
||||
}
|
172
pkg/handler/testing/users_test.go
Normal file
172
pkg/handler/testing/users_test.go
Normal file
@@ -0,0 +1,172 @@
|
||||
package testing
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"github.com/drone/drone/database"
|
||||
. "github.com/drone/drone/database/testing"
|
||||
"github.com/drone/drone/handler"
|
||||
. "github.com/drone/drone/model"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
)
|
||||
|
||||
func TestUserProfilePage(t *testing.T) {
|
||||
// seed the database with values
|
||||
Setup()
|
||||
defer Teardown()
|
||||
|
||||
// dummy request
|
||||
req := http.Request{}
|
||||
req.Form = url.Values{}
|
||||
|
||||
Convey("User Profile", t, func() {
|
||||
SkipConvey("View Profile Information", func() {
|
||||
user, _ := database.GetUser(1)
|
||||
res := httptest.NewRecorder()
|
||||
handler.UserUpdate(res, &req, user)
|
||||
|
||||
Convey("Email Address is correct", func() {
|
||||
|
||||
})
|
||||
Convey("User Name is correct", func() {
|
||||
|
||||
})
|
||||
})
|
||||
Convey("Update Email Address", func() {
|
||||
Convey("With a Valid Email Address", func() {
|
||||
user, _ := database.GetUser(1)
|
||||
req.Form.Set("name", "John Smith")
|
||||
req.Form.Set("email", "John.Smith@gmail.com")
|
||||
res := httptest.NewRecorder()
|
||||
handler.UserUpdate(res, &req, user)
|
||||
|
||||
So(res.Code, ShouldEqual, http.StatusOK)
|
||||
})
|
||||
Convey("With an Invalid Email Address", func() {
|
||||
user, _ := database.GetUser(1)
|
||||
req.Form.Set("name", "John Smith")
|
||||
req.Form.Set("email", "John.Smith")
|
||||
res := httptest.NewRecorder()
|
||||
handler.UserUpdate(res, &req, user)
|
||||
|
||||
So(res.Code, ShouldEqual, http.StatusBadRequest)
|
||||
So(res.Body.String(), ShouldContainSubstring, ErrInvalidEmail.Error())
|
||||
})
|
||||
Convey("With an Empty Email Address", func() {
|
||||
user, _ := database.GetUser(1)
|
||||
req.Form.Set("name", "John Smith")
|
||||
req.Form.Set("email", "")
|
||||
res := httptest.NewRecorder()
|
||||
handler.UserUpdate(res, &req, user)
|
||||
|
||||
So(res.Code, ShouldEqual, http.StatusBadRequest)
|
||||
So(res.Body.String(), ShouldContainSubstring, ErrInvalidEmail.Error())
|
||||
})
|
||||
Convey("With a Duplicate Email Address", func() {
|
||||
user, _ := database.GetUser(1)
|
||||
req.Form.Set("name", "John Smith")
|
||||
req.Form.Set("email", "cavepig@gmail.com")
|
||||
res := httptest.NewRecorder()
|
||||
handler.UserUpdate(res, &req, user)
|
||||
|
||||
So(res.Code, ShouldEqual, http.StatusBadRequest)
|
||||
})
|
||||
})
|
||||
|
||||
Convey("Update User Name", func() {
|
||||
Convey("With a Valid Name", func() {
|
||||
user, _ := database.GetUser(1)
|
||||
req.Form.Set("name", "John Smith")
|
||||
req.Form.Set("email", "John.Smith@gmail.com")
|
||||
res := httptest.NewRecorder()
|
||||
handler.UserUpdate(res, &req, user)
|
||||
|
||||
So(res.Code, ShouldEqual, http.StatusOK)
|
||||
})
|
||||
Convey("With an Empty Name", func() {
|
||||
user, _ := database.GetUser(1)
|
||||
req.Form.Set("name", "")
|
||||
req.Form.Set("email", "John.Smith@gmail.com")
|
||||
res := httptest.NewRecorder()
|
||||
handler.UserUpdate(res, &req, user)
|
||||
|
||||
So(res.Code, ShouldEqual, http.StatusBadRequest)
|
||||
So(res.Body.String(), ShouldContainSubstring, ErrInvalidUserName.Error())
|
||||
})
|
||||
})
|
||||
|
||||
Convey("Change Password", func() {
|
||||
Convey("To a Valid Password", func() {
|
||||
user, _ := database.GetUser(1)
|
||||
req.Form.Set("password", "password123")
|
||||
res := httptest.NewRecorder()
|
||||
handler.UserPassUpdate(res, &req, user)
|
||||
|
||||
So(res.Code, ShouldEqual, http.StatusOK)
|
||||
So(user.ComparePassword("password123"), ShouldBeNil)
|
||||
})
|
||||
Convey("To an Invalid Password, too short", func() {
|
||||
user, _ := database.GetUser(1)
|
||||
req.Form.Set("password", "123")
|
||||
res := httptest.NewRecorder()
|
||||
handler.UserPassUpdate(res, &req, user)
|
||||
|
||||
So(res.Code, ShouldEqual, http.StatusBadRequest)
|
||||
})
|
||||
})
|
||||
Convey("Delete the Account", func() {
|
||||
Convey("Providing an Invalid Password", func() {
|
||||
user, _ := database.GetUser(1)
|
||||
req.Form.Set("password", "password111")
|
||||
res := httptest.NewRecorder()
|
||||
handler.UserDelete(res, &req, user)
|
||||
|
||||
So(res.Code, ShouldEqual, http.StatusBadRequest)
|
||||
})
|
||||
SkipConvey("Providing a Valid Password", func() {
|
||||
// TODO Skipping because there are no teampltes
|
||||
// loaded which will cause a panic
|
||||
user, _ := database.GetUser(2)
|
||||
req.Form.Set("password", "password")
|
||||
res := httptest.NewRecorder()
|
||||
handler.UserDelete(res, &req, user)
|
||||
|
||||
So(res.Code, ShouldEqual, http.StatusOK)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func TestUserTeamPage(t *testing.T) {
|
||||
// seed the database with values
|
||||
Setup()
|
||||
defer Teardown()
|
||||
|
||||
// dummy request
|
||||
//req := http.Request{}
|
||||
//req.Form = url.Values{}
|
||||
|
||||
Convey("User Team Page", t, func() {
|
||||
SkipConvey("View List of Teams", func() {
|
||||
|
||||
})
|
||||
SkipConvey("View Empty List of Teams", func() {
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
Convey("Create a Team", t, func() {
|
||||
SkipConvey("With an Invalid Name", func() {
|
||||
|
||||
})
|
||||
SkipConvey("With an Invalid Email", func() {
|
||||
|
||||
})
|
||||
SkipConvey("With a Valid Name and Email", func() {
|
||||
|
||||
})
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user