Ejemplo n.º 1
0
 def test_custom(self):
     config.set("auth", "type", "custom")
     config.set("auth", "custom_handler", "tests.custom.auth")
     self.application = radicale.Application()
     status, headers, answer = self.request(
         "GET", "/", HTTP_AUTHORIZATION=self.userpass)
     assert status == 200
     assert "Radicale works!" in answer
Ejemplo n.º 2
0
 def setup(self):
     """Setup function for each test."""
     self.colpath = tempfile.mkdtemp()
     config.set("storage", "type", self.storage_type)
     from radicale.storage import filesystem
     filesystem.FOLDER = self.colpath
     filesystem.GIT_REPOSITORY = None
     self.application = radicale.Application()
Ejemplo n.º 3
0
 def setup(self):
     """Setup function for each test."""
     self.colpath = tempfile.mkdtemp()
     config.set("storage", "type", self.storage_type)
     from radicale.storage import filesystem
     filesystem.FOLDER = self.colpath
     filesystem.GIT_REPOSITORY = None
     self.application = radicale.Application()
Ejemplo n.º 4
0
 def test_custom(self):
     """Custom authentication."""
     config.set("auth", "type", "custom")
     config.set("auth", "custom_handler", "tests.custom.auth")
     self.application = radicale.Application()
     status, headers, answer = self.request("GET", "/", HTTP_AUTHORIZATION=self.userpass)
     assert status == 200
     assert "Radicale works!" in answer
Ejemplo n.º 5
0
 def setup(self):
     """Setup function for each test."""
     self.colpath = tempfile.mkdtemp()
     config.set("storage", "type", self.storage_type)
     config.set("storage", "custom_handler", "tests.custom.storage")
     from tests.custom import storage
     storage.FOLDER = self.colpath
     storage.GIT_REPOSITORY = None
     self.application = radicale.Application()
Ejemplo n.º 6
0
 def setup(self):
     """Setup function for each test."""
     self.colpath = tempfile.mkdtemp()
     config.set("storage", "type", self.storage_type)
     config.set("storage", "custom_handler", "tests.custom.storage")
     from tests.custom import storage
     storage.FOLDER = self.colpath
     storage.GIT_REPOSITORY = None
     self.application = radicale.Application()
Ejemplo n.º 7
0
 def setup(self):
     config.set("storage", "type", "database")
     config.set("storage", "database_url", "sqlite://")
     from radicale.storage import database
     database.Session = sessionmaker()
     database.Session.configure(bind=create_engine("sqlite://"))
     session = database.Session()
     for st in get_file_content("schema.sql").split(";"):
         session.execute(st)
     session.commit()
     self.application = radicale.Application()
Ejemplo n.º 8
0
 def setup(self):
     self.colpath = tempfile.mkdtemp()
     htpasswd_file_path = os.path.join(self.colpath, ".htpasswd")
     with open(htpasswd_file_path, "wb") as fd:
         fd.write(b"tmp:{SHA}" + base64.b64encode(
             hashlib.sha1(b"bepo").digest()))
     config.set("auth", "type", "htpasswd")
     self.userpass = "******"
     self.application = radicale.Application()
     htpasswd.FILENAME = htpasswd_file_path
     htpasswd.ENCRYPTION = "sha1"
Ejemplo n.º 9
0
 def setup(self):
     config.set("storage", "type", "database")
     config.set("storage", "database_url", "sqlite://")
     from radicale.storage import database
     database.Session = sessionmaker()
     database.Session.configure(bind=create_engine("sqlite://"))
     session = database.Session()
     for st in get_file_content("schema.sql").split(";"):
         session.execute(st)
     session.commit()
     self.application = radicale.Application()
Ejemplo n.º 10
0
 def setup(self):
     self.colpath = tempfile.mkdtemp()
     htpasswd_file_path = os.path.join(self.colpath, ".htpasswd")
     with open(htpasswd_file_path, "wb") as fd:
         fd.write(b"tmp:{SHA}" +
                  base64.b64encode(hashlib.sha1(b"bepo").digest()))
     config.set("auth", "type", "htpasswd")
     self.userpass = "******"
     self.application = radicale.Application()
     htpasswd.FILENAME = htpasswd_file_path
     htpasswd.ENCRYPTION = "sha1"
Ejemplo n.º 11
0
        def get_app():
            config = radicale.config.load(())
            config.set('storage', 'filesystem_folder', str(tmpdir))
            config.set('rights', 'type', 'owner_only')

            app = radicale.Application(config, logger)

            def is_authenticated(user, password):
                return user == 'bob' and password == 'bob'

            app.is_authenticated = is_authenticated
            return app
Ejemplo n.º 12
0
        def get_app():
            config = radicale.config.load(())
            config.set('storage', 'filesystem_folder', str(tmpdir))
            config.set('rights', 'type', 'owner_only')

            app = radicale.Application(config, logger)

            def is_authenticated(user, password):
                return user == 'bob' and password == 'bob'

            app.is_authenticated = is_authenticated
            return app
Ejemplo n.º 13
0
    def test_root(self):
        """Htpasswd authentication."""
        self.colpath = tempfile.mkdtemp()
        htpasswd_file_path = os.path.join(self.colpath, ".htpasswd")
        with open(htpasswd_file_path, "wb") as fd:
            fd.write(b"tmp:{SHA}" + base64.b64encode(hashlib.sha1(b"bepo").digest()))
        config.set("auth", "type", "htpasswd")

        htpasswd.FILENAME = htpasswd_file_path
        htpasswd.ENCRYPTION = "sha1"

        self.application = radicale.Application()

        status, headers, answer = self.request("GET", "/", HTTP_AUTHORIZATION=self.userpass)
        assert status == 200
        assert "Radicale works!" in answer
Ejemplo n.º 14
0
    def test_root(self):
        self.colpath = tempfile.mkdtemp()
        htpasswd_file_path = os.path.join(self.colpath, ".htpasswd")
        with open(htpasswd_file_path, "wb") as fd:
            fd.write(b"tmp:{SHA}" +
                     base64.b64encode(hashlib.sha1(b"bepo").digest()))
        config.set("auth", "type", "htpasswd")

        htpasswd.FILENAME = htpasswd_file_path
        htpasswd.ENCRYPTION = "sha1"

        self.application = radicale.Application()

        status, headers, answer = self.request(
            "GET", "/", HTTP_AUTHORIZATION=self.userpass)
        assert status == 200
        assert "Radicale works!" in answer
Ejemplo n.º 15
0
    def _prepare_config(self):
        from tracim.config.app_cfg import CFG
        cfg = CFG.get_instance()

        tracim_auth = 'tracim.lib.radicale.auth'
        tracim_rights = 'tracim.lib.radicale.rights'
        tracim_storage = 'tracim.lib.radicale.storage'
        fs_path = cfg.RADICALE_SERVER_FILE_SYSTEM_FOLDER
        allow_origin = cfg.RADICALE_SERVER_ALLOW_ORIGIN
        realm_message = cfg.RADICALE_SERVER_REALM_MESSAGE

        radicale_config.set('auth', 'type', 'custom')
        radicale_config.set('auth', 'custom_handler', tracim_auth)

        radicale_config.set('rights', 'type', 'custom')
        radicale_config.set('rights', 'custom_handler', tracim_rights)

        radicale_config.set('storage', 'type', 'custom')
        radicale_config.set('storage', 'custom_handler', tracim_storage)
        radicale_config.set('storage', 'filesystem_folder', fs_path)

        radicale_config.set('server', 'realm', realm_message)

        try:
            radicale_config.add_section('headers')
        except DuplicateSectionError:
            pass  # It is not a problem, we just want it exist

        if allow_origin:
            radicale_config.set(
                'headers',
                'Access-Control-Allow-Origin',
                allow_origin,
            )

        # Radicale is not 100% CALDAV Compliant, we force some Allow-Methods
        radicale_config.set(
            'headers',
            'Access-Control-Allow-Methods',
            'DELETE, HEAD, GET, MKCALENDAR, MKCOL, MOVE, OPTIONS, PROPFIND, '
            'PROPPATCH, PUT, REPORT',
        )

        # Radicale is not 100% CALDAV Compliant, we force some Allow-Headers
        radicale_config.set(
            'headers',
            'Access-Control-Allow-Headers',
            'X-Requested-With,X-Auth-Token,Content-Type,Content-Length,'
            'X-Client,Authorization,depth,Prefer,If-None-Match,If-Match',
        )
Ejemplo n.º 16
0
 def teardown(self):
     config.set("auth", "type", "None")
     radicale.auth.is_authenticated = lambda *_: True
Ejemplo n.º 17
0
    def _prepare_config(self):
        from tracim.config.app_cfg import CFG
        cfg = CFG.get_instance()

        tracim_auth = 'tracim.lib.radicale.auth'
        tracim_rights = 'tracim.lib.radicale.rights'
        tracim_storage = 'tracim.lib.radicale.storage'
        fs_path = cfg.RADICALE_SERVER_FILE_SYSTEM_FOLDER
        allow_origin = cfg.RADICALE_SERVER_ALLOW_ORIGIN
        realm_message = cfg.RADICALE_SERVER_REALM_MESSAGE

        radicale_config.set('auth', 'type', 'custom')
        radicale_config.set('auth', 'custom_handler', tracim_auth)

        radicale_config.set('rights', 'type', 'custom')
        radicale_config.set('rights', 'custom_handler', tracim_rights)

        radicale_config.set('storage', 'type', 'custom')
        radicale_config.set('storage', 'custom_handler', tracim_storage)
        radicale_config.set('storage', 'filesystem_folder', fs_path)

        radicale_config.set('server', 'realm', realm_message)

        try:
            radicale_config.add_section('headers')
        except DuplicateSectionError:
            pass  # It is not a problem, we just want it exist

        if allow_origin:
            radicale_config.set(
                'headers',
                'Access-Control-Allow-Origin',
                allow_origin,
            )

        # Radicale is not 100% CALDAV Compliant, we force some Allow-Methods
        radicale_config.set(
            'headers',
            'Access-Control-Allow-Methods',
            'DELETE, HEAD, GET, MKCALENDAR, MKCOL, MOVE, OPTIONS, PROPFIND, '
            'PROPPATCH, PUT, REPORT',
        )

        # Radicale is not 100% CALDAV Compliant, we force some Allow-Headers
        radicale_config.set(
            'headers',
            'Access-Control-Allow-Headers',
            'X-Requested-With,X-Auth-Token,Content-Type,Content-Length,'
            'X-Client,Authorization,depth,Prefer,If-None-Match,If-Match',
        )
Ejemplo n.º 18
0
 def teardown(self):
     config.set("auth", "type", "None")
     radicale.auth.is_authenticated = lambda *_: True