From 2d0d7210c3803b36565d867220a62b59882c5bea Mon Sep 17 00:00:00 2001 From: pfeairheller Date: Sat, 9 Mar 2024 08:13:04 -0800 Subject: [PATCH] Update to match PR WebOfTrust/keripy#701 for defaulting to non-deterministic salts that broke a bunch of tests here. Signed-off-by: pfeairheller --- setup.py | 2 +- src/keria/app/agenting.py | 4 ++-- tests/app/test_agenting.py | 4 ++-- tests/app/test_aiding.py | 10 +++++----- tests/core/test_authing.py | 9 ++++++--- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/setup.py b/setup.py index 5f5e2041..c30c5784 100644 --- a/setup.py +++ b/setup.py @@ -79,7 +79,7 @@ 'keri @ git+https://git@github.com/weboftrust/keripy.git@development', 'mnemonic>=0.20', 'multicommand>=1.0.0', - 'falcon>=3.1.0', + 'falcon>=3.1.3', 'http_sfv>=0.9.8', 'dataclasses_json>=0.5.7', 'apispec>=6.3.0', diff --git a/src/keria/app/agenting.py b/src/keria/app/agenting.py index 963fb716..78fbf345 100644 --- a/src/keria/app/agenting.py +++ b/src/keria/app/agenting.py @@ -173,7 +173,7 @@ def __init__(self, name, bran, base="", configFile=None, configDir=None, adb=Non self.adb = adb if adb is not None else basing.AgencyBaser(name="TheAgency", base=base, reopen=True, temp=temp) super(Agency, self).__init__(doers=[], always=True) - def create(self, caid): + def create(self, caid, salt=None): ks = keeping.Keeper(name=caid, base=self.base, temp=self.temp, @@ -196,7 +196,7 @@ def create(self, caid): cf.put(data) # Create the Hab for the Agent with only 2 AIDs - agentHby = habbing.Habery(name=caid, base=self.base, bran=self.bran, ks=ks, cf=cf, temp=self.temp) + agentHby = habbing.Habery(name=caid, base=self.base, bran=self.bran, ks=ks, cf=cf, temp=self.temp, salt=salt) agentHab = agentHby.makeHab(f"agent-{caid}", ns="agent", transferable=True, delpre=caid) agentRgy = Regery(hby=agentHby, name=agentHab.name, base=self.base, temp=self.temp) diff --git a/tests/app/test_agenting.py b/tests/app/test_agenting.py index d0d6d8df..42a05a56 100644 --- a/tests/app/test_agenting.py +++ b/tests/app/test_agenting.py @@ -79,7 +79,7 @@ def test_agency(): doist.enter(doers=[agency]) caid = "ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose" - agent = agency.create(caid) + agent = agency.create(caid, salt=salter.qb64) assert agent.pre == "EIAEKYpTygdBtFHBrHKWeh0aYCdx0ZJqZtzQLFnaDB2b" badcaid = "E987eerAdhmvrjDeam2eAO2SR5niCgnjAJXJHtJoe" @@ -121,7 +121,7 @@ def test_agency(): doist.enter(doers=[agency]) caid = "ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose" - agent = agency.create(caid) + agent = agency.create(caid, salt=salter.qb64) assert agent.pre == "EEXekkGu9IAzav6pZVJhkLnjtjM5v3AcyA-pdKUcaGei" # Rcreate the agency to see if agent is reloaded from disk diff --git a/tests/app/test_aiding.py b/tests/app/test_aiding.py index 7b6efe29..15f84477 100644 --- a/tests/app/test_aiding.py +++ b/tests/app/test_aiding.py @@ -242,9 +242,12 @@ def test_agent_resource(helpers, mockHelpingNowUTC): def test_identifier_collection_end(helpers): + salt = b'0123456789abcdef' + salter = coring.Salter(raw=salt) + with helpers.openKeria() as (agency, agent, app, client), \ - habbing.openHby(name="p1", temp=True) as p1hby, \ - habbing.openHby(name="p2", temp=True) as p2hby: + habbing.openHby(name="p1", temp=True, salt=salter.qb64) as p1hby, \ + habbing.openHby(name="p2", temp=True, salt=salter.qb64) as p2hby: end = aiding.IdentifierCollectionEnd() resend = aiding.IdentifierResourceEnd() app.add_route("/identifiers", end) @@ -1449,7 +1452,6 @@ def test_approve_delegation(helpers): assert res.status_code == 200 agt = res.json["agent"] ctrl = res.json["controller"] - assert agt["i"] == "EHyaw-1bCenigGQCZRs_hXNdndHw0fSf-Q5-LpUwOR8r" assert ctrl["state"]["i"] == controllerAID anchor = dict(i=agt["i"], s="0", d=agt["d"]) @@ -1533,9 +1535,7 @@ def test_rotation(helpers): res = client.simulate_get(path=f"/agent/{serder.pre}") assert res.status_code == 200 - agt = res.json["agent"] ctrl = res.json["controller"] - assert agt["i"] == "EHyaw-1bCenigGQCZRs_hXNdndHw0fSf-Q5-LpUwOR8r" assert ctrl["state"]["i"] == controllerAID op = helpers.createAid(client, name="salty_aid", salt=bran) diff --git a/tests/core/test_authing.py b/tests/core/test_authing.py index c425c104..5aa24692 100644 --- a/tests/core/test_authing.py +++ b/tests/core/test_authing.py @@ -12,7 +12,7 @@ from hio.help import Hict from keri import kering from keri.app import habbing -from keri.core import parsing, eventing +from keri.core import parsing, eventing, coring from keri.end import ending from keria.app import agenting @@ -21,6 +21,8 @@ def test_authenticater(mockHelpingNowUTC): salt = b'0123456789abcdef' + salter = coring.Salter(raw=salt) + with habbing.openHab(name="caid", salt=salt, temp=True) as (controllerHby, controller): agency = agenting.Agency(name="agency", base='', bran=None, temp=True) @@ -30,7 +32,7 @@ def test_authenticater(mockHelpingNowUTC): doist = doing.Doist(limit=1.0, tock=0.03125, real=True) doist.enter(doers=[agency]) - agent = agency.create(caid=controller.pre) + agent = agency.create(caid=controller.pre, salt=salter.qb64) # Create authenticater with Agent and controllers AID headers = Hict([ @@ -203,6 +205,7 @@ def test_signature_validation(mockHelpingNowUTC): assert rep.status == falcon.HTTP_401 salt = b'0123456789abcdef' + salter = coring.Salter(raw=salt) with habbing.openHab(name="caid", salt=salt, temp=True) as (controllerHby, controller): agency = agenting.Agency(name="agency", base='', bran=None, temp=True) @@ -212,7 +215,7 @@ def test_signature_validation(mockHelpingNowUTC): doist = doing.Doist(limit=1.0, tock=0.03125, real=True) doist.enter(doers=[agency]) - agent = agency.create(caid=controller.pre) + agent = agency.create(caid=controller.pre, salt=salter.qb64) req = testing.create_req(method="POST", path="/reward") req.context.agent = agent rep = falcon.Response()