本文整理匯總了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"