예제 #1
0
	def test_non_cached_authenticated_user(self):
		""" Tests that non-cached but authenticated user returns the user """
		self.request.args = {'access_token': self.access_token}
		assert users.get_current_user() is None
		assert 'access_token' in flask.request.args
		assert mc.get("%s-%s" % (AuthTestCase.MC_NAMESPACE, self.access_token)) is None
		self.assertEqual(auth.authenticate()['email'], self.user_email)
예제 #2
0
	def test_non_cached_non_authenticated_user(self):
		""" Tests that non-cached, non-authenticated user returns _anon """
		self.request.args = {'access_token': self.access_token}
		def authenticate(access_token):
			raise AuthenticationException()
		app.config['AUTHENTICATOR'].authenticate = authenticate
		assert users.get_current_user() is None
		assert 'access_token' in flask.request.args
		assert mc.get("%s-%s" % (AuthTestCase.MC_NAMESPACE, self.access_token)) is None
		self.assertEqual(auth.authenticate()['email'], '_anon')
예제 #3
0
	def test_cached_user(self):
		""" Tests that cached user is returned """
		mc.set(
			"%s-%s" % (AuthTestCase.MC_NAMESPACE, self.access_token),
			{'email': [self.user_email]})
		self.request.args = {'access_token': self.access_token}
		assert users.get_current_user() is None
		assert 'access_token' in flask.request.args
		assert mc.get('%s-%s' % (AuthTestCase.MC_NAMESPACE, self.access_token))
		self.assertEqual(auth.authenticate()['email'][0], self.user_email)
예제 #4
0
	def test_nonauthenticated_anon(self):
		""" Tests return <anon> when no access token """
		AuthTestCase.user = None
		assert users.get_current_user() is None
		assert 'access_token' not in flask.request.args
		self.assertEqual(auth.authenticate()['email'], '<anon>')
예제 #5
0
	def test_authenticated(self):
		""" Tests that an authenticated user is allowed """
		self.user = self.obj().set(email=lambda: self.user_email)
		self.assertEqual(auth.authenticate()['email'], self.user.email())