mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
Removes Credentials type from common/models.go:
Every test will fail except from the user's package since it is the only one using the new Request type.
This commit is contained in:
parent
487810f148
commit
59a37bf601
3 changed files with 10 additions and 20 deletions
|
@ -175,9 +175,3 @@ type File struct {
|
|||
// File itself
|
||||
FileData []byte `gorm:"column:FileData"`
|
||||
}
|
||||
|
||||
// Credentials type (not for DB)
|
||||
type credentials struct {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
|
|
@ -14,15 +14,15 @@ var MsgOK = ResponseMsg{
|
|||
}
|
||||
|
||||
// Users
|
||||
var strPassword0 = "xyz789"
|
||||
var strPasswordA = "abc123"
|
||||
var strPasswordB = "bcd234"
|
||||
var StrPassword0 = "xyz789"
|
||||
var StrPasswordA = "abc123"
|
||||
var StrPasswordB = "bcd234"
|
||||
|
||||
// Hash passwords with bcrypt algorithm
|
||||
var bcryptCost = 10
|
||||
var pw0, _ = bcrypt.GenerateFromPassword([]byte(strPassword0), bcryptCost)
|
||||
var pwA, _ = bcrypt.GenerateFromPassword([]byte(strPasswordA), bcryptCost)
|
||||
var pwB, _ = bcrypt.GenerateFromPassword([]byte(strPasswordB), bcryptCost)
|
||||
var pw0, _ = bcrypt.GenerateFromPassword([]byte(StrPassword0), bcryptCost)
|
||||
var pwA, _ = bcrypt.GenerateFromPassword([]byte(StrPasswordA), bcryptCost)
|
||||
var pwB, _ = bcrypt.GenerateFromPassword([]byte(StrPasswordB), bcryptCost)
|
||||
|
||||
var User0 = User{Username: "User_0", Password: string(pw0),
|
||||
Role: "Admin", Mail: "User_0@example.com"}
|
||||
|
@ -33,14 +33,9 @@ var UserB = User{Username: "User_B", Password: string(pwB),
|
|||
|
||||
// Credentials
|
||||
|
||||
var CredAdmin = credentials{
|
||||
var AdminCredentials = Request{
|
||||
Username: User0.Username,
|
||||
Password: strPassword0,
|
||||
}
|
||||
|
||||
var CredUser = credentials{
|
||||
Username: UserA.Username,
|
||||
Password: strPasswordA,
|
||||
Password: StrPassword0,
|
||||
}
|
||||
|
||||
// Simulators
|
||||
|
|
|
@ -22,8 +22,9 @@ func TestUserEndpoints(t *testing.T) {
|
|||
api.Use(Authentication(true))
|
||||
RegisterUserEndpoints(api.Group("/users"))
|
||||
|
||||
// authenticate
|
||||
token, err := common.NewAuthenticateForTest(router,
|
||||
"/api/authenticate", "POST", common.CredAdmin, 200)
|
||||
"/api/authenticate", "POST", common.AdminCredentials, 200)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// test GET user/
|
||||
|
|
Loading…
Add table
Reference in a new issue