This repository has been archived on 2025-08-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
web-app-template/service/auth_test.go
Tim Wundenberg f184e261ee
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 47s
tbs
2024-09-17 22:47:54 +02:00

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")
}
}
}