mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-31 03:45:17 +00:00
feat: update condition in image verify cache tests (#8318)
Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com> Co-authored-by: kyverno-bot <104836976+kyverno-bot@users.noreply.github.com> Co-authored-by: shuting <shuting@nirmata.com>
This commit is contained in:
parent
10bb27b4da
commit
aeabe7048d
1 changed files with 6 additions and 6 deletions
|
@ -1063,7 +1063,7 @@ func Test_ImageVerifyCacheCosign(t *testing.T) {
|
||||||
er, ivm = testImageVerifyCache(imageVerifyCache, context.TODO(), registryclient.NewOrDie(), nil, policyContext, cfg)
|
er, ivm = testImageVerifyCache(imageVerifyCache, context.TODO(), registryclient.NewOrDie(), nil, policyContext, cfg)
|
||||||
secondOperationTime := time.Since(start)
|
secondOperationTime := time.Since(start)
|
||||||
errorAssertionUtil(t, image, ivm, er)
|
errorAssertionUtil(t, image, ivm, er)
|
||||||
assert.Check(t, secondOperationTime < firstOperationTime/10, "cache entry is valid, so image verification should be from cache.", firstOperationTime, secondOperationTime)
|
assert.Check(t, secondOperationTime < firstOperationTime/2, "cache entry is valid, so image verification should be from cache.", firstOperationTime, secondOperationTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_ImageVerifyCacheExpiredCosign(t *testing.T) {
|
func Test_ImageVerifyCacheExpiredCosign(t *testing.T) {
|
||||||
|
@ -1092,7 +1092,7 @@ func Test_ImageVerifyCacheExpiredCosign(t *testing.T) {
|
||||||
er, ivm = testImageVerifyCache(imageVerifyCache, context.TODO(), registryclient.NewOrDie(), nil, policyContext, cfg)
|
er, ivm = testImageVerifyCache(imageVerifyCache, context.TODO(), registryclient.NewOrDie(), nil, policyContext, cfg)
|
||||||
secondOperationTime := time.Since(start)
|
secondOperationTime := time.Since(start)
|
||||||
errorAssertionUtil(t, image, ivm, er)
|
errorAssertionUtil(t, image, ivm, er)
|
||||||
assert.Check(t, secondOperationTime > firstOperationTime/10 && secondOperationTime < firstOperationTime*10, "cache entry is expired, so image verification should not be from cache.")
|
assert.Check(t, secondOperationTime > firstOperationTime/2 && secondOperationTime < firstOperationTime*2, "cache entry is expired, so image verification should not be from cache.")
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_changePolicyCacheVerificationCosign(t *testing.T) {
|
func Test_changePolicyCacheVerificationCosign(t *testing.T) {
|
||||||
|
@ -1119,7 +1119,7 @@ func Test_changePolicyCacheVerificationCosign(t *testing.T) {
|
||||||
er, ivm = testImageVerifyCache(imageVerifyCache, context.TODO(), registryclient.NewOrDie(), nil, policyContext, cfg)
|
er, ivm = testImageVerifyCache(imageVerifyCache, context.TODO(), registryclient.NewOrDie(), nil, policyContext, cfg)
|
||||||
secondOperationTime := time.Since(start)
|
secondOperationTime := time.Since(start)
|
||||||
errorAssertionUtil(t, image, ivm, er)
|
errorAssertionUtil(t, image, ivm, er)
|
||||||
assert.Check(t, secondOperationTime > firstOperationTime/10 && secondOperationTime < firstOperationTime*10, "cache entry not found, so image verification should not be from cache.")
|
assert.Check(t, secondOperationTime > firstOperationTime/2 && secondOperationTime < firstOperationTime*2, "cache entry not found, so image verification should not be from cache.")
|
||||||
}
|
}
|
||||||
|
|
||||||
var verifyImageNotaryPolicy = `{
|
var verifyImageNotaryPolicy = `{
|
||||||
|
@ -1266,7 +1266,7 @@ func Test_ImageVerifyCacheNotary(t *testing.T) {
|
||||||
er, ivm = testImageVerifyCache(imageVerifyCache, context.TODO(), registryclient.NewOrDie(), nil, policyContext, cfg)
|
er, ivm = testImageVerifyCache(imageVerifyCache, context.TODO(), registryclient.NewOrDie(), nil, policyContext, cfg)
|
||||||
secondOperationTime := time.Since(start)
|
secondOperationTime := time.Since(start)
|
||||||
errorAssertionUtil(t, image, ivm, er)
|
errorAssertionUtil(t, image, ivm, er)
|
||||||
assert.Check(t, secondOperationTime < firstOperationTime/10, "cache entry is valid, so image verification should be from cache.", firstOperationTime, secondOperationTime)
|
assert.Check(t, secondOperationTime < firstOperationTime/2, "cache entry is valid, so image verification should be from cache.", firstOperationTime, secondOperationTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_ImageVerifyCacheExpiredNotary(t *testing.T) {
|
func Test_ImageVerifyCacheExpiredNotary(t *testing.T) {
|
||||||
|
@ -1293,7 +1293,7 @@ func Test_ImageVerifyCacheExpiredNotary(t *testing.T) {
|
||||||
er, ivm = testImageVerifyCache(imageVerifyCache, context.TODO(), registryclient.NewOrDie(), nil, policyContext, cfg)
|
er, ivm = testImageVerifyCache(imageVerifyCache, context.TODO(), registryclient.NewOrDie(), nil, policyContext, cfg)
|
||||||
secondOperationTime := time.Since(start)
|
secondOperationTime := time.Since(start)
|
||||||
errorAssertionUtil(t, image, ivm, er)
|
errorAssertionUtil(t, image, ivm, er)
|
||||||
assert.Check(t, secondOperationTime > firstOperationTime/10 && secondOperationTime < firstOperationTime*10, "cache entry is expired, so image verification should not be from cache.")
|
assert.Check(t, secondOperationTime > firstOperationTime/2 && secondOperationTime < firstOperationTime*2, "cache entry is expired, so image verification should not be from cache.")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1318,6 +1318,6 @@ func Test_changePolicyCacheVerificationNotary(t *testing.T) {
|
||||||
er, ivm = testImageVerifyCache(imageVerifyCache, context.TODO(), registryclient.NewOrDie(), nil, policyContext, cfg)
|
er, ivm = testImageVerifyCache(imageVerifyCache, context.TODO(), registryclient.NewOrDie(), nil, policyContext, cfg)
|
||||||
secondOperationTime := time.Since(start)
|
secondOperationTime := time.Since(start)
|
||||||
errorAssertionUtil(t, image, ivm, er)
|
errorAssertionUtil(t, image, ivm, er)
|
||||||
assert.Check(t, secondOperationTime > firstOperationTime/10 && secondOperationTime < firstOperationTime*10, "cache entry not found, so image verification should not be from cache.")
|
assert.Check(t, secondOperationTime > firstOperationTime/2 && secondOperationTime < firstOperationTime*2, "cache entry not found, so image verification should not be from cache.")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue