comparison test/db_test_base.py @ 5329:19e12a540b91

Add a valid journal entry to the testJournalNonexistingProperty tests to verify that changes in this area don't break valid journal access for non-admin users.
author John Rouillard <rouilj@ieee.org>
date Tue, 05 Jun 2018 21:25:11 -0400
parents 62de601bdf6f
children c5e72a3c69dd
comparison
equal deleted inserted replaced
5328:ba1ce44254df 5329:19e12a540b91
1280 # non-existing classes and link/unlink events to non-existing 1280 # non-existing classes and link/unlink events to non-existing
1281 # properties in a class: These all may be the result of a schema 1281 # properties in a class: These all may be the result of a schema
1282 # change and should not lead to a traceback. 1282 # change and should not lead to a traceback.
1283 self.db.user.create(username="mary", roles="User") 1283 self.db.user.create(username="mary", roles="User")
1284 id = self.db.issue.create(title="spam", status='1') 1284 id = self.db.issue.create(title="spam", status='1')
1285 self.db.issue.set(id, title='green eggs')
1285 self.db.commit() 1286 self.db.commit()
1286 journal = self.db.getjournal('issue', id) 1287 journal = self.db.getjournal('issue', id)
1287 now = date.Date('.') 1288 now = date.Date('.')
1288 sec = date.Interval('0:00:01') 1289 sec = date.Interval('0:00:01')
1289 sec2 = date.Interval('0:00:02') 1290 sec2 = date.Interval('0:00:02')
1291 jp0 = dict(title = 'spam')
1290 # Non-existing property changed 1292 # Non-existing property changed
1291 jp1 = dict(nonexisting = None) 1293 jp1 = dict(nonexisting = None)
1292 journal.append ((id, now, '1', 'set', jp1)) 1294 journal.append ((id, now, '1', 'set', jp1))
1293 # Link from user-class to non-existing property 1295 # Link from user-class to non-existing property
1294 jp2 = ('user', '1', 'xyzzy') 1296 jp2 = ('user', '1', 'xyzzy')
1300 self.db.commit() 1302 self.db.commit()
1301 result=self.db.issue.history(id) 1303 result=self.db.issue.history(id)
1302 result.sort() 1304 result.sort()
1303 # anydbm drops unknown properties during serialisation 1305 # anydbm drops unknown properties during serialisation
1304 if self.db.dbtype == 'anydbm': 1306 if self.db.dbtype == 'anydbm':
1305 self.assertEqual(len(result), 3)
1306 self.assertEqual(result [1][4], jp2)
1307 self.assertEqual(result [2][4], jp3)
1308 else:
1309 self.assertEqual(len(result), 4) 1307 self.assertEqual(len(result), 4)
1310 self.assertEqual(result [1][4], jp1) 1308 self.assertEqual(result [1][4], jp0)
1311 self.assertEqual(result [2][4], jp2) 1309 self.assertEqual(result [2][4], jp2)
1312 self.assertEqual(result [3][4], jp3) 1310 self.assertEqual(result [3][4], jp3)
1311 else:
1312 self.assertEqual(len(result), 5)
1313 self.assertEqual(result [1][4], jp0)
1314 self.assertEqual(result [2][4], jp1)
1315 self.assertEqual(result [3][4], jp2)
1316 self.assertEqual(result [4][4], jp3)
1313 self.db.close() 1317 self.db.close()
1314 # Verify that normal user doesn't see obsolete props/classes 1318 # Verify that normal user doesn't see obsolete props/classes
1315 # Backend memorydb cannot re-open db for different user 1319 # Backend memorydb cannot re-open db for different user
1316 if self.db.dbtype != 'memorydb': 1320 if self.db.dbtype != 'memorydb':
1317 self.open_database('mary') 1321 self.open_database('mary')
1318 setupSchema(self.db, 0, self.module) 1322 setupSchema(self.db, 0, self.module)
1323 # allow mary to see issue fields like title
1324 self.db.security.addPermissionToRole('User', 'View', 'issue')
1319 result=self.db.issue.history(id) 1325 result=self.db.issue.history(id)
1320 self.assertEqual(len(result), 1) 1326 self.assertEqual(len(result), 2)
1327 self.assertEqual(result [1][4], jp0)
1321 1328
1322 def testJournalPreCommit(self): 1329 def testJournalPreCommit(self):
1323 id = self.db.user.create(username="mary") 1330 id = self.db.user.create(username="mary")
1324 self.assertEqual(len(self.db.getjournal('user', id)), 1) 1331 self.assertEqual(len(self.db.getjournal('user', id)), 1)
1325 self.db.commit() 1332 self.db.commit()

Roundup Issue Tracker: http://roundup-tracker.org/