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