Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent creating 2 registries per agent with the same name. #195

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading