예제 #1
0
    def test_account_login_browserid(self):
        from floof.views.account import account_login_browserid as view

        def verify(request, next_url, flash_msg):
            response = view(request.context, request)
            flashes = request.session['_f_']
            assert len(flashes) == 1
            assert flash_msg in flashes[0]
            assert response['next_url'] == next_url

        audience = 'https://mysite.example.org'
        self.config.add_settings({'auth.browserid.audience': audience})
        request = self._make_request()
        request.method = 'POST'
        request.user = sim.sim_user(credentials=[('browserid', OLD_ASSERTION_ADDR)])

        for a in (None, '', self._randstr(), OLD_ASSERTION):
            request.POST = MultiDict({'assertion': a})
            verify(request,
                   next_url=request.route_url('account.login'),
                   flash_msg='signature was invalid')
            request.session.clear()

        email = self._randstr() + '@example.com'
        verifier = DummyVerifier()
        a = verifier.make_assertion(email, audience)
        request.POST = MultiDict({'assertion': a})
        request.user = sim.sim_user(credentials=[('browserid', email)])
        request.environ['paste.testing'] = True
        request.environ['tests.auth.browserid.verifier'] = verifier
        request.environ['tests.auth.browserid.audience'] = audience
        verify(request,
               next_url=request.route_url('root'),
               flash_msg='Re-authentication successful')
예제 #2
0
파일: test_account.py 프로젝트: eevee/floof
    def test_account_login_persona(self):
        from floof.views.account import account_login_persona as view

        def verify(request, next_url, flash_msg):
            response = view(request.context, request)
            flashes = request.session['_f_']
            assert len(flashes) == 1
            assert flash_msg in flashes[0]
            assert response['redirect-to'] == next_url

        audience = 'https://localhost'
        self.config.add_settings({'auth.persona.audience': audience})
        request = self._make_request()
        request.method = 'POST'
        request.user = sim.sim_user(credentials=[('persona', OLD_ASSERTION_ADDR)])

        # Test failures

        trials = (
            (None, 'unspecified error'),
            ('', 'unspecified error'),
            (self._randstr(), 'unspecified error'),
            (OLD_ASSERTION, 'signature was invalid')
        )

        for a, f in trials:
            request.POST = MultiDict({'assertion': a})
            verify(request,
                   next_url=request.route_url('account.login'),
                   flash_msg=f)
            request.session.clear()

        # Test success

        email = self._randstr() + '@example.com'
        verifier = LocalVerifier([audience], warning=False)
        a = make_assertion(email, audience)

        request.POST = MultiDict({'assertion': a})
        request.user = sim.sim_user(credentials=[('persona', email)])
        request.environ['paste.testing'] = True
        request.environ['tests.auth.persona.verifier'] = verifier
        request.environ['tests.auth.persona.audience'] = audience
        with patched_supportdoc_fetching():
            verify(request,
                   next_url=request.route_url('root'),
                   flash_msg='Re-authentication successful')
예제 #3
0
    def setUp(self):
        """Creates a user to be used as a fake login."""
        super(TestFloofAuthnPolicy, self).setUp()

        self.user = sim.sim_user()
        self.env = partial(sim.sim_user_env, self.user)

        self.policy = FloofAuthnPolicy()
예제 #4
0
    def setUp(self):
        """Creates a user to be used as a fake login."""
        super(TestControls, self).setUp()

        self.user = sim.sim_user(credentials=[])
        model.session.flush()

        self.default_environ = {'tests.user_id': self.user.id}
예제 #5
0
    def setUp(self):
        """Creates a user to be used as a fake login."""
        super(TestControls, self).setUp()

        self.user = sim.sim_user(credentials=[])
        model.session.flush()

        self.default_environ = {'tests.user_id': self.user.id}
예제 #6
0
파일: test_account.py 프로젝트: silky/floof
    def test_account_login_persona(self):
        from floof.views.account import account_login_persona as view

        def verify(request, next_url, flash_msg):
            response = view(request.context, request)
            flashes = request.session['_f_']
            assert len(flashes) == 1
            assert flash_msg in flashes[0]
            assert response['redirect-to'] == next_url

        audience = 'https://localhost'
        self.config.add_settings({'auth.persona.audience': audience})
        request = self._make_request()
        request.method = 'POST'
        request.user = sim.sim_user(credentials=[('persona',
                                                  OLD_ASSERTION_ADDR)])

        # Test failures

        trials = ((None, 'unspecified error'), ('', 'unspecified error'),
                  (self._randstr(), 'unspecified error'),
                  (OLD_ASSERTION, 'signature was invalid'))

        for a, f in trials:
            request.POST = MultiDict({'assertion': a})
            verify(request,
                   next_url=request.route_url('account.login'),
                   flash_msg=f)
            request.session.clear()

        # Test success

        email = self._randstr() + '@example.com'
        verifier = LocalVerifier([audience], warning=False)
        a = make_assertion(email, audience)

        request.POST = MultiDict({'assertion': a})
        request.user = sim.sim_user(credentials=[('persona', email)])
        request.environ['paste.testing'] = True
        request.environ['tests.auth.persona.verifier'] = verifier
        request.environ['tests.auth.persona.audience'] = audience
        with patched_supportdoc_fetching():
            verify(request,
                   next_url=request.route_url('root'),
                   flash_msg='Re-authentication successful')
예제 #7
0
파일: test_account.py 프로젝트: eevee/floof
    def setUp(self):
        """Creates a user to be used as a fake login."""
        super(TestAccount, self).setUp()

        self.user = sim.sim_user()
        model.session.flush()

        self.default_environ = {
                'tests.user_id': self.user.id,
                'tests.auth_openid_uid': self.user.id,
                'tests.auth_openid_time': time.time(),
                }
예제 #8
0
    def test_artwork(self):
        """Test tagging an artwork."""
        # Create some art with a known tag
        user = sim.sim_user()
        artwork = sim.sim_artwork(user=user)
        tag = sim.sim_tag()
        artwork.tag_objs.append(tag)
        model.session.flush()

        # Ensure it shows in the tag's gallery
        res = self.app.get(self.url('tags.artwork', tag=tag))
        assert artwork.title in res
예제 #9
0
파일: test_account.py 프로젝트: silky/floof
    def setUp(self):
        """Creates a user to be used as a fake login."""
        super(TestAccount, self).setUp()

        self.user = sim.sim_user()
        model.session.flush()

        self.default_environ = {
            'tests.user_id': self.user.id,
            'tests.auth_openid_uid': self.user.id,
            'tests.auth_openid_time': time.time(),
        }
예제 #10
0
파일: test_art.py 프로젝트: krinndnz/floof
 def setUp(self):
     """Creates a user to be used as a fake login."""
     super(TestArt, self).setUp()
     self.user = sim.sim_user()
     model.session.flush()
예제 #11
0
 def setUp(self):
     """Creates a user to be used as a fake login."""
     super(TestArt, self).setUp()
     self.user = sim.sim_user()
     model.session.flush()