# HG changeset patch # User Sylvain Thénault # Date 1258042507 -3600 # Node ID 3b6bbb3a3c3e9d54635e413629a49c4815e60f41 # Parent 9674d62a54f9d0f55be845524bacb6ed12e6fa7d close #472361: omit password and bytes attributes in allowed mass-mailing keys by fixing default implementation for allowed_massmail_keys() in the Emailable pluggable mixin (cw.common.mixins). Added test (in entities.test though), also fix CWUserTC classes conflicts in the test module. diff -r 9674d62a54f9 -r 3b6bbb3a3c3e common/mixins.py --- a/common/mixins.py Thu Nov 12 13:53:26 2009 +0100 +++ b/common/mixins.py Thu Nov 12 17:15:07 2009 +0100 @@ -180,7 +180,9 @@ For instance, the Person class might want to return a `companyname` key. """ - return set(rs.type for rs, _ in cls.e_schema.attribute_definitions()) + return set(rschema.type + for rschema, attrtype in cls.e_schema.attribute_definitions() + if attrtype.type not in ('Password', 'Bytes')) def as_email_context(self): """returns the dictionary as used by the sendmail controller to diff -r 9674d62a54f9 -r 3b6bbb3a3c3e entities/test/unittest_base.py --- a/entities/test/unittest_base.py Thu Nov 12 13:53:26 2009 +0100 +++ b/entities/test/unittest_base.py Thu Nov 12 17:15:07 2009 +0100 @@ -45,18 +45,6 @@ {'description_format': ('format', 'description')}) -class CWUserTC(BaseEntityTC): - def test_dc_title_and_name(self): - e = self.entity('CWUser U WHERE U login "member"') - self.assertEquals(e.dc_title(), 'member') - self.assertEquals(e.name(), 'member') - self.execute(u'SET X firstname "bouah" WHERE X is CWUser, X login "member"') - self.assertEquals(e.dc_title(), 'member') - self.assertEquals(e.name(), u'bouah') - self.execute(u'SET X surname "lôt" WHERE X is CWUser, X login "member"') - self.assertEquals(e.dc_title(), 'member') - self.assertEquals(e.name(), u'bouah lôt') - class EmailAddressTC(BaseEntityTC): def test_canonical_form(self): email1 = self.execute('INSERT EmailAddress X: X address "maarten.ter.huurne@philips.com"').get_entity(0, 0) @@ -94,6 +82,25 @@ self.failUnless(e.matching_groups(('xyz', 'managers'))) self.failIf(e.matching_groups(('xyz', 'abcd'))) + def test_dc_title_and_name(self): + e = self.entity('CWUser U WHERE U login "member"') + self.assertEquals(e.dc_title(), 'member') + self.assertEquals(e.name(), 'member') + e.set_attributes(firstname=u'bouah') + self.assertEquals(e.dc_title(), 'member') + self.assertEquals(e.name(), u'bouah') + e.set_attributes(surname=u'lôt') + self.assertEquals(e.dc_title(), 'member') + self.assertEquals(e.name(), u'bouah lôt') + + def test_allowed_massmail_keys(self): + e = self.entity('CWUser U WHERE U login "member"') + # Bytes/Password attributes should be omited + self.assertEquals(e.allowed_massmail_keys(), + set(('surname', 'firstname', 'login', 'last_login_time', + 'creation_date', 'modification_date', 'cwuri', 'eid')) + ) + class InterfaceTC(EnvBasedTC):