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
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()
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
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()
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()
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"
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"
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
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
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
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', )
def teardown(self): config.set("auth", "type", "None") radicale.auth.is_authenticated = lambda *_: True