Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
02e97de7
Commit
02e97de7
authored
7 years ago
by
Armon Dadgar
Browse files
Options
Download
Email Patches
Plain Diff
api: support token listing
parent
7584b355
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/acl.go
+21
-0
api/acl.go
api/acl_test.go
+19
-0
api/acl_test.go
with
40 additions
and
0 deletions
+40
-0
api/acl.go
+
21
-
0
View file @
02e97de7
...
...
@@ -82,6 +82,16 @@ func (a *ACLTokens) Bootstrap(q *WriteOptions) (*ACLToken, *WriteMeta, error) {
return
&
resp
,
wm
,
nil
}
// List is used to dump all of the tokens.
func
(
a
*
ACLTokens
)
List
(
q
*
QueryOptions
)
([]
*
ACLTokenListStub
,
*
QueryMeta
,
error
)
{
var
resp
[]
*
ACLTokenListStub
qm
,
err
:=
a
.
client
.
query
(
"/v1/acl/tokens"
,
&
resp
,
q
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
return
resp
,
qm
,
nil
}
// ACLPolicyListStub is used to for listing ACL policies
type
ACLPolicyListStub
struct
{
Name
string
...
...
@@ -111,3 +121,14 @@ type ACLToken struct {
CreateIndex
uint64
ModifyIndex
uint64
}
type
ACLTokenListStub
struct
{
AccessorID
string
Name
string
Type
string
Policies
[]
string
Global
bool
CreateTime
time
.
Time
CreateIndex
uint64
ModifyIndex
uint64
}
This diff is collapsed.
Click to expand it.
api/acl_test.go
+
19
-
0
View file @
02e97de7
...
...
@@ -108,3 +108,22 @@ func TestACLPolicies_Info(t *testing.T) {
assertQueryMeta
(
t
,
qm
)
assert
.
Equal
(
t
,
policy
.
Name
,
out
.
Name
)
}
func
TestACLTokens_List
(
t
*
testing
.
T
)
{
t
.
Parallel
()
c
,
s
,
_
:=
makeACLClient
(
t
,
nil
,
nil
)
defer
s
.
Stop
()
at
:=
c
.
ACLTokens
()
// Expect out bootstrap token
result
,
qm
,
err
:=
at
.
List
(
nil
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
if
qm
.
LastIndex
==
0
{
t
.
Fatalf
(
"bad index: %d"
,
qm
.
LastIndex
)
}
if
n
:=
len
(
result
);
n
!=
1
{
t
.
Fatalf
(
"expected 1 token, got: %d"
,
n
)
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help