Commit f904129e authored by Rafael Monnerat's avatar Rafael Monnerat

SlapTool: Store since when the logged information is there.

parent 390480e4
...@@ -13,7 +13,6 @@ import xml.dom.ext.reader.Sax ...@@ -13,7 +13,6 @@ import xml.dom.ext.reader.Sax
import xml.dom.ext import xml.dom.ext
import StringIO import StringIO
import difflib import difflib
import transaction
from OFS.Traversable import NotFound from OFS.Traversable import NotFound
class Simulator: class Simulator:
...@@ -451,6 +450,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -451,6 +450,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
def test_not_accessed_getComputerStatus(self): def test_not_accessed_getComputerStatus(self):
self.login(self.computer_user_id) self.login(self.computer_user_id)
created_at = rfc1123_date(DateTime()) created_at = rfc1123_date(DateTime())
since = created_at
response = self.portal_slap.getComputerStatus(self.computer_id) response = self.portal_slap.getComputerStatus(self.computer_id)
self.assertEqual(200, response.status) self.assertEqual(200, response.status)
self.assertEqual('public, max-age=60, stale-if-error=604800', self.assertEqual('public, max-age=60, stale-if-error=604800',
...@@ -474,6 +474,8 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -474,6 +474,8 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
<dictionary id='i2'> <dictionary id='i2'>
<string>created_at</string> <string>created_at</string>
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>since</string>
<string>%(since)s</string>
<string>text</string> <string>text</string>
<string>#error no data found for %(computer_id)s</string> <string>#error no data found for %(computer_id)s</string>
<string>user</string> <string>user</string>
...@@ -482,6 +484,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -482,6 +484,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
</marshal> </marshal>
""" % dict( """ % dict(
created_at=created_at, created_at=created_at,
since=since,
computer_id=self.computer_id computer_id=self.computer_id
) )
self.assertEqual(expected_xml, got_xml, self.assertEqual(expected_xml, got_xml,
...@@ -492,6 +495,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -492,6 +495,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
self.portal_slap.getFullComputerInformation(self.computer_id) self.portal_slap.getFullComputerInformation(self.computer_id)
created_at = rfc1123_date(DateTime()) created_at = rfc1123_date(DateTime())
since = created_at
response = self.portal_slap.getComputerStatus(self.computer_id) response = self.portal_slap.getComputerStatus(self.computer_id)
self.assertEqual(200, response.status) self.assertEqual(200, response.status)
self.assertEqual('public, max-age=60, stale-if-error=604800', self.assertEqual('public, max-age=60, stale-if-error=604800',
...@@ -516,6 +520,8 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -516,6 +520,8 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
<dictionary id='i2'> <dictionary id='i2'>
<string>created_at</string> <string>created_at</string>
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>since</string>
<string>%(since)s</string>
<string>text</string> <string>text</string>
<string>#access %(computer_id)s</string> <string>#access %(computer_id)s</string>
<string>user</string> <string>user</string>
...@@ -524,6 +530,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -524,6 +530,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
</marshal> </marshal>
""" % dict( """ % dict(
created_at=created_at, created_at=created_at,
since=since,
computer_id=self.computer_id computer_id=self.computer_id
) )
self.assertEqual(expected_xml, got_xml, self.assertEqual(expected_xml, got_xml,
...@@ -549,6 +556,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -549,6 +556,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
error_log) error_log)
self.assertEqual('None', response) self.assertEqual('None', response)
created_at = rfc1123_date(DateTime()) created_at = rfc1123_date(DateTime())
since = created_at
response = self.portal_slap.getComputerStatus(self.computer_id) response = self.portal_slap.getComputerStatus(self.computer_id)
# check returned XML # check returned XML
xml_fp = StringIO.StringIO() xml_fp = StringIO.StringIO()
...@@ -563,6 +571,8 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -563,6 +571,8 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
<dictionary id='i2'> <dictionary id='i2'>
<string>created_at</string> <string>created_at</string>
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>since</string>
<string>%(since)s</string>
<string>text</string> <string>text</string>
<string>#error bang</string> <string>#error bang</string>
<string>user</string> <string>user</string>
...@@ -571,6 +581,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -571,6 +581,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
</marshal> </marshal>
""" % dict( """ % dict(
created_at=created_at, created_at=created_at,
since=since,
computer_id=self.computer_id, computer_id=self.computer_id,
) )
self.assertEqual(expected_xml, got_xml, self.assertEqual(expected_xml, got_xml,
...@@ -618,6 +629,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -618,6 +629,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
self.computer_bang_simulator = tempfile.mkstemp()[1] self.computer_bang_simulator = tempfile.mkstemp()[1]
self.login(self.computer_user_id) self.login(self.computer_user_id)
created_at = rfc1123_date(DateTime()) created_at = rfc1123_date(DateTime())
since = created_at
software_installation = self.start_requested_software_installation software_installation = self.start_requested_software_installation
url_string = software_installation.getUrlString() url_string = software_installation.getUrlString()
response = self.portal_slap.getSoftwareInstallationStatus(url_string, response = self.portal_slap.getSoftwareInstallationStatus(url_string,
...@@ -644,6 +656,8 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -644,6 +656,8 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
<dictionary id='i2'> <dictionary id='i2'>
<string>created_at</string> <string>created_at</string>
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>since</string>
<string>%(since)s</string>
<string>text</string> <string>text</string>
<string>#error no data found for %(reference)s</string> <string>#error no data found for %(reference)s</string>
<string>user</string> <string>user</string>
...@@ -652,6 +666,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -652,6 +666,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
</marshal> </marshal>
""" % dict( """ % dict(
created_at=created_at, created_at=created_at,
since=since,
reference=software_installation.getReference() reference=software_installation.getReference()
) )
self.assertEqual(expected_xml, got_xml, self.assertEqual(expected_xml, got_xml,
...@@ -691,6 +706,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -691,6 +706,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
url_string, self.computer_id) url_string, self.computer_id)
self.assertEqual('None', response) self.assertEqual('None', response)
created_at = rfc1123_date(DateTime()) created_at = rfc1123_date(DateTime())
since = created_at
response = self.portal_slap.getSoftwareInstallationStatus( response = self.portal_slap.getSoftwareInstallationStatus(
url_string, self.computer_id) url_string, self.computer_id)
# check returned XML # check returned XML
...@@ -706,6 +722,8 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -706,6 +722,8 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
<dictionary id='i2'> <dictionary id='i2'>
<string>created_at</string> <string>created_at</string>
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>since</string>
<string>%(since)s</string>
<string>text</string> <string>text</string>
<string>#access software release %(url_string)s available</string> <string>#access software release %(url_string)s available</string>
<string>user</string> <string>user</string>
...@@ -714,6 +732,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -714,6 +732,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
</marshal> </marshal>
""" % dict( """ % dict(
created_at=created_at, created_at=created_at,
since=since,
url_string=url_string, url_string=url_string,
computer_id=self.computer_id, computer_id=self.computer_id,
) )
...@@ -730,6 +749,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -730,6 +749,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
url_string, self.computer_id) url_string, self.computer_id)
self.assertEqual('None', response) self.assertEqual('None', response)
created_at = rfc1123_date(DateTime()) created_at = rfc1123_date(DateTime())
since = created_at
response = self.portal_slap.getSoftwareInstallationStatus( response = self.portal_slap.getSoftwareInstallationStatus(
url_string, self.computer_id) url_string, self.computer_id)
# check returned XML # check returned XML
...@@ -745,6 +765,8 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -745,6 +765,8 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
<dictionary id='i2'> <dictionary id='i2'>
<string>created_at</string> <string>created_at</string>
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>since</string>
<string>%(since)s</string>
<string>text</string> <string>text</string>
<string>#building software release %(url_string)s</string> <string>#building software release %(url_string)s</string>
<string>user</string> <string>user</string>
...@@ -753,6 +775,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -753,6 +775,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
</marshal> </marshal>
""" % dict( """ % dict(
created_at=created_at, created_at=created_at,
since=since,
url_string=url_string, url_string=url_string,
computer_id=self.computer_id, computer_id=self.computer_id,
) )
...@@ -769,6 +792,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -769,6 +792,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
url_string, self.computer_id, 'error log') url_string, self.computer_id, 'error log')
self.assertEqual('None', response) self.assertEqual('None', response)
created_at = rfc1123_date(DateTime()) created_at = rfc1123_date(DateTime())
since = created_at
response = self.portal_slap.getSoftwareInstallationStatus( response = self.portal_slap.getSoftwareInstallationStatus(
url_string, self.computer_id) url_string, self.computer_id)
# check returned XML # check returned XML
...@@ -784,6 +808,8 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -784,6 +808,8 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
<dictionary id='i2'> <dictionary id='i2'>
<string>created_at</string> <string>created_at</string>
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>since</string>
<string>%(since)s</string>
<string>text</string> <string>text</string>
<string>#error while installing %(url_string)s</string> <string>#error while installing %(url_string)s</string>
<string>user</string> <string>user</string>
...@@ -792,6 +818,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -792,6 +818,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
</marshal> </marshal>
""" % dict( """ % dict(
created_at=created_at, created_at=created_at,
since=since,
url_string=url_string, url_string=url_string,
computer_id=self.computer_id, computer_id=self.computer_id,
) )
...@@ -1091,6 +1118,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1091,6 +1118,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
partition_id = self.start_requested_software_instance.getAggregateValue( partition_id = self.start_requested_software_instance.getAggregateValue(
portal_type='Computer Partition').getReference() portal_type='Computer Partition').getReference()
created_at = rfc1123_date(DateTime()) created_at = rfc1123_date(DateTime())
since = created_at
self.login(self.start_requested_software_instance.getUserId()) self.login(self.start_requested_software_instance.getUserId())
response = self.portal_slap.getComputerPartitionStatus(self.computer_id, response = self.portal_slap.getComputerPartitionStatus(self.computer_id,
partition_id) partition_id)
...@@ -1115,6 +1143,8 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1115,6 +1143,8 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<dictionary id='i2'> <dictionary id='i2'>
<string>created_at</string> <string>created_at</string>
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>since</string>
<string>%(since)s</string>
<string>text</string> <string>text</string>
<string>#error no data found for %(instance_guid)s</string> <string>#error no data found for %(instance_guid)s</string>
<string>user</string> <string>user</string>
...@@ -1123,6 +1153,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1123,6 +1153,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
</marshal> </marshal>
""" % dict( """ % dict(
created_at=created_at, created_at=created_at,
since=since,
instance_guid=self.start_requested_software_instance.getReference(), instance_guid=self.start_requested_software_instance.getReference(),
) )
self.assertEqual(expected_xml, got_xml, self.assertEqual(expected_xml, got_xml,
...@@ -1133,6 +1164,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1133,6 +1164,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
partition_id = self.start_requested_software_instance.getAggregateValue( partition_id = self.start_requested_software_instance.getAggregateValue(
portal_type='Computer Partition').getReference() portal_type='Computer Partition').getReference()
created_at = rfc1123_date(DateTime()) created_at = rfc1123_date(DateTime())
since = created_at
self.login(self.start_requested_software_instance.getUserId()) self.login(self.start_requested_software_instance.getUserId())
self.portal_slap.registerComputerPartition(self.computer_id, partition_id) self.portal_slap.registerComputerPartition(self.computer_id, partition_id)
response = self.portal_slap.getComputerPartitionStatus(self.computer_id, response = self.portal_slap.getComputerPartitionStatus(self.computer_id,
...@@ -1158,6 +1190,8 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1158,6 +1190,8 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<dictionary id='i2'> <dictionary id='i2'>
<string>created_at</string> <string>created_at</string>
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>since</string>
<string>%(since)s</string>
<string>text</string> <string>text</string>
<string>#error no data found for %(instance_guid)s</string> <string>#error no data found for %(instance_guid)s</string>
<string>user</string> <string>user</string>
...@@ -1166,6 +1200,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1166,6 +1200,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
</marshal> </marshal>
""" % dict( """ % dict(
created_at=created_at, created_at=created_at,
since=since,
instance_guid=self.start_requested_software_instance.getReference(), instance_guid=self.start_requested_software_instance.getReference(),
computer_id=self.computer_id, computer_id=self.computer_id,
partition_id=partition_id partition_id=partition_id
...@@ -1507,6 +1542,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1507,6 +1542,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
partition_id, error_log) partition_id, error_log)
self.assertEqual('None', response) self.assertEqual('None', response)
created_at = rfc1123_date(DateTime()) created_at = rfc1123_date(DateTime())
since = created_at
response = self.portal_slap.getComputerPartitionStatus(self.computer_id, response = self.portal_slap.getComputerPartitionStatus(self.computer_id,
partition_id) partition_id)
# check returned XML # check returned XML
...@@ -1522,6 +1558,8 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1522,6 +1558,8 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<dictionary id='i2'> <dictionary id='i2'>
<string>created_at</string> <string>created_at</string>
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>since</string>
<string>%(since)s</string>
<string>text</string> <string>text</string>
<string>#error while instanciating: The error</string> <string>#error while instanciating: The error</string>
<string>user</string> <string>user</string>
...@@ -1530,6 +1568,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1530,6 +1568,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
</marshal> </marshal>
""" % dict( """ % dict(
created_at=created_at, created_at=created_at,
since = since,
instance_guid=self.start_requested_software_instance.getReference(), instance_guid=self.start_requested_software_instance.getReference(),
) )
self.assertEqual(expected_xml, got_xml, self.assertEqual(expected_xml, got_xml,
...@@ -1557,6 +1596,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1557,6 +1596,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
partition_id, error_log) partition_id, error_log)
self.assertEqual('OK', response) self.assertEqual('OK', response)
created_at = rfc1123_date(DateTime()) created_at = rfc1123_date(DateTime())
since = created_at
response = self.portal_slap.getComputerPartitionStatus(self.computer_id, response = self.portal_slap.getComputerPartitionStatus(self.computer_id,
partition_id) partition_id)
# check returned XML # check returned XML
...@@ -1572,6 +1612,8 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1572,6 +1612,8 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<dictionary id='i2'> <dictionary id='i2'>
<string>created_at</string> <string>created_at</string>
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>since</string>
<string>%(since)s</string>
<string>text</string> <string>text</string>
<string>#error bang called</string> <string>#error bang called</string>
<string>user</string> <string>user</string>
...@@ -1580,6 +1622,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1580,6 +1622,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
</marshal> </marshal>
""" % dict( """ % dict(
created_at=created_at, created_at=created_at,
since=since,
instance_guid=self.start_requested_software_instance.getReference(), instance_guid=self.start_requested_software_instance.getReference(),
) )
self.assertEqual(expected_xml, got_xml, self.assertEqual(expected_xml, got_xml,
...@@ -1832,6 +1875,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1832,6 +1875,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
partition_id) partition_id)
self.assertEqual('None', response) self.assertEqual('None', response)
created_at = rfc1123_date(DateTime()) created_at = rfc1123_date(DateTime())
since = created_at
response = self.portal_slap.getComputerPartitionStatus(self.computer_id, response = self.portal_slap.getComputerPartitionStatus(self.computer_id,
partition_id) partition_id)
# check returned XML # check returned XML
...@@ -1847,6 +1891,8 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1847,6 +1891,8 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<dictionary id='i2'> <dictionary id='i2'>
<string>created_at</string> <string>created_at</string>
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>since</string>
<string>%(since)s</string>
<string>text</string> <string>text</string>
<string>#access Instance correctly stopped</string> <string>#access Instance correctly stopped</string>
<string>user</string> <string>user</string>
...@@ -1855,6 +1901,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1855,6 +1901,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
</marshal> </marshal>
""" % dict( """ % dict(
created_at=created_at, created_at=created_at,
since=since,
instance_guid=self.start_requested_software_instance.getReference(), instance_guid=self.start_requested_software_instance.getReference(),
) )
self.assertEqual(expected_xml, got_xml, self.assertEqual(expected_xml, got_xml,
...@@ -1869,6 +1916,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1869,6 +1916,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
partition_id) partition_id)
self.assertEqual('None', response) self.assertEqual('None', response)
created_at = rfc1123_date(DateTime()) created_at = rfc1123_date(DateTime())
since = created_at
response = self.portal_slap.getComputerPartitionStatus(self.computer_id, response = self.portal_slap.getComputerPartitionStatus(self.computer_id,
partition_id) partition_id)
# check returned XML # check returned XML
...@@ -1884,6 +1932,8 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1884,6 +1932,8 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<dictionary id='i2'> <dictionary id='i2'>
<string>created_at</string> <string>created_at</string>
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>since</string>
<string>%(since)s</string>
<string>text</string> <string>text</string>
<string>#access Instance correctly started</string> <string>#access Instance correctly started</string>
<string>user</string> <string>user</string>
...@@ -1892,6 +1942,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1892,6 +1942,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
</marshal> </marshal>
""" % dict( """ % dict(
created_at=created_at, created_at=created_at,
since=since,
instance_guid=self.start_requested_software_instance.getReference(), instance_guid=self.start_requested_software_instance.getReference(),
) )
self.assertEqual(expected_xml, got_xml, self.assertEqual(expected_xml, got_xml,
...@@ -2098,6 +2149,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2098,6 +2149,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
def test_not_accessed_getComputerStatus(self): def test_not_accessed_getComputerStatus(self):
self.login(self.person_user_id) self.login(self.person_user_id)
created_at = rfc1123_date(DateTime()) created_at = rfc1123_date(DateTime())
since = created_at
response = self.portal_slap.getComputerStatus(self.computer_id) response = self.portal_slap.getComputerStatus(self.computer_id)
self.assertEqual(200, response.status) self.assertEqual(200, response.status)
self.assertEqual('public, max-age=60, stale-if-error=604800', self.assertEqual('public, max-age=60, stale-if-error=604800',
...@@ -2121,6 +2173,8 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2121,6 +2173,8 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
<dictionary id='i2'> <dictionary id='i2'>
<string>created_at</string> <string>created_at</string>
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>since</string>
<string>%(since)s</string>
<string>text</string> <string>text</string>
<string>#error no data found for %(computer_id)s</string> <string>#error no data found for %(computer_id)s</string>
<string>user</string> <string>user</string>
...@@ -2129,6 +2183,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2129,6 +2183,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
</marshal> </marshal>
""" % dict( """ % dict(
created_at=created_at, created_at=created_at,
since=since,
computer_id=self.computer_id computer_id=self.computer_id
) )
self.assertEqual(expected_xml, got_xml, self.assertEqual(expected_xml, got_xml,
...@@ -2139,6 +2194,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2139,6 +2194,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
self.portal_slap.getFullComputerInformation(self.computer_id) self.portal_slap.getFullComputerInformation(self.computer_id)
self.login(self.person_user_id) self.login(self.person_user_id)
created_at = rfc1123_date(DateTime()) created_at = rfc1123_date(DateTime())
since = created_at
response = self.portal_slap.getComputerStatus(self.computer_id) response = self.portal_slap.getComputerStatus(self.computer_id)
self.assertEqual(200, response.status) self.assertEqual(200, response.status)
self.assertEqual('public, max-age=60, stale-if-error=604800', self.assertEqual('public, max-age=60, stale-if-error=604800',
...@@ -2163,6 +2219,8 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2163,6 +2219,8 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
<dictionary id='i2'> <dictionary id='i2'>
<string>created_at</string> <string>created_at</string>
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>since</string>
<string>%(since)s</string>
<string>text</string> <string>text</string>
<string>#access %(computer_id)s</string> <string>#access %(computer_id)s</string>
<string>user</string> <string>user</string>
...@@ -2171,6 +2229,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2171,6 +2229,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
</marshal> </marshal>
""" % dict( """ % dict(
created_at=created_at, created_at=created_at,
since=since,
computer_id=self.computer_id computer_id=self.computer_id
) )
self.assertEqual(expected_xml, got_xml, self.assertEqual(expected_xml, got_xml,
...@@ -2195,6 +2254,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2195,6 +2254,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
error_log) error_log)
self.assertEqual('None', response) self.assertEqual('None', response)
created_at = rfc1123_date(DateTime()) created_at = rfc1123_date(DateTime())
since = created_at
response = self.portal_slap.getComputerStatus(self.computer_id) response = self.portal_slap.getComputerStatus(self.computer_id)
# check returned XML # check returned XML
xml_fp = StringIO.StringIO() xml_fp = StringIO.StringIO()
...@@ -2209,6 +2269,8 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2209,6 +2269,8 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
<dictionary id='i2'> <dictionary id='i2'>
<string>created_at</string> <string>created_at</string>
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>since</string>
<string>%(since)s</string>
<string>text</string> <string>text</string>
<string>#error bang</string> <string>#error bang</string>
<string>user</string> <string>user</string>
...@@ -2217,6 +2279,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2217,6 +2279,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
</marshal> </marshal>
""" % dict( """ % dict(
created_at=created_at, created_at=created_at,
since=since,
person_reference=self.person_reference, person_reference=self.person_reference,
) )
self.assertEqual(expected_xml, got_xml, self.assertEqual(expected_xml, got_xml,
...@@ -2232,6 +2295,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2232,6 +2295,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
partition_id = self.start_requested_software_instance.getAggregateValue( partition_id = self.start_requested_software_instance.getAggregateValue(
portal_type='Computer Partition').getReference() portal_type='Computer Partition').getReference()
created_at = rfc1123_date(DateTime()) created_at = rfc1123_date(DateTime())
since = created_at
self.login(self.start_requested_software_instance.getUserId()) self.login(self.start_requested_software_instance.getUserId())
response = self.portal_slap.getComputerPartitionStatus(self.computer_id, response = self.portal_slap.getComputerPartitionStatus(self.computer_id,
partition_id) partition_id)
...@@ -2256,6 +2320,8 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2256,6 +2320,8 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
<dictionary id='i2'> <dictionary id='i2'>
<string>created_at</string> <string>created_at</string>
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>since</string>
<string>%(since)s</string>
<string>text</string> <string>text</string>
<string>#error no data found for %(instance_guid)s</string> <string>#error no data found for %(instance_guid)s</string>
<string>user</string> <string>user</string>
...@@ -2264,6 +2330,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2264,6 +2330,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
</marshal> </marshal>
""" % dict( """ % dict(
created_at=created_at, created_at=created_at,
since=since,
instance_guid=self.start_requested_software_instance.getReference(), instance_guid=self.start_requested_software_instance.getReference(),
) )
self.assertEqual(expected_xml, got_xml, self.assertEqual(expected_xml, got_xml,
...@@ -2275,6 +2342,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2275,6 +2342,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
partition_id = self.start_requested_software_instance.getAggregateValue( partition_id = self.start_requested_software_instance.getAggregateValue(
portal_type='Computer Partition').getReference() portal_type='Computer Partition').getReference()
created_at = rfc1123_date(DateTime()) created_at = rfc1123_date(DateTime())
since = created_at
self.login(self.start_requested_software_instance.getUserId()) self.login(self.start_requested_software_instance.getUserId())
self.portal_slap.registerComputerPartition(self.computer_id, partition_id) self.portal_slap.registerComputerPartition(self.computer_id, partition_id)
self.login(self.person_user_id) self.login(self.person_user_id)
...@@ -2301,6 +2369,8 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2301,6 +2369,8 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
<dictionary id='i2'> <dictionary id='i2'>
<string>created_at</string> <string>created_at</string>
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>since</string>
<string>%(since)s</string>
<string>text</string> <string>text</string>
<string>#error no data found for %(instance_guid)s</string> <string>#error no data found for %(instance_guid)s</string>
<string>user</string> <string>user</string>
...@@ -2309,6 +2379,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2309,6 +2379,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
</marshal> </marshal>
""" % dict( """ % dict(
created_at=created_at, created_at=created_at,
since=since,
instance_guid=self.start_requested_software_instance.getReference(), instance_guid=self.start_requested_software_instance.getReference(),
computer_id=self.computer_id, computer_id=self.computer_id,
partition_id=partition_id partition_id=partition_id
...@@ -2587,6 +2658,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2587,6 +2658,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
partition_id, error_log) partition_id, error_log)
self.assertEqual('OK', response) self.assertEqual('OK', response)
created_at = rfc1123_date(DateTime()) created_at = rfc1123_date(DateTime())
since = created_at
response = self.portal_slap.getComputerPartitionStatus(self.computer_id, response = self.portal_slap.getComputerPartitionStatus(self.computer_id,
partition_id) partition_id)
# check returned XML # check returned XML
...@@ -2602,6 +2674,8 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2602,6 +2674,8 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
<dictionary id='i2'> <dictionary id='i2'>
<string>created_at</string> <string>created_at</string>
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>since</string>
<string>%(since)s</string>
<string>text</string> <string>text</string>
<string>#error bang called</string> <string>#error bang called</string>
<string>user</string> <string>user</string>
...@@ -2610,6 +2684,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2610,6 +2684,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
</marshal> </marshal>
""" % dict( """ % dict(
created_at=created_at, created_at=created_at,
since=since,
person_reference=self.person_reference, person_reference=self.person_reference,
) )
self.assertEqual(expected_xml, got_xml, self.assertEqual(expected_xml, got_xml,
......
...@@ -46,22 +46,22 @@ ...@@ -46,22 +46,22 @@
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple>
<string>W: 28, 10: Use of eval (eval-used)</string> <string>W: 27, 10: Use of eval (eval-used)</string>
<string>W:529, 13: Use of eval (eval-used)</string> <string>W:540, 13: Use of eval (eval-used)</string>
<string>W:580, 13: Use of eval (eval-used)</string> <string>W:595, 13: Use of eval (eval-used)</string>
<string>W:805, 13: Use of eval (eval-used)</string> <string>W:836, 13: Use of eval (eval-used)</string>
<string>W:1422, 13: Use of eval (eval-used)</string> <string>W:1461, 13: Use of eval (eval-used)</string>
<string>W:1535, 13: Use of eval (eval-used)</string> <string>W:1578, 13: Use of eval (eval-used)</string>
<string>W:1589, 13: Use of eval (eval-used)</string> <string>W:1636, 13: Use of eval (eval-used)</string>
<string>W:1629, 13: Use of eval (eval-used)</string> <string>W:1676, 13: Use of eval (eval-used)</string>
<string>W:2177, 13: Use of eval (eval-used)</string> <string>W:2239, 13: Use of eval (eval-used)</string>
<string>W:2566, 13: Use of eval (eval-used)</string> <string>W:2640, 13: Use of eval (eval-used)</string>
<string>W:2620, 13: Use of eval (eval-used)</string> <string>W:2698, 13: Use of eval (eval-used)</string>
<string>W:2647, 13: Use of eval (eval-used)</string> <string>W:2725, 13: Use of eval (eval-used)</string>
<string>W:2804, 13: Use of eval (eval-used)</string> <string>W:2882, 13: Use of eval (eval-used)</string>
<string>W:2832, 13: Use of eval (eval-used)</string> <string>W:2910, 13: Use of eval (eval-used)</string>
<string>W:2881, 13: Use of eval (eval-used)</string> <string>W:2959, 13: Use of eval (eval-used)</string>
<string>W:2928, 13: Use of eval (eval-used)</string> <string>W:3006, 13: Use of eval (eval-used)</string>
</tuple> </tuple>
</value> </value>
</item> </item>
...@@ -134,6 +134,7 @@ ...@@ -134,6 +134,7 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
<none/>
</tuple> </tuple>
</pickle> </pickle>
</record> </record>
......
...@@ -863,10 +863,22 @@ class SlapTool(BaseTool): ...@@ -863,10 +863,22 @@ class SlapTool(BaseTool):
def _logAccess(self, user_reference, context_reference, text): def _logAccess(self, user_reference, context_reference, text):
memcached_dict = self.Base_getSlapToolMemcachedDict() memcached_dict = self.Base_getSlapToolMemcachedDict()
previous = self._getCachedAccessInfo(context_reference)
created_at = rfc1123_date(DateTime())
since = created_at
if previous is not None:
previous_json = json.loads(previous)
if text.split(" ")[0] == previous_json.get("text", "").split(" ")[0]:
since = previous_json.get("since",
previous_json.get("created_at", rfc1123_date(DateTime())))
value = json.dumps({ value = json.dumps({
'user': '%s' % user_reference, 'user': '%s' % user_reference,
'created_at': '%s' % rfc1123_date(DateTime()), 'created_at': '%s' % created_at,
'text': '%s' % text, 'text': '%s' % text,
'since': '%s' % since
}) })
memcached_dict[context_reference] = value memcached_dict[context_reference] = value
...@@ -1098,17 +1110,20 @@ class SlapTool(BaseTool): ...@@ -1098,17 +1110,20 @@ class SlapTool(BaseTool):
def _getAccessStatus(self, context_reference): def _getAccessStatus(self, context_reference):
d = self._getCachedAccessInfo(context_reference) d = self._getCachedAccessInfo(context_reference)
last_modified = rfc1123_date(DateTime())
if d is None: if d is None:
if context_reference is None: if context_reference is None:
d = { d = {
"user": "SlapOS Master", "user": "SlapOS Master",
'created_at': '%s' % rfc1123_date(DateTime()), 'created_at': '%s' % last_modified,
'since': '%s' % last_modified,
"text": "#error no data found" "text": "#error no data found"
} }
else: else:
d = { d = {
"user": "SlapOS Master", "user": "SlapOS Master",
'created_at': '%s' % rfc1123_date(DateTime()), 'created_at': '%s' % last_modified,
'since': '%s' % last_modified,
"text": "#error no data found for %s" % context_reference "text": "#error no data found for %s" % context_reference
} }
# Prepare for xml marshalling # Prepare for xml marshalling
...@@ -1123,7 +1138,7 @@ class SlapTool(BaseTool): ...@@ -1123,7 +1138,7 @@ class SlapTool(BaseTool):
'public, max-age=60, stale-if-error=604800') 'public, max-age=60, stale-if-error=604800')
self.REQUEST.response.setHeader('Vary', self.REQUEST.response.setHeader('Vary',
'REMOTE_USER') 'REMOTE_USER')
self.REQUEST.response.setHeader('Last-Modified', rfc1123_date(DateTime())) self.REQUEST.response.setHeader('Last-Modified', last_modified)
self.REQUEST.response.setHeader('Content-Type', 'text/xml; charset=utf-8') self.REQUEST.response.setHeader('Content-Type', 'text/xml; charset=utf-8')
self.REQUEST.response.setBody(xml_marshaller.xml_marshaller.dumps(d)) self.REQUEST.response.setBody(xml_marshaller.xml_marshaller.dumps(d))
return self.REQUEST.response return self.REQUEST.response
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment