Back to index

plone3  3.1.7
Public Member Functions | Private Member Functions
PluggableAuthService.plugins.tests.test_exportimport.ZODBUserManagerExportImportTests Class Reference
Inheritance diagram for PluggableAuthService.plugins.tests.test_exportimport.ZODBUserManagerExportImportTests:
Inheritance graph
[legend]
Collaboration diagram for PluggableAuthService.plugins.tests.test_exportimport.ZODBUserManagerExportImportTests:
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_users
def test_export_with_users
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 49 of file test_exportimport.py.


Member Function Documentation

Definition at line 51 of file test_exportimport.py.

00051 
00052         def _getTargetClass(self):
00053             from Products.PluggableAuthService.plugins.exportimport \
00054                 import ZODBUserManagerExportImport
00055             return ZODBUserManagerExportImport

def PluggableAuthService.plugins.tests.test_exportimport.ZODBUserManagerExportImportTests._makePlugin (   self,
  id = 'zodbusers',
  args,
  kw 
) [private]

Definition at line 56 of file test_exportimport.py.

00056 
00057         def _makePlugin(self, id='zodbusers', *args, **kw):
00058             from Products.PluggableAuthService.plugins.ZODBUserManager \
00059                 import ZODBUserManager
00060             return ZODBUserManager(id, *args, **kw)

Definition at line 68 of file test_exportimport.py.

00068 
00069         def test__getExportInfo_empty(self):
00070             plugin = self._makePlugin('empty').__of__(self.root)
00071             adapter = self._makeOne(plugin)
00072 
00073             info = adapter._getExportInfo()
00074             self.assertEqual(info['title'], None)
00075             self.assertEqual(len(info['users']), 0)

Definition at line 89 of file test_exportimport.py.

00089 
00090         def test__getExportInfo_with_users(self):
00091 
00092             plugin = self._makePlugin('with_users').__of__(self.root)
00093             plugin.title = 'Plugin Title'
00094             source_info = []
00095 
00096             for info in _ZODB_USER_INFO:
00097                 info = info.copy()
00098                 plugin.addUser(**info)
00099                 hash = plugin._user_passwords[info['user_id']]
00100                 info['password_hash'] = hash
00101                 source_info.append(info)
00102 
00103             adapter = self._makeOne(plugin)
00104 
00105             info = adapter._getExportInfo()
00106             self.assertEqual(info['title'], 'Plugin Title')
00107             self.assertEqual(len(info['users']), len(source_info))
00108 
00109             for x, y in zip(info['users'], source_info):
00110                 self.assertEqual(x['user_id'], y['user_id'])
00111                 self.assertEqual(x['login_name'], y['login_name'])
00112                 self.assertEqual(x['password_hash'], y['password_hash'])

Definition at line 76 of file test_exportimport.py.

00076 
00077         def test_export_empty(self):
00078             plugin = self._makePlugin('empty').__of__(self.root)
00079             adapter = self._makeOne(plugin)
00080 
00081             context = DummyExportContext(plugin)
00082             adapter.export(context, 'plugins', False)
00083 
00084             self.assertEqual( len( context._wrote ), 1 )
00085             filename, text, content_type = context._wrote[ 0 ]
00086             self.assertEqual( filename, 'plugins/empty.xml' )
00087             self._compareDOM( text, _EMPTY_ZODB_USERS )
00088             self.assertEqual( content_type, 'text/xml' )

Definition at line 113 of file test_exportimport.py.

00113 
00114         def test_export_with_users(self):
00115 
00116             plugin = self._makePlugin('with_users').__of__(self.root)
00117             plugin.title = 'Plugin Title'
00118 
00119             hashes = []
00120             for info in _ZODB_USER_INFO:
00121                 plugin.addUser(**info)
00122                 hash = plugin._user_passwords[info['user_id']]
00123                 hashes.append(hash)
00124 
00125             adapter = self._makeOne(plugin)
00126             context = DummyExportContext(plugin)
00127             adapter.export(context, 'plugins', False)
00128 
00129             self.assertEqual( len(context._wrote), 1)
00130             filename, text, content_type = context._wrote[ 0 ]
00131             self.assertEqual(filename, 'plugins/with_users.xml')
00132             self._compareDOM(text, _FILLED_ZODB_USERS % tuple(hashes))
00133             self.assertEqual(content_type, 'text/xml')

Definition at line 134 of file test_exportimport.py.

00134 
00135         def test_import_empty(self):
00136             HASHES = ('abcde', 'wxyz')
00137             plugin = self._makePlugin('empty').__of__(self.root)
00138             adapter = self._makeOne(plugin)
00139 
00140             context = DummyImportContext(plugin)
00141             context._files['plugins/empty.xml'] = _FILLED_ZODB_USERS % HASHES
00142             self.assertEqual(plugin.title, None)
00143 
00144             adapter.import_(context, 'plugins', False)
00145 
00146             self.assertEqual(len(plugin._user_passwords), len(_ZODB_USER_INFO))
00147             self.assertEqual(plugin.title, 'Plugin Title')
00148 
00149             for info, hash in zip(_ZODB_USER_INFO, HASHES):
00150                 user_id = info['user_id']
00151                 self.assertEqual(plugin.getLoginForUserId(user_id),
00152                                 info['login_name'])
00153                 self.assertEqual(plugin._user_passwords[user_id], hash)

Definition at line 172 of file test_exportimport.py.

00172 
00173         def test_import_with_purge_wipes_existing_users(self):
00174 
00175             plugin = self._makePlugin('with_users').__of__(self.root)
00176             plugin.title = 'Plugin Title'
00177 
00178             for info in _ZODB_USER_INFO:
00179                 plugin.addUser(**info)
00180 
00181             adapter = self._makeOne(plugin)
00182 
00183             context = DummyImportContext(plugin, purge=True)
00184             context._files['plugins/with_users.xml'] = _EMPTY_ZODB_USERS
00185 
00186             self.assertEqual(len(plugin._user_passwords), len(_ZODB_USER_INFO))
00187             adapter.import_(context, 'plugins', False)
00188             self.assertEqual(len(plugin._user_passwords), 0)
00189             self.assertEqual(plugin.title, None)
00190 
    class ZODBGroupManagerExportImportTests(_TestBase):

Definition at line 154 of file test_exportimport.py.

00154 
00155         def test_import_without_purge_leaves_existing_users(self):
00156 
00157             plugin = self._makePlugin('with_users').__of__(self.root)
00158             plugin.title = 'Plugin Title'
00159 
00160             for info in _ZODB_USER_INFO:
00161                 plugin.addUser(**info)
00162 
00163             adapter = self._makeOne(plugin)
00164 
00165             context = DummyImportContext(plugin, purge=False)
00166             context._files['plugins/with_users.xml'] = _EMPTY_ZODB_USERS
00167 
00168             self.assertEqual(len(plugin._user_passwords), len(_ZODB_USER_INFO))
00169             adapter.import_(context, 'plugins', False)
00170             self.assertEqual(len(plugin._user_passwords), len(_ZODB_USER_INFO))
00171             self.assertEqual(plugin.title, None)

Definition at line 61 of file test_exportimport.py.

00061 
00062         def test_listExportableItems(self):
00063             plugin = self._makePlugin('lEI').__of__(self.root)
00064             adapter = self._makeOne(plugin)
00065             self.assertEqual(len(adapter.listExportableItems()), 0)
00066             plugin.addUser('foo', 'bar', 'baz')
00067             self.assertEqual(len(adapter.listExportableItems()), 0)


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