chore(auth): add test for passwort checking #181
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 46s
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 46s
This commit is contained in:
40
service/auth_test.go
Normal file
40
service/auth_test.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestValidPasswords(t *testing.T) {
|
||||
passwords := []string{
|
||||
"aB!'2d2y", //normal
|
||||
"v-#:j`fQurudEEUk#xA)uzI-B+'eZW3`F*5Eaf+{YID#PWuD.TbyH'f<MC)Ck$!]K[K6~dIN&R'mRaKO,qpDpP'*A!/}73=ilK_COqM/Q%!(hyS8V75e2@J2k223T`tv", // 128 characters
|
||||
`aB!"'2d2y`, // include " in password
|
||||
}
|
||||
|
||||
for _, password := range passwords {
|
||||
|
||||
err := checkPassword(password)
|
||||
if err != nil {
|
||||
t.Errorf("Expected nil, got error")
|
||||
}
|
||||
}
|
||||
}
|
||||
func TestInvalidPasswords(t *testing.T) {
|
||||
passwords := []string{
|
||||
"aB!'2d2", // too short
|
||||
"", // empty
|
||||
"ab123SSa", // no special character
|
||||
"passwor1!", // no uppercase
|
||||
"PASSWOR1!", // no lowercase
|
||||
"Password!", // no number
|
||||
"Password1", // no special character
|
||||
}
|
||||
|
||||
for _, password := range passwords {
|
||||
|
||||
err := checkPassword(password)
|
||||
if err == nil {
|
||||
t.Errorf("Expected error, got nil")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user