File: library

package info (click to toggle)
assword 0.8-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 176 kB
  • ctags: 110
  • sloc: sh: 896; python: 522; makefile: 27
file content (99 lines) | stat: -rwxr-xr-x 2,016 bytes parent folder | download
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env bash

test_description='library interface'

. lib/test-lib.sh

################################################################

test_begin_subtest "create db"
python - <<EOF | sed "s|$ASSWORD_DB|ASSWORD_DB|" >OUTPUT
import assword
db = assword.Database("$ASSWORD_DB")
print db
print db.version
db.add("foo@bar")
print 'foo@bar' in db
db.save('$ASSWORD_KEYID')
EOF
cat <<EOF >EXPECTED
<assword.Database "ASSWORD_DB">
1
True
EOF
test_expect_equal_file OUTPUT EXPECTED

test_begin_subtest "decrypt db"
python - <<EOF | sed "s|$ASSWORD_DB|ASSWORD_DB|" >OUTPUT
import assword
db = assword.Database("$ASSWORD_DB")
print db
print db.version
print 'foo@bar' in db
EOF
cat <<EOF >EXPECTED
<assword.Database "ASSWORD_DB">
1
True
EOF
test_expect_equal_file OUTPUT EXPECTED

test_begin_subtest "add second entry"
python - <<EOF | sed "s|$ASSWORD_DB|ASSWORD_DB|" >OUTPUT
import assword
db = assword.Database("$ASSWORD_DB", '$ASSWORD_KEYID')
db.add("aaaa")
print 'aaaa' in db
for e in sorted(db):
  print e
db.save()
EOF
cat <<EOF >EXPECTED
True
aaaa
foo@bar
EOF
test_expect_equal_file OUTPUT EXPECTED

test_begin_subtest "replace entry"
python - <<EOF | sed "s|$ASSWORD_DB|ASSWORD_DB|" >OUTPUT
import assword
db = assword.Database("$ASSWORD_DB", '$ASSWORD_KEYID')
p1 = db['aaaa']['password']
db.replace("aaaa")
print 'aaaa' in db
p2 = db['aaaa']['password']
print p1 == p2
db.save()
EOF
cat <<EOF >EXPECTED
True
False
EOF
test_expect_equal_file OUTPUT EXPECTED

test_begin_subtest "remove entry"
python - <<EOF | sed "s|$ASSWORD_DB|ASSWORD_DB|" >OUTPUT
import assword
db = assword.Database("$ASSWORD_DB", '$ASSWORD_KEYID')
print 'foo@bar' in db
db.remove("foo@bar")
print 'foo@bar' in db
db.save()
EOF
python - <<EOF | sed "s|$ASSWORD_DB|ASSWORD_DB|" >>OUTPUT
import assword
db = assword.Database("$ASSWORD_DB", '$ASSWORD_KEYID')
for e in db:
  print e
EOF
cat <<EOF >EXPECTED
True
False
aaaa
EOF
test_expect_equal_file OUTPUT EXPECTED

################################################################

test_done