144 |
144 |
145 |
145 |
146 |
146 |
147 class UserGroupHooksTC(CubicWebTC): |
147 class UserGroupHooksTC(CubicWebTC): |
148 |
148 |
149 def test_user_synchronization(self): |
|
150 with self.admin_access.repo_cnx() as cnx: |
|
151 self.create_user(cnx, 'toto', password='hop', commit=False) |
|
152 self.assertRaises(AuthenticationError, |
|
153 self.repo.connect, u'toto', password='hop') |
|
154 cnx.commit() |
|
155 cnxid = self.repo.connect(u'toto', password='hop') |
|
156 self.assertNotEqual(cnxid, cnx.sessionid) |
|
157 cnx.execute('DELETE CWUser X WHERE X login "toto"') |
|
158 self.repo.execute(cnxid, 'State X') |
|
159 cnx.commit() |
|
160 self.assertRaises(BadConnectionId, |
|
161 self.repo.execute, cnxid, 'State X') |
|
162 |
|
163 def test_user_group_synchronization(self): |
149 def test_user_group_synchronization(self): |
164 with self.admin_access.repo_cnx() as cnx: |
150 with self.admin_access.repo_cnx() as cnx: |
165 user = cnx.user |
151 user = cnx.user |
166 self.assertEqual(user.groups, set(('managers',))) |
152 self.assertEqual(user.groups, set(('managers',))) |
167 cnx.execute('SET X in_group G WHERE X eid %s, G name "guests"' % user.eid) |
153 cnx.execute('SET X in_group G WHERE X eid %s, G name "guests"' % user.eid) |