def test_revoked_raising_exception(): Adolf = users.get_by_name('adolf') ssid = auth.new_ssid(Adolf.get('uid'), 'Chrome') token = auth.make_access_token(Adolf.get('uid'), ssid) redis.delete(auth.SSAGENT_KEY % ssid) with AssertRaises(auth.TokenRevoked): auth.decode_and_check(token)
def test_of_session_list(): Adolf = users.get_by_name('adolf') ssid1 = auth.new_ssid(Adolf.get('uid'), 'Chrome') ssid2 = auth.new_ssid(Adolf.get('uid'), 'Android') ssid3 = auth.new_ssid(Adolf.get('uid'), 'Android') redis.delete(auth.SSAGENT_KEY % ssid3) sslist = auth.sessions_of(Adolf.get('uid')) assert_is_instance(sslist, list) assert_eq(len(sslist), 2) assert_eq(sslist[0].get('agent'), 'Chrome') assert_eq(sslist[1].get('agent'), 'Android') # clean after test redis.delete(auth.SSAGENT_KEY % ssid1) redis.delete(auth.SSAGENT_KEY % ssid2)
def revoke(ssid): key = SSAGENT_KEY % ssid redis.delete(key)
def test_before(): [redis.delete(key) for key in redis.keys('auth:*')]
def test_after(): [redis.delete(key) for key in redis.keys('auth:*')]