Skip to content

Commit

Permalink
Add feature for renaming and deleting aids (#111)
Browse files Browse the repository at this point in the history
* rename and delete aids

* vstring fix

* mockito version
  • Loading branch information
rodolfomiranda authored Apr 11, 2024
1 parent 042c205 commit 5246899
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
tests_require=[
'responses>=0.22.0',
'coverage>=6.5.0',
'pytest==7.2.0',
'pytest>=7.2.0',
'mockito==1.4.0'
],
setup_requires=[
Expand Down
10 changes: 7 additions & 3 deletions src/signify/app/aiding.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ def list(self, start=0, end=24):
def get(self, name):
res = self.client.get(f"/identifiers/{name}")
return res.json()

def rename(self, name, newName):
res = self.client.put(f"/identifiers/{name}", json={"name": newName})
return res.json()

def create(self, name, transferable=True, isith="1", nsith="1", wits=None, toad="0", proxy=None, delpre=None,
dcode=MtrDex.Blake3_256, data=None, algo=Algos.salty, estOnly=False, DnD=False, **kwargs):
Expand Down Expand Up @@ -104,7 +108,7 @@ def update(self, name, typ, **kwas):
pass

def delete(self, name):
pass
self.client.delete(f"/identifiers/{name}")

def interact(self, name, data=None):
hab = self.get(name)
Expand All @@ -125,7 +129,7 @@ def interact(self, name, data=None):
sigs=sigs)
json[keeper.algo] = keeper.params()

res = self.client.put(f"/identifiers/{name}?type=ixn", json=json)
res = self.client.post(f"/identifiers/{name}/events", json=json)
return serder, sigs, res.json()

def rotate(self, name, *, transferable=True, nsith=None, toad=None, cuts=None, adds=None,
Expand Down Expand Up @@ -188,7 +192,7 @@ def rotate(self, name, *, transferable=True, nsith=None, toad=None, cuts=None, a
if rstates is not None:
json['rmids'] = [state['i'] for state in rstates]

res = self.client.put(f"/identifiers/{name}", json=json)
res = self.client.post(f"/identifiers/{name}/events", json=json)
return serder, sigs, res.json()

def addEndRole(self, name, *, role=Roles.agent, eid=None, stamp=None):
Expand Down
10 changes: 7 additions & 3 deletions tests/app/test_aiding.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ def test_aiding_delete():
from signify.app.aiding import Identifiers
ids = Identifiers(client=mock_client) # type: ignore

from requests import Response
mock_response = mock({'json': lambda: {'success': 'yay'}}, spec=Response, strict=True)
expect(mock_client, times=1).delete('/identifiers/aid1').thenReturn(mock_response)

ids.delete(name='aid1')

verifyNoUnwantedInteractions()
Expand Down Expand Up @@ -299,7 +303,7 @@ def test_aiding_interact_no_data():
}
from requests import Response
mock_response = mock({'json': lambda: {'success': 'yay'}}, spec=Response, strict=True)
expect(mock_client, times=1).put('/identifiers/aid1?type=ixn', json=expected_data).thenReturn(mock_response)
expect(mock_client, times=1).post('/identifiers/aid1/events', json=expected_data).thenReturn(mock_response)

ids.interact(name='aid1')

Expand Down Expand Up @@ -342,7 +346,7 @@ def test_aiding_interact_with_data():

from requests import Response
mock_response = mock({'json': lambda: {'success': 'yay'}}, spec=Response, strict=True)
expect(mock_client, times=1).put('/identifiers/aid1?type=ixn', json=expected_data).thenReturn(mock_response)
expect(mock_client, times=1).post('/identifiers/aid1/events', json=expected_data).thenReturn(mock_response)

ids.interact(name='aid1', data=[{'some': 'data'}, {'some': 'more'}])

Expand Down Expand Up @@ -390,7 +394,7 @@ def test_aiding_rotate():
mock_response = mock(spec=Response, strict=True)
expected_data = {'rot': {'a': 'key event dictionary'}, 'sigs': ['a signature'], 'salty': {'keeper': 'params'},
'smids': ['state 1', 'state 2'], 'rmids': ['rstate 1', 'rstate 2']}
expect(mock_client, times=1).put('/identifiers/aid1', json=expected_data).thenReturn(mock_response)
expect(mock_client, times=1).post('/identifiers/aid1/events', json=expected_data).thenReturn(mock_response)
expect(mock_response, times=1).json().thenReturn({'success': 'yay'})

_, _, out = ids.rotate(name='aid1', states=[{'i': 'state 1'}, {'i': 'state 2'}],
Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_authing.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def test_approve_delegation():
})

from keri.core import coring
e1 = dict(v=coring.Vstrings.json,
e1 = dict(v="KERI10JSON000000_",
d="",
i="ABCDEFG",
s="1",
Expand Down

0 comments on commit 5246899

Please sign in to comment.