Ejemplo n.º 1
0
 def setUp(self):
     super(ServerAuthenticationMiddlewareTestCase, self).setUp()
     app = mock.Mock()
     self._state = CouchServerState(self.couch_url)
     app.state = self._state
     self.auth_middleware = SoledadTokenAuthMiddleware(app)
     self._authorize('valid-uuid', 'valid-token')
Ejemplo n.º 2
0
def application(environ, start_response):
    conf = load_configuration('/etc/soledad/soledad-server.conf')
    conf = conf['soledad-server']
    state = CouchServerState(conf['couch_url'], create_cmd=conf['create_cmd'])
    SoledadBackend.BATCH_SUPPORT = conf['batching']
    # WSGI application that may be used by `twistd -web`
    application = GzipMiddleware(SoledadTokenAuthMiddleware(SoledadApp(state)))

    return application(environ, start_response)
Ejemplo n.º 3
0
 def test_wrong_couch_version_raises(self):
     wrong_schema_version = SCHEMA_VERSION + 1
     self.db.create({
         '_id': CONFIG_DOC_ID,
         SCHEMA_VERSION_KEY: wrong_schema_version
     })
     with pytest.raises(WrongCouchSchemaVersionError):
         CouchServerState(self.couch_url,
                          create_cmd='/bin/echo',
                          check_schema_versions=True)
Ejemplo n.º 4
0
 def make_app(self):
     self.request_state = CouchServerState(self.couch_url)
     return self.make_app_with_state(self.request_state)
Ejemplo n.º 5
0
def _get_backend_from_config():
    conf = get_config()
    if conf['blobs']:
        return BlobsServerState("filesystem", blobs_path=conf['blobs_path'])
    return CouchServerState(conf['couch_url'])
Ejemplo n.º 6
0
def _get_couch_state(conf):
    state = CouchServerState(conf['couch_url'], create_cmd=conf['create_cmd'])
    SoledadBackend.BATCH_SUPPORT = conf.get('batching', False)
    return state
Ejemplo n.º 7
0
 def test_missing_config_doc_raises(self):
     self.db.create({})
     with pytest.raises(MissingCouchConfigDocumentError):
         CouchServerState(self.couch_url,
                          create_cmd='/bin/echo',
                          check_schema_versions=True)
Ejemplo n.º 8
0
def _get_couch_state():
    conf = _load_config()
    state = CouchServerState(conf['couch_url'], create_cmd=conf['create_cmd'],
                             check_schema_versions=True)
    SoledadBackend.BATCH_SUPPORT = conf.get('batching', False)
    return state