diff options
Diffstat (limited to 'src/tests/keywords/cache')
-rw-r--r-- | src/tests/keywords/cache | 229 |
1 files changed, 229 insertions, 0 deletions
diff --git a/src/tests/keywords/cache b/src/tests/keywords/cache new file mode 100644 index 0000000..58ce207 --- /dev/null +++ b/src/tests/keywords/cache @@ -0,0 +1,229 @@ +# +# 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 +} + + |