server/test/unittest_querier.py
changeset 7398 26695dd703d8
parent 7397 6a9e66d788b3
child 7484 45a350d6b22f
equal deleted inserted replaced
7397:6a9e66d788b3 7398:26695dd703d8
  1114         aeid, = self.o.execute(s, 'INSERT EmailAddress X: X address "toto@logilab.fr", X alias "hop"')[0]
  1114         aeid, = self.o.execute(s, 'INSERT EmailAddress X: X address "toto@logilab.fr", X alias "hop"')[0]
  1115         # XXX would be nice if the rql below was enough...
  1115         # XXX would be nice if the rql below was enough...
  1116         #'INSERT Email X: X messageid "<1234>", X subject "test", X sender Y, X recipients Y'
  1116         #'INSERT Email X: X messageid "<1234>", X subject "test", X sender Y, X recipients Y'
  1117         eeid, = self.o.execute(s, 'INSERT Email X: X messageid "<1234>", X subject "test", X sender Y, X recipients Y WHERE Y is EmailAddress')[0]
  1117         eeid, = self.o.execute(s, 'INSERT Email X: X messageid "<1234>", X subject "test", X sender Y, X recipients Y WHERE Y is EmailAddress')[0]
  1118         self.o.execute(s, "DELETE Email X")
  1118         self.o.execute(s, "DELETE Email X")
  1119         sqlc = s.pool['system']
  1119         sqlc = s.cnxset['system']
  1120         sqlc.execute('SELECT * FROM recipients_relation')
  1120         sqlc.execute('SELECT * FROM recipients_relation')
  1121         self.assertEqual(len(sqlc.fetchall()), 0)
  1121         self.assertEqual(len(sqlc.fetchall()), 0)
  1122         sqlc.execute('SELECT * FROM owned_by_relation WHERE eid_from=%s'%eeid)
  1122         sqlc.execute('SELECT * FROM owned_by_relation WHERE eid_from=%s'%eeid)
  1123         self.assertEqual(len(sqlc.fetchall()), 0)
  1123         self.assertEqual(len(sqlc.fetchall()), 0)
  1124 
  1124 
  1227         rset = self.execute("INSERT CWUser X: X login 'bob', X upassword 'toto'")
  1227         rset = self.execute("INSERT CWUser X: X login 'bob', X upassword 'toto'")
  1228         self.assertEqual(len(rset.rows), 1)
  1228         self.assertEqual(len(rset.rows), 1)
  1229         self.assertEqual(rset.description, [('CWUser',)])
  1229         self.assertEqual(rset.description, [('CWUser',)])
  1230         self.assertRaises(Unauthorized,
  1230         self.assertRaises(Unauthorized,
  1231                           self.execute, "Any P WHERE X is CWUser, X login 'bob', X upassword P")
  1231                           self.execute, "Any P WHERE X is CWUser, X login 'bob', X upassword P")
  1232         cursor = self.pool['system']
  1232         cursor = self.cnxset['system']
  1233         cursor.execute("SELECT %supassword from %sCWUser WHERE %slogin='bob'"
  1233         cursor.execute("SELECT %supassword from %sCWUser WHERE %slogin='bob'"
  1234                        % (SQL_PREFIX, SQL_PREFIX, SQL_PREFIX))
  1234                        % (SQL_PREFIX, SQL_PREFIX, SQL_PREFIX))
  1235         passwd = str(cursor.fetchone()[0])
  1235         passwd = str(cursor.fetchone()[0])
  1236         self.assertEqual(passwd, crypt_password('toto', passwd[:2]))
  1236         self.assertEqual(passwd, crypt_password('toto', passwd[:2]))
  1237         rset = self.execute("Any X WHERE X is CWUser, X login 'bob', X upassword %(pwd)s",
  1237         rset = self.execute("Any X WHERE X is CWUser, X login 'bob', X upassword %(pwd)s",
  1242     def test_update_upassword(self):
  1242     def test_update_upassword(self):
  1243         rset = self.execute("INSERT CWUser X: X login 'bob', X upassword %(pwd)s", {'pwd': 'toto'})
  1243         rset = self.execute("INSERT CWUser X: X login 'bob', X upassword %(pwd)s", {'pwd': 'toto'})
  1244         self.assertEqual(rset.description[0][0], 'CWUser')
  1244         self.assertEqual(rset.description[0][0], 'CWUser')
  1245         rset = self.execute("SET X upassword %(pwd)s WHERE X is CWUser, X login 'bob'",
  1245         rset = self.execute("SET X upassword %(pwd)s WHERE X is CWUser, X login 'bob'",
  1246                             {'pwd': 'tutu'})
  1246                             {'pwd': 'tutu'})
  1247         cursor = self.pool['system']
  1247         cursor = self.cnxset['system']
  1248         cursor.execute("SELECT %supassword from %sCWUser WHERE %slogin='bob'"
  1248         cursor.execute("SELECT %supassword from %sCWUser WHERE %slogin='bob'"
  1249                        % (SQL_PREFIX, SQL_PREFIX, SQL_PREFIX))
  1249                        % (SQL_PREFIX, SQL_PREFIX, SQL_PREFIX))
  1250         passwd = str(cursor.fetchone()[0])
  1250         passwd = str(cursor.fetchone()[0])
  1251         self.assertEqual(passwd, crypt_password('tutu', passwd[:2]))
  1251         self.assertEqual(passwd, crypt_password('tutu', passwd[:2]))
  1252         rset = self.execute("Any X WHERE X is CWUser, X login 'bob', X upassword %(pwd)s",
  1252         rset = self.execute("Any X WHERE X is CWUser, X login 'bob', X upassword %(pwd)s",