func TestCacheValidityCleanup(t *testing.T) {
	assert := audit.NewTestingAssertion(t, true)
	assert.Logf("testing cache validity based cleanup")
	cache := jwt.NewCache(time.Minute, time.Second, time.Second, 10)
	key := []byte("secret")
	now := time.Now()
	nbf := now.Add(-2 * time.Second)
	exp := now.Add(2 * time.Second)
	claims := initClaims()
	claims.SetNotBefore(nbf)
	claims.SetExpiration(exp)
	jwtIn, err := jwt.Encode(claims, key, jwt.HS512)
	assert.Nil(err)
	cache.Put(jwtIn)
	token := jwtIn.String()
	jwtOut, ok := cache.Get(token)
	assert.True(ok)
	assert.Equal(jwtIn, jwtOut)
	// Now access until it is invalid and not
	// available anymore.
	var i int
	for i = 0; i < 5; i++ {
		time.Sleep(time.Second)
		jwtOut, ok = cache.Get(token)
		if !ok {
			break
		}
		assert.Equal(jwtIn, jwtOut)
	}
	assert.True(i > 1 && i < 4)
}
// TestCacheValidityCleanup tests the validity based cleanup
// of the JWT cache.
TestCacheValidityCleanup tests the validity based cleanup
of the JWT cache.
// TestCacheValidityCleanup tests the validity based cleanup // of the JWT cache .
func TestCacheValidityCleanup(t *testing.T) {
	assert := audit.NewTestingAssertion(t, true)
	assert.Logf("testing cache validity based cleanup")
	cache := jwt.NewCache(time.Minute, time.Second, time.Second, 10)
	key := []byte("secret")
	now := time.Now()
	nbf := now.Add(-2 * time.Second)
	exp := now.Add(2 * time.Second)
	claims := initClaims()
	claims.SetNotBefore(nbf)
	claims.SetExpiration(exp)
	jwtIn, err := jwt.Encode(claims, key, jwt.HS512)
	assert.Nil(err)
	cache.Put(jwtIn)
	token := jwtIn.String()
	jwtOut, ok := cache.Get(token)
	assert.True(ok)
	assert.Equal(jwtIn, jwtOut)
	var i int
	for i = 0; i < 5; i++ {
		time.Sleep(time.Second)
		jwtOut, ok = cache.Get(token)
		if !ok {
			break
		}
		assert.Equal(jwtIn, jwtOut)
	}
	assert.True(i > 1 && i < 4)
}
func TestCacheValidityCleanup ( t * testing . T ) { assert := audit . NewTestingAssertion ( t , true ) assert . Logf ( " " ) cache := jwt . NewCache ( time . Minute , time . Second , time . Second , 10 ) key := [ ] byte ( " " ) now := time . Now ( ) nbf := now . Add ( - 2 * time . Second ) exp := now . Add ( 2 * time . Second ) claims := initClaims ( ) claims . SetNotBefore ( nbf ) claims . SetExpiration ( exp ) jwtIn , err := jwt . Encode ( claims , key , jwt . HS512 ) assert . Nil ( err ) cache . Put ( jwtIn ) token := jwtIn . String ( ) jwtOut , ok := cache . Get ( token ) assert . True ( ok ) assert . Equal ( jwtIn , jwtOut ) var i int for i = 0 ; i < 5 ; i ++ { time . Sleep ( time . Second ) jwtOut , ok = cache . Get ( token ) if ! ok { break } assert . Equal ( jwtIn , jwtOut ) } assert . True ( i > 1 && i < 4 ) }
TestCacheValidityCleanup tests the validity based cleanup
of the JWT cache.
TestCacheValidityCleanup tests the validity based cleanup of the JWT cache .
// Now access until it is invalid and not // available anymore.