8000 add clone token · python-microservices/consulate@c590d58 · GitHub
[go: up one dir, main page]

Skip to content
65E2

Commit c590d58

Browse files
committed
add clone token
1 parent 4085943 commit c590d58

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

consulate/api/acl.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,18 @@ def update_token(self,
276276
roles=roles,
277277
service_identities=service_identities)))
278278

279+
def clone_token(self, accessor_id, description=None):
280+
"""Clone a token by the accessor_id.
281+
282+
:param str accessor_id: A UUID for accessing the token.
283+
:param str description: A human-readable description of the token.
284+
:param rtype: dict
285+
286+
"""
287+
return self._put_response_body(
288+
["token", accessor_id, "clone"], {},
289+
dict(model.ACLToken(description=description)))
290+
279291
def delete_token(self, accessor_id):
280292
"""Delete an existing token with the given AcccessorID.
281293

tests/acl_tests.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,20 @@ def test_create_and_update_token(self):
270270
value["AccessorID"], policies=POLICYLINKS_UPDATE_SAMPLE)
271271
self.assertGreater(result["ModifyIndex"], result["CreateIndex"])
272272

273+
def test_create_and_clone_token(self):
274+
secret_id = self.uuidv4()
275+
accessor_id = self.uuidv4()
276+
clone_description = "clone token of " + accessor_id
277+
value = self.consul.acl.create_token(
278+
accessor_id=accessor_id,
279+
secret_id=secret_id,
280+
roles=ROLELINKS_SAMPLE,
281+
policies=POLICYLINKS_SAMPLE,
282+
service_identities=SERVICE_IDENTITIES_SAMPLE)
283+
result = self.consul.acl.clone_token(value["AccessorID"],
284+
description="clone")
285+
self.assertEqual(result["Description"], clone_description)
286+
273287
def test_create_and_delete_token(self):
274288
secret_id = self.uuidv4()
275289
accessor_id = self.uuidv4()

0 commit comments

Comments
 (0)
0