File: __driver__.lua

package info (click to toggle)
monotone 1.1-9
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 20,984 kB
  • ctags: 8,622
  • sloc: cpp: 86,450; sh: 6,906; perl: 924; makefile: 813; python: 517; lisp: 379; sql: 118; exp: 91; ansic: 52
file content (76 lines) | stat: -rw-r--r-- 2,561 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76

mtn_setup()

tkey = "happy@bogus.com"

-- empty passphrase
check(mtn("genkey", tkey .. ".empty"), 0, false, false)

-- fail to enter passphrase 3 times
check(mtn("genkey", tkey), 1, false, false, tkey .. "\n" .. "\n" .. "\n" .. tkey .. "\n" .. tkey .. "\n")

-- generate a new key
check(mtn("genkey", tkey), 0, false, true, tkey .. "\n" .. tkey .. "\n")
-- genkey prints key hash
check(qgrep("key '" .. tkey .. "' has hash '[[:xdigit:]]{40}'", "stderr"))

-- check key exists
check(mtn("ls", "keys"), 0, true)
check(qgrep(tkey, "stdout"))

-- check globbing on name works
check(mtn("ls", "keys", "happy*"), 0, true)
check(qgrep(tkey, "stdout"))

-- check globbing on bogus name misses key
check(mtn("ls", "keys", "burp*"), 0, true, false)
check(not qgrep(tkey, "stdout"))


-- second section, check making certs with this key

writefile("input.txt", "blah blah blah\n")

check(mtn("add", "input.txt"), 0, false, false)
commit()
tsha = base_revision()
check(mtn("--key", tkey, "cert", tsha, "color", "pink"), 0, false, false)
check(mtn("ls", "certs", tsha), 0, true)
check(qgrep("pink", "stdout"))

check(mtn("--key", tkey, "cert", tsha, "color"), 0, false, false, "yellow\n")
check(mtn("ls", "certs", tsha), 0, true, false)
check(qgrep("pink", "stdout"))
check(qgrep("yellow", "stdout"))

-- third section, keys with a + in the user portion work, keys with a
-- + in the domain portion also work.
goodkey = "test+thing@example.com"

check(mtn("genkey", goodkey), 0, false, false, string.rep(goodkey .. "\n", 2))
--exists
check(mtn("ls", "keys"), 0, true)
-- remember '+' is a special character for regexes
check(qgrep(string.gsub(goodkey, "+", "\\+"), "stdout"))

-- bad keys fail
badkey1 = "test+thing@example+456.com"
check(mtn("genkey", badkey1), 0, false, false, string.rep(badkey1 .. "\n", 2))
badkey2 = "testthing@example+123.com"
check(mtn("genkey", badkey2), 0, false, false, string.rep(badkey2 .. "\n", 2))

-- fourth section, keys with all supported characters (for the user portion)
-- in the user portion work, keys with the same in the domain portion don't
-- work.
goodkey = "test_a_+thing.ie@example.com"

check(mtn("genkey", goodkey), 0, false, false, string.rep(goodkey .. "\n", 2))
--exists
check(mtn("ls", "keys"), 0, true)
check(qgrep(string.gsub(goodkey, "+", "\\+"), "stdout"))

-- bad keys fail
badkey1 = "test_a_+thing.ie@exa_m+p.le.com"
check(mtn("genkey", badkey1), 0, false, false, string.rep(badkey1 .. "\n", 2))
badkey2 = "testthing@exa_m+p.le123.com"
check(mtn("genkey", badkey2), 0, false, false, string.rep(badkey2 .. "\n", 2))