summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--test/php/list-extensions/index.php11
-rw-r--r--test/php/list-extensions/php.ini1
-rw-r--r--test/test_php_isolation.py54
3 files changed, 66 insertions, 0 deletions
diff --git a/test/php/list-extensions/index.php b/test/php/list-extensions/index.php
new file mode 100644
index 00000000..d6eb40d0
--- /dev/null
+++ b/test/php/list-extensions/index.php
@@ -0,0 +1,11 @@
+<?php
+
+function quote($str) {
+ return '"' . $str . '"';
+}
+
+header('Content-Type: application/json');
+
+print "[" . join(",", array_map('quote', get_loaded_extensions())) . "]";
+
+?>
diff --git a/test/php/list-extensions/php.ini b/test/php/list-extensions/php.ini
new file mode 100644
index 00000000..5848a0f2
--- /dev/null
+++ b/test/php/list-extensions/php.ini
@@ -0,0 +1 @@
+extension=json.so
diff --git a/test/test_php_isolation.py b/test/test_php_isolation.py
index 1b70ef02..abaf70a2 100644
--- a/test/test_php_isolation.py
+++ b/test/test_php_isolation.py
@@ -52,6 +52,60 @@ class TestPHPIsolation(TestApplicationPHP):
self.assertEqual(self.get()['status'], 200, 'empty rootfs')
+ def test_php_isolation_rootfs_extensions(self):
+ isolation_features = self.available['features']['isolation'].keys()
+
+ if not self.is_su:
+ if 'user' not in isolation_features:
+ print('requires unprivileged userns or root')
+ raise unittest.SkipTest()
+
+ if not 'unprivileged_userns_clone' in isolation_features:
+ print('requires unprivileged userns or root')
+ raise unittest.SkipTest()
+
+ if 'mnt' not in isolation_features:
+ print('requires mnt ns')
+ raise unittest.SkipTest()
+
+ isolation = {
+ 'rootfs': self.current_dir,
+ 'namespaces': {
+ 'credential': not self.is_su,
+ 'mount': not self.is_su,
+ },
+ }
+
+ self.load('list-extensions', isolation=isolation)
+
+ self.assertIn(
+ 'success',
+ self.conf(
+ '"/php/list-extensions"', 'applications/list-extensions/root'
+ ),
+ )
+
+ self.assertIn(
+ 'success',
+ self.conf(
+ {'file': '/php/list-extensions/php.ini'},
+ 'applications/list-extensions/options',
+ ),
+ )
+
+ self.assertIn(
+ 'success',
+ self.conf(
+ '"/php/list-extensions"',
+ 'applications/list-extensions/working_directory',
+ ),
+ )
+
+ extensions = self.getjson()['body']
+
+ self.assertIn('json', extensions, 'json in extensions list')
+ self.assertIn('unit', extensions, 'unit in extensions list')
+
if __name__ == '__main__':
TestPHPIsolation.main()