From 11f2cf973cde2a812bcfeb5f89d4856f80b60a99 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Fri, 4 Oct 2024 09:56:24 +0200
Subject: [PATCH] add test script

---
 test/get_redirect.php | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/test/get_redirect.php b/test/get_redirect.php
index c4fe7b0..5af2322 100644
--- a/test/get_redirect.php
+++ b/test/get_redirect.php
@@ -1,7 +1,13 @@
 <?php
 /**
+ * 
  * TEST
  * Verify if a redirect works
+ * 
+ * Usage:
+ * cd ./tests
+ * php get_redirect.php
+ * 
  */
 require_once '../public_html/classes/redirect.class.php';
 
@@ -9,13 +15,20 @@ require_once '../public_html/classes/redirect.class.php';
 // CONFIG
 // ------------------------------------------------------------------------
 $aTests=[
-    'www.example.com - static entry' => [
+    'www.example.com - static entry /mail' => [
         'host'=>'www.example.com',
         'request'=>'/mail',
 
         'target'=>'https://www.example.com/webmail',
         'code'=>301,
     ],
+    'www.example.com - /mail2 should not match /mail but the regex' => [
+        'host'=>'www.example.com',
+        'request'=>'/mail2',
+
+        'target'=>'https://www.example.com/',
+        'code'=>307,
+    ],
     'www.example.com - regex' => [
         'host'=>'www.example.com',
         'request'=>'/somethingold',
@@ -23,6 +36,20 @@ $aTests=[
         'target'=>'https://www.example.com/',
         'code'=>307,
     ],
+    'www.example.com - /iml must match regex ^/iml' => [
+        'host'=>'www.example.com',
+        'request'=>'/iml',
+
+        'target'=>'https://www.iml.unibe.ch/',
+        'code'=>307,
+    ],
+    'www.example.com - /iml2 must match regex ^/iml too' => [
+        'host'=>'www.example.com',
+        'request'=>'/iml2',
+
+        'target'=>'https://www.iml.unibe.ch/',
+        'code'=>307,
+    ],
 ];
 
 // ------------------------------------------------------------------------
-- 
GitLab