Ejemplo n.º 1
0
    def test_header_auth(self, api):
        '''Should handle header API Key authentication'''
        with api.user() as user:  # API Key auth
            response = api.post(url_for('api.fake'),
                                headers={'X-API-KEY': user.apikey})

        assert200(response)
        assert response.content_type == 'application/json'
        assert response.json == {'success': True}
Ejemplo n.º 2
0
    def test_header_auth(self, api):
        '''Should handle header API Key authentication'''
        with api.user() as user:  # API Key auth
            response = api.post(url_for('api.fake'),
                                headers={'X-API-KEY': user.apikey})

        assert200(response)
        assert response.content_type == 'application/json'
        assert response.json == {'success': True}
Ejemplo n.º 3
0
    def test_inactive_user(self, api):
        '''Should raise a HTTP 401 if the user is inactive'''
        user = UserFactory(active=False)
        with api.user(user) as user:
            response = api.post(url_for('api.fake'),
                                headers={'X-API-KEY': user.apikey})

        assert401(response)
        assert response.content_type == 'application/json'
        assert 'message' in response.json
Ejemplo n.º 4
0
    def test_inactive_user(self, api):
        '''Should raise a HTTP 401 if the user is inactive'''
        user = UserFactory(active=False)
        with api.user(user) as user:
            response = api.post(url_for('api.fake'),
                                headers={'X-API-KEY': user.apikey})

        assert401(response)
        assert response.content_type == 'application/json'
        assert 'message' in response.json