Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request cd34#58 from sontek/add-password-salt
Add password salt Thank you for the pull request.
- Loading branch information
Showing
6 changed files
with
138 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Store: | ||
Type: SQL | ||
DB: sqlite:///%(here)s/apex_test.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import os | ||
import unittest | ||
from sqlalchemy import engine_from_config | ||
from pyramid import testing | ||
from sqlalchemy.orm import sessionmaker | ||
from apex.models import DBSession | ||
from apex.models import Base | ||
here = os.path.abspath(os.path.dirname(__file__)) | ||
|
||
|
||
""" bare minimum settings required for testing | ||
""" | ||
settings = { | ||
'sqlalchemy.url':'sqlite:///apex.test.db', | ||
'mako.directories':'{0}/../apex/templates'.format(here), | ||
'apex.session_secret':'session_secret', | ||
'apex.auth_secret':'auth_secret', | ||
'apex.came_from_route':'home', | ||
'apex.velruse_config':'{0}/CONFIG.yaml'.format(here), | ||
'apex.use_recaptcha_on_login': 'false', | ||
} | ||
|
||
|
||
class BaseTestCase(unittest.TestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
""" must add default route 'home' and include apex | ||
we also must create a default user/pass/group to test | ||
""" | ||
cls.engine = engine_from_config(settings, prefix='sqlalchemy.') | ||
DBSession.configure(bind=cls.engine) | ||
Base.metadata.create_all(cls.engine) | ||
|
||
cls.Session = sessionmaker() | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
DBSession.close() | ||
from apex.models import Base | ||
Base.metadata.drop_all(cls.engine) | ||
|
||
|
||
def setUp(self): | ||
self.config = testing.setUp() | ||
self.config.add_route('home', '/') | ||
self.config.add_settings(settings) | ||
self.config.include('apex') | ||
|
||
connection = self.engine.connect() | ||
|
||
# begin a non-ORM transaction | ||
self.trans = connection.begin() | ||
|
||
# bind an individual Session to the connection | ||
DBSession.configure(bind=connection) | ||
self.session = self.Session(bind=connection) | ||
|
||
def tearDown(self): | ||
# rollback - everything that happened with the | ||
# Session above (including calls to commit()) | ||
# is rolled back. | ||
testing.tearDown() | ||
self.trans.rollback() | ||
self.session.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters