MCPcopy
hub / github.com/saltstack/salt / test_cryptical_dumps_valid_nonce

Function test_cryptical_dumps_valid_nonce

tests/pytests/unit/crypt/test_crypt.py:51–64  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49
50
51def test_cryptical_dumps_valid_nonce():
52 nonce = uuid.uuid4().hex
53 master_crypt = salt.crypt.Crypticle({}, salt.crypt.Crypticle.generate_key_string())
54 data = {"foo": "bar"}
55 ret = master_crypt.dumps(data, nonce=nonce)
56
57 assert isinstance(ret, bytes)
58 une = master_crypt.decrypt(ret)
59 une.startswith(master_crypt.PICKLE_PAD)
60 nonce_and_data = une[len(master_crypt.PICKLE_PAD) :]
61 assert nonce_and_data.startswith(nonce.encode())
62 assert salt.payload.loads(nonce_and_data[len(nonce) :]) == data
63
64 assert master_crypt.loads(ret, nonce=nonce) == data
65
66
67def test_cryptical_dumps_invalid_nonce():

Callers

nothing calls this directly

Calls 5

dumpsMethod · 0.95
decryptMethod · 0.95
loadsMethod · 0.95
generate_key_stringMethod · 0.80
loadsMethod · 0.45

Tested by

no test coverage detected