Esempio n. 1
0
    def setUp(self):
        data = dict(
            name=get_random_name(),
        )
        self.tenant1 = self.api.create_tenant(initial=data)

        data = dict(
            name=get_random_name(),
        )
        self.tenant2 = self.api.create_tenant(initial=data)
Esempio n. 2
0
    def setUp(self):
        self.tenant_data = dict(name=get_random_name(), )
        self.tenant1 = self.api.create_tenant(initial=self.tenant_data)

        self.user_data = dict(
            username=get_random_name(),
            name=get_random_name(),
            surname=get_random_name(),
            tenant=self.tenant1,
            userServer=self.server1,
        )
        self.user1 = self.api.create_user(initial=self.user_data)
Esempio n. 3
0
    def setUp(self):
        data = dict(
            name=get_random_name(),
        )
        self.tenant1 = self.api.create_tenant(initial=data)

        data = dict(
            username=get_random_name(),
            name=get_random_name(),
            surname=get_random_name(),
            tenant=self.tenant1,
            userServer=self.server1,
        )
        self.user1 = self.api.create_user(initial=data)
Esempio n. 4
0
    def setUp(self):
        data = dict(name=get_random_name(), )
        self.tenant1 = self.api.create_tenant(initial=data)

        data = dict(
            username=get_random_name(),
            name=get_random_name(),
            surname=get_random_name(),
            tenant=self.tenant1,
            userServer=self.server1,
        )
        self.user1 = self.api.create_user(initial=data)

        data = dict(
            name=get_random_name(),
            members=[self.user1],
            tenant=self.tenant1,
        )
        self.group1 = self.api.create_group(initial=data)
Esempio n. 5
0
    def test_group_crud(self):
        data1 = dict(
            name=get_random_name(),
            mail=u'*****@*****.**',
            members=[
                self.user1,
                self.user2,
            ],
            sendAsPrivilege=[
            ],
            tenant=self.tenant1,
        )

        data2 = dict(
            name=get_random_name(),
            mail=u'*****@*****.**',
            members=[],
            sendAsPrivilege=[
                self.user1,
                self.user2,
            ],
            tenant=self.tenant1,
        )

        # Pre-condition check
        with self.assertRaises(ObjectDoesNotExist):
            self.api.get_group(tenant=self.tenant1, name=data1['name'])
        with self.assertRaises(ObjectDoesNotExist):
            self.api.get_group(tenant=self.tenant1, name=data2['name'])

        # Create and verify
        group1 = self.api.create_group(initial=data1)
        self.verify_model_attributes(group1, data1)

        group2 = self.api.create_group(initial=data2)
        self.verify_model_attributes(group2, data2)

        # Fetch and verify
        group1 = self.api.get_group(tenant=self.tenant1, name=data1['name'])
        self.verify_model_attributes(group1, data1)

        group2 = self.api.get_group(tenant=self.tenant1, name=data2['name'])
        self.verify_model_attributes(group2, data2)

        # Update
        data1.update(dict(
            mail=u'*****@*****.**',
            members=[
            ],
            sendAsPrivilege=[
                self.user2,
            ],
        ))
        group1.update_with(data1)
        self.api.update_group(group1)

        data2.update(dict(
            mail=u'*****@*****.**',
            members=[
                self.user1,
                self.user2,
            ],
            sendAsPrivilege=[
                self.user1,
            ],
        ))
        group2.update_with(data2)
        self.api.update_group(group2)

        # Verify
        group1 = self.api.get_group(tenant=self.tenant1, name=data1['name'])
        self.verify_model_attributes(group1, data1)

        group2 = self.api.get_group(tenant=self.tenant1, name=data2['name'])
        self.verify_model_attributes(group2, data2)

        # Delete
        self.api.delete_group(group1)
        self.api.delete_group(group2)

        # Post-condition check
        with self.assertRaises(ObjectDoesNotExist):
            self.api.get_group(tenant=self.tenant1, name=data1['name'])
        with self.assertRaises(ObjectDoesNotExist):
            self.api.get_group(tenant=self.tenant1, name=data2['name'])
Esempio n. 6
0
    def test_tenant_crud(self):
        data2 = dict(
            #id
            #users
            name=get_random_name(),
            isAccount=True,
            isHidden=False,
            mailDomains=[u'node4', u'node2'],
            viewPrivilege=[
                self.tenant1,
            ],
            adminPrivilege=[],
            systemAdmin=self.user1,
            quotaOverride=True,
            quotaWarn=30,
            userDefaultQuotaOverride=False,
            userDefaultQuotaWarn=10,
            userDefaultQuotaSoft=12,
            userDefaultQuotaHard=15,
            quotaUserWarningRecipients=[],
            quotaCompanyWarningRecipients=[],
            #companyServer=u'node5',
        )

        # Pre-condition check
        with self.assertRaises(ObjectDoesNotExist):
            self.api.get_tenant(name=data2['name'])

        # Create and verify
        tenant2 = self.api.create_tenant(initial=data2)
        self.verify_model_attributes(tenant2, data2)

        # Fetch and verify
        tenant2 = self.api.get_tenant(name=data2['name'])
        self.verify_model_attributes(tenant2, data2)

        # Update
        data2.update(
            dict(
                #id
                #users
                isAccount=False,
                isHidden=True,
                mailDomains=[u'node2', u'node9'],
                viewPrivilege=[],
                adminPrivilege=[
                    self.user2,
                ],
                systemAdmin=self.user2,
                quotaOverride=False,
                quotaWarn=31,
                userDefaultQuotaOverride=True,
                userDefaultQuotaWarn=11,
                userDefaultQuotaSoft=13,
                userDefaultQuotaHard=16,
                quotaUserWarningRecipients=[
                    self.user1,
                ],
                quotaCompanyWarningRecipients=[
                    self.user2,
                ],
                #companyServer=u'nodeX',
            ))
        tenant2.update_with(data2)
        self.api.update_tenant(tenant2)

        # Verify
        tenant2 = self.api.get_tenant(name=data2['name'])
        self.verify_model_attributes(tenant2, data2)

        # Delete
        self.api.delete_tenant(tenant2)

        # Post-condition check
        with self.assertRaises(ObjectDoesNotExist):
            self.api.get_tenant(name=data2['name'])
Esempio n. 7
0
    def test_user_crud(self):
        data1 = dict(
            username=get_random_name(),
            name=u'Hank Wills',
            surname=u'Wills',
            tenant=self.tenant1,
            userServer=self.server1,
        )

        data2 = dict(
            username=get_random_name(),
            name=u'John Wayne',
            surname=u'Wayne',
            jpegPhoto=u'aGFuaw==',
            tenant=self.tenant2,
            userServer=self.server1,
        )

        # Pre-condition check
        with self.assertRaises(ObjectDoesNotExist):
            self.api.get_user(tenant=self.tenant1, username=data1['username'])
        with self.assertRaises(ObjectDoesNotExist):
            self.api.get_user(tenant=self.tenant2, username=data2['username'])

        # Create and verify
        user1 = self.api.create_user(initial=data1)
        self.verify_model_attributes(user1, data1)

        user2 = self.api.create_user(initial=data2)
        self.verify_model_attributes(user2, data2)

        # Fetch and verify
        user1 = self.api.get_user(tenant=self.tenant1, username=data1['username'])
        self.verify_model_attributes(user1, data1)

        user2 = self.api.get_user(tenant=self.tenant2, username=data2['username'])
        self.verify_model_attributes(user2, data2)

        # Update
        data1.update(dict(
            mail=u'*****@*****.**',
            name=u'Willis Z',
            tenant=self.tenant1,
            userServer=self.server1,
            sendAsPrivilege=[
                user2,
            ],
        ))
        user1.update_with(data1)
        self.api.update_user(user1)

        data2.update(dict(
            mail=u'*****@*****.**',
            name=u'Wayne',
            jpegPhoto=None,
            tenant=self.tenant2,
            userServer=self.server1,
            sendAsPrivilege=[
                user1,
            ],
        ))
        user2.update_with(data2)
        self.api.update_user(user2)

        # Verify
        user1 = self.api.get_user(tenant=self.tenant1, username=data1['username'])
        self.verify_model_attributes(user1, data1)

        user2 = self.api.get_user(tenant=self.tenant2, username=data2['username'])
        self.verify_model_attributes(user2, data2)

        # Soft delete and verify
        self.api.post_user_softDelete(user1)
        user1 = self.api.get_user(tenant=self.tenant1, username=data1['username'])
        self.assertIsNotNone(user1.softDeletedDate)
        self.assertTrue(utcnow() - user1.softDeletedDate < timedelta(minutes=1),
                        u'softDeletedDate field is out of date.')

        # Soft undelete and verify
        self.api.post_user_softUndelete(user1)
        user1 = self.api.get_user(tenant=self.tenant1, username=data1['username'])
        self.assertIsNone(user1.softDeletedDate)

        # Delete
        self.api.delete_user(user1)
        self.api.delete_user(user2)

        # Post-condition check
        with self.assertRaises(ObjectDoesNotExist):
            self.api.get_user(tenant=self.tenant1, username=data1['username'])
        with self.assertRaises(ObjectDoesNotExist):
            self.api.get_user(tenant=self.tenant2, username=data2['username'])
Esempio n. 8
0
    def test_group_crud(self):
        data1 = dict(
            name=get_random_name(),
            mail=u'*****@*****.**',
            members=[
                self.user1,
                self.user2,
            ],
            sendAsPrivilege=[],
            tenant=self.tenant1,
        )

        data2 = dict(
            name=get_random_name(),
            mail=u'*****@*****.**',
            members=[],
            sendAsPrivilege=[
                self.user1,
                self.user2,
            ],
            tenant=self.tenant1,
        )

        # Pre-condition check
        with self.assertRaises(ObjectDoesNotExist):
            self.api.get_group(tenant=self.tenant1, name=data1['name'])
        with self.assertRaises(ObjectDoesNotExist):
            self.api.get_group(tenant=self.tenant1, name=data2['name'])

        # Create and verify
        group1 = self.api.create_group(initial=data1)
        self.verify_model_attributes(group1, data1)

        group2 = self.api.create_group(initial=data2)
        self.verify_model_attributes(group2, data2)

        # Fetch and verify
        group1 = self.api.get_group(tenant=self.tenant1, name=data1['name'])
        self.verify_model_attributes(group1, data1)

        group2 = self.api.get_group(tenant=self.tenant1, name=data2['name'])
        self.verify_model_attributes(group2, data2)

        # Update
        data1.update(
            dict(
                mail=u'*****@*****.**',
                members=[],
                sendAsPrivilege=[
                    self.user2,
                ],
            ))
        group1.update_with(data1)
        self.api.update_group(group1)

        data2.update(
            dict(
                mail=u'*****@*****.**',
                members=[
                    self.user1,
                    self.user2,
                ],
                sendAsPrivilege=[
                    self.user1,
                ],
            ))
        group2.update_with(data2)
        self.api.update_group(group2)

        # Verify
        group1 = self.api.get_group(tenant=self.tenant1, name=data1['name'])
        self.verify_model_attributes(group1, data1)

        group2 = self.api.get_group(tenant=self.tenant1, name=data2['name'])
        self.verify_model_attributes(group2, data2)

        # Delete
        self.api.delete_group(group1)
        self.api.delete_group(group2)

        # Post-condition check
        with self.assertRaises(ObjectDoesNotExist):
            self.api.get_group(tenant=self.tenant1, name=data1['name'])
        with self.assertRaises(ObjectDoesNotExist):
            self.api.get_group(tenant=self.tenant1, name=data2['name'])
Esempio n. 9
0
    def test_tenant_crud(self):
        data2 = dict(
            #id
            #users
            name=get_random_name(),
            isAccount=True,
            isHidden=False,
            mailDomains=[u'node4', u'node2'],
            viewPrivilege=[
                self.tenant1,
            ],
            adminPrivilege=[],
            systemAdmin=self.user1,
            quotaOverride=True,
            quotaWarn=30,
            userDefaultQuotaOverride=False,
            userDefaultQuotaWarn=10,
            userDefaultQuotaSoft=12,
            userDefaultQuotaHard=15,
            quotaUserWarningRecipients=[],
            quotaCompanyWarningRecipients=[],
            #companyServer=u'node5',
        )

        # Pre-condition check
        with self.assertRaises(ObjectDoesNotExist):
            self.api.get_tenant(name=data2['name'])

        # Create and verify
        tenant2 = self.api.create_tenant(initial=data2)
        self.verify_model_attributes(tenant2, data2)

        # Fetch and verify
        tenant2 = self.api.get_tenant(name=data2['name'])
        self.verify_model_attributes(tenant2, data2)

        # Update
        data2.update(dict(
            #id
            #users
            isAccount=False,
            isHidden=True,
            mailDomains=[u'node2', u'node9'],
            viewPrivilege=[
            ],
            adminPrivilege=[
                self.user2,
            ],
            systemAdmin=self.user2,
            quotaOverride=False,
            quotaWarn=31,
            userDefaultQuotaOverride=True,
            userDefaultQuotaWarn=11,
            userDefaultQuotaSoft=13,
            userDefaultQuotaHard=16,
            quotaUserWarningRecipients=[
                self.user1,
            ],
            quotaCompanyWarningRecipients=[
                self.user2,
            ],
            #companyServer=u'nodeX',
        ))
        tenant2.update_with(data2)
        self.api.update_tenant(tenant2)

        # Verify
        tenant2 = self.api.get_tenant(name=data2['name'])
        self.verify_model_attributes(tenant2, data2)

        # Delete
        self.api.delete_tenant(tenant2)

        # Post-condition check
        with self.assertRaises(ObjectDoesNotExist):
            self.api.get_tenant(name=data2['name'])
Esempio n. 10
0
    def __init__(self, *args, **kwargs):
        super(UnicodeTests, self).__init__(*args, **kwargs)

        self.ten_data = dict(
            name=u'èé' + get_random_name(),
        )