48 Commits

Author SHA1 Message Date
Sebastian Spaeth
a89df96132 Restructure ForgotPassword view
1) Remove mongo limitations (no 'or' when querying for either username
or email).

2) Lost password function revealed if an user name or email address
   is registered, which can be considered a data leak.
   Leaking user names is OK, they are public anyway, but don't reveal
   lookup success in case the lookup happened by email address.
   Simply respond: "If you have an account here, we have send you
                    your email"?

3) username and email search was case sensitive. Made username search
   case insensitive (they are always stored lowercase in the db).
   Keep email-address search case sensitive for now. This might need
   further discussion

4) Remove a whole bunch of indention in the style of:
   if no error:
        ...
        if no error:
            ...
            if no error:
                actually do something in the regular case

   by restructuring the function.

5) Outsource the sanity checking for username and email fields into the
   validator function. This way, we get automatic case sanity checking
   and sanitizing for all required fields.

6) Require 5-char password and fix tests

   Originally, the Change password form required a password between 6-30
   chars while the registration and login form did not require anything
   special. This commit introduces a common minimum limit for all forms
   which breaks the test suite which uses a 5 char password by
   default. :-).  As 5 chars seem sensible enough to enforce (people
   should be picking much longer ones anyway), just reduce the limit to
   5 chars, thereby making all tests pass.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-21 17:14:59 +01:00
Elrond
1be247b36e Rename get_test_app to get_app.
nosetests runs everything that even vaguely looks like a
test case... even our get_test_app. And as it is imported
everywhere... it is run everywhere as a test case. Renaming
it saves us about 10+ tests and a few seconds of time.
2013-01-18 11:40:40 +01:00
Sebastian Spaeth
b97144dcc9 tests: More instances where a fresh database is not needed
Save test runtime by not dumping the databases when not needed.
2013-01-08 15:55:32 +01:00
Sebastian Spaeth
b0c8328e54 Move db.sql.models* to db.models* 2013-01-07 11:44:29 +01:00
Sebastian Spaeth
0eff207dff tests/auth: Don't rely on case sensitive error strings
webob's 404 status is "404 NOT FOUND" while werkzeug's is
"404 Not Found". Our test suite was checking the upper case string
for equality. Just test the status error code "404" rather than the
full string which might change at some points/versions and should
not need to be tested.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-21 08:12:25 +01:00
Sebastian Spaeth
5c2b84869f Move DBModel._id -> DBModel.id
We were refering to model._id in most of the code base as this is
what Mongo uses. However, each use of _id required a) fixup of queries:
e.g. what we did in our find() and find_one() functions moving all
'_id' to 'id'. It also required using AliasFields to make the ._id
attribute available. This all means lots of superfluous fixing and
transitioning in a SQL world.

It will also not work in the long run. Much newer code already refers
to the objects by model.id (e.g. in the oauth plugin), which will break
with Mongo. So let's be honest, rip out the _id mongoism and live with
.id as the one canonical way to address objects.

This commit modifies all users and providers of model._id to use
model.id instead. This patch works with or without Mongo removed first,
but will break Mongo usage (even more than before)

I have not bothered to fixup db.mongo.* and db.sql.convert
(which converts from Mongo to SQL)

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-21 00:30:48 +01:00
Sebastian Spaeth
7e55bcb898 Fix up tests
empty find() queries would not work anymore with the simplified .find
compatability code, so remove these and use proper sqlalchemy in the
tests.

The storage test failed because my virtualenv environment ran
mediagoblin/local/mediagoblin/tests/test_storage.py and somehow decided
the 2 classes are different objects. Just test against the full class name.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-21 00:30:48 +01:00
Brett Smith
766d9ae7be Prevent SQLAlchemy non-Unicode warnings from this test. 2012-07-08 10:24:57 -04:00
Elrond
f4162cb640 Reload the user for current values.
This might not be needed, but it helped at one point.
2012-03-26 20:31:36 +02:00
Christopher Allan Webber
cf29e8a824 It's 2012 all up in here 2012-02-02 09:44:13 -06:00
Elrond
445d811043 Fix unit tests for new forget password flow
After changing the password, the login page is now shown.
It contains a message.  (we can't test for that easily
currently.  There is a bug open on this problem.)

At least for the login page being shown now.
2012-01-01 19:20:38 +01:00
Joar Wandborg
4601c30c2e Fixed submission error handling and broken tests
- Fixed broken test_auth test
- Fixed error handling on submission, it now raises the exception
  if it is not explicitly relevant to file submission.
2011-12-31 22:57:08 +01:00
Joar Wandborg
7c7ba01ee3 Fixed broken confirm_password test 2011-12-30 19:11:47 +01:00
Elrond
2d540fed8b Dot-Notation for Users.fp_token_expire 2011-12-05 21:08:58 +01:00
Elrond
dc39e4555c Dot-Notation for Users.fp_verification_key 2011-12-05 21:08:58 +01:00
Elrond
00bb95502e Dot-Notation for Users.verification_key 2011-12-05 21:08:57 +01:00
Elrond
7a3d00ec21 Dot-Notation for Users.status 2011-12-05 21:08:57 +01:00
Elrond
4facc7a0a2 Dot-Notation for Users.email_verified 2011-12-05 21:08:57 +01:00
Elrond
ea5a5b15a3 Merge branch 'misc/fixture_add_user'
* misc/fixture_add_user:
  fixture_add_user: Factoring a unit test tool
2011-12-04 14:59:33 +01:00
Elrond
93e4622491 Expect 404 in unit tests, if we now use 404.
Our unit tests for auth were expecting a 400.
Well, now we give a 404. So expect that!

I'm not completely sure, if the 404 is the right thing
here, but that's another topic.
2011-12-02 00:09:13 +01:00
Elrond
9754802d4b fixture_add_user: Factoring a unit test tool
Some unit tests need a user in the database, especially to
act as that user.  Some routines did that on their own.  So
factored this whole thing into a new function and use it
around.
2011-12-01 23:33:47 +01:00
Elrond
eabe6b678a Dot-Notation for "_id"
Note: Migrations can't use "Dot Notation"!

Migrations run on pymongo, not mongokit.
So they can't use the "Dot Notation".
This isn't really a big issue, as migrations are anyway
quite mongo specific.
2011-11-15 11:32:13 +01:00
Aaron Williamson
152a3bfaa3 Finished splitting util.py into separate files. 2011-10-01 18:05:44 -04:00
Aaron Williamson
ae3bc7fabf Moved common, translation, template, and url code out of util.py and into tools/[file].py 2011-10-01 09:31:42 -04:00
Christopher Allan Webber
f373599bd7 Merge branch 'gullydwarf-cfdv-f357_lost_password_functionality'
Conflicts:
	mediagoblin/auth/routing.py
2011-09-08 08:12:43 -05:00
Christopher Allan Webber
f03fef4ea8 Updating calls to recall password URLs to respect changed routing 2011-09-07 23:23:26 -05:00
Caleb Forbes Davis V
4bcaf9f32a for readability, and adds unit test for expired token 2011-09-05 18:57:06 -05:00
Caleb Forbes Davis V
65a8304794 added unit tests for lost password code 2011-09-05 17:33:01 -05:00
Will Kahn-Greene
12a100e4d8 508. Updates copyright/license information 2011-09-01 20:50:19 -04:00
Christopher Allan Webber
a656ccd561 Updating tests to reflect we redirect to the user's page after verification now. 2011-08-01 08:34:50 -05:00
Christopher Allan Webber
f73f4c4b84 Log in user after regitration 2011-07-29 08:43:59 -05:00
Christopher Allan Webber
0bc036209d Redirect to the user's profile after registration
- Updated the view
 - Updated the tests
 - Fixed a weirdness in the registration view where the 'user'
   variable used to be called 'entry'
2011-07-29 08:22:26 -05:00
Caleb Forbes Davis V
e054ae9b3d allows using messaging instead of verify_email.html to pass tests
* re-instated verification_successful flag
* modified test_auth to verify nav to user_pages/user.html template
2011-07-04 20:04:00 -05:00
Chris Moylan
12c231c8ac added test coverage for redirecting after login with the next param 2011-06-19 12:28:53 -05:00
Chris Moylan
0a4cecdc66 Added tests for all sorts of login form abuse.
Added tests for log out
2011-06-19 00:22:47 -05:00
Chris Moylan
757690cc2e logins are now somewhat tested 2011-06-17 00:15:24 -05:00
Christopher Allan Webber
6e7ce8d1af mediagoblin.globals->mediagoblin.mg_globals 2011-06-12 17:27:37 -05:00
Christopher Allan Webber
3aa4c668b9 A setup_fresh_app decorator which should make writing tests a bit easier.
Setting test_register_views() to use it also.
2011-06-06 07:45:18 -05:00
Christopher Allan Webber
2fecc29d06 Docstring for test_register_views() 2011-06-05 18:16:31 -05:00
Christopher Allan Webber
8a869db8e4 Make sure that two users with the same username can't register. 2011-06-05 18:14:48 -05:00
Christopher Allan Webber
7b1e17ed0d Email verification view test works 2011-06-05 17:49:43 -05:00
Christopher Allan Webber
1972a888b3 Make sure we can register, and then that we get the verification email 2011-06-05 17:39:47 -05:00
Christopher Allan Webber
cb9bac0c83 Just a bit of formatting for these unfinished tests ;) 2011-06-05 15:33:48 -05:00
Christopher Allan Webber
651403f025 Test registration form integrity 2011-06-05 15:30:07 -05:00
Christopher Allan Webber
460ce56493 The first bit of the registration tests working. Not fully there, but
it's clear that the webtest part is working, without having tested the
database yet.  :)
2011-06-05 10:34:29 -05:00
Will Kahn-Greene
8e1e744d27 Changes Mediagoblin -> MediaGoblin. 2011-04-13 10:04:30 -04:00
Christopher Allan Webber
db78002412 Also make sure the auth system successfully returns False when login
failboats.
2011-04-02 12:42:07 -05:00
Christopher Allan Webber
4b5f4e8791 Unit tests for our bcrypt auth stuff. Our first tests! 2011-04-02 10:48:34 -05:00