def setup_ftp_users(self): # Define a new user with full r/w permissions return ( aioftp.User(str(self.user), str(self.pword), home_path=self.home, permissions=( aioftp.Permission('/', readable=False, writable=False), aioftp.Permission(self.home, readable=True, writable=True), ), maximum_connections=MAX_CONNECTIONS, read_speed_limit=SPEED_LIMIT, write_speed_limit=SPEED_LIMIT, read_speed_limit_per_connection=SPEED_LIMIT_PER_CONN, write_speed_limit_per_connection=SPEED_LIMIT_PER_CONN), aioftp.User(home_path=ANON_HOME_PATH, permissions=( aioftp.Permission('/', readable=False, writable=False), aioftp.Permission(ANON_HOME_PATH, readable=True), ), maximum_connections=MAX_ANON_CONNECTIONS, read_speed_limit=SPEED_LIMIT, write_speed_limit=SPEED_LIMIT, read_speed_limit_per_connection=SPEED_LIMIT_PER_CONN, write_speed_limit_per_connection=SPEED_LIMIT_PER_CONN), )
async def test_permission_overriden(pair_factory, Server): s = Server([ aioftp.User( permissions=[ aioftp.Permission("/", writable=False), aioftp.Permission("/foo"), ] ) ]) async with pair_factory(None, s) as pair: await pair.client.make_directory("foo") await pair.client.remove_directory("foo")
async def test_permission_denied(pair_factory, Server, expect_codes_in_exception): s = Server([ aioftp.User(permissions=[aioftp.Permission(writable=False)]) ]) async with pair_factory(None, s) as pair: with expect_codes_in_exception("550"): await pair.client.make_directory("foo")
def test_permission_representation(): p = aioftp.Permission(writable=False) nose.tools.eq_( repr(p), "Permission(PurePosixPath('/'), readable=True, writable=False)")
def test_permission_is_parent(): p = aioftp.Permission("/foo/bar") assert p.is_parent(pathlib.PurePosixPath("/foo/bar/baz")) assert not p.is_parent(pathlib.PurePosixPath("/bar/baz"))
def test_reprs_works(): repr(aioftp.Throttle()) repr(aioftp.Permission()) repr(aioftp.User())