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 (46 lines) | stat: -rw-r--r-- 1,716 bytes parent folder | download | duplicates (4)
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

mtn_setup()

addfile("testfile", "foo bar")
check(mtn("ci", "-m", "foobar"), 0, false, false)
check(mtn("automate", "generate_key", "foo@bar.com", "foopass"), 0, false, false)
check(mtn("automate", "generate_key", "dbkey@bar.com", "foopass"), 0, false, false)
check(mtn("pubkey", "dbkey@bar.com"), 0, true)
rename("stdout", "dbkey")
check(mtn("dropkey", "dbkey@bar.com"), 0, false, false)
check(mtn("read"), 0, false, false, {"dbkey"})

-- foo@bar.com is now in keystore, dbkey@bar.com is in the DB

-- Should fail, foo@bar.com exists in the keystore
check(mtn("automate", "generate_key", "foo@bar.com", "foopass"), 1, false, false)

-- Should fail, dbkey@bar.com exists in the DB
check(mtn("automate", "generate_key", "dbkey@bar.com", "foopass"), 1, false, false)

-- Should fail, missing parameters
check(mtn("automate", "generate_key", "bar@foo.com"), 1, false, false)

-- Should work, we'll check the output below
check(mtn("automate", "generate_key", "foo@baz.com", "foopass"), 0, true, false)

parsed = parse_basic_io(readfile("stdout"))
locs = {}
for _,line in pairs(parsed) do
  if line.name == "name" then
    key = line.values[1]
    locs[key] = {db = false, ks = false, pub = false, priv = false}
  end
  if string.find(line.name, "location") then
    for _,v in pairs(line.values) do
      if v == "keystore" then locs[key].ks = true end
      if v == "database" then locs[key].db = true end
    end
  end
  if string.find(line.name, "private") then locs[key].priv = true end
  if string.find(line.name, "public") then locs[key].pub = true end
end
check(locs["foo@baz.com"].db == true)
check(locs["foo@baz.com"].ks == true)
check(locs["foo@baz.com"].priv == true)
check(locs["foo@baz.com"].pub == true)