# # PRE: update if # update { &control:Cleartext-Password := 'hello' &request:Tmp-String-0 := 'testkey' &reply:Filter-Id := 'filter' } # # Basic store and retrieve # update control { &control:Tmp-String-1 := 'cache me' } cache if (!updated) { update reply { Filter-Id := 'fail 0' } reject } # Check status-only works correctly (should return ok and consume attribute) update control { Cache-Status-Only := 'yes' } cache if (!ok) { update reply { Filter-Id := 'fail 2a' } reject } if (&control:Cache-Status-Only) { update reply { Filter-Id := 'fail 2b' } reject } # Retrieve the entry (should be copied to request list) cache if (!ok) { update reply { Filter-Id := 'fail 3a' } reject } if (&request:Tmp-String-1 != &control:Tmp-String-1) { update reply { Filter-Id := 'fail 3b' } } # Retrieving the entry should not expire it update request { Tmp-String-1 !* ANY } cache if (!ok) { update reply { Filter-Id := 'fail 4a' } reject } if (&request:Tmp-String-1 != &control:Tmp-String-1) { update reply { Filter-Id := 'fail 4b' } reject } # Force expiry of the entry update control { Cache-TTL := 0 } cache if (!ok) { update reply { Filter-Id := 'fail 5' } reject } # Check status-only works correctly (should return notfound and consume attribute) update control { Cache-Status-Only := 'yes' } cache if (!notfound) { update reply { Filter-Id := 'fail 6a' } reject } if (&control:Cache-Status-Only) { update reply { Filter-Id := 'fail 6b' } reject } # Check read-only works correctly (should return notfound and consume attribute) update control { Cache-Read-Only := 'yes' } cache if (!notfound) { update reply { Filter-Id := 'fail 7a' } reject } if (&control:Cache-Read-Only) { update reply { Filter-Id := 'fail 7b' } reject } # ...and check the entry wasn't recreated update control { Cache-Status-Only := 'yes' } cache if (!notfound) { update reply { Filter-Id := 'fail 7c' } reject } # This should still allow the creation of a new entry update control { Cache-TTL := -1 } cache if (!updated) { update reply { Filter-Id := 'fail 8a' } reject } cache if (!ok) { update reply { Filter-Id := 'fail 8b' } reject } if (&Cache-TTL) { update reply { Filter-Id := 'fail 8c' } reject } if (&request:Tmp-String-1 != &control:Tmp-String-1) { update reply { Filter-Id := 'fail 8d' } reject } update control { Tmp-String-1 := 'cache me2' } # Updating the Cache-TTL shouldn't make things go boom (we can't really check if it works) update control { Cache-TTL := 30 } cache if (!ok) { update reply { Filter-Id := 'fail 9a' } reject } # Request Tmp-String-1 shouldn't have been updated yet if (&request:Tmp-String-1 == &control:Tmp-String-1) { update reply { Filter-Id := 'fail 9b' } reject } # Check that a new entry is created update control { Cache-TTL := -1 } cache if (!updated) { update reply { Filter-Id := 'fail 10a' } reject } # Check Cache-Entry-Hits is updated as we expect if (&request:Cache-Entry-Hits != 0) { update reply { Filter-Id := 'fail 12a' } reject } cache if (&request:Cache-Entry-Hits != 1) { update reply { Filter-Id := 'fail 12b' } reject }