source: OpenWorkouts-current/ow/tests/test_security.py @ 8c2b094

current
Last change on this file since 8c2b094 was 1d92bf2, checked in by borja <borja@…>, 5 years ago

(#37) Allow login using email address instead of username:

  • Use user uids as keys in the root folder for referencing user objects (instead of username)
  • Use uids for referencing users all over the place (auth, permissions, traversal urls, etc)
  • Replaced the username concept with nickname. This nickname will be used as a shortcut to access "public profile" pages for users
  • Reworked lots of basic methods in the OpenWorkouts root object (s/username/nickname, marked as properties some methods like users, emails, etc)
  • Added new add_user() and delete_user() helpers to the OpenWorkouts root object
  • Fixed bug in the dashboard redirect view, causing an endless loop if an authenticated user does not exist anymore when loading a page.
  • Lots of tests fixes, adaptations and catch up.
  • Property mode set to 100644
File size: 724 bytes
Line 
1import pytest
2
3from pyramid.testing import DummyRequest
4
5from ow.security import groupfinder
6from ow.models.root import OpenWorkouts
7from ow.models.user import User
8
9
10class TestSecurity(object):
11
12    @pytest.fixture
13    def root(self):
14        root = OpenWorkouts()
15        root['john'] = User(firstname='John', lastname='Doe',
16                            email='john.doe@example.net')
17        root['john'].password = 's3cr3t'
18        return root
19
20    def test_groupfinder(self, root):
21        request = DummyRequest()
22        request.root = root
23        # User does exist
24        assert groupfinder('john', request) == [str(root['john'].uid)]
25        # User does not exist
26        assert groupfinder('jack', request) == []
Note: See TracBrowser for help on using the repository browser.