File: cli

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 (92 lines) | stat: -rwxr-xr-x 1,810 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
#!/usr/bin/env bash

test_description='cli'

. lib/test-lib.sh

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

test_expect_code 10 'dump non-existant db' \
    'assword dump'

test_expect_success 'add first entry' \
    'assword add foo@bar'

test_expect_success 'add second entry' \
    "assword add 'baz asdf Dokw okb 32438uoijdf'"

test_expect_code 1 'add existing context' \
    'assword add foo@bar'

test_begin_subtest "dump all entries"
assword dump | sed 's/"date": ".*"/FOO/g' >OUTPUT
cat <<EOF >EXPECTED
{
  "baz asdf Dokw okb 32438uoijdf": {
    FOO
  }, 
  "foo@bar": {
    FOO
  }
}
EOF
test_expect_equal_file OUTPUT EXPECTED

test_begin_subtest "dump search 0"
assword dump foo | sed 's/"date": ".*"/FOO/g' >OUTPUT
cat <<EOF >EXPECTED
{
  "foo@bar": {
    FOO
  }
}
EOF
test_expect_equal_file OUTPUT EXPECTED

test_begin_subtest "dump search 1"
assword dump asdf | sed 's/"date": ".*"/FOO/g' >OUTPUT
cat <<EOF >EXPECTED
{
  "baz asdf Dokw okb 32438uoijdf": {
    FOO
  }
}
EOF
test_expect_equal_file OUTPUT EXPECTED

test_begin_subtest "dump search 2"
assword dump ba | sed 's/"date": ".*"/FOO/g' >OUTPUT
cat <<EOF >EXPECTED
{
  "baz asdf Dokw okb 32438uoijdf": {
    FOO
  }, 
  "foo@bar": {
    FOO
  }
}
EOF
test_expect_equal_file OUTPUT EXPECTED

test_expect_code 1 'add existing context' 'assword add foo@bar'
test_expect_code 1 'replace non-existing context' \
    'assword replace aaaa'


test_expect_code 1 'remove non-existant entry' 'assword remove aaaa'

test_begin_subtest "remove entry"
echo yes | assword remove foo@bar
assword dump | sed 's/"date": ".*"/FOO/g' >OUTPUT
cat <<EOF >EXPECTED
{
  "baz asdf Dokw okb 32438uoijdf": {
    FOO
  }
}
EOF
test_expect_equal_file OUTPUT EXPECTED

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

test_done