本文整理汇总了Python中ansible.parsing.vault.VaultLib._add_header方法的典型用法代码示例。如果您正苦于以下问题:Python VaultLib._add_header方法的具体用法?Python VaultLib._add_header怎么用?Python VaultLib._add_header使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ansible.parsing.vault.VaultLib
的用法示例。
在下文中一共展示了VaultLib._add_header方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_header
# 需要导入模块: from ansible.parsing.vault import VaultLib [as 别名]
# 或者: from ansible.parsing.vault.VaultLib import _add_header [as 别名]
def test_add_header(self):
v = VaultLib("ansible")
v.cipher_name = "TEST"
sensitive_data = "ansible"
data = v._add_header(sensitive_data)
lines = data.split("\n")
assert len(lines) > 1, "failed to properly add header"
header = lines[0]
assert header.endswith(";TEST"), "header does end with cipher name"
header_parts = header.split(";")
assert len(header_parts) == 3, "header has the wrong number of parts"
assert header_parts[0] == "$ANSIBLE_VAULT", "header does not start with $ANSIBLE_VAULT"
assert header_parts[1] == v.version, "header version is incorrect"
assert header_parts[2] == "TEST", "header does end with cipher name"
示例2: test_add_header
# 需要导入模块: from ansible.parsing.vault import VaultLib [as 别名]
# 或者: from ansible.parsing.vault.VaultLib import _add_header [as 别名]
def test_add_header(self):
v = VaultLib('ansible')
v.cipher_name = "TEST"
sensitive_data = "ansible"
data = v._add_header(sensitive_data)
lines = data.split(b'\n')
assert len(lines) > 1, "failed to properly add header"
header = to_unicode(lines[0])
assert header.endswith(';TEST'), "header does end with cipher name"
header_parts = header.split(';')
assert len(header_parts) == 3, "header has the wrong number of parts"
assert header_parts[0] == '$ANSIBLE_VAULT', "header does not start with $ANSIBLE_VAULT"
assert header_parts[1] == v.version, "header version is incorrect"
assert header_parts[2] == 'TEST', "header does end with cipher name"