Skip to content

Commit

Permalink
Update to match PR WebOfTrust/keripy#701 for defaulting to non-determ…
Browse files Browse the repository at this point in the history
…inistic salts that broke a bunch of tests here.

Signed-off-by: pfeairheller <[email protected]>
  • Loading branch information
pfeairheller committed Mar 9, 2024
1 parent da8e53f commit 2d0d721
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
'keri @ git+https://[email protected]/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',
Expand Down
4 changes: 2 additions & 2 deletions src/keria/app/agenting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions tests/app/test_agenting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions tests/app/test_aiding.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"])
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions tests/core/test_authing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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([
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down

0 comments on commit 2d0d721

Please sign in to comment.