💾 Archived View for gemini.rmf-dev.com › repo › Vaati › Gemigit › files › dbb40b2fccd65b3112e7d71ed0… captured on 2023-09-08 at 16:27:28. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-05-24)
-=-=-=-=-=-=-
0 package db
1
2 import (
3 "testing"
4 "gemigit/test"
5 )
6
7 func TestPassword(t *testing.T) {
8
9 test.IsNotNil(t, isPasswordValid(""), "empty passwords are invalid")
10 test.IsNotNil(t, isPasswordValid("12345"),
11 "short passwords are invalid")
12 test.IsNotNil(t, isPasswordValid("1234567890abcdefghjklmnopqrstuvwx"),
13 "passwords longer than the length limit are invalid")
14 test.IsNil(t, isPasswordValid("123456"))
15
16 hash, err := hashPassword("123456")
17 test.IsNil(t, err)
18
19 b := checkPassword("123456", hash)
20 test.IsEqual(t, b, true)
21
22 b = checkPassword("1234567", hash)
23 test.IsEqual(t, b, false)
24
25 }
26
27 func TestUsername(t *testing.T) {
28
29 test.IsNotNil(t, isRepoNameValid(""), "empty usernames are invalid")
30
31 test.IsNotNil(t, isUsernameValid("0abc"),
32 "name should start with a letter")
33
34 test.IsNotNil(t, isGroupNameValid("iiiiiiiiiiiiiiiiiiiiiiiiI"),
35 "name should be shorter than the length limit")
36
37 s := "abc$"
38 if isUsernameValid(s) == nil || isGroupNameValid(s) == nil ||
39 isRepoNameValid(s) == nil {
40 t.Fatal("name should only contain letters and numbers")
41 }
42 n := "abc0"
43 s = "abc_0-"
44 test.IsNil(t, isUsernameValid(n))
45 test.IsNil(t, isGroupNameValid(s))
46 test.IsNil(t, isRepoNameValid(s))
47 }
48