Beispiel #1
0
 def setUp(self):
     self.app = application_instance
     self.app_context = application_instance.app_context()
     self.app_context.push()
     self.app.testing = True
     register_blueprints(self.app)
     self.configuration = {
         "backend": {
             "module": "medallion.backends.mongodb_backend",
             "module_class": "MongoBackend",
             "uri": "mongodb://localhost:27017/",
             "default_page_size": 20
         },
         "users": {
             "admin": "Password0"
         },
         "taxii": {
             "max_page_size": 20
         }
     }
     self.client = application_instance.test_client()
     set_users_config(self.app, self.configuration["users"])
     set_taxii_config(self.app, self.configuration["taxii"])
     encoded_auth = 'Basic ' + base64.b64encode(b"admin:Password0").decode(
         "ascii")
     self.auth = {'Authorization': encoded_auth}
Beispiel #2
0
 def setUp(self):
     self.app = application_instance
     self.app_context = application_instance.app_context()
     self.app_context.push()
     self.app.testing = True
     register_blueprints(self.app)
     if self.type == "mongo":
         reset_db(self.mongodb_config["backend"]["uri"])
         self.configuration = self.mongodb_config
     elif self.type == "memory":
         self.configuration = self.memory_config
     elif self.type == "memory_no_config":
         self.configuration = self.no_config
     elif self.type == "no_taxii":
         self.configuration = self.config_no_taxii
     elif self.type == "no_auth":
         self.configuration = self.config_no_auth
     elif self.type == "no_backend":
         self.configuration = self.config_no_backend
     else:
         raise RuntimeError("Unknown backend!")
     set_config(self.app, "backend", self.configuration)
     set_config(self.app, "users", self.configuration)
     set_config(self.app, "taxii", self.configuration)
     self.client = application_instance.test_client()
     if self.type == "memory_no_config" or self.type == "no_auth":
         encoded_auth = "Basic " + \
             base64.b64encode(b"user:pass").decode("ascii")
     else:
         encoded_auth = "Basic " + \
             base64.b64encode(b"admin:Password0").decode("ascii")
     self.auth = {"Authorization": encoded_auth}
 def setUp(self):
     self.app = application_instance
     self.app_context = application_instance.app_context()
     self.app_context.push()
     self.app.testing = True
     register_blueprints(self.app)
     if self.type == "mongo":
         reset_db()
         self.configuration = self.mongodb_config
     else:
         self.memory_config['backend']['filename'] = self.DATA_FILE
         self.configuration = self.memory_config
     init_backend(self.app, self.configuration["backend"])
     set_users_config(self.app, self.configuration["users"])
     set_taxii_config(self.app, self.configuration["taxii"])
     self.client = application_instance.test_client()
     encoded_auth = 'Basic ' + \
         base64.b64encode(b"admin:Password0").decode("ascii")
     self.auth = {'Authorization': encoded_auth}
 def setUp(self):
     self.app = application_instance
     self.app_context = application_instance.app_context()
     self.app_context.push()
     self.app.testing = True
     register_blueprints(self.app)
     self.configuration = {
         "backend": {
             "module": "medallion.backends.memory_backend",
             "module_class": "MemoryBackend",
             "filename": DATA_FILE
         },
         "users": {
             "admin": "Password0"
         }
     }
     init_backend(self.app, self.configuration["backend"])
     set_config(self.app, self.configuration["users"])
     self.client = application_instance.test_client()
     encoded_auth = 'Basic ' + base64.b64encode(b"admin:Password0").decode("ascii")
     self.auth = {'Authorization': encoded_auth}