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}
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