2021-06-03 03:43:42 -06:00
|
|
|
#!/usr/bin/env python3
|
2016-08-02 09:03:46 -06:00
|
|
|
import os
|
|
|
|
import subprocess
|
2022-04-11 16:32:57 -06:00
|
|
|
import sys
|
|
|
|
import unittest
|
|
|
|
|
2016-08-02 09:03:46 -06:00
|
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
|
|
|
|
rootDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
|
|
|
|
|
|
|
|
class TestVerboseOutput(unittest.TestCase):
|
|
|
|
def test_private_info_arg(self):
|
|
|
|
outp = subprocess.Popen(
|
|
|
|
[
|
2022-04-17 14:58:28 -06:00
|
|
|
sys.executable, 'yt_dlp/__main__.py',
|
|
|
|
'-v', '--ignore-config',
|
2016-08-02 09:03:46 -06:00
|
|
|
'--username', 'johnsmith@gmail.com',
|
2022-01-09 06:57:06 -07:00
|
|
|
'--password', 'my_secret_password',
|
2016-08-02 09:03:46 -06:00
|
|
|
], cwd=rootDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
sout, serr = outp.communicate()
|
2016-08-13 03:36:14 -06:00
|
|
|
self.assertTrue(b'--username' in serr)
|
|
|
|
self.assertTrue(b'johnsmith' not in serr)
|
|
|
|
self.assertTrue(b'--password' in serr)
|
2022-01-09 06:57:06 -07:00
|
|
|
self.assertTrue(b'my_secret_password' not in serr)
|
2016-08-02 09:03:46 -06:00
|
|
|
|
|
|
|
def test_private_info_shortarg(self):
|
|
|
|
outp = subprocess.Popen(
|
|
|
|
[
|
2022-04-17 14:58:28 -06:00
|
|
|
sys.executable, 'yt_dlp/__main__.py',
|
|
|
|
'-v', '--ignore-config',
|
2016-08-02 09:03:46 -06:00
|
|
|
'-u', 'johnsmith@gmail.com',
|
2022-01-09 06:57:06 -07:00
|
|
|
'-p', 'my_secret_password',
|
2016-08-02 09:03:46 -06:00
|
|
|
], cwd=rootDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
sout, serr = outp.communicate()
|
2016-08-13 03:36:14 -06:00
|
|
|
self.assertTrue(b'-u' in serr)
|
|
|
|
self.assertTrue(b'johnsmith' not in serr)
|
|
|
|
self.assertTrue(b'-p' in serr)
|
2022-01-09 06:57:06 -07:00
|
|
|
self.assertTrue(b'my_secret_password' not in serr)
|
2016-08-02 09:03:46 -06:00
|
|
|
|
|
|
|
def test_private_info_eq(self):
|
|
|
|
outp = subprocess.Popen(
|
|
|
|
[
|
2022-04-17 14:58:28 -06:00
|
|
|
sys.executable, 'yt_dlp/__main__.py',
|
|
|
|
'-v', '--ignore-config',
|
2016-08-02 09:03:46 -06:00
|
|
|
'--username=johnsmith@gmail.com',
|
2022-01-09 06:57:06 -07:00
|
|
|
'--password=my_secret_password',
|
2016-08-02 09:03:46 -06:00
|
|
|
], cwd=rootDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
sout, serr = outp.communicate()
|
2016-08-13 03:36:14 -06:00
|
|
|
self.assertTrue(b'--username' in serr)
|
|
|
|
self.assertTrue(b'johnsmith' not in serr)
|
|
|
|
self.assertTrue(b'--password' in serr)
|
2022-01-09 06:57:06 -07:00
|
|
|
self.assertTrue(b'my_secret_password' not in serr)
|
2016-08-02 09:03:46 -06:00
|
|
|
|
|
|
|
def test_private_info_shortarg_eq(self):
|
|
|
|
outp = subprocess.Popen(
|
|
|
|
[
|
2022-04-17 14:58:28 -06:00
|
|
|
sys.executable, 'yt_dlp/__main__.py',
|
|
|
|
'-v', '--ignore-config',
|
2016-08-02 09:03:46 -06:00
|
|
|
'-u=johnsmith@gmail.com',
|
2022-01-09 06:57:06 -07:00
|
|
|
'-p=my_secret_password',
|
2016-08-02 09:03:46 -06:00
|
|
|
], cwd=rootDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
sout, serr = outp.communicate()
|
2016-08-13 03:36:14 -06:00
|
|
|
self.assertTrue(b'-u' in serr)
|
|
|
|
self.assertTrue(b'johnsmith' not in serr)
|
|
|
|
self.assertTrue(b'-p' in serr)
|
2022-01-09 06:57:06 -07:00
|
|
|
self.assertTrue(b'my_secret_password' not in serr)
|
2016-08-02 09:03:46 -06:00
|
|
|
|
2016-11-17 04:42:56 -07:00
|
|
|
|
2016-08-02 09:03:46 -06:00
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|