2014-05-15 12:37:05 +00:00
|
|
|
import glob
|
2014-09-12 01:16:52 +00:00
|
|
|
import mock
|
2014-07-26 09:51:27 +00:00
|
|
|
from libmproxy import utils, script
|
2014-05-15 12:37:05 +00:00
|
|
|
from libmproxy.proxy import config
|
|
|
|
import tservers
|
|
|
|
|
2014-09-12 01:16:52 +00:00
|
|
|
@mock.patch.dict("sys.modules", {"bs4": mock.Mock()})
|
2014-07-26 09:51:27 +00:00
|
|
|
def test_load_scripts():
|
|
|
|
example_dir = utils.Data("libmproxy").path("../examples")
|
|
|
|
scripts = glob.glob("%s/*.py" % example_dir)
|
|
|
|
|
|
|
|
tmaster = tservers.TestMaster(config.ProxyConfig())
|
2014-05-15 12:37:05 +00:00
|
|
|
|
2014-07-26 09:51:27 +00:00
|
|
|
for f in scripts:
|
2014-09-05 13:05:44 +00:00
|
|
|
if "iframe_injector" in f:
|
|
|
|
f += " foo" # one argument required
|
2014-07-26 09:51:27 +00:00
|
|
|
if "modify_response_body" in f:
|
|
|
|
f += " foo bar" # two arguments required
|
|
|
|
script.Script(f, tmaster) # Loads the script file.
|