diff --git a/pkg/api/property_test.go b/pkg/api/property_test.go index df9eebdc..0b10aa80 100644 --- a/pkg/api/property_test.go +++ b/pkg/api/property_test.go @@ -2100,6 +2100,9 @@ func TestApiGetPropertyDisabled(t *testing.T) { t.Fatal(err) } + // Clear cache so the next request fetches fresh data from DB + cache.Delete(ctx, db.PropertyByIDCacheKey(property.ID)) + // Try to get the disabled property _, meta, err = requestResponseAPISuite[*apiPropertyOutput](ctx, nil, http.MethodGet, diff --git a/pkg/api/puzzle_test.go b/pkg/api/puzzle_test.go index 10441b87..cd9a0744 100644 --- a/pkg/api/puzzle_test.go +++ b/pkg/api/puzzle_test.go @@ -390,8 +390,12 @@ func TestGetPuzzleDisabledProperty(t *testing.T) { t.Fatal(err) } - // Clear cache so we fetch fresh data + // Clear cache and reload the property from DB so it has Enabled: false cache.Delete(ctx, db.PropertyBySitekeyCacheKey(sitekey)) + _, err = store.Impl().RetrievePropertyBySitekey(ctx, sitekey) + if err != nil { + t.Fatal(err) + } // Now the puzzle request should be forbidden resp, err = puzzleSuite(ctx, sitekey, property.Domain) diff --git a/pkg/db/cache.go b/pkg/db/cache.go index af02032e..49dfc018 100644 --- a/pkg/db/cache.go +++ b/pkg/db/cache.go @@ -338,6 +338,9 @@ func orgPropertiesCacheKey(orgID int32, key string) CacheKey { func propertyByIDCacheKey(propID int32) CacheKey { return Int32CacheKey(propertyByIDCacheKeyPrefix, propID) } +func PropertyByIDCacheKey(propID int32) CacheKey { + return Int32CacheKey(propertyByIDCacheKeyPrefix, propID) +} func PropertyBySitekeyCacheKey(sitekey string) CacheKey { return StringCacheKey(propertyBySitekeyCacheKeyPrefix, sitekey) }