Ejemplo n.º 1
0
 def velruse_login_complete_view(self):
     context = self.context
     request = self.request
     profile = context.profile
     account = profile['accounts'][0]
     domain = account['domain']
     username = account['username']
     userid = account['userid']
     sd_userid = f'{domain}_{userid}'
     root = root_factory(request)
     adapter = request.registry.queryMultiAdapter(
         (root, request), IUserLocator)
     if adapter is None:
         adapter = DefaultUserLocator(root, request)
     user = adapter.get_user_by_login(sd_userid)
     headers = []
     if user is None:
         photos = profile.get('photos')
         if photos:
             photo_url = photos[0]['value']
             request.session['photo_url'] = photo_url
         request.session['userid'] = sd_userid
         realname = profile['displayName']
         request.session['profilename'] = username
         request.session['realname'] = realname
         location = request.resource_url(root, 'create_profile')
     else:
         objectmap = find_objectmap(root)
         performer = list(objectmap.sources(user, PerformerToUser))[0]
         location = request.resource_url(performer)
         headers = remember(request, get_oid(user))
     return HTTPFound(location, headers=headers)
Ejemplo n.º 2
0
    def setUp(self):
        import tempfile
        import os.path
        self.tmpdir = tempfile.mkdtemp()
        dbpath = os.path.join( self.tmpdir, 'test.db')
        uri = 'file://' + dbpath
        settings = {'zodbconn.uri': uri,
                    'substanced.secret': 'sosecret',
                    'substanced.initial_login': '******',
                    'substanced.initial_password': '******',
                    'pyramid.includes': [
                        'substanced',
                        'pyramid_chameleon',
                        'pyramid_layout',
                        'pyramid_mailer.testing', # have to be after substanced to override the mailer
                        'pyramid_tm',
                        'dace',
                        'pontus',
        ]}

        app = main({}, **settings)
        self.db = app.registry._zodb_databases['']
        request = DummyRequest()
        testing.setUp(registry=app.registry, request=request)
        self.app = root_factory(request)
        request.root = self.app
        from webtest import TestApp
        self.testapp = TestApp(app)
        self.request = request
        import time; time.sleep(2)
Ejemplo n.º 3
0
def velruse_login_complete_view(context, request):
    provider = context.provider_name
    profile = context.profile
    username = profile['accounts'][0]['username']
    root = root_factory(request)
    adapter = request.registry.queryMultiAdapter(
        (root, request), IUserLocator)
    if adapter is None:
        adapter = DefaultUserLocator(root, request)
    user = adapter.get_user_by_login(username)
    if user is None:
        registry = request.registry
        principals = find_service(root, 'principals')
        user = principals.add_user(username, registry=registry)
        performer = registry.content.create('Performer')
        root['performers'][username] = performer
        performer.title = profile['displayName']
        addresses = profile.get('addresses')
        if addresses:
            user.email = performer.email = addresses[0]['formatted']
        photos = profile.get('photos')
        if photos:
            performer.photo_url = photos[0]['value']
        performer.age = colander.null
        performer.sex = user.favorite_genre = None
        performer.user = user
        set_acl(performer, [(Allow, user.__oid__, ['yss.edit-profile'])])
        location = request.resource_url(performer, 'edit.html')
    else:
        location = request.resource_url(root['performers'][username])
    headers = remember(request, get_oid(user))
    return HTTPFound(location, headers=headers)
Ejemplo n.º 4
0
def persona_login(context, request):
    check_csrf_token(request)
    email = verify_persona_assertion(request)
    root = root_factory(request)
    adapter = request.registry.queryMultiAdapter(
        (root, request), IUserLocator)
    if adapter is None:
        adapter = DefaultUserLocator(root, request)
    user = adapter.get_user_by_email(email)
    if user is None:
        registry = request.registry
        username = '******' % email
        principals = find_service(root, 'principals')
        user = principals.add_user(username, registry=registry)
        user.email = email
        performer = registry.content.create('Performer')
        root['performers'][username] = performer
        performer.user = user
        set_acl(performer, [(Allow, user.__oid__, ['yss.edit-profile'])])
        location = request.resource_url(performer, 'edit.html')
        performer.title = email
        performer.email = email
        performer.photo_url = persona_gravatar_photo(request, email)
        performer.age = colander.null
        performer.sex = user.favorite_genre = None
        location = request.resource_url(performer, 'edit.html')
    else:
        location = request.resource_url(root['performers'][user.__name__])
    headers = remember(request, get_oid(user))
    request.response.headers.extend(headers)
    return {'redirect': location, 'success': True}
Ejemplo n.º 5
0
    def setUp(self):
        import tempfile
        import os.path
        self.tmpdir = tempfile.mkdtemp()
        dbpath = os.path.join(self.tmpdir, 'test.db')
        uri = 'file://' + dbpath + '?blobstorage_dir=' + self.tmpdir
        settings = {
            'zodbconn.uri':
            uri,
            'sms.service':
            'pyramid_sms.ovh.OvhService',
            'substanced.secret':
            'sosecret',
            'substanced.initial_login':
            '******',
            'substanced.initial_password':
            '******',
            'novaideo.secret':
            'seekri1',
            'substanced.uploads_tempdir':
            self.tmpdir,
            'mail.default_sender':
            '*****@*****.**',
            'pyramid.includes': [
                'substanced',
                'pyramid_chameleon',
                'pyramid_layout',
                'pyramid_mailer.testing',  # have to be after substanced to override the mailer
                'pyramid_tm',
                'dace',
                'pontus',
                'daceui'
            ]
        }

        testing.setUp()
        from novaideo import main
        self.app = app = main({}, **settings)
        self.db = app.registry._zodb_databases['']
        self.request = request = testing.DummyRequest()
        self.request.invalidate_cache = True
        self.config = testing.setUp(registry=app.registry, request=request)
        self.registry = self.config.registry
        from .catalog import (NovaideoIndexes, Text, Lexicon, Splitter,
                              CaseNormalizer, StopWordRemover)
        # lexicon is a persistent object, we need to be sure it's a fresh one
        # between tests
        NovaideoIndexes.relevant_data = Text(
            lexicon=Lexicon(Splitter(), CaseNormalizer(), StopWordRemover()))
        self.root = root_factory(request)
        request.root = self.root
Ejemplo n.º 6
0
    def setUp(self):
        import tempfile
        import os.path
        self.tmpdir = tempfile.mkdtemp()

        dbpath = os.path.join( self.tmpdir, 'test.db')
        uri = 'file://' + dbpath
        settings = {'zodbconn.uri': uri,
                    'substanced.secret': 'sosecret',
                    'substanced.initial_login': '******',
                    'substanced.initial_password': '******',
                    'pyramid.includes': [
            'pyramid_tm',
            'substanced',
            'dace',
        ]}

        app = main({}, **settings)
        self.db = app.registry._zodb_databases['']
        self.request = request = DummyRequest()
        self.request.test = True
        self.config = testing.setUp(registry=app.registry, request=request)

        # set extensions (add_request_method, so the request.user works)
        extensions = app.registry.queryUtility(IRequestExtensions)
        if extensions is not None:
            if getattr(request, '_set_extensions', None) is not None:  # pyramid 1.5.7
                request._set_extensions(extensions)
            else:
                from pyramid.request import apply_request_extensions
                apply_request_extensions(request, extensions=extensions)

        self.registry = self.config.registry
        self.app = root_factory(request)
        request.root = request.context = self.app
        # request.user execute substanced.sdi.user which get request.context to find objectmap
        self.users = self.app['principals']['users']
        self.app['principals'].add_user('alice',
                                        password='******',
                                        email='*****@*****.**')
        self.app['principals'].add_user('bob',
                                        password='******',
                                        email='*****@*****.**')
        login('admin')
        # request.user is the admin user, but if you do later login('system'), you will still have admin in request.user
        #request.user = self.users['admin']
        self.def_container = self.app['process_definition_container']
Ejemplo n.º 7
0
    def setUp(self):
        import tempfile
        import os.path
        self.tmpdir = tempfile.mkdtemp()
        dbpath = os.path.join(self.tmpdir, 'test.db')
        uri = 'file://' + dbpath + '?blobstorage_dir=' + self.tmpdir
        settings = {'zodbconn.uri': uri,
                    'sms.service': 'pyramid_sms.ovh.OvhService',
                    'substanced.secret': 'sosecret',
                    'substanced.initial_login': '******',
                    'substanced.initial_password': '******',
                    'novaideo.secret' : 'seekri1',
                    'substanced.uploads_tempdir' : self.tmpdir,
                    'mail.default_sender': '*****@*****.**',
                    'pyramid.includes': [
                        'substanced',
                        'pyramid_chameleon',
                        'pyramid_layout',
                        'pyramid_mailer.testing', # have to be after substanced to override the mailer
                        'pyramid_tm',
                        'dace',
                        'pontus',
                        'daceui'
        ]}

        testing.setUp()
        from novaideo import main
        self.app = app = main({}, **settings)
        self.db = app.registry._zodb_databases['']
        self.request = request = testing.DummyRequest()
        self.request.invalidate_cache = True
        self.config = testing.setUp(registry=app.registry, request=request)
        self.registry = self.config.registry
        from .catalog import (
            NovaideoIndexes, Text,
            Lexicon, Splitter,
            CaseNormalizer, StopWordRemover)
        # lexicon is a persistent object, we need to be sure it's a fresh one
        # between tests
        NovaideoIndexes.relevant_data = Text(
            lexicon=Lexicon(Splitter(), CaseNormalizer(), StopWordRemover()))
        self.root = root_factory(request)
        request.root = self.root
Ejemplo n.º 8
0
    def setUp(self):
        import tempfile
        import os.path
        self.tmpdir = tempfile.mkdtemp()

        dbpath = os.path.join( self.tmpdir, 'test.db')
        uri = 'file://' + dbpath
        settings = {'zodbconn.uri': uri,
                    'substanced.secret': 'sosecret',
                    'substanced.initial_login': '******',
                    'substanced.initial_password': '******',
                    'pyramid.includes': [
            'pyramid_tm',
            'substanced',
            'dace',
        ]}

        app = main({}, **settings)
        self.db = app.registry._zodb_databases['']
        self.request = request = DummyRequest()
        self.request.test = True
        self.config = testing.setUp(registry=app.registry, request=request)

        # set extensions (add_request_method, so the request.user works)
        extensions = app.registry.queryUtility(IRequestExtensions)
        if extensions is not None:
            request._set_extensions(extensions)

        self.registry = self.config.registry
        self.app = root_factory(request)
        request.root = request.context = self.app
        # request.user execute substanced.sdi.user which get request.context to find objectmap
        self.users = self.app['principals']['users']
        self.app['principals'].add_user('alice',
                                        password='******',
                                        email='*****@*****.**')
        self.app['principals'].add_user('bob',
                                        password='******',
                                        email='*****@*****.**')
        login('admin')
        # request.user is the admin user, but if you do later login('system'), you will still have admin in request.user
        #request.user = self.users['admin']
        self.def_container = self.app['process_definition_container']
Ejemplo n.º 9
0
    def setUp(self):
        import tempfile
        import os.path
        self.tmpdir = tempfile.mkdtemp()
        dbpath = os.path.join(self.tmpdir, 'test.db')
        uri = 'file://' + dbpath + '?blobstorage_dir=' + self.tmpdir
        settings = {'zodbconn.uri': uri,
                    'substanced.secret': 'sosecret',
                    'substanced.initial_login': '******',
                    'substanced.initial_password': '******',
                    'lac.secret' : 'seekri1',
                    'substanced.uploads_tempdir' : self.tmpdir,
                    'lac.admin_email': '*****@*****.**',
                    'pyramid.includes': [
                        'substanced',
                        'pyramid_chameleon',
                        'pyramid_layout',
                        'pyramid_mailer.testing', # have to be after substanced to override the mailer
                        'pyramid_tm',
                        'dace',
                        'pontus',
                        'daceui',

        ]}

        testing.setUp()
        from lac import main
        from lac.catalog import CreationCuturelleIndexes
        if hasattr(CreationCuturelleIndexes, 'relevant_data'):
            del(CreationCuturelleIndexes.relevant_data)

        self.app = app = main({}, **settings)
        self.db = app.registry._zodb_databases['']
        self.request = request = testing.DummyRequest()
        self.config = testing.setUp(registry=app.registry, request=request)
        self.registry = self.config.registry
        self.root = root_factory(request)
        request.root = self.root
        request.user = self.root['principals']['users']['admin']
        request.get_site_folder = self.root.site_folders[0]
        request.site_folder = request.get_site_folder