From 0f68ad3ebc84ad423ba9bff073ef0969aa0b09bb Mon Sep 17 00:00:00 2001 From: Julien Boulen Date: Mon, 16 Dec 2024 15:55:58 +0100 Subject: [PATCH] MDL-79121 lib: Improve the dataset for is_proxybypass_provider() --- lib/tests/moodlelib_test.php | 61 +++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/lib/tests/moodlelib_test.php b/lib/tests/moodlelib_test.php index f41ab281ff311..2ad8a76dd1829 100644 --- a/lib/tests/moodlelib_test.php +++ b/lib/tests/moodlelib_test.php @@ -5489,38 +5489,83 @@ public static function is_proxybypass_provider(): array { return [ 'Proxybypass contains the same IP as the beginning of the URL' => [ 'http://192.168.5.5-fake-app-7f000101.nip.io', - '192.168.5.5, 127.0.0.1', - false + '192.168.5.5,127.0.0.1', + false, + ], + 'Proxybypass contains some extra whitespaces (test with hostname)' => [ + 'store.mydomain.com', + 'store.mydomain.com , 192.168.5.5', + false, + ], + 'Proxybypass contains some extra whitespaces (test with IP)' => [ + '192.168.5.5', + 'store.mydomain.com , 192.168.5.5', + false, ], 'Proxybypass contains the last part of the URL' => [ 'http://192.168.5.5-fake-app-7f000101.nip.io', 'app-7f000101.nip.io', - false + false, ], 'Proxybypass contains the last part of the URL 2' => [ 'http://store.mydomain.com', 'mydomain.com', - false + false, ], 'Proxybypass contains part of the url' => [ 'http://myweb.com', 'store.myweb.com', - false + false, + ], + 'Proxybypass with a wildcard contains part of the url' => [ + 'http://myweb.com', + '*.myweb.com', + false, ], 'Different IPs used in proxybypass' => [ 'http://192.168.5.5', '192.168.5.3', - false + false, + ], + 'Different partial IPs used in proxybypass' => [ + 'http://192.168.5.5', + '192.16', + false, + ], + 'Different partial IPs used in proxybypass with ending dot' => [ + 'http://192.168.5.5', + '192.16.', + false, ], 'Proxybypass and URL matchs' => [ 'http://store.mydomain.com', 'store.mydomain.com', - true + true, + ], + 'Proxybypass with a wildcard value covers any subdomain' => [ + 'http://store.mydomain.com', + '*.mydomain.com', + true, + ], + 'Proxybypass with a wildcard value covers any higher level subdomain' => [ + 'http://another.store.mydomain.com', + '*.mydomain.com', + true, + ], + 'Proxybypass with multiple domains' => [ + 'http://store.mydomain.com', + '127.0.0.1,*.mydomain.com', + true, ], 'IP used in proxybypass' => [ 'http://192.168.5.5', '192.168.5.5', - true + true, + ], + 'Partial IP used in proxybypass' => [ + 'http://192.168.5.5', + '192.168.', + true, ], ]; }