-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli_test.go
84 lines (70 loc) · 2.04 KB
/
cli_test.go
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
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestGetAction(t *testing.T) {
t.SkipNow()
}
func TestPromptForPassword(t *testing.T) {
t.SkipNow()
}
func TestVerifyAndDispatch(t *testing.T) {
// help
action, msg, err :=
verifyAndDispatch(true, false, false, false, nil, nil, nil)
assert.Nil(t, action)
assert.NotEmpty(t, msg)
assert.Nil(t, err)
// version
action, msg, err =
verifyAndDispatch(false, true, false, false, nil, nil, nil)
assert.Nil(t, action)
assert.NotEmpty(t, msg)
assert.Nil(t, err)
// empty
action, msg, err =
verifyAndDispatch(false, false, false, false, nil, nil, []string{"certmin"})
assert.Nil(t, action)
assert.NotEmpty(t, msg)
assert.Nil(t, err)
// unknown command
action, msg, err =
verifyAndDispatch(
false, false, false, false, nil, nil, []string{"certmin", "foo", "t/myserver.crt"})
assert.Nil(t, action)
assert.Empty(t, msg)
assert.NotNil(t, err)
// no certs
action, msg, err =
verifyAndDispatch(false, false, false, false, nil, nil, []string{"certmin", "skim"})
assert.Nil(t, action)
assert.Contains(t, "unkmown command", msg)
assert.NotNil(t, err)
// illegal verify key
action, msg, err = verifyAndDispatch(
false, false, false, false, nil, nil, []string{"certmin", "verify-key", "foo"})
assert.Nil(t, action)
assert.NotNil(t, err)
// legal actions
action, msg, err = verifyAndDispatch(
false, false, false, false, nil, nil, []string{"certmin", "skim", "foo", "bar"})
assert.NotNil(t, action)
assert.Nil(t, err)
action, msg, err = verifyAndDispatch(
false, false, false, false,
[]string{"foo"}, nil, []string{"certmin", "verify-chain", "foo", "fa"})
assert.NotNil(t, action)
assert.Nil(t, err)
action, msg, err = verifyAndDispatch(
false, false, true, false,
nil, nil, []string{"certmin", "verify-chain", "foo", "fa"})
assert.NotNil(t, action)
assert.Nil(t, err)
action, msg, err =
verifyAndDispatch(
false, false, false, false,
nil, nil, []string{"certmin", "verify-key", "foo", "bar"})
assert.NotNil(t, action)
assert.Nil(t, err)
}