| 1 | package gotp |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | ) |
| 6 | |
| 7 | func TestBuildUri(t *testing.T) { |
| 8 | s := BuildUri( |
| 9 | "totp", |
| 10 | "4S62BZNFXXSZLCRO", |
| 11 | "xlzd", |
| 12 | "SomeOrg", |
| 13 | "sha1", |
| 14 | 0, |
| 15 | 6, |
| 16 | 0, |
| 17 | ) |
| 18 | if s != "otpauth://totp/SomeOrg:xlzd?secret=4S62BZNFXXSZLCRO&issuer=SomeOrg" { |
| 19 | t.Error("BuildUri test failed") |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | func TestITob(t *testing.T) { |
| 24 | i := 1524486261 |
| 25 | expect := []byte{0, 0, 0, 0, 90, 221, 208, 117} |
| 26 | |
| 27 | if string(expect) != string(Itob(i)) { |
| 28 | t.Error("ITob error") |
| 29 | } |
| 30 | } |