Debian Codegraph @

test/integration/targets/cli/test-cli.py

raw ◀ ▶
1 Debian patch touch this file
•1 #!/usr/bin/env python3
2 # Copyright (c) 2019 Matt Martz <[email protected]>
3 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
4
5 from __future__ import annotations
6
7 import base64
8 import os
9
10 import pexpect
11
12
13 input_password = '{{ 1 + 2 }}'
14
15 # We use base64 to bypass masking of password. Easier than trying to
16 # compare in the process and deal with argv and template escaping.
17 input_password_b64 = base64.b64encode(input_password.encode())
18
19 os.environ['ANSIBLE_NOCOLOR'] = '1'
20 out = pexpect.run(
21 'ansible localhost -m debug -a msg="{{ ansible_password | b64encode }}" -k',
22 events={
23 'SSH password:': f"{input_password}\n"
24 }
25 )
26
27 assert input_password_b64 in out