コード例 #1
0
ファイル: base_test.py プロジェクト: tdgunes/cti-taxii-server
    def setUp(self):
        if self.type == "mongo":
            reset_db()
            create_users()
            self.configuration = self.mongodb_config
        elif self.type == "memory":
            self.memory_config['backend']['filename'] = self.DATA_FILE
            self.configuration = self.memory_config
        elif self.type == "directory":
            self.configuration = self.directory_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!")

        self.app = create_app(self.configuration)
        self.app_context = self.app.app_context()
        self.app_context.push()

        # TODO: It might be better to not reuse the test client.
        self.client = self.app.test_client()
        self.auth = {'Authorization': 'Token abc123'}
コード例 #2
0
ファイル: base_test.py プロジェクト: ping95/msa
 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}
コード例 #3
0
def backend():
    reset_db()
    init({
        "backend": {
            "type": "mongodb",
            "url": "mongodb://localhost:27017/"
        },
        "users": []
    })
    return get_backend()
コード例 #4
0
ファイル: test_views.py プロジェクト: eiyuki/cti-taxii-server
    def setUp(self):
        reset_db()
        self.configuration = config.mongodb_config()
        self.configuration['backend']['default_page_size'] = 20

        self.app = create_app(self.configuration)

        self.app_context = self.app.app_context()
        self.app_context.push()

        self.client = self.app.test_client()
        self.auth = {'Authorization': 'Token abc123'}
コード例 #5
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.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}
コード例 #6
0
 def setUp(self):
     self.app = application_instance
     self.application_context = self.app.app_context()
     self.application_context.push()
     self.app.testing = True
     register_blueprints(self.app)
     reset_db()
     self.configuration = {
         "backend": {
             "module": "medallion.backends.mongodb_backend",
             "module_class": "MongoBackend",
             "url": "mongodb://localhost:27017/"
         },
         "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}
コード例 #7
0
def backend():
    reset_db()
    init_backend({"type": "mongodb", "url": "mongodb://localhost:27017/"})
    return get_backend()