add ShadowManagerTest

This commit is contained in:
Jan Dittberner 2014-06-01 15:42:32 +02:00
parent b37e44ccfd
commit 20f5686d85

View file

@ -1,6 +1,9 @@
from datetime import date
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.test import TestCase from django.test import TestCase
from django.test.utils import override_settings from django.test.utils import override_settings
from django.utils import timezone
from mock import patch, MagicMock from mock import patch, MagicMock
@ -86,6 +89,24 @@ class GroupTest(TestCaseWithCeleryTasks):
self.assertEqual(taskres[0].modelname, 'test') self.assertEqual(taskres[0].modelname, 'test')
class ShadowManagerTest(TestCaseWithCeleryTasks):
def test_create_shadow(self):
user = User(
username='test', uid=1000,
group=Group(gid=1000, groupname='test'),
homedir='/home/test', shell='/bin/fooshell')
shadow = Shadow.objects.create_shadow(user, 'test')
self.assertTrue(sha512_crypt.verify('test', shadow.passwd))
self.assertEqual(shadow.changedays,
(timezone.now().date() - date(1970, 1, 1)).days)
self.assertEqual(shadow.user, user)
self.assertEqual(shadow.minage, 0)
self.assertIsNone(shadow.maxage)
self.assertEqual(shadow.gracedays, 7)
self.assertEqual(shadow.inactdays, 30)
self.assertIsNone(shadow.expiredays)
class ShadowTest(TestCaseWithCeleryTasks): class ShadowTest(TestCaseWithCeleryTasks):
def test___str__(self): def test___str__(self):
group = Group.objects.create( group = Group.objects.create(