Remove Sha field and add password widget

issue3713
review3791003
This commit is contained in:
Cédric Krier
2014-03-07 19:38:01 +01:00
parent 8f89bc5b49
commit f0a4bbcff7
13 changed files with 7 additions and 274 deletions
+2
View File
@@ -1,3 +1,5 @@
* Remove Sha field
* Add password widget
* Add Len to PYSON
* Use bcrypt to hash password if possible
* Use a sequence of ids, values to set fields
-9
View File
@@ -257,15 +257,6 @@ A single line string field.
ComboboxEntry in the client.
The set of field names could be filled by using the decorator :meth:`depends`.
Sha
---
.. class:: Sha(string[, \**options])
A string field which value will be stored with a `secure hash algorithm`_.
.. _`secure hash algorithm`: http://en.wikipedia.org/wiki/Secure_Hash_Algorithm
Text
----
+1 -1
View File
@@ -48,7 +48,7 @@ attlist.field &=
| "integer"
| "selection"
| "char"
| "sha"
| "password"
| "float_time"
| "boolean"
| "reference"
+1 -1
View File
@@ -147,7 +147,7 @@
<value>integer</value>
<value>selection</value>
<value>char</value>
<value>sha</value>
<value>password</value>
<value>float_time</value>
<value>boolean</value>
<value>reference</value>
+1 -1
View File
@@ -11,7 +11,7 @@ this repository contains the full copyright notices and license terms. -->
<label name="login"/>
<field name="login"/>
<label name="password"/>
<field name="password" widget="sha"/>
<field name="password" widget="password"/>
<label name="email"/>
<field name="email" widget="email"/>
<separator name="signature" colspan="4"/>
+1 -1
View File
@@ -9,7 +9,7 @@ this repository contains the full copyright notices and license terms. -->
<label name="email"/>
<field name="email" widget="email"/>
<label name="password"/>
<field name="password" widget="sha"/>
<field name="password" widget="password"/>
<separator name="signature" colspan="4"/>
<field name="signature" colspan="4"/>
</page>
-4
View File
@@ -39,9 +39,6 @@ def register():
TextRequired,
TextSize,
TextTranslate,
Sha,
ShaDefault,
ShaRequired,
Date,
DateDefault,
DateRequired,
@@ -108,7 +105,6 @@ def register():
ImportDataNumericRequired,
ImportDataChar,
ImportDataText,
ImportDataSha,
ImportDataDate,
ImportDataDateTime,
ImportDataSelection,
-1
View File
@@ -25,7 +25,6 @@ class ExportData(ModelSQL):
numeric = fields.Numeric('Numeric')
char = fields.Char('Char')
text = fields.Text('Text')
sha = fields.Sha('Sha')
date = fields.Date('Date')
datetime = fields.DateTime('DateTime')
selection = fields.Selection([
+1 -7
View File
@@ -7,7 +7,7 @@ __all__ = [
'ImportDataBoolean', 'ImportDataInteger', 'ImportDataIntegerRequired',
'ImportDataFloat', 'ImportDataFloatRequired',
'ImportDataNumeric', 'ImportDataNumericRequired',
'ImportDataChar', 'ImportDataText', 'ImportDataSha',
'ImportDataChar', 'ImportDataText',
'ImportDataDate', 'ImportDataDateTime', 'ImportDataSelection',
'ImportDataMany2OneTarget', 'ImportDataMany2One',
'ImportDataMany2ManyTarget', 'ImportDataMany2Many',
@@ -71,12 +71,6 @@ class ImportDataText(ModelSQL):
text = fields.Text('Text')
class ImportDataSha(ModelSQL):
"Import Data Sha"
__name__ = 'test.import_data.sha'
sha = fields.Sha('Sha')
class ImportDataDate(ModelSQL):
"Import Data Date"
__name__ = 'test.import_data.date'
-26
View File
@@ -13,7 +13,6 @@ __all__ = [
'Numeric', 'NumericDefault', 'NumericRequired', 'NumericDigits',
'Char', 'CharDefault', 'CharRequired', 'CharSize', 'CharTranslate',
'Text', 'TextDefault', 'TextRequired', 'TextSize', 'TextTranslate',
'Sha', 'ShaDefault', 'ShaRequired',
'Date', 'DateDefault', 'DateRequired',
'DateTime', 'DateTimeDefault', 'DateTimeRequired', 'DateTimeFormat',
'Time', 'TimeDefault', 'TimeRequired', 'TimeFormat',
@@ -226,31 +225,6 @@ class TextTranslate(ModelSQL):
required=False, translate=True)
class Sha(ModelSQL):
'Sha'
__name__ = 'test.sha'
sha = fields.Sha(string='Sha', help='Test sha',
required=False)
class ShaDefault(ModelSQL):
'Sha Default'
__name__ = 'test.sha_default'
sha = fields.Sha(string='Sha', help='Test sha',
required=False)
@staticmethod
def default_sha():
return 'Sha'
class ShaRequired(ModelSQL):
'Sha Required'
__name__ = 'test.sha_required'
sha = fields.Sha(string='Sha', help='Test sha',
required=True)
class Date(ModelSQL):
'Date'
__name__ = 'test.date'
-13
View File
@@ -162,19 +162,6 @@ class ExportDataTestCase(unittest.TestCase):
transaction.cursor.rollback()
def test0070sha(self):
'Test sha'
with Transaction().start(DB_NAME, USER,
context=CONTEXT) as transaction:
export1, = self.export_data.create([{
'sha': 'Test',
}])
self.assertEqual(
self.export_data.export_data([export1], ['sha']),
[['640ab2bae07bedc4c163f679a746f7ab7fb5d1fa']])
transaction.cursor.rollback()
def test0080date(self):
'Test date'
with Transaction().start(DB_NAME, USER,
-194
View File
@@ -52,10 +52,6 @@ class FieldsTestCase(unittest.TestCase):
self.text_size = POOL.get('test.text_size')
self.text_translate = POOL.get('test.text_translate')
self.sha = POOL.get('test.sha')
self.sha_default = POOL.get('test.sha_default')
self.sha_required = POOL.get('test.sha_required')
self.date = POOL.get('test.date')
self.date_default = POOL.get('test.date_default')
self.date_required = POOL.get('test.date_required')
@@ -1304,196 +1300,6 @@ class FieldsTestCase(unittest.TestCase):
transaction.cursor.rollback()
def test0070sha(self):
'Test Sha'
with Transaction().start(DB_NAME, USER,
context=CONTEXT) as transaction:
sha1, = self.sha.create([{
'sha': 'Test',
}])
self.assert_(sha1)
self.assertEqual(sha1.sha,
'640ab2bae07bedc4c163f679a746f7ab7fb5d1fa')
sha = self.sha.search([
('sha', '=', 'Test'),
])
self.assertEqual(sha, [sha1])
sha = self.sha.search([
('sha', '=', 'Foo'),
])
self.assertEqual(sha, [])
sha = self.sha.search([
('sha', '=', None),
])
self.assertEqual(sha, [])
sha = self.sha.search([
('sha', '!=', 'Test'),
])
self.assertEqual(sha, [])
sha = self.sha.search([
('sha', '!=', 'Foo'),
])
self.assert_(sha, [sha1])
sha = self.sha.search([
('sha', '!=', None),
])
self.assertEqual(sha, [sha1])
sha = self.sha.search([
('sha', 'in', ['Test']),
])
self.assertEqual(sha, [sha1])
sha = self.sha.search([
('sha', 'in', ['Foo']),
])
self.assertEqual(sha, [])
sha = self.sha.search([
('sha', 'in', [None]),
])
self.assertEqual(sha, [])
sha = self.sha.search([
('sha', 'in', []),
])
self.assertEqual(sha, [])
sha = self.sha.search([
('sha', 'not in', ['Test']),
])
self.assertEqual(sha, [])
sha = self.sha.search([
('sha', 'not in', ['Foo']),
])
self.assertEqual(sha, [sha1])
sha = self.sha.search([
('sha', 'not in', [None]),
])
self.assertEqual(sha, [sha1])
sha = self.sha.search([
('sha', 'not in', []),
])
self.assertEqual(sha, [sha1])
sha = self.sha.search([
('sha', 'like', 'Test'),
])
self.assertEqual(sha, [sha1])
sha = self.sha.search([
('sha', 'like', 'Foo'),
])
self.assertEqual(sha, [])
sha = self.sha.search([
('sha', 'ilike', 'Test'),
])
self.assertEqual(sha, [sha1])
sha = self.sha.search([
('sha', 'ilike', 'foo'),
])
self.assertEqual(sha, [])
sha = self.sha.search([
('sha', 'not like', 'Test'),
])
self.assertEqual(sha, [])
sha = self.sha.search([
('sha', 'not like', 'Foo'),
])
self.assertEqual(sha, [sha1])
sha = self.sha.search([
('sha', 'not ilike', 'foo'),
])
self.assertEqual(sha, [sha1])
sha2, = self.sha.create([{
'sha': None,
}])
self.assert_(sha2)
self.assertEqual(sha2.sha, None)
sha = self.sha.search([
('sha', '=', None),
])
self.assertEqual(sha, [sha2])
sha = self.sha.search([
('sha', 'in', [None, 'Test']),
])
self.assertEqual(sha, [sha1, sha2])
sha = self.sha.search([
('sha', 'not in', [None, 'Test']),
])
self.assertEqual(sha, [])
sha3, = self.sha.create([{}])
self.assert_(sha3)
self.assertEqual(sha3.sha, None)
sha4, = self.sha_default.create([{}])
self.assert_(sha4)
self.assertEqual(sha4.sha,
'ba79baeb9f10896a46ae74715271b7f586e74640')
self.sha.write([sha1], {
'sha': None,
})
self.assertEqual(sha1.sha, None)
self.sha.write([sha2], {
'sha': 'Test',
})
self.assertEqual(sha2.sha,
'640ab2bae07bedc4c163f679a746f7ab7fb5d1fa')
self.assertRaises(Exception, self.sha_required.create, [{}])
transaction.cursor.rollback()
sha5, = self.sha_required.create([{
'sha': 'Test',
}])
self.assert_(sha5)
sha6, = self.sha.create([{
'sha': u'é',
}])
self.assert_(sha6)
self.assertEqual(sha6.sha,
u'bf15be717ac1b080b4f1c456692825891ff5073d')
sha = self.sha.search([
('sha', '=', u'é'),
])
self.assertEqual(sha, [sha6])
self.sha.write([sha6], {
'sha': 'é',
})
self.assertEqual(sha6.sha,
u'bf15be717ac1b080b4f1c456692825891ff5073d')
sha = self.sha.search([
('sha', '=', 'é'),
])
self.assertEqual(sha, [sha6])
transaction.cursor.rollback()
def test0080date(self):
'Test Date'
with Transaction().start(DB_NAME, USER,
-16
View File
@@ -21,7 +21,6 @@ class ImportDataTestCase(unittest.TestCase):
self.numeric_required = POOL.get('test.import_data.numeric_required')
self.char = POOL.get('test.import_data.char')
self.text = POOL.get('test.import_data.text')
self.sha = POOL.get('test.import_data.sha')
self.date = POOL.get('test.import_data.date')
self.datetime = POOL.get('test.import_data.datetime')
self.selection = POOL.get('test.import_data.selection')
@@ -267,21 +266,6 @@ class ImportDataTestCase(unittest.TestCase):
transaction.cursor.rollback()
def test0070sha(self):
'Test sha'
with Transaction().start(DB_NAME, USER,
context=CONTEXT) as transaction:
self.assertEqual(self.sha.import_data(['sha'],
[['test']]), (1, 0, 0, 0))
self.assertEqual(self.sha.import_data(['sha'],
[['']]), (1, 0, 0, 0))
self.assertEqual(self.sha.import_data(['sha'],
[['test'], ['foo']]), (2, 0, 0, 0))
transaction.cursor.rollback()
def test0080date(self):
'Test date'
with Transaction().start(DB_NAME, USER,