Fixes on tests0
This commit is contained in:
parent
277f3cf760
commit
d0c7c760af
|
@ -51,6 +51,7 @@ class PasswdVirtualUserBackend(ServiceController):
|
|||
filtering = mailbox.get_filtering()
|
||||
if filtering:
|
||||
context['filtering'] = '# %(banner)s\n' + filtering
|
||||
self.append("mkdir -p $(dirname '%(filtering_path)s')" % context)
|
||||
self.append("echo '%(filtering)s' > %(filtering_path)s" % context)
|
||||
else:
|
||||
self.append("rm -f %(filtering_path)s" % context)
|
||||
|
@ -159,10 +160,10 @@ class PostfixAddressBackend(ServiceController):
|
|||
|
||||
def exclude_virtual_alias_maps(self, context):
|
||||
self.append(textwrap.dedent("""
|
||||
if [[ $(grep "^%(email)s\s") ]]; then
|
||||
if [[ $(grep "^%(email)s\s" %(virtual_alias_maps)s) ]]; then
|
||||
sed -i "/^%(email)s\s.*$/d" %(virtual_alias_maps)s
|
||||
UPDATED_VIRTUAL_ALIAS_MAPS=1
|
||||
fi"""
|
||||
fi""" % context
|
||||
))
|
||||
|
||||
def save(self, address):
|
||||
|
|
|
@ -33,6 +33,7 @@ def close_connection(execute):
|
|||
try:
|
||||
log = execute(*args, **kwargs)
|
||||
except:
|
||||
logger.error('EXCEPTION executing backend %s %s' % (str(args), str(kwargs)))
|
||||
raise
|
||||
else:
|
||||
# Using the wrapper function as threader messenger for the execute output
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from django.core.exceptions import ObjectDoesNotExist
|
||||
|
||||
from orchestra.apps.accounts.models import Account
|
||||
from orchestra.core import services
|
||||
|
||||
|
@ -16,7 +18,10 @@ def get_related_objects(origin, max_depth=2):
|
|||
yield getattr(node, field.name)
|
||||
for field in node._meta.fields:
|
||||
if field.rel:
|
||||
yield getattr(node, field.name)
|
||||
try:
|
||||
yield getattr(node, field.name)
|
||||
except ObjectDoesNotExist:
|
||||
pass
|
||||
|
||||
# BFS model relation transversal
|
||||
queue = [[origin]]
|
||||
|
|
|
@ -61,10 +61,10 @@ class ServiceHandler(plugins.Plugin):
|
|||
return None
|
||||
value, unit = self.ignore_period.split('_')
|
||||
value = text2int(value)
|
||||
if unit.lowe().startswith('day'):
|
||||
return timedelta(days=value)
|
||||
if unit.lowe().startswith('month'):
|
||||
return timedelta(months=value)
|
||||
if unit.lower().startswith('day'):
|
||||
return datetime.timedelta(days=value)
|
||||
if unit.lower().startswith('month'):
|
||||
return datetime.timedelta(months=value)
|
||||
else:
|
||||
raise ValueError("Unknown unit %s" % unit)
|
||||
|
||||
|
|
|
@ -22,11 +22,15 @@ class SystemUserBackend(ServiceController):
|
|||
usermod %(username)s --password '%(password)s' --shell %(shell)s %(groups_arg)s
|
||||
else
|
||||
useradd %(username)s --home %(home)s --password '%(password)s' --shell %(shell)s %(groups_arg)s
|
||||
usermod -a -G %(username)s %(mainusername)s
|
||||
fi
|
||||
mkdir -p %(home)s
|
||||
chown %(username)s.%(username)s %(home)s""" % context
|
||||
))
|
||||
for member in settings.SYSTEMUSERS_DEFAULT_GROUP_MEMBERS:
|
||||
context['member'] = member
|
||||
self.append('usermod -a -G %(username)s %(member)s' % context)
|
||||
if not user.is_main:
|
||||
self.append('usermod -a -G %(username)s %(mainusername)s' % context)
|
||||
|
||||
def delete(self, user):
|
||||
context = self.get_context(user)
|
||||
|
@ -45,9 +49,7 @@ class SystemUserBackend(ServiceController):
|
|||
def get_groups(self, user):
|
||||
if user.is_main:
|
||||
return user.account.systemusers.exclude(username=user.username).values_list('username', flat=True)
|
||||
groups = list(user.groups.values_list('username', flat=True))
|
||||
groups += list(settings.SYSTEMUSERS_DEFAULT_GROUP_MEMBERS)
|
||||
return groups
|
||||
return list(user.groups.values_list('username', flat=True))
|
||||
|
||||
def get_context(self, user):
|
||||
context = {
|
||||
|
|
|
@ -263,7 +263,8 @@ class AdminSystemUserMixin(SystemUserMixin):
|
|||
|
||||
@snapshot_on_error
|
||||
def delete_account(self, username):
|
||||
self.admin_delete(self.account)
|
||||
account = Account.objects.get(username=username)
|
||||
self.admin_delete(account)
|
||||
|
||||
@snapshot_on_error
|
||||
def disable(self, username):
|
||||
|
@ -317,6 +318,10 @@ class AdminSystemUserTest(AdminSystemUserMixin, BaseLiveServerTestCase):
|
|||
password = self.selenium.find_element_by_id('id_password2')
|
||||
password.send_keys(account_password)
|
||||
|
||||
full_name = random_ascii(10)
|
||||
full_name_field = self.selenium.find_element_by_id('id_full_name')
|
||||
full_name_field.send_keys(full_name)
|
||||
|
||||
account_email = 'orchestra@orchestra.lan'
|
||||
email = self.selenium.find_element_by_id('id_email')
|
||||
email.send_keys(account_email)
|
||||
|
@ -330,9 +335,8 @@ class AdminSystemUserTest(AdminSystemUserMixin, BaseLiveServerTestCase):
|
|||
email.submit()
|
||||
self.assertNotEqual(url, self.selenium.current_url)
|
||||
|
||||
account = Account.objects.get(username=account_username)
|
||||
self.addCleanup(self.delete_account, account_username)
|
||||
self.assertEqual(0, sshr(self.MASTER_SERVER, "id %s" % account.username).return_code)
|
||||
self.assertEqual(0, sshr(self.MASTER_SERVER, "id %s" % account_username).return_code)
|
||||
|
||||
@snapshot_on_error
|
||||
def test_delete_account(self):
|
||||
|
@ -368,4 +372,4 @@ class AdminSystemUserTest(AdminSystemUserMixin, BaseLiveServerTestCase):
|
|||
# Reenable for test cleanup
|
||||
self.account.is_active = True
|
||||
self.account.save()
|
||||
# self.admin_login()
|
||||
self.admin_login()
|
||||
|
|
|
@ -30,7 +30,7 @@ class PHPFPMBackend(WebAppServiceMixin, ServiceController):
|
|||
|
||||
def delete(self, webapp):
|
||||
context = self.get_context(webapp)
|
||||
self.append("rm '%(fpm_config)s'" % context)
|
||||
self.append("rm '%(fpm_path)s'" % context)
|
||||
self.delete_webapp_dir(context)
|
||||
|
||||
def commit(self):
|
||||
|
|
|
@ -99,7 +99,8 @@ class RESTWebAppMixin(object):
|
|||
|
||||
@save_response_on_error
|
||||
def save_systemuser(self):
|
||||
self.rest.systemusers.retrieve().get().save()
|
||||
systemuser = self.rest.systemusers.retrieve().get()
|
||||
systemuser.update(is_active=True)
|
||||
|
||||
@save_response_on_error
|
||||
def add_webapp(self, name, options=[]):
|
||||
|
|
Loading…
Reference in New Issue