Back to index

plone3  3.1.7
Public Member Functions | Private Member Functions
PluggableAuthService.plugins.tests.test_exportimport.DomainAuthHelperExportImportTests Class Reference
Inheritance diagram for PluggableAuthService.plugins.tests.test_exportimport.DomainAuthHelperExportImportTests:
Inheritance graph
[legend]
Collaboration diagram for PluggableAuthService.plugins.tests.test_exportimport.DomainAuthHelperExportImportTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_listExportableItems
def test__getExportInfo_empty
def test_export_empty
def test__getExportInfo_with_map
def test_export_with_map
def test_import_empty
def test_import_without_purge_leaves_existing_users
def test_import_with_purge_wipes_existing_users

Private Member Functions

def _getTargetClass
def _makePlugin

Detailed Description

Definition at line 601 of file test_exportimport.py.


Member Function Documentation

Definition at line 603 of file test_exportimport.py.

00603 
00604         def _getTargetClass(self):
00605             from Products.PluggableAuthService.plugins.exportimport \
00606                 import DomainAuthHelperExportImport
00607             return DomainAuthHelperExportImport

Definition at line 608 of file test_exportimport.py.

00608 
00609         def _makePlugin(self, id, *args, **kw):
00610             from Products.PluggableAuthService.plugins.DomainAuthHelper \
00611                 import DomainAuthHelper
00612             return DomainAuthHelper(id, *args, **kw)

Here is the caller graph for this function:

Definition at line 627 of file test_exportimport.py.

00627 
00628         def test__getExportInfo_empty(self):
00629             plugin = self._makePlugin('empty', None).__of__(self.root)
00630             adapter = self._makeOne(plugin)
00631 
00632             info = adapter._getExportInfo()
00633             self.assertEqual(info['title'], None)
00634             self.assertEqual(len(info['map']), 0)

Definition at line 648 of file test_exportimport.py.

00648 
00649         def test__getExportInfo_with_map(self):
00650             TITLE = 'With Map'
00651             USER_ID = 'some_user_id'
00652             DOMAIN = 'host.example.com'
00653             ROLES = ['foo', 'bar']
00654             plugin = self._makePlugin('with_map', TITLE).__of__(self.root)
00655             adapter = self._makeOne(plugin)
00656 
00657             plugin.manage_addMapping(user_id=USER_ID,
00658                                      match_type='equals',
00659                                      match_string=DOMAIN,
00660                                      roles=ROLES,
00661                                     )
00662 
00663             info = adapter._getExportInfo()
00664             self.assertEqual(info['title'], TITLE)
00665             user_map = info['map']
00666             self.assertEqual(len(user_map), 1)
00667             self.failUnless(USER_ID in user_map)
00668             match_list = user_map[USER_ID]
00669             self.assertEqual(len(match_list), 1)
00670             match = match_list[0]
00671             self.assertEqual(match['username'], USER_ID)
00672             self.assertEqual(match['match_type'], 'equals')
00673             self.assertEqual(match['match_string'], DOMAIN)
00674             self.assertEqual(match['roles'], ','.join(ROLES))

Definition at line 635 of file test_exportimport.py.

00635 
00636         def test_export_empty(self):
00637             plugin = self._makePlugin('empty', None).__of__(self.root)
00638             adapter = self._makeOne(plugin)
00639 
00640             context = DummyExportContext(plugin)
00641             adapter.export(context, 'plugins', False)
00642 
00643             self.assertEqual( len( context._wrote ), 1 )
00644             filename, text, content_type = context._wrote[ 0 ]
00645             self.assertEqual( filename, 'plugins/empty.xml' )
00646             self._compareDOM( text, _EMPTY_DOMAIN_AUTH )
00647             self.assertEqual( content_type, 'text/xml' )

Definition at line 675 of file test_exportimport.py.

00675 
00676         def test_export_with_map(self):
00677             TITLE = 'With Map'
00678             USER_ID = 'some_user_id'
00679             DOMAIN = 'host.example.com'
00680             ROLES = ['foo', 'bar']
00681             plugin = self._makePlugin('with_map', TITLE).__of__(self.root)
00682             adapter = self._makeOne(plugin)
00683 
00684             plugin.manage_addMapping(user_id=USER_ID,
00685                                      match_type='equals',
00686                                      match_string=DOMAIN,
00687                                      roles=ROLES,
00688                                     )
00689 
00690             context = DummyExportContext(plugin)
00691             adapter.export(context, 'plugins', False)
00692 
00693             self.assertEqual(len(context._wrote), 1)
00694             filename, text, content_type = context._wrote[0]
00695             self.assertEqual(filename, 'plugins/with_map.xml' )
00696             self._compareDOM(text,
00697                              _FILLED_DOMAIN_AUTH %
00698                               (TITLE,
00699                                USER_ID,
00700                                DOMAIN,
00701                                'equals',
00702                                ','.join(ROLES),
00703                                USER_ID,
00704                               ))
00705             self.assertEqual( content_type, 'text/xml' )

Definition at line 706 of file test_exportimport.py.

00706 
00707         def test_import_empty(self):
00708             TITLE = 'With Map'
00709             USER_ID = 'some_user_id'
00710             DOMAIN = 'host.example.com'
00711             ROLES = ['foo', 'bar']
00712             plugin = self._makePlugin('empty').__of__(self.root)
00713             adapter = self._makeOne(plugin)
00714 
00715             context = DummyImportContext(plugin)
00716             context._files['plugins/empty.xml'
00717                           ] = _FILLED_DOMAIN_AUTH % (TITLE,
00718                                                      USER_ID,
00719                                                      DOMAIN,
00720                                                      'equals',
00721                                                      ','.join(ROLES),
00722                                                      USER_ID,
00723                                                     )
00724             self.assertEqual(plugin.title, '')
00725 
00726             adapter.import_(context, 'plugins', False)
00727 
00728             self.assertEqual(len(plugin._domain_map), 1)
00729             self.assertEqual(plugin.title, TITLE)
00730 
00731             username, match_list = plugin._domain_map.items()[0]
00732             self.assertEqual(username, USER_ID)
00733             self.assertEqual(len(match_list), 1)
00734             match = match_list[0]
00735             self.assertEqual(match['username'], USER_ID)
00736             self.assertEqual(match['match_string'], DOMAIN)
00737             self.assertEqual(match['match_real'], DOMAIN)
00738             self.assertEqual(match['match_type'], 'equals')
00739             self.assertEqual(len(match['roles']), len(ROLES))
00740             for role in ROLES:
00741                 self.failUnless(role in match['roles'])

Definition at line 766 of file test_exportimport.py.

00766 
00767         def test_import_with_purge_wipes_existing_users(self):
00768             TITLE = 'With Map'
00769             USER_ID = 'some_user_id'
00770             DOMAIN = 'host.example.com'
00771             ROLES = ['foo', 'bar']
00772             plugin = self._makePlugin('with_map', TITLE).__of__(self.root)
00773 
00774             adapter = self._makeOne(plugin)
00775 
00776             plugin.manage_addMapping(user_id=USER_ID,
00777                                      match_type='equals',
00778                                      match_string=DOMAIN,
00779                                      roles=ROLES,
00780                                     )
00781             adapter = self._makeOne(plugin)
00782 
00783             context = DummyImportContext(plugin, purge=True)
00784             context._files['plugins/with_map.xml'] = _EMPTY_DOMAIN_AUTH
00785 
00786             self.assertEqual(len(plugin._domain_map), 1)
00787             adapter.import_(context, 'plugins', False)
00788             self.assertEqual(len(plugin._domain_map), 0)
00789             self.assertEqual(plugin.title, None)
00790 
    class TitleOnlyExportImportTests(_TestBase):

Definition at line 742 of file test_exportimport.py.

00742 
00743         def test_import_without_purge_leaves_existing_users(self):
00744             TITLE = 'With Map'
00745             USER_ID = 'some_user_id'
00746             DOMAIN = 'host.example.com'
00747             ROLES = ['foo', 'bar']
00748             plugin = self._makePlugin('with_map', TITLE).__of__(self.root)
00749             adapter = self._makeOne(plugin)
00750 
00751             plugin.manage_addMapping(user_id=USER_ID,
00752                                      match_type='equals',
00753                                      match_string=DOMAIN,
00754                                      roles=ROLES,
00755                                     )
00756 
00757             adapter = self._makeOne(plugin)
00758 
00759             context = DummyImportContext(plugin, purge=False)
00760             context._files['plugins/with_map.xml'] = _EMPTY_DOMAIN_AUTH
00761 
00762             self.assertEqual(len(plugin._domain_map), 1)
00763             adapter.import_(context, 'plugins', False)
00764             self.assertEqual(len(plugin._domain_map), 1)
00765             self.assertEqual(plugin.title, None)

Definition at line 613 of file test_exportimport.py.

00613 
00614         def test_listExportableItems(self):
00615             plugin = self._makePlugin('lEI').__of__(self.root)
00616             adapter = self._makeOne(plugin)
00617 
00618             self.assertEqual(len(adapter.listExportableItems()), 0)
00619             plugin.cookie_name = 'COOKIE_NAME'
00620             plugin.login_path = 'LOGIN_PATH'
00621             plugin.manage_addMapping(user_id='user_id',
00622                                      match_type='equals',
00623                                      match_string='host.example.com',
00624                                      roles=['foo', 'bar'],
00625                                     )
00626             self.assertEqual(len(adapter.listExportableItems()), 0)


The documentation for this class was generated from the following file: