get UNIXUserController instead of SystemUserBackend and RoundcubeIdentityController instead of PasswdVirtualUserBackend

This commit is contained in:
Cayo Puigdefabregas 2021-02-10 18:18:40 +01:00
parent 7bee5facbc
commit 4286c4f77a
4 changed files with 26 additions and 28 deletions

View File

@ -149,7 +149,7 @@ class ListMixin(object):
self.update_address_name(name, address_name) self.update_address_name(name, address_name)
self.validate_add(name, address="%s@%s" % (address_name, address_domain)) self.validate_add(name, address="%s@%s" % (address_name, address_domain))
@skip("Skip because not exists get_auth_token in orm.api.Api") # @skip("Skip because not exists get_auth_token in orm.api.Api")
def test_delete(self): def test_delete(self):
name = '%s_list' % random_ascii(10) name = '%s_list' % random_ascii(10)
password = '@!?%spppP001' % random_ascii(5) password = '@!?%spppP001' % random_ascii(5)

View File

@ -40,7 +40,7 @@ class MailboxMixin(object):
def add_route(self): def add_route(self):
server = Server.objects.create(name=self.MASTER_SERVER) server = Server.objects.create(name=self.MASTER_SERVER)
backend = backends.PasswdVirtualUserBackend.get_name() backend = backends.RoundcubeIdentityController.get_name()
Route.objects.create(backend=backend, match=True, host=server) Route.objects.create(backend=backend, match=True, host=server)
backend = backends.PostfixAddressController.get_name() backend = backends.PostfixAddressController.get_name()
Route.objects.create(backend=backend, match=True, host=server) Route.objects.create(backend=backend, match=True, host=server)
@ -49,7 +49,6 @@ class MailboxMixin(object):
Resource.objects.create( Resource.objects.create(
name='disk', name='disk',
content_type=ContentType.objects.get_for_model(Mailbox), content_type=ContentType.objects.get_for_model(Mailbox),
period=Resource.LAST,
verbose_name='Mail quota', verbose_name='Mail quota',
unit='MB', unit='MB',
scale=10**6, scale=10**6,
@ -109,7 +108,7 @@ class MailboxMixin(object):
home = Mailbox.objects.get(name=username).get_home() home = Mailbox.objects.get(name=username).get_home()
sshrun(self.MASTER_SERVER, "grep '%s' %s/Maildir/new/*" % (token, home), display=False) sshrun(self.MASTER_SERVER, "grep '%s' %s/Maildir/new/*" % (token, home), display=False)
@skip("Skip because not exists PasswdVirtualUserBackend") @skip("Skip because not exists get_auth_token in orm.api.Api")
def test_add(self): def test_add(self):
username = '%s_mailbox' % random_ascii(10) username = '%s_mailbox' % random_ascii(10)
password = '@!?%spppP001' % random_ascii(5) password = '@!?%spppP001' % random_ascii(5)
@ -118,7 +117,7 @@ class MailboxMixin(object):
imap = self.login_imap(username, password) imap = self.login_imap(username, password)
self.validate_mailbox(username) self.validate_mailbox(username)
@skip("Skip because not exists PasswdVirtualUserBackend") @skip("Skip because not exists get_auth_token in orm.api.Api")
def test_change_password(self): def test_change_password(self):
username = '%s_systemuser' % random_ascii(10) username = '%s_systemuser' % random_ascii(10)
password = '@!?%spppP001' % random_ascii(5) password = '@!?%spppP001' % random_ascii(5)
@ -129,7 +128,7 @@ class MailboxMixin(object):
self.change_password(username, new_password) self.change_password(username, new_password)
imap = self.login_imap(username, new_password) imap = self.login_imap(username, new_password)
@skip("Skip because not exists PasswdVirtualUserBackend") @skip("Skip because not exists get_auth_token in orm.api.Api")
def test_quota(self): def test_quota(self):
username = '%s_mailbox' % random_ascii(10) username = '%s_mailbox' % random_ascii(10)
password = '@!?%spppP001' % random_ascii(5) password = '@!?%spppP001' % random_ascii(5)
@ -144,7 +143,7 @@ class MailboxMixin(object):
imap_quota = int(imap.getquotaroot("INBOX")[1][1][0].split(' ')[-1].split(')')[0]) imap_quota = int(imap.getquotaroot("INBOX")[1][1][0].split(' ')[-1].split(')')[0])
self.assertEqual(quota*1024, imap_quota) self.assertEqual(quota*1024, imap_quota)
@skip("Skip because not exists PasswdVirtualUserBackend") @skip("Skip because not exists get_auth_token in orm.api.Api")
def test_send_email(self): def test_send_email(self):
username = '%s_mailbox' % random_ascii(10) username = '%s_mailbox' % random_ascii(10)
password = '@!?%spppP001' % random_ascii(5) password = '@!?%spppP001' % random_ascii(5)
@ -161,7 +160,7 @@ class MailboxMixin(object):
finally: finally:
server.quit() server.quit()
@skip("Skip because not exists PasswdVirtualUserBackend") @skip("Skip because not exists get_auth_token in orm.api.Api")
def test_address(self): def test_address(self):
username = '%s_mailbox' % random_ascii(10) username = '%s_mailbox' % random_ascii(10)
password = '@!?%spppP001' % random_ascii(5) password = '@!?%spppP001' % random_ascii(5)
@ -175,7 +174,7 @@ class MailboxMixin(object):
self.send_email("%s@%s" % (name, domain), token) self.send_email("%s@%s" % (name, domain), token)
self.validate_email(username, token) self.validate_email(username, token)
@skip("Skip because not exists PasswdVirtualUserBackend") @skip("Skip because not exists get_auth_token in orm.api.Api")
def test_disable(self): def test_disable(self):
username = '%s_systemuser' % random_ascii(10) username = '%s_systemuser' % random_ascii(10)
password = '@!?%spppP001' % random_ascii(5) password = '@!?%spppP001' % random_ascii(5)
@ -186,7 +185,7 @@ class MailboxMixin(object):
self.disable(username) self.disable(username)
self.assertRaises(imap.error, self.login_imap, username, password) self.assertRaises(imap.error, self.login_imap, username, password)
@skip("Skip because not exists PasswdVirtualUserBackend") @skip("Skip because not exists get_auth_token in orm.api.Api")
def test_delete(self): def test_delete(self):
username = '%s_systemuser' % random_ascii(10) username = '%s_systemuser' % random_ascii(10)
password = '@!?%sppppP001' % random_ascii(5) password = '@!?%sppppP001' % random_ascii(5)
@ -202,7 +201,7 @@ class MailboxMixin(object):
self.assertRaises(CommandError, self.assertRaises(CommandError,
sshrun, self.MASTER_SERVER, 'ls %s' % home, display=False) sshrun, self.MASTER_SERVER, 'ls %s' % home, display=False)
@skip("Skip because not exists PasswdVirtualUserBackend") @skip("Skip because not exists get_auth_token in orm.api.Api")
def test_delete_address(self): def test_delete_address(self):
username = '%s_mailbox' % random_ascii(10) username = '%s_mailbox' % random_ascii(10)
password = '@!?%spppP001' % random_ascii(5) password = '@!?%spppP001' % random_ascii(5)
@ -219,7 +218,7 @@ class MailboxMixin(object):
self.send_email("%s@%s" % (name, domain), token) self.send_email("%s@%s" % (name, domain), token)
self.validate_email(username, token) self.validate_email(username, token)
@skip("Skip because not exists PasswdVirtualUserBackend") @skip("Skip because not exists get_auth_token in orm.api.Api")
def test_custom_filtering(self): def test_custom_filtering(self):
username = '%s_mailbox' % random_ascii(10) username = '%s_mailbox' % random_ascii(10)
password = '@!?%spppP001' % random_ascii(5) password = '@!?%spppP001' % random_ascii(5)

View File

@ -40,7 +40,7 @@ class SystemUserMixin(object):
def add_route(self): def add_route(self):
master = Server.objects.create(name=self.MASTER_SERVER) master = Server.objects.create(name=self.MASTER_SERVER)
backend = backends.SystemUserBackend.get_name() backend = backends.UNIXUserController.get_name()
Route.objects.create(backend=backend, match=True, host=master) Route.objects.create(backend=backend, match=True, host=master)
def save(self): def save(self):
@ -105,7 +105,7 @@ class SystemUserMixin(object):
self.assertEqual(0, channel.recv_exit_status()) self.assertEqual(0, channel.recv_exit_status())
channel.close() channel.close()
@skip("Skip because not exists SystemUserBackend") @skip("Skip because not exists get_auth_token in orm.api.Api")
def test_add(self): def test_add(self):
username = '%s_systemuser' % random_ascii(10) username = '%s_systemuser' % random_ascii(10)
password = '@!?%spppP001' % random_ascii(5) password = '@!?%spppP001' % random_ascii(5)
@ -113,7 +113,7 @@ class SystemUserMixin(object):
self.addCleanup(self.delete, username) self.addCleanup(self.delete, username)
self.validate_user(username) self.validate_user(username)
@skip("Skip because not exists SystemUserBackend") @skip("Skip because not exists get_auth_token in orm.api.Api")
def test_ftp(self): def test_ftp(self):
username = '%s_systemuser' % random_ascii(10) username = '%s_systemuser' % random_ascii(10)
password = '@!?%spppP001' % random_ascii(5) password = '@!?%spppP001' % random_ascii(5)
@ -124,7 +124,7 @@ class SystemUserMixin(object):
self.assertRaises(paramiko.AuthenticationException, self.assertRaises(paramiko.AuthenticationException,
self.validate_ssh, username, password) self.validate_ssh, username, password)
@skip("Skip because not exists SystemUserBackend") @skip("Skip because not exists get_auth_token in orm.api.Api")
def test_sftp(self): def test_sftp(self):
username = '%s_systemuser' % random_ascii(10) username = '%s_systemuser' % random_ascii(10)
password = '@!?%spppP001' % random_ascii(5) password = '@!?%spppP001' % random_ascii(5)
@ -133,7 +133,7 @@ class SystemUserMixin(object):
self.validate_sftp(username, password) self.validate_sftp(username, password)
self.assertRaises(AssertionError, self.validate_ssh, username, password) self.assertRaises(AssertionError, self.validate_ssh, username, password)
@skip("Skip because not exists SystemUserBackend") @skip("Skip because not exists get_auth_token in orm.api.Api")
def test_ssh(self): def test_ssh(self):
username = '%s_systemuser' % random_ascii(10) username = '%s_systemuser' % random_ascii(10)
password = '@!?%spppP001' % random_ascii(5) password = '@!?%spppP001' % random_ascii(5)
@ -141,7 +141,7 @@ class SystemUserMixin(object):
self.addCleanup(self.delete, username) self.addCleanup(self.delete, username)
self.validate_ssh(username, password) self.validate_ssh(username, password)
@skip("Skip because not exists SystemUserBackend") @skip("Skip because not exists get_auth_token in orm.api.Api")
def test_delete(self): def test_delete(self):
username = '%s_systemuser' % random_ascii(10) username = '%s_systemuser' % random_ascii(10)
password = '@!?%sppppP001' % random_ascii(5) password = '@!?%sppppP001' % random_ascii(5)
@ -151,7 +151,7 @@ class SystemUserMixin(object):
self.validate_delete(username) self.validate_delete(username)
self.assertRaises(Exception, self.delete, self.account.username) self.assertRaises(Exception, self.delete, self.account.username)
@skip("Skip because not exists SystemUserBackend") @skip("Skip because not exists get_auth_token in orm.api.Api")
def test_add_group(self): def test_add_group(self):
username = '%s_systemuser' % random_ascii(10) username = '%s_systemuser' % random_ascii(10)
password = '@!?%spppP001' % random_ascii(5) password = '@!?%spppP001' % random_ascii(5)
@ -169,7 +169,7 @@ class SystemUserMixin(object):
self.assertIn(username2, groups) self.assertIn(username2, groups)
self.validate_user(username) self.validate_user(username)
@skip("Skip because not exists SystemUserBackend") @skip("Skip because not exists get_auth_token in orm.api.Api")
def test_disable(self): def test_disable(self):
username = '%s_systemuser' % random_ascii(10) username = '%s_systemuser' % random_ascii(10)
password = '@!?%spppP001' % random_ascii(5) password = '@!?%spppP001' % random_ascii(5)
@ -180,7 +180,7 @@ class SystemUserMixin(object):
self.validate_user(username) self.validate_user(username)
self.assertRaises(ftplib.error_perm, self.validate_ftp, username, password) self.assertRaises(ftplib.error_perm, self.validate_ftp, username, password)
@skip("Skip because not exists SystemUserBackend") @skip("Skip because not exists get_auth_token in orm.api.Api")
def test_change_password(self): def test_change_password(self):
username = '%s_systemuser' % random_ascii(10) username = '%s_systemuser' % random_ascii(10)
password = '@!?%spppP001' % random_ascii(5) password = '@!?%spppP001' % random_ascii(5)
@ -312,7 +312,7 @@ class RESTSystemUserTest(RESTSystemUserMixin, BaseLiveServerTestCase):
class AdminSystemUserTest(AdminSystemUserMixin, BaseLiveServerTestCase): class AdminSystemUserTest(AdminSystemUserMixin, BaseLiveServerTestCase):
@skip("Skip because not exists SystemUserBackend") @skip("Skip because not exists get_auth_token in orm.api.Api")
@snapshot_on_error @snapshot_on_error
def test_create_account(self): def test_create_account(self):
url = self.live_server_url + reverse('admin:accounts_account_add') url = self.live_server_url + reverse('admin:accounts_account_add')
@ -348,7 +348,7 @@ class AdminSystemUserTest(AdminSystemUserMixin, BaseLiveServerTestCase):
self.addCleanup(self.delete_account, account_username) self.addCleanup(self.delete_account, account_username)
self.assertEqual(0, sshr(self.MASTER_SERVER, "id %s" % account_username).exit_code) self.assertEqual(0, sshr(self.MASTER_SERVER, "id %s" % account_username).exit_code)
@skip("Skip because not exists SystemUserBackend") @skip("Skip because not exists get_auth_token in orm.api.Api")
@snapshot_on_error @snapshot_on_error
def test_delete_account(self): def test_delete_account(self):
home = self.account.main_systemuser.get_home() home = self.account.main_systemuser.get_home()
@ -359,7 +359,7 @@ class AdminSystemUserTest(AdminSystemUserMixin, BaseLiveServerTestCase):
self.selenium.delete_all_cookies() self.selenium.delete_all_cookies()
self.admin_login() self.admin_login()
@skip("Skip because not exists SystemUserBackend") @skip("Skip because not exists get_auth_token in orm.api.Api")
@snapshot_on_error @snapshot_on_error
def test_disable_account(self): def test_disable_account(self):
username = '%s_systemuser' % random_ascii(10) username = '%s_systemuser' % random_ascii(10)

View File

@ -6,7 +6,7 @@ from unittest import skip
from django.conf import settings as djsettings from django.conf import settings as djsettings
from orchestra.contrib.orchestration.models import Server, Route from orchestra.contrib.orchestration.models import Server, Route
# from orchestra.contrib.systemusers.backends import SystemUserBackend from orchestra.contrib.systemusers.backends import UNIXUserController
from orchestra.utils.tests import BaseLiveServerTestCase, random_ascii, snapshot_on_error, save_response_on_error from orchestra.utils.tests import BaseLiveServerTestCase, random_ascii, snapshot_on_error, save_response_on_error
from ... import backends from ... import backends
@ -27,9 +27,8 @@ class WebAppMixin(object):
def add_route(self): def add_route(self):
server, __ = Server.objects.get_or_create(name=self.MASTER_SERVER) server, __ = Server.objects.get_or_create(name=self.MASTER_SERVER)
# TODO we don't have SystemUserBackend backend = UNIXUserController.get_name()
# backend = SystemUserBackend.get_name() Route.objects.get_or_create(backend=backend, match=True, host=server)
# Route.objects.get_or_create(backend=backend, match=True, host=server)
backend = self.backend.get_name() backend = self.backend.get_name()
match = 'webapp.type == "%s"' % self.type_value match = 'webapp.type == "%s"' % self.type_value
Route.objects.create(backend=backend, match=match, host=server) Route.objects.create(backend=backend, match=match, host=server)