diff options
Diffstat (limited to 'src/tests/modules/always')
-rw-r--r-- | src/tests/modules/always/all.mk | 3 | ||||
-rw-r--r-- | src/tests/modules/always/module.conf | 7 | ||||
-rw-r--r-- | src/tests/modules/always/replace.unlang | 11 | ||||
-rw-r--r-- | src/tests/modules/always/set_rcode.unlang | 44 | ||||
-rw-r--r-- | src/tests/modules/always/set_status_dead.unlang | 18 | ||||
-rw-r--r-- | src/tests/modules/always/set_status_revive.unlang | 28 |
6 files changed, 111 insertions, 0 deletions
diff --git a/src/tests/modules/always/all.mk b/src/tests/modules/always/all.mk new file mode 100644 index 0000000..8f1127f --- /dev/null +++ b/src/tests/modules/always/all.mk @@ -0,0 +1,3 @@ +# +# Test the "always" module +# diff --git a/src/tests/modules/always/module.conf b/src/tests/modules/always/module.conf new file mode 100644 index 0000000..39995e5 --- /dev/null +++ b/src/tests/modules/always/module.conf @@ -0,0 +1,7 @@ +always my_reject { + rcode = reject +} + +always db_status { + rcode = ok +} diff --git a/src/tests/modules/always/replace.unlang b/src/tests/modules/always/replace.unlang new file mode 100644 index 0000000..1d502f7 --- /dev/null +++ b/src/tests/modules/always/replace.unlang @@ -0,0 +1,11 @@ +%{poke:my_reject.rcode=ok} + +my_reject # should be "ok" + +update control { + Cleartext-Password := "hello" +} + +update reply { + Filter-Id := "success" +} diff --git a/src/tests/modules/always/set_rcode.unlang b/src/tests/modules/always/set_rcode.unlang new file mode 100644 index 0000000..faaed28 --- /dev/null +++ b/src/tests/modules/always/set_rcode.unlang @@ -0,0 +1,44 @@ +# +# Set status to "notfound". xlat should expand to previous status, "alive" +# +if ("%{db_status:notfound}" != "alive") { + update reply { + Filter-Id += "failed" + } +} + + +# +# Verify that the status was changed +# +db_status +if (!notfound) { + update reply { + Filter-Id += "failed" + } +} + + +# +# Fetch status using xlat without setting the status +# +if ("%{db_status:}" != "notfound") { + update reply { + Filter-Id += "failed" + } +} + + +# +# Verify that the status did not change +# +db_status +if (notfound) { + update reply { + Filter-Id += "success" + } +} + +update control { + Cleartext-Password := "hello" +} diff --git a/src/tests/modules/always/set_status_dead.unlang b/src/tests/modules/always/set_status_dead.unlang new file mode 100644 index 0000000..6b29ede --- /dev/null +++ b/src/tests/modules/always/set_status_dead.unlang @@ -0,0 +1,18 @@ +# +# Set the module status to dead, call it and check that it fails +# +%{db_status:dead} + +db_status { + fail = 1 +} + +if (fail) { + update reply { + Filter-Id := "success" + } +} + +update control { + Cleartext-Password := "hello" +} diff --git a/src/tests/modules/always/set_status_revive.unlang b/src/tests/modules/always/set_status_revive.unlang new file mode 100644 index 0000000..3e71d39 --- /dev/null +++ b/src/tests/modules/always/set_status_revive.unlang @@ -0,0 +1,28 @@ +# +# Fail a module... +# +%{db_status:dead} +db_status { + fail = 1 +} +if (!fail) { + update reply { + Filter-Id += "failed" + } +} + + +# +# ... Now revive it +# +%{db_status:alive} +db_status +if (ok) { + update reply { + Filter-Id += "success" + } +} + +update control { + Cleartext-Password := "hello" +} |