def test_no_user(self):
        with patch('flask_identity_client.startup_funcs.session', {}):
            response = user_required()

        self.assertStatus(response, 302)
        self.assertEqual(
            response.headers['Location'],
            url_for('identity_client.index', next='http://localhost/'))
    def test_no_account(self):
        session = {
            'user_data': {
                'uuid': 'a82670c2-027e-4079-b5c7-81f2433041b3',
                'email': '*****@*****.**',
                'accounts': [],
            },
        }

        with patch('flask_identity_client.startup_funcs.session', session):
            response = user_required()
        self.assertIsNone(response)
Пример #3
0
    def test_no_account(self):
        session = {
            'user_data': {
                'uuid': 'a82670c2-027e-4079-b5c7-81f2433041b3',
                'email': '*****@*****.**',
                'accounts': [],
            },
        }

        with patch('flask_identity_client.startup_funcs.session', session):
            response = user_required()
        self.assertIsNone(response)
Пример #4
0
    def test_user_required(self):
        uuid = self.account_uuid

        session = {
            'user_data': {
                'uuid': 'a82670c2-027e-4079-b5c7-81f2433041b3',
                'email': '*****@*****.**',
                'accounts': [uuid],
            },
        }

        with patch('flask_identity_client.startup_funcs.session', session):
            self.assertTrue(user_required() is None)

        self.assertEqual(g.user_data, {
            'uuid': 'a82670c2-027e-4079-b5c7-81f2433041b3',
            'email': '*****@*****.**',
            'accounts': [uuid],
        })
    def test_user_required(self):
        uuid = self.account_uuid

        session = {
            'user_data': {
                'uuid': 'a82670c2-027e-4079-b5c7-81f2433041b3',
                'email': '*****@*****.**',
                'accounts': [uuid],
            },
        }

        with patch('flask_identity_client.startup_funcs.session', session):
            self.assertTrue(user_required() is None)

        self.assertEqual(
            g.user_data, {
                'uuid': 'a82670c2-027e-4079-b5c7-81f2433041b3',
                'email': '*****@*****.**',
                'accounts': [uuid],
            })
Пример #6
0
def index():
    return user_required() or 'OK'
Пример #7
0
    def test_no_user(self):
        with patch('flask_identity_client.startup_funcs.session', {}):
            response = user_required()

        self.assertStatus(response, 302)
        self.assertEqual(response.headers['Location'], url_for('identity_client.index', next='http://localhost/'))