Skip to content

Commit

Permalink
Prevent creating 2 registries per agent with the same name. (WebOfTru…
Browse files Browse the repository at this point in the history
…st#195)

Signed-off-by: pfeairheller <pfeairheller@gmail.com>
  • Loading branch information
pfeairheller authored Feb 15, 2024
1 parent f225c8e commit eddf7bf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/keria/app/credentialing.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ def on_post(self, req, rep, name):
if hab is None:
raise falcon.HTTPNotFound(description="alias is not a valid reference to an identifier")

if agent.rgy.registryByName(name=rname) is not None:
raise falcon.HTTPBadRequest(description=f"registry name {rname} already in use")

registry = agent.rgy.makeSignifyRegistry(name=rname, prefix=hab.pre, regser=vcp)

if hab.kever.estOnly:
Expand Down
6 changes: 5 additions & 1 deletion tests/app/test_credentialing.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,15 @@ def test_registry_end(helpers, seeder):

assert regser.pre in agent.tvy.tevers

result = client.simulate_post(path="/identifiers/test/registries", body=json.dumps(body).encode("utf-8"))
assert result.status == falcon.HTTP_400
assert result.json == {'description': 'registry name test already in use', 'title': '400 Bad Request'}

body = dict(name="test", alias="test", vcp=regser.ked, ixn=serder.ked, sigs=sigers)
result = client.simulate_post(path="/identifiers/bad_test/registries", body=json.dumps(body).encode("utf-8"))
assert result.status == falcon.HTTP_404
assert result.json == {'description': 'alias is not a valid reference to an identifier', 'title': '404 Not Found'}
assert result.json == {'description': 'alias is not a valid reference to an identifier',
'title': '404 Not Found'}


result = client.simulate_get(path="/identifiers/not_test/registries")
Expand Down

0 comments on commit eddf7bf

Please sign in to comment.