All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 46s
41 lines
889 B
Go
41 lines
889 B
Go
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")
|
|
}
|
|
}
|
|
}
|