@@ -12,11 +12,77 @@ TestRegister.addTests([
1212 {
1313 name : "Generate HOTP" ,
1414 input : "JBSWY3DPEHPK3PXP" ,
15- expectedOutput : `URI: otpauth://hotp/?secret=JBSWY3DPEHPK3PXP&algorithm=SHA1&digits=6&counter=0\n\nPassword: 282760` ,
15+ expectedOutput : `URI: otpauth://hotp/Account ?secret=JBSWY3DPEHPK3PXP&algorithm=SHA1&digits=6&counter=0\n\nPassword: 282760` ,
1616 recipeConfig : [
1717 {
1818 op : "Generate HOTP" ,
19- args : [ "" , 6 , 0 ] , // [Name, Code length, Counter]
19+ args : [ "Account" , 6 , 0 ] , // [Name, Code length, Counter]
20+ } ,
21+ ] ,
22+ } ,
23+ {
24+ name : "Generate HOTP - empty name rejected" ,
25+ input : "JBSWY3DPEHPK3PXP" ,
26+ expectedOutput : "Name cannot be empty." ,
27+ recipeConfig : [
28+ {
29+ op : "Generate HOTP" ,
30+ args : [ "" , 6 , 0 ] ,
31+ } ,
32+ ] ,
33+ } ,
34+ {
35+ name : "Generate HOTP - code length below minimum rejected" ,
36+ input : "JBSWY3DPEHPK3PXP" ,
37+ expectedOutput : "Code length must be greater than or equal to 6." ,
38+ recipeConfig : [
39+ {
40+ op : "Generate HOTP" ,
41+ args : [ "Account" , - 6 , 0 ] ,
42+ } ,
43+ ] ,
44+ } ,
45+ {
46+ name : "Generate HOTP - code length above maximum rejected" ,
47+ input : "JBSWY3DPEHPK3PXP" ,
48+ expectedOutput : "Code length must be less than or equal to 8." ,
49+ recipeConfig : [
50+ {
51+ op : "Generate HOTP" ,
52+ args : [ "Account" , 9 , 0 ] ,
53+ } ,
54+ ] ,
55+ } ,
56+ {
57+ name : "Generate HOTP - non-integer code length rejected" ,
58+ input : "JBSWY3DPEHPK3PXP" ,
59+ expectedOutput : "Code length must be an integer." ,
60+ recipeConfig : [
61+ {
62+ op : "Generate HOTP" ,
63+ args : [ "Account" , 6.5 , 0 ] ,
64+ } ,
65+ ] ,
66+ } ,
67+ {
68+ name : "Generate HOTP - negative counter rejected" ,
69+ input : "JBSWY3DPEHPK3PXP" ,
70+ expectedOutput : "Counter must be greater than or equal to 0." ,
71+ recipeConfig : [
72+ {
73+ op : "Generate HOTP" ,
74+ args : [ "Account" , 6 , - 1 ] ,
75+ } ,
76+ ] ,
77+ } ,
78+ {
79+ name : "Generate HOTP - special characters in name are URI-encoded" ,
80+ input : "JBSWY3DPEHPK3PXP" ,
81+ expectedOutput : `URI: otpauth://hotp/user%40example.com?secret=JBSWY3DPEHPK3PXP&algorithm=SHA1&digits=6&counter=0\n\nPassword: 282760` ,
82+ recipeConfig : [
83+ {
84+ op : "Generate HOTP" ,
85+ args : [ "user@example.com" , 6 , 0 ] ,
2086 } ,
2187 ] ,
2288 } ,
0 commit comments