def test_ceph_key(self, mock_urandom):
result = utils.JinjaUtils.ceph_key()
# First, decode the base64
raw_result = base64.b64decode(result.encode('ascii'))
# Decompose into a header and a key
hdr_struct = struct.Struct('<hiih')
header = raw_result[:hdr_struct.size]
key = raw_result[hdr_struct.size:]
# Interpret the header
_type, _secs, _nanosecs, key_len = hdr_struct.unpack(header)
assert key_len == len(key)
# Verify that the key is what it should be
assert key == b'0123456789012345'
评论列表
文章目录