Skip to content

Commit

Permalink
removes package level salt (#561)
Browse files Browse the repository at this point in the history
  • Loading branch information
m00sey authored Aug 25, 2023
1 parent a8773f7 commit de4ad16
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
8 changes: 3 additions & 5 deletions src/keri/app/habbing.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@

logger = help.ogler.getLogger()

SALT = coring.Salter(raw=b'0123456789abcdef').qb64 # '0AAwMTIzNDU2Nzg5YWJjZGVm'


@contextmanager
def openHby(*, name="test", base="", temp=True, salt=SALT, **kwa):
def openHby(*, name="test", base="", temp=True, salt=None, **kwa):
"""
Context manager wrapper for Habery instance.
Context 'with' statements call .close on exit of 'with' block
Expand Down Expand Up @@ -72,6 +69,7 @@ def openHby(*, name="test", base="", temp=True, salt=SALT, **kwa):
"""
habery = None
salt = salt if not None else coring.Salter(raw=b'0123456789abcdef').qb64
try:
habery = Habery(name=name, base=base, temp=temp, salt=salt, **kwa)
yield habery
Expand Down Expand Up @@ -296,7 +294,7 @@ def setup(self, *, seed=None, aeid=None, bran=None, pidx=None, algo=None,
aeid = signer.verfer.qb64 # lest it remove encryption

if salt is None: # salt for signing keys not aeid seed
salt = SALT
salt = coring.Salter(raw=b'0123456789abcdef').qb64
else:
salt = coring.Salter(qb64=salt).qb64

Expand Down
6 changes: 4 additions & 2 deletions tests/app/cli/test_kli_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def test_standalone_kli_commands(helpers, capsys):
assert os.path.isdir("/usr/local/var/keri/ks/test") is False

parser = multicommand.create_parser(commands)
args = parser.parse_args(["init", "--name", "test", "--nopasscode", "--salt", habbing.SALT])
salt = coring.Salter(raw=b'0123456789abcdef').qb64
args = parser.parse_args(["init", "--name", "test", "--nopasscode", "--salt", salt])
assert args.handler is not None
doers = args.handler(args)

Expand Down Expand Up @@ -257,7 +258,8 @@ def test_incept_and_rotate_opts(helpers, capsys):
assert os.path.isdir("/usr/local/var/keri/ks/test-opts") is False

parser = multicommand.create_parser(commands)
args = parser.parse_args(["init", "--name", "test-opts", "--nopasscode", "--salt", habbing.SALT])
salt = coring.Salter(raw=b'0123456789abcdef').qb64
args = parser.parse_args(["init", "--name", "test-opts", "--nopasscode", "--salt", salt])
assert args.handler is not None
doers = args.handler(args)

Expand Down
15 changes: 8 additions & 7 deletions tests/app/test_habbing.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def test_habery():
Test Habery class
"""
# test default
default_salt = coring.Salter(raw=b'0123456789abcdef').qb64
hby = habbing.Habery(temp=True)
assert hby.name == "test"
assert hby.base == ""
Expand Down Expand Up @@ -54,7 +55,7 @@ def test_habery():

assert hby.mgr.seed == ""
assert hby.mgr.aeid == ""
assert hby.mgr.salt == habbing.SALT
assert hby.mgr.salt == default_salt
assert hby.mgr.pidx == 1
assert hby.mgr.algo == keeping.Algos.salty
assert hby.mgr.tier == coring.Tiers.low
Expand Down Expand Up @@ -87,7 +88,7 @@ def test_habery():

assert hby.mgr.seed == seed4bran
assert hby.mgr.aeid == aeid4seed
assert hby.mgr.salt == habbing.SALT
assert hby.mgr.salt == default_salt
assert hby.mgr.pidx == 1
assert hby.mgr.algo == keeping.Algos.salty
assert hby.mgr.tier == coring.Tiers.low
Expand Down Expand Up @@ -154,7 +155,7 @@ def test_habery():
assert hby.mgr is not None
assert hby.mgr.seed == seed4bran
assert hby.mgr.aeid == aeid4seed
assert hby.mgr.salt == habbing.SALT
assert hby.mgr.salt == default_salt
assert hby.mgr.pidx == 1
assert hby.mgr.algo == keeping.Algos.salty
assert hby.mgr.tier == coring.Tiers.low
Expand Down Expand Up @@ -215,7 +216,7 @@ def test_habery():
assert hby.mgr is not None
assert hby.mgr.seed == seed4bran
assert hby.mgr.aeid == aeid4seed
assert hby.mgr.salt == habbing.SALT
assert hby.mgr.salt == default_salt
assert hby.mgr.pidx == 1
assert hby.mgr.algo == keeping.Algos.salty
assert hby.mgr.tier == coring.Tiers.low
Expand Down Expand Up @@ -263,7 +264,7 @@ def test_habery():

assert hby.mgr.seed == ""
assert hby.mgr.aeid == ""
assert hby.mgr.salt == habbing.SALT
assert hby.mgr.salt == default_salt
assert hby.mgr.pidx == 1
assert hby.mgr.algo == keeping.Algos.salty
assert hby.mgr.tier == coring.Tiers.low
Expand Down Expand Up @@ -312,7 +313,7 @@ def test_habery():
# test bran to seed
assert hby.mgr.seed == seed4bran
assert hby.mgr.aeid == aeid4seed
assert hby.mgr.salt == habbing.SALT
assert hby.mgr.salt == default_salt
assert hby.mgr.pidx == 1
assert hby.mgr.algo == keeping.Algos.salty
assert hby.mgr.tier == coring.Tiers.low
Expand Down Expand Up @@ -606,7 +607,7 @@ def test_habery_reconfigure(mockHelpingNowUTC):
# salt = salter.qb64
# assert salt == '0ABaqPLVOa6fpVnAKcmwhIdQ'

salt = habbing.SALT
salt = coring.Salter(raw=b'0123456789abcdef').qb64

cname = "tam" # controller name
cbase = "main" # controller base shared
Expand Down

0 comments on commit de4ad16

Please sign in to comment.