Exemplo n.º 1
0
 def test_verify_plugin_bad_structure(self):
     """Verify that verify_plugin method returns False if the plugin appears invalid due
     to having an invalid structure (support files in sub-folder; only module.py and
     README allowed in root)"""
     bad_plugin_installer = plugin_installer.RemotePluginInstaller(self.badstructure_plugin_url)
     bad_plugin_installer.fetch()
     self.assertFalse(bad_plugin_installer.verify_plugin())
Exemplo n.º 2
0
 def test_init(self):
     """Verify correct initialization"""
     uname = random.sample(string.ascii_letters, 7)
     pword = random.sample(string.ascii_letters, 11)
     zip_pword = random.sample(string.ascii_letters, 9)
     a_plugin_fetcher = plugin_installer.RemotePluginInstaller(self.good_plugin_url,
                                                               username=uname, password=pword,
                                                               zip_password=zip_pword)
     self.assertEqual(self.good_plugin_url, a_plugin_fetcher.plugin_url)
     self.assertEqual(uname, a_plugin_fetcher.plugin_url_username)
     self.assertEqual(pword, a_plugin_fetcher.plugin_url_password)
     self.assertEqual(zip_pword, a_plugin_fetcher.zip_password)
     self.assertIsNone(a_plugin_fetcher.plugin)
     self.assertIsNone(a_plugin_fetcher.plugin_contents)
Exemplo n.º 3
0
 def test_install_plugin(self):
     """Verify install_plugin method correctly installs a plugin; also
     verifies handling of encrypted ZIPs"""
     sample_plugin_url = TestRemotePluginInstaller.plugin_url('greets_plugin.zip')
     installed_plugin_name = os.path.join(pathfinder.plugins_path(), 'greets_plugin.py')
     installer = plugin_installer.RemotePluginInstaller(sample_plugin_url, zip_password='******')
     installer.fetch()
     self.assertTrue(installer.verify_plugin())
     install_success = installer.install_plugin()
     self.assertTrue(os.path.exists(installed_plugin_name))
     self.assertTrue(install_success)
     # Clean up - attempt to remove the sample plugin if it already exists
     if os.path.exists(installed_plugin_name):
         try:
             os.remove(installed_plugin_name)
         except WindowsError: # file in use
             return
 def get_plugin(self, url_dict):
     """Downloads the plugin"""
     plugin_url = url_dict.get('url')
     module_logger.info("Downloading plugin from {0}".format(plugin_url))
     if url_dict.get('login', False):
         username = url_dict.get('username')
         password = url_dict.get('password')
         module_logger.info("username and password fields set")
     else:
         username = None
         password = None
         module_logger.info("username and password fields set to None")
     if url_dict.get('zip_encrypted', False):
         zip_password = url_dict.get('zip_password')
         module_logger.info("zip_password field set")
     else:
         zip_password = None
         module_logger.info("zip_password field set to None")
     self.plugin_fetcher = plugin_installer.RemotePluginInstaller(plugin_url, username,
                                                                  password,
                                                                  zip_password)
     self.plugin_fetcher.fetch()
Exemplo n.º 5
0
 def test_verify_plugin_bad_noreadme(self):
     """Verify that verify_plugin method returns False if the plugin appears invalid due
     to not having a README file in the root."""
     bad_plugin_installer = plugin_installer.RemotePluginInstaller(self.badnoreadme_plugin_url)
     bad_plugin_installer.fetch()
     self.assertFalse(bad_plugin_installer.verify_plugin())
Exemplo n.º 6
0
 def test_verify_plugin_bad_readme(self):
     """Verify that verify_plugin method returns False if the plugin appears invalid due
     to improperly-named README."""
     bad_plugin_installer = plugin_installer.RemotePluginInstaller(self.badreadme_plugin_url)
     bad_plugin_installer.fetch()
     self.assertFalse(bad_plugin_installer.verify_plugin())
Exemplo n.º 7
0
 def setUp(self):
     """Creates a SimpleHTTPServer instance to handle a single
     request.  Use self.server_thd.start() to initiate."""
     #self.server_thd = threading.Thread(target=TestRemotePluginInstaller.httpd.handle_request)
     self.good_plugin_installer = plugin_installer.RemotePluginInstaller(self.good_plugin_url)
     self.plugin_reader = zipper.UnZipper(self.good_plugin)