Ejemplo n.º 1
0
 def setUpTestData(cls):
     """Create test data."""
     super(AliasAPITestCase, cls).setUpTestData()
     parameters.save_admin("ENABLE_ADMIN_LIMITS", "no", app="limits")
     factories.populate_database()
     cls.da_token = Token.objects.create(user=core_models.User.objects.get(
         username="******"))
Ejemplo n.º 2
0
 def setUp(self):
     """Initialize tests."""
     super(AccessRuleTestCase, self).setUp()
     self.rights_file_path = tempfile.mktemp()
     parameters.save_admin("RIGHTS_FILE_PATH",
                           self.rights_file_path,
                           app="modoboa_radicale")
Ejemplo n.º 3
0
 def setUp(self):
     super(AccessRuleTestCase, self).setUp()
     self.activate_extensions('radicale')
     populate_database()
     self.rights_file_path = tempfile.mktemp()
     parameters.save_admin(
         "RIGHTS_FILE_PATH", self.rights_file_path, app="radicale")
Ejemplo n.º 4
0
 def setUpTestData(cls):
     """Create test data."""
     super(AliasAPITestCase, cls).setUpTestData()
     parameters.save_admin("ENABLE_ADMIN_LIMITS", "no", app="limits")
     factories.populate_database()
     cls.da_token = Token.objects.create(
         user=core_models.User.objects.get(username="******"))
Ejemplo n.º 5
0
 def setUp(self):
     super(AccessRuleTestCase, self).setUp()
     populate_database()
     self.rights_file_path = tempfile.mktemp()
     parameters.save_admin("RIGHTS_FILE_PATH",
                           self.rights_file_path,
                           app="radicale")
Ejemplo n.º 6
0
 def setUpTestData(cls):
     """Custom setUpTestData method."""
     super(ResourceTestCase, cls).setUpTestData()
     for name, tpl in utils.get_limit_templates():
         parameters.save_admin("DEFLT_{0}_LIMIT".format(name.upper()),
                               2,
                               app="limits")
     populate_database()
Ejemplo n.º 7
0
 def setUpTestData(cls):
     """Create test data."""
     super(APIDomainLimitsTestCase, cls).setUpTestData()
     parameters.save_admin("ENABLE_DOMAIN_LIMITS", "yes")
     for name, tpl in utils.get_domain_limit_templates():
         parameters.save_admin(
             "DEFLT_DOMAIN_{}_LIMIT".format(name.upper()), 2)
     populate_database()
Ejemplo n.º 8
0
    def setUp(self):
        super(LimitsTestCase, self).setUp()

        for tpl in LimitTemplates().templates:
            parameters.save_admin("DEFLT_{0}".format(tpl[0].upper()), 2, app="limits")
        self.user = UserFactory.create(username="******", groups=("Resellers",))
        self.clt.logout()
        self.clt.login(username="******", password="******")
Ejemplo n.º 9
0
 def setUpTestData(cls):
     """Create some data."""
     super(MXTestCase, cls).setUpTestData()
     cls.domain = factories.DomainFactory(name="modoboa.org")
     # should not exist
     cls.bad_domain = factories.DomainFactory(name="pouet.com")
     parameters.save_admin("VALID_MXS", "127.0.0.1")
     models.MXRecord.objects.all().delete()
Ejemplo n.º 10
0
 def setUpTestData(cls):
     """Create test data."""
     super(APIDomainLimitsTestCase, cls).setUpTestData()
     parameters.save_admin("ENABLE_DOMAIN_LIMITS", "yes")
     for name, tpl in utils.get_domain_limit_templates():
         parameters.save_admin("DEFLT_DOMAIN_{}_LIMIT".format(name.upper()),
                               2)
     populate_database()
Ejemplo n.º 11
0
 def setUpTestData(cls):
     """Custom setUpTestData method."""
     super(ResourceTestCase, cls).setUpTestData()
     for tpl in LimitTemplates().templates:
         parameters.save_admin("DEFLT_{0}".format(tpl[0].upper()),
                               2,
                               app="limits")
     populate_database()
Ejemplo n.º 12
0
def unset_default_topredirection(extension):
    """
    Simple callback to change the default redirection if the
    corresponding extension is being disabled.
    """
    topredirection = parameters.get_admin("DEFAULT_TOP_REDIRECTION")
    if topredirection == extension.name:
        parameters.save_admin("DEFAULT_TOP_REDIRECTION", "userprefs")
Ejemplo n.º 13
0
def unset_default_topredirection(extension):
    """
    Simple callback to change the default redirection if the
    corresponding extension is being disabled.
    """
    topredirection = parameters.get_admin("DEFAULT_TOP_REDIRECTION")
    if topredirection == extension.name:
        parameters.save_admin("DEFAULT_TOP_REDIRECTION", "userprefs")
Ejemplo n.º 14
0
 def setUpTestData(cls):
     """Custom setUpTestData method."""
     super(ResourceTestCase, cls).setUpTestData()
     for tpl in LimitTemplates().templates:
         parameters.save_admin(
             "DEFLT_{0}".format(tpl[0].upper()), 2,
             app="limits"
         )
     populate_database()
Ejemplo n.º 15
0
 def setUpTestData(cls):
     """Custom setUpTestData method."""
     super(ResourceTestCase, cls).setUpTestData()
     for name, tpl in utils.get_limit_templates():
         parameters.save_admin(
             "DEFLT_{0}_LIMIT".format(name.upper()), 2,
             app="limits"
         )
     populate_database()
Ejemplo n.º 16
0
    def setUpTestData(cls):
        """Create test data."""
        super(LimitsTestCase, cls).setUpTestData()

        for tpl in LimitTemplates().templates:
            parameters.save_admin("DEFLT_{0}".format(tpl[0].upper()),
                                  2,
                                  app="limits")
        cls.user = UserFactory.create(username='******',
                                      groups=('Resellers', ))
Ejemplo n.º 17
0
    def setUp(self):
        """Custom setUp method.

        The 'limits' is manually loaded to ensure extra parameters
        provided by 'postfix_relay_domains' are properly received.
        """
        super(ResourceTestCase, self).setUp()
        for tpl in LimitTemplates().templates:
            parameters.save_admin('DEFLT_%s' % tpl[0].upper(), 2, app='limits')
        populate_database()
Ejemplo n.º 18
0
    def setUpTestData(cls):
        """Create test data."""
        super(LimitsTestCase, cls).setUpTestData()

        for name, tpl in limits_utils.get_limit_templates():
            parameters.save_admin("DEFLT_{0}_LIMIT".format(name.upper()),
                                  2,
                                  app="limits")
        cls.user = UserFactory.create(username='******',
                                      groups=('Resellers', ))
Ejemplo n.º 19
0
    def setUp(self):
        super(LimitsTestCase, self).setUp()
        from modoboa.extensions.limits.models import LimitTemplates

        for tpl in LimitTemplates().templates:
            parameters.save_admin('DEFLT_%s' % tpl[0].upper(), 2, app='limits')
        self.user = UserFactory.create(username='******',
                                       groups=('Resellers', ))
        self.clt.logout()
        self.clt.login(username='******', password='******')
Ejemplo n.º 20
0
    def setUpTestData(cls):
        """Create test data."""
        super(LimitsTestCase, cls).setUpTestData()

        for name, tpl in limits_utils.get_limit_templates():
            parameters.save_admin(
                "DEFLT_{0}_LIMIT".format(name.upper()), 2, app="limits"
            )
        cls.user = UserFactory.create(
            username='******', groups=('Resellers',)
        )
Ejemplo n.º 21
0
    def setUpTestData(cls):
        """Create test data."""
        super(LimitsTestCase, cls).setUpTestData()

        for tpl in LimitTemplates().templates:
            parameters.save_admin(
                "DEFLT_{0}".format(tpl[0].upper()), 2, app="limits"
            )
        cls.user = UserFactory.create(
            username='******', groups=('Resellers',)
        )
Ejemplo n.º 22
0
 def test_autocreate_disabled(self):
     """Check if objects are not created as expected."""
     self.activate_ldap_authentication()
     self.searchbind_mode()
     parameters.save_admin("AUTO_CREATE_DOMAIN_AND_MAILBOX", "no")
     username = "******"
     self.authenticate(username, "test")
     self.assertFalse(
         models.Domain.objects.filter(name="example.com").exists())
     self.assertFalse(
         models.Mailbox.objects.filter(address="testuser").exists())
Ejemplo n.º 23
0
 def test_autocreate_disabled(self):
     """Check if objects are not created as expected."""
     self.activate_ldap_authentication()
     self.searchbind_mode()
     parameters.save_admin("AUTO_CREATE_DOMAIN_AND_MAILBOX", "no")
     username = "******"
     self.authenticate(username, "test")
     self.assertFalse(
         models.Domain.objects.filter(name="example.com").exists())
     self.assertFalse(
         models.Mailbox.objects.filter(address="testuser").exists())
Ejemplo n.º 24
0
    def setUp(self):
        super(LimitsTestCase, self).setUp()
        from modoboa.extensions.limits.models import LimitTemplates

        for tpl in LimitTemplates().templates:
            parameters.save_admin('DEFLT_%s' % tpl[0].upper(), 2, app='limits')
        self.user = UserFactory.create(
            username='******', groups=('Resellers',)
        )
        self.clt.logout()
        self.clt.login(username='******', password='******')
Ejemplo n.º 25
0
 def test_model(self):
     """Check few things about the model."""
     Radicale().load()
     mbox = Mailbox.objects.get(address="admin", domain__name="test.com")
     cal = UserCalendarFactory(name="MyCal", mailbox=mbox)
     with self.assertRaises(lib_exceptions.InternalError) as cm:
         url = cal.url
     self.assertEqual(
         str(cm.exception), "Server location is not set, please fix it.")
     parameters.save_admin(
         "SERVER_LOCATION", "http://localhost", app="modoboa_radicale")
     self.assertEqual(cal.url, "http://localhost/test.com/user/admin/MyCal")
Ejemplo n.º 26
0
 def test_domain_detail_view(self):
     """Test Domain detail view."""
     parameters.save_admin("ENABLE_DOMAIN_LIMITS", "no", app="limits")
     domain = Domain.objects.get(name="test.com")
     url = reverse("admin:domain_detail", args=[domain.pk])
     response = self.client.get(url)
     self.assertEqual(response.status_code, 200)
     self.assertIn("Summary", response.content)
     self.assertIn("Administrators", response.content)
     self.assertNotIn("Resources usage", response.content)
     parameters.save_admin("ENABLE_DOMAIN_LIMITS", "yes", app="limits")
     response = self.client.get(url)
     self.assertIn("Resources usage", response.content)
Ejemplo n.º 27
0
 def setUpTestData(cls):
     """Create test data."""
     super(APIAdminLimitsTestCase, cls).setUpTestData()
     for name, tpl in utils.get_user_limit_templates():
         parameters.save_admin(
             "DEFLT_USER_{}_LIMIT".format(name.upper()), 2)
     populate_database()
     cls.user = User.objects.get(username="******")
     cls.da_token = Token.objects.create(user=cls.user)
     cls.reseller = core_factories.UserFactory(
         username="******", groups=("Resellers", ),
     )
     cls.r_token = Token.objects.create(user=cls.reseller)
Ejemplo n.º 28
0
 def test_account_detail_view(self):
     """Test account detail view."""
     parameters.save_admin("ENABLE_ADMIN_LIMITS", "no", app="limits")
     account = User.objects.get(username="******")
     url = reverse("admin:account_detail", args=[account.pk])
     response = self.client.get(url)
     self.assertEqual(response.status_code, 200)
     self.assertIn("Summary", response.content)
     self.assertIn("Administered domains", response.content)
     self.assertNotIn("Resources usage", response.content)
     parameters.save_admin("ENABLE_ADMIN_LIMITS", "yes", app="limits")
     response = self.client.get(url)
     self.assertIn("Resources usage", response.content)
Ejemplo n.º 29
0
 def test_model(self):
     """Check few things about the model."""
     Radicale().load()
     mbox = Mailbox.objects.get(address="admin", domain__name="test.com")
     cal = UserCalendarFactory(name="MyCal", mailbox=mbox)
     with self.assertRaises(lib_exceptions.InternalError) as cm:
         url = cal.url
     self.assertEqual(str(cm.exception),
                      "Server location is not set, please fix it.")
     parameters.save_admin("SERVER_LOCATION",
                           "http://localhost",
                           app="modoboa_radicale")
     self.assertEqual(cal.url, "http://localhost/test.com/user/admin/MyCal")
Ejemplo n.º 30
0
    def setUp(self):
        super(LimitsTestCase, self).setUp()
        from modoboa_admin_limits.models import LimitTemplates

        for tpl in LimitTemplates().templates:
            parameters.save_admin(
                "DEFLT_{0}".format(tpl[0].upper()), 2,
                app="modoboa_admin_limits"
            )
        self.user = UserFactory.create(
            username='******', groups=('Resellers',)
        )
        self.clt.logout()
        self.clt.login(username='******', password='******')
Ejemplo n.º 31
0
    def setUp(self):
        """Custom setUp method.

        The 'limits' is manually loaded to ensure extra parameters
        provided by 'postfix_relay_domains' are properly received.
        """
        super(ResourceTestCase, self).setUp()
        #exts_pool.load_extension("modoboa_admin_limits")
        for tpl in LimitTemplates().templates:
            parameters.save_admin(
                "DEFLT_{0}".format(tpl[0].upper()), 2,
                app="modoboa_admin_limits"
            )
        populate_database()
Ejemplo n.º 32
0
    def test_searchbind_authentication(self):
        """Test the bind&search method."""
        self.searchbind_mode()
        username = "******"
        self.authenticate(username, "test")
        self.check_created_user(username)
        self.client.logout()

        parameters.save_admin("LDAP_ADMIN_GROUPS", "admins")
        parameters.save_admin("LDAP_GROUPS_SEARCH_BASE",
                              "ou=groups,dc=example,dc=com")
        username = "******"
        self.authenticate(username, "test", False)
        self.check_created_user(username, "DomainAdmins")
Ejemplo n.º 33
0
 def test_create_using_default_quota(self):
     parameters.save_admin('DEFAULT_DOMAIN_QUOTA', 50, app='admin')
     values = {
         "name": "pouet.com",
         "create_dom_admin": "yes",
         "dom_admin_username": "******",
         "create_aliases": "yes",
         "stepid": 'step2'
     }
     self.ajax_post(reverse("admin:domain_add"), values)
     dom = Domain.objects.get(name="pouet.com")
     self.assertEqual(dom.quota, 50)
     da = User.objects.get(username="******")
     self.assertEqual(da.mailbox_set.all()[0].quota, 50)
Ejemplo n.º 34
0
    def test_searchbind_authentication(self):
        """Test the bind&search method."""
        self.searchbind_mode()
        username = "******"
        self.authenticate(username, "test")
        self.check_created_user(username)
        self.client.logout()

        parameters.save_admin("LDAP_ADMIN_GROUPS", "admins")
        parameters.save_admin(
            "LDAP_GROUPS_SEARCH_BASE", "ou=groups,dc=example,dc=com")
        username = "******"
        self.authenticate(username, "test", False)
        self.check_created_user(username, "DomainAdmins")
Ejemplo n.º 35
0
 def setUpTestData(cls):
     """Create test data."""
     super(APIAdminLimitsTestCase, cls).setUpTestData()
     for name, tpl in utils.get_user_limit_templates():
         parameters.save_admin("DEFLT_USER_{}_LIMIT".format(name.upper()),
                               2)
     populate_database()
     cls.user = User.objects.get(username="******")
     cls.da_token = Token.objects.create(user=cls.user)
     cls.reseller = core_factories.UserFactory(
         username="******",
         groups=("Resellers", ),
     )
     cls.r_token = Token.objects.create(user=cls.reseller)
Ejemplo n.º 36
0
 def test_create_using_default_quota(self):
     parameters.save_admin('DEFAULT_DOMAIN_QUOTA', 50, app='admin')
     values = {
         "name": "pouet.com", "create_dom_admin": "yes",
         "dom_admin_username": "******", "create_aliases": "yes",
         "type": "domain", "stepid": 'step3'
     }
     self.ajax_post(
         reverse("admin:domain_add"),
         values
     )
     dom = Domain.objects.get(name="pouet.com")
     self.assertEqual(dom.quota, 50)
     da = User.objects.get(username="******")
     self.assertEqual(da.mailbox.quota, 50)
Ejemplo n.º 37
0
 def test_create_using_default_quota(self):
     parameters.save_admin('DEFAULT_DOMAIN_QUOTA', 50, app='admin')
     values = {
         "name": "pouet.com", "create_dom_admin": "yes",
         "dom_admin_username": "******", "create_aliases": "yes",
         "stepid": 'step2'
     }
     self.ajax_post(
         reverse("modoboa.extensions.admin.views.domain.newdomain"),
         values
     )
     dom = Domain.objects.get(name="pouet.com")
     self.assertEqual(dom.quota, 50)
     da = User.objects.get(username="******")
     self.assertEqual(da.mailbox_set.all()[0].quota, 50)
Ejemplo n.º 38
0
 def test_domain_detail_view(self):
     """Test Domain detail view."""
     parameters.save_admin(
         "ENABLE_DOMAIN_LIMITS", "no", app="limits")
     domain = Domain.objects.get(name="test.com")
     url = reverse("admin:domain_detail", args=[domain.pk])
     response = self.client.get(url)
     self.assertEqual(response.status_code, 200)
     self.assertIn("Information", response.content)
     self.assertIn("Administrators", response.content)
     self.assertNotIn("Resources usage", response.content)
     parameters.save_admin(
         "ENABLE_DOMAIN_LIMITS", "yes", app="limits")
     response = self.client.get(url)
     self.assertIn("Resources usage", response.content)
Ejemplo n.º 39
0
    def setUpTestData(cls):
        """Create test data."""
        from modoboa.lib import parameters
        from modoboa.limits.models import LimitTemplates

        super(PermissionsTestCase, cls).setUpTestData()
        for tpl in LimitTemplates().templates:
            parameters.save_admin("DEFLT_{0}".format(tpl[0].upper()),
                                  2,
                                  app="limits")
        factories.populate_database()
        cls.user = User.objects.get(username='******')
        cls.values = dict(username=cls.user.username,
                          role="DomainAdmins",
                          is_active=cls.user.is_active,
                          email="*****@*****.**",
                          quota_act=True)
Ejemplo n.º 40
0
    def setUpTestData(cls):
        """Create test data."""
        from modoboa.lib import parameters
        from modoboa.limits import utils as limits_utils

        super(PermissionsTestCase, cls).setUpTestData()
        for name, tpl in limits_utils.get_user_limit_templates():
            parameters.save_admin("DEFLT_USER_{0}_LIMIT".format(name.upper()),
                                  2,
                                  app="limits")
        factories.populate_database()
        cls.user = User.objects.get(username='******')
        cls.values = dict(username=cls.user.username,
                          role="DomainAdmins",
                          is_active=cls.user.is_active,
                          email="*****@*****.**",
                          quota_act=True)
Ejemplo n.º 41
0
    def setUpTestData(cls):
        """Create test data."""
        from modoboa.lib import parameters
        from modoboa.limits import utils as limits_utils

        super(PermissionsTestCase, cls).setUpTestData()
        for name, tpl in limits_utils.get_user_limit_templates():
            parameters.save_admin(
                "DEFLT_USER_{0}_LIMIT".format(name.upper()), 2,
                app="limits"
            )
        factories.populate_database()
        cls.user = User.objects.get(username='******')
        cls.values = dict(
            username=cls.user.username, role="DomainAdmins",
            is_active=cls.user.is_active, email="*****@*****.**",
            quota_act=True
        )
Ejemplo n.º 42
0
    def setUpTestData(cls):
        """Create test data."""
        from modoboa.lib import parameters
        from modoboa.limits.models import LimitTemplates

        super(PermissionsTestCase, cls).setUpTestData()
        for tpl in LimitTemplates().templates:
            parameters.save_admin(
                "DEFLT_{0}".format(tpl[0].upper()), 2,
                app="limits"
            )
        factories.populate_database()
        cls.user = User.objects.get(username='******')
        cls.values = dict(
            username=cls.user.username, role="DomainAdmins",
            is_active=cls.user.is_active, email="*****@*****.**",
            quota_act=True
        )
Ejemplo n.º 43
0
    def test_directbind_authentication(self):
        """Test the directbind method."""
        self.client.logout()
        self.directbind_mode()

        # 1: must fail because usernames of simple users must be email
        # addresses
        username = "******"
        with self.assertRaises(TypeError):
            self.client.login(username=username, password="******")

        # 1: must work because usernames of domain admins are not
        # always email addresses
        parameters.save_admin("LDAP_ADMIN_GROUPS", "admins")
        parameters.save_admin(
            "LDAP_GROUPS_SEARCH_BASE", "ou=groups,dc=example,dc=com")
        username = "******"
        self.authenticate(username, "test", False)
        self.check_created_user(username, "DomainAdmins", False)
Ejemplo n.º 44
0
    def test_directbind_authentication(self):
        """Test the directbind method."""
        self.client.logout()
        self.directbind_mode()

        # 1: must fail because usernames of simple users must be email
        # addresses
        username = "******"
        with self.assertRaises(TypeError):
            self.client.login(username=username, password="******")

        # 1: must work because usernames of domain admins are not
        # always email addresses
        parameters.save_admin("LDAP_ADMIN_GROUPS", "admins")
        parameters.save_admin("LDAP_GROUPS_SEARCH_BASE",
                              "ou=groups,dc=example,dc=com")
        username = "******"
        self.authenticate(username, "test", False)
        self.check_created_user(username, "DomainAdmins", False)
Ejemplo n.º 45
0
    def test_rights_file_generation_with_admin(self):
        parameters.save_admin(
            "ALLOW_CALENDARS_ADMINISTRATION", "yes", app="radicale")
        management.call_command("generate_rights", verbosity=False)
        cfg = SafeConfigParser()
        with open(self.rights_file_path) as fpo:
            cfg.readfp(fpo)

        # Check mandatory rules
        self.assertTrue(cfg.has_section("domain-shared-calendars"))
        self.assertTrue(cfg.has_section("owners-access"))

        # Super admin rules
        section = "sa-admin-acr"
        self.assertTrue(cfg.has_section(section))

        # Domain admin rules
        for section in ["[email protected]",
                        "[email protected]"]:
            self.assertTrue(cfg.has_section(section))
Ejemplo n.º 46
0
    def test_rights_file_generation_with_admin(self):
        parameters.save_admin("ALLOW_CALENDARS_ADMINISTRATION",
                              "yes",
                              app="radicale")
        management.call_command("generate_rights", verbosity=False)
        cfg = SafeConfigParser()
        with open(self.rights_file_path) as fpo:
            cfg.readfp(fpo)

        # Check mandatory rules
        self.assertTrue(cfg.has_section("domain-shared-calendars"))
        self.assertTrue(cfg.has_section("owners-access"))

        # Super admin rules
        section = "sa-admin-acr"
        self.assertTrue(cfg.has_section(section))

        # Domain admin rules
        for section in [
                "[email protected]",
                "[email protected]"
        ]:
            self.assertTrue(cfg.has_section(section))
Ejemplo n.º 47
0
 def setUpTestData(cls):
     """Custom setUpTestData method."""
     super(ResourceTestCase, cls).setUpTestData()
     parameters.save_admin("ENABLE_ADMIN_LIMITS", "yes")
     parameters.save_admin("ENABLE_DOMAIN_LIMITS", "no")
     for name, tpl in utils.get_user_limit_templates():
         parameters.save_admin("DEFLT_USER_{0}_LIMIT".format(name.upper()),
                               2,
                               app="limits")
     populate_database()
Ejemplo n.º 48
0
 def directbind_mode(self):
     """Apply settings required by the directbind mode."""
     parameters.save_admin("LDAP_AUTH_METHOD", "directbind")
     parameters.save_admin(
         "LDAP_USER_DN_TEMPLATE", "cn=%(user)s,ou=users,dc=example,dc=com")
Ejemplo n.º 49
0
 def activate_ldap_authentication(self):
     """Modify settings."""
     parameters.save_admin(
         "AUTHENTICATION_TYPE", "ldap")
     parameters.save_admin("LDAP_SERVER_PORT", "3389")
Ejemplo n.º 50
0
 def searchbind_mode(self):
     """Apply settings required by the searchbind mode."""
     parameters.save_admin("LDAP_AUTH_METHOD", "searchbind")
     parameters.save_admin("LDAP_BIND_DN", "cn=admin,dc=example,dc=com")
     parameters.save_admin("LDAP_BIND_PASSWORD", "test")
     parameters.save_admin("LDAP_SEARCH_BASE", "ou=users,dc=example,dc=com")
Ejemplo n.º 51
0
 def setUp(self):
     """Test setup."""
     super(AccountAPITestCase, self).setUp()
     parameters.save_admin("ENABLE_ADMIN_LIMITS", "no", app="limits")
     parameters.save_admin("ENABLE_DOMAIN_LIMITS", "no", app="limits")
Ejemplo n.º 52
0
 def setUpTestData(cls):
     """Create test data."""
     super(ImportTestCase, cls).setUpTestData()
     parameters.save_admin("ENABLE_ADMIN_LIMITS", "no", app="limits")
     factories.populate_database()
Ejemplo n.º 53
0
 def test_save_admin(self):
     parameters.save_admin("PARAM1", "45", app="test")
     self.assertEqual(parameters.get_admin("PARAM1", app="test"), "45")
Ejemplo n.º 54
0
 def test_update_param(self):
     with self.assertRaisesRegexp(RuntimeError, "new value 35"):
         parameters.save_admin("PARAM2", 35, app="test")
Ejemplo n.º 55
0
 def _test_scheme(self, name, startpattern):
     parameters.save_admin('PASSWORD_SCHEME', name, app='core')
     self._create_account()
     account = User.objects.get(username='******')
     self.assertTrue(account.password.startswith(startpattern))
     self.assertTrue(account.check_password('toto'))
Ejemplo n.º 56
0
 def test_save_admin(self):
     parameters.save_admin("PARAM1", "45", app="test")
     self.assertEqual(parameters.get_admin("PARAM1", app="test"), "45")
Ejemplo n.º 57
0
 def test_update_param(self):
     with self.assertRaisesRegexp(RuntimeError, "new value 35"):
         parameters.save_admin("PARAM2", 35, app="test")
Ejemplo n.º 58
0
 def setUpTestData(cls):
     """Create some data."""
     super(MXTestCase, cls).setUpTestData()
     cls.domain = factories.DomainFactory(name="modoboa.org")
     factories.DomainFactory(name="pouet.com")  # should not exist
     parameters.save_admin('VALID_MXS', '127.0.0.1', app='admin')
Ejemplo n.º 59
0
 def _test_scheme(self, name, startpattern):
     parameters.save_admin('PASSWORD_SCHEME', name, app='core')
     self._create_account()
     account = User.objects.get(username='******')
     self.assertTrue(account.password.startswith(startpattern))
     self.assertTrue(account.check_password('Toto1234'))