Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #629 (closed defect: fixed)

Opened 13 years ago

Last modified 12 years ago

[PATCH] IdentityManagementNotEnabledException in a freshly quickstarted project

Reported by: nyenyec Owned by: anonymous
Priority: high Milestone: 1.0.2
Component: Identity Version:
Severity: major Keywords:
Cc:

Description

When running a freshly quickstarted project (r858) the generated tests fail with the following trace:

C:\local\python\cleanprj>nosetests
..E
======================================================================
ERROR: Object creation should set the name
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\local\python\cleanprj\cleanprj\tests\test_model.py", line 15, in test
_creation
    password = "Wafer-thin Mint")
  File "c:\python24\lib\site-packages\SQLObject-0.7.1dev_r1457-py2.4.egg\sqlobje
ct\main.py", line 1197, in __init__
    self._create(id, **kw)
  File "c:\python24\lib\site-packages\SQLObject-0.7.1dev_r1457-py2.4.egg\sqlobje
ct\inheritance\__init__.py", line 218, in _create
    super(InheritableSQLObject, self)._create(id, **kw)
  File "c:\python24\lib\site-packages\SQLObject-0.7.1dev_r1457-py2.4.egg\sqlobje
ct\main.py", line 1221, in _create
    self.set(**kw)
  File "c:\python24\lib\site-packages\SQLObject-0.7.1dev_r1457-py2.4.egg\sqlobje
ct\main.py", line 1097, in set
    setattr(self, name, value)
  File "c:\local\turbogears\svn\turbogears\turbogears\identity\soprovider.py", l
ine 292, in _set_password
    hash = identity.current_provider.encrypt_password(cleartext_password)
  File "c:\local\turbogears\svn\turbogears\turbogears\identity\__init__.py", lin
e 74, in __getattr__
    raise IdentityManagementNotEnabledException()
IdentityManagementNotEnabledException: An attempt was made to use a facility of
the TurboGears Identity Management framework but identity management hasn't been
 enabled in the config file [via identity.on].

----------------------------------------------------------------------
Ran 3 tests in 2.003s

FAILED (errors=1)

This can be related to #624.

Attachments

fix_test_controllers.diff Download (1.9 KB) - added by peter.russell@… 13 years ago.
Patch to make the tests in quickstarted test_controlers.py a class.

Change History

comment:1 Changed 13 years ago by godoy

  • Status changed from new to closed
  • Resolution set to fixed

This is fixed in the trunk.

% tg-admin quickstart
(...)
% cd testing123
% nosetests
..
----------------------------------------------------------------------
Ran 2 tests in 1.574s

OK

comment:2 Changed 13 years ago by peter.russell@…

  • Status changed from closed to reopened
  • Resolution fixed deleted

I think the bug is fixed only by the fact that since r1003 the test_model was commented out by default. This bug can now be reproduced with the following steps:

tg-admin quickstart

Set project name to something like "sample" (It's important you *don't* call it "test", as this badly confuses nose.)

Answer yes to using identity, and set the provider to be sqlobject.

Edit sample/tests/test_model, and uncomment everything, but delete the import of "YourDataClass?" as it isn't created yet. Save the file

Now from the root of your project run nosetests. You will get two tests that pass, and one, the one you just edited, which fails, with the following stack trace:

----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/psr/sample/sample/tests/test_model.py", line 21, in test_creation
    password = "Wafer-thin Mint")
  File "/home/psr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1772-py2.4.egg/sqlobject/declarative.py", line 93, in _wrapper
    return fn(self, *args, **kwargs)
  File "/home/psr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1772-py2.4.egg/sqlobject/main.py", line 1197, in __init__
    self._create(id, **kw)
  File "/home/psr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1772-py2.4.egg/sqlobject/main.py", line 1221, in _create
    self.set(**kw)
  File "/home/psr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1772-py2.4.egg/sqlobject/main.py", line 1097, in set
    setattr(self, name, value)
  File "/home/psr/sample/sample/model.py", line 77, in _set_password
    hash = identity.encrypt_password(cleartext_password)
  File "/home/psr/soft/turbogears/turbogears/identity/__init__.py", line 115, in encrypt_password
    return encrypt_password(cleartext)
  File "/home/psr/soft/turbogears/turbogears/identity/soprovider.py", line 391, in encrypt_password
    hash = identity.current_provider.\
  File "/home/psr/soft/turbogears/turbogears/identity/__init__.py", line 79, in __getattr__
    raise IdentityManagementNotEnabledException()
IdentityManagementNotEnabledException: An attempt was made to use a facility of the TurboGears Identity Management framework but identity management hasn't been enabled in the config file [via identity.on].
----------------------------------------------------------------------

This bug seems to stem from test_controller not cleaning up after itself.

$ nosetests -o sample/tests/test_model.py sample/tests/test_controllers.py
...
----------------------------------------------------------------------
Ran 3 tests in 1.767s

OK
$ nosetests -o sample/tests/test_controllers.py sample/tests/test_model.py
..E
======================================================================
ERROR: Object creation should set the name
----------------------------------------------------------------------
<snipped backtrace>
----------------------------------------------------------------------
Ran 3 tests in 1.218s

FAILED (errors=1)

Will attach a patch in a bit.

Changed 13 years ago by peter.russell@…

Patch to make the tests in quickstarted test_controlers.py a class.

comment:3 Changed 13 years ago by peter.russell@…

Added an attachment which makes the tests in test_controllers methods of a unittest.TestCase?. I can't honestly say I understand why that fixes the problem, but it appears to.

comment:4 Changed 13 years ago by peter.russell@…

  • Summary changed from IdentityManagementNotEnabledException in a freshly quickstarted project to [PATCH] IdentityManagementNotEnabledException in a freshly quickstarted project

Just realised I should have [PATCH] in the summary if I want anyone to see this

comment:5 Changed 13 years ago by jorge.vargas

  • Milestone changed from 0.9 to 1.0b2

comment:6 Changed 13 years ago by jorge.vargas

  • Priority changed from normal to high

this is still present in 1.0b1

now do we really need this tests? I mean they will break almost instantly

comment:7 Changed 13 years ago by max

  • Severity changed from normal to major

the question is not whether or not we need tests (we do). the question is -- you cannot write them right now. I face the problem myself -- tests that worked in TG1.0a no longer work raise exception shown above.

comment:8 Changed 13 years ago by max

Looks like I cannot reproduce it. I don't see why the patch proposed should help. And why uncommenting test_model makes test_controllers fail.

comment:9 Changed 12 years ago by alberto

  • Milestone changed from 1.0b2 to 1.1

comment:10 Changed 12 years ago by jorge.vargas

  • Milestone changed from 1.1 to 1.0.2

comment:11 Changed 12 years ago by alberto

  • Status changed from reopened to closed
  • Resolution set to fixed

Applied a fix at [2837]

Alberto

Note: See TracTickets for help on using tickets.