@@ -4,168 +4,84 @@ import (
44 "testing"
55)
66
7- var listAccurate * List
8- var listNoCase * List
9-
10- func init () {
11- listAccurate = NewList (true )
12- listNoCase = NewList (false )
13- }
7+ var list = NewList ()
148
159func TestUserPlain (t * testing.T ) {
16- // accurate
17- listAccurate .AddPlain ("plain_user" , "123" )
18- if ! listAccurate .Auth ("plain_user" , "123" ) {
19- t .Error ()
20- }
21- if listAccurate .Auth ("Plain_user" , "123" ) {
10+ list .AddPlain ("plain_user" , "123" )
11+ if ! list .Auth ("plain_user" , "123" ) {
2212 t .Error ()
2313 }
24- if listAccurate .Auth ("plain_user " , "12 " ) {
14+ if ! list .Auth ("Plain_User " , "123 " ) {
2515 t .Error ()
2616 }
27-
28- // no case
29- listNoCase .AddPlain ("plain_user" , "123" )
30- if ! listNoCase .Auth ("plain_user" , "123" ) {
31- t .Error ()
32- }
33- if ! listNoCase .Auth ("Plain_User" , "123" ) {
34- t .Error ()
35- }
36- if listNoCase .Auth ("plain_user" , "12" ) {
17+ if list .Auth ("plain_user" , "12" ) {
3718 t .Error ()
3819 }
3920}
4021
4122func TestUserBase64 (t * testing.T ) {
42- // accurate
43- listAccurate .AddBase64 ("base64_user" , "MjM0" )
44- if ! listAccurate .Auth ("base64_user" , "234" ) {
45- t .Error ()
46- }
47- if listAccurate .Auth ("Base64_user" , "234" ) {
23+ list .AddBase64 ("base64_user" , "MjM0" )
24+ if ! list .Auth ("base64_user" , "234" ) {
4825 t .Error ()
4926 }
50- if listAccurate .Auth ("base64_user " , "23 " ) {
27+ if ! list .Auth ("Base64_user " , "234 " ) {
5128 t .Error ()
5229 }
53-
54- // no case
55- listNoCase .AddBase64 ("base64_user" , "MjM0" )
56- if ! listNoCase .Auth ("base64_user" , "234" ) {
57- t .Error ()
58- }
59- if ! listNoCase .Auth ("Base64_user" , "234" ) {
60- t .Error ()
61- }
62- if listNoCase .Auth ("base64_user" , "23" ) {
30+ if list .Auth ("base64_user" , "23" ) {
6331 t .Error ()
6432 }
6533
6634}
6735
6836func TestUserMd5 (t * testing.T ) {
69- // accurate
70- listAccurate .AddMd5 ("md5_user" , "d81f9c1be2e08964bf9f24b15f0e4900" )
71- if ! listAccurate .Auth ("md5_user" , "345" ) {
72- t .Error ()
73- }
74- if listAccurate .Auth ("Md5_user" , "345" ) {
75- t .Error ()
76- }
77- if listAccurate .Auth ("md5_user" , "34" ) {
78- t .Error ()
79- }
80-
81- // no case
82- listNoCase .AddMd5 ("md5_user" , "d81f9c1be2e08964bf9f24b15f0e4900" )
83- if ! listNoCase .Auth ("md5_user" , "345" ) {
37+ list .AddMd5 ("md5_user" , "d81f9c1be2e08964bf9f24b15f0e4900" )
38+ if ! list .Auth ("md5_user" , "345" ) {
8439 t .Error ()
8540 }
86- if ! listNoCase .Auth ("Md5_user" , "345" ) {
41+ if ! list .Auth ("Md5_user" , "345" ) {
8742 t .Error ()
8843 }
89- if listNoCase .Auth ("md5_user" , "34" ) {
44+ if list .Auth ("md5_user" , "34" ) {
9045 t .Error ()
9146 }
9247
9348}
9449
9550func TestUserSha1 (t * testing.T ) {
96- // accurate
97- listAccurate .AddSha1 ("sha1_user" , "51eac6b471a284d3341d8c0c63d0f1a286262a18" )
98- if ! listAccurate .Auth ("sha1_user" , "456" ) {
99- t .Error ()
100- }
101- if listAccurate .Auth ("Sha1_user" , "456" ) {
51+ list .AddSha1 ("sha1_user" , "51eac6b471a284d3341d8c0c63d0f1a286262a18" )
52+ if ! list .Auth ("sha1_user" , "456" ) {
10253 t .Error ()
10354 }
104- if listAccurate .Auth ("sha1_user" , "45" ) {
105- t .Error ()
106- }
107-
108- // no case
109- listNoCase .AddSha1 ("sha1_user" , "51eac6b471a284d3341d8c0c63d0f1a286262a18" )
110- if ! listNoCase .Auth ("sha1_user" , "456" ) {
55+ if ! list .Auth ("Sha1_user" , "456" ) {
11156 t .Error ()
11257 }
113- if ! listNoCase .Auth ("Sha1_user" , "456" ) {
114- t .Error ()
115- }
116- if listNoCase .Auth ("sha1_user" , "45" ) {
58+ if list .Auth ("sha1_user" , "45" ) {
11759 t .Error ()
11860 }
11961}
12062
12163func TestUserSha256 (t * testing.T ) {
122- // accurate
123- listAccurate .AddSha256 ("sha256_user" , "97a6d21df7c51e8289ac1a8c026aaac143e15aa1957f54f42e30d8f8a85c3a55" )
124- if ! listAccurate .Auth ("sha256_user" , "567" ) {
125- t .Error ()
126- }
127- if listAccurate .Auth ("Sha256_user" , "567" ) {
128- t .Error ()
129- }
130- if listAccurate .Auth ("sha256_user" , "56" ) {
131- t .Error ()
132- }
133-
134- // no case
135- listNoCase .AddSha256 ("sha256_user" , "97a6d21df7c51e8289ac1a8c026aaac143e15aa1957f54f42e30d8f8a85c3a55" )
136- if ! listNoCase .Auth ("sha256_user" , "567" ) {
64+ list .AddSha256 ("sha256_user" , "97a6d21df7c51e8289ac1a8c026aaac143e15aa1957f54f42e30d8f8a85c3a55" )
65+ if ! list .Auth ("sha256_user" , "567" ) {
13766 t .Error ()
13867 }
139- if ! listNoCase .Auth ("Sha256_user" , "567" ) {
68+ if ! list .Auth ("Sha256_user" , "567" ) {
14069 t .Error ()
14170 }
142- if listNoCase .Auth ("sha256_user" , "56" ) {
71+ if list .Auth ("sha256_user" , "56" ) {
14372 t .Error ()
14473 }
14574}
14675
14776func TestUserSha512 (t * testing.T ) {
148- // accurate
149- listAccurate .AddSha512 ("sha512_user" , "c7d57e5c0b0792b154d573089792d80f5b64d2bc0cf4d7d1f551a9e4a4966e925d06b253cc9662c01df76623fdfecb812a2a0604119cb1ac37c47e8027e94cb5" )
150- if ! listAccurate .Auth ("sha512_user" , "678" ) {
151- t .Error ()
152- }
153- if listAccurate .Auth ("Sha512_user" , "678" ) {
154- t .Error ()
155- }
156- if listAccurate .Auth ("sha512_user" , "67" ) {
157- t .Error ()
158- }
159-
160- // no case
161- listNoCase .AddSha512 ("sha512_user" , "c7d57e5c0b0792b154d573089792d80f5b64d2bc0cf4d7d1f551a9e4a4966e925d06b253cc9662c01df76623fdfecb812a2a0604119cb1ac37c47e8027e94cb5" )
162- if ! listNoCase .Auth ("sha512_user" , "678" ) {
77+ list .AddSha512 ("sha512_user" , "c7d57e5c0b0792b154d573089792d80f5b64d2bc0cf4d7d1f551a9e4a4966e925d06b253cc9662c01df76623fdfecb812a2a0604119cb1ac37c47e8027e94cb5" )
78+ if ! list .Auth ("sha512_user" , "678" ) {
16379 t .Error ()
16480 }
165- if ! listNoCase .Auth ("Sha512_user" , "678" ) {
81+ if ! list .Auth ("Sha512_user" , "678" ) {
16682 t .Error ()
16783 }
168- if listNoCase .Auth ("sha512_user" , "67" ) {
84+ if list .Auth ("sha512_user" , "67" ) {
16985 t .Error ()
17086 }
17187}
0 commit comments