server/test/unittest_querier.py
branchstable
changeset 1951 f28e7f300d3f
parent 1950 ab7a41b2cd26
child 1977 606923dff11b
equal deleted inserted replaced
1950:ab7a41b2cd26 1951:f28e7f300d3f
  1078         self.assertRaises(Unauthorized,
  1078         self.assertRaises(Unauthorized,
  1079                           self.execute, "Any P WHERE X is CWUser, X login 'bob', X upassword P")
  1079                           self.execute, "Any P WHERE X is CWUser, X login 'bob', X upassword P")
  1080         cursor = self.pool['system']
  1080         cursor = self.pool['system']
  1081         cursor.execute("SELECT %supassword from %sCWUser WHERE %slogin='bob'"
  1081         cursor.execute("SELECT %supassword from %sCWUser WHERE %slogin='bob'"
  1082                        % (SQL_PREFIX, SQL_PREFIX, SQL_PREFIX))
  1082                        % (SQL_PREFIX, SQL_PREFIX, SQL_PREFIX))
  1083         passwd = cursor.fetchone()[0].getvalue()
  1083         passwd = str(cursor.fetchone()[0])
  1084         self.assertEquals(passwd, crypt_password('toto', passwd[:2]))
  1084         self.assertEquals(passwd, crypt_password('toto', passwd[:2]))
  1085         rset = self.execute("Any X WHERE X is CWUser, X login 'bob', X upassword '%s'" % passwd)
  1085         rset = self.execute("Any X WHERE X is CWUser, X login 'bob', X upassword '%s'" % passwd)
  1086         self.assertEquals(len(rset.rows), 1)
  1086         self.assertEquals(len(rset.rows), 1)
  1087         self.assertEquals(rset.description, [('CWUser',)])
  1087         self.assertEquals(rset.description, [('CWUser',)])
  1088 
  1088 
  1092         self.assertEquals(rset.description[0][0], 'CWUser')
  1092         self.assertEquals(rset.description[0][0], 'CWUser')
  1093         rset = self.execute("SET X upassword %(pwd)s WHERE X is CWUser, X login 'bob'",
  1093         rset = self.execute("SET X upassword %(pwd)s WHERE X is CWUser, X login 'bob'",
  1094                             {'pwd': 'tutu'})
  1094                             {'pwd': 'tutu'})
  1095         cursor.execute("SELECT %supassword from %sCWUser WHERE %slogin='bob'"
  1095         cursor.execute("SELECT %supassword from %sCWUser WHERE %slogin='bob'"
  1096                        % (SQL_PREFIX, SQL_PREFIX, SQL_PREFIX))
  1096                        % (SQL_PREFIX, SQL_PREFIX, SQL_PREFIX))
  1097         passwd = cursor.fetchone()[0].getvalue()
  1097         passwd = str(cursor.fetchone()[0])
  1098         self.assertEquals(passwd, crypt_password('tutu', passwd[:2]))
  1098         self.assertEquals(passwd, crypt_password('tutu', passwd[:2]))
  1099         rset = self.execute("Any X WHERE X is CWUser, X login 'bob', X upassword '%s'" % passwd)
  1099         rset = self.execute("Any X WHERE X is CWUser, X login 'bob', X upassword '%s'" % passwd)
  1100         self.assertEquals(len(rset.rows), 1)
  1100         self.assertEquals(len(rset.rows), 1)
  1101         self.assertEquals(rset.description, [('CWUser',)])
  1101         self.assertEquals(rset.description, [('CWUser',)])
  1102 
  1102