diff options
Diffstat (limited to '_test')
-rw-r--r-- | _test/cases/inc/auth_admincheck.test.php | 88 | ||||
-rw-r--r-- | _test/cases/inc/parser/xhtml_links.test.php | 4 | ||||
-rw-r--r-- | _test/cases/lib/exe/css_css_loadfile.test.php | 57 |
3 files changed, 142 insertions, 7 deletions
diff --git a/_test/cases/inc/auth_admincheck.test.php b/_test/cases/inc/auth_admincheck.test.php index b21c2fe27..a71c8801a 100644 --- a/_test/cases/inc/auth_admincheck.test.php +++ b/_test/cases/inc/auth_admincheck.test.php @@ -3,20 +3,47 @@ require_once DOKU_INC.'inc/init.php'; require_once DOKU_INC.'inc/auth.php'; +class auth_admin_test_AuthInSensitive extends auth_basic { + function isCaseSensitive(){ + return false; + } +} + class auth_admin_test extends UnitTestCase { + private $oldauth; + + function setup() { + global $auth; + $this->oldauth = $auth; + parent::setup(); + } + + function setSensitive() { + global $auth; + $auth = new auth_basic; + } + + function setInSensitive() { + global $auth; + $auth = new auth_admin_test_AuthInSensitive; + } + function teardown() { + global $auth; global $conf; global $AUTH_ACL; unset($conf); unset($AUTH_ACL); - + $auth = $this->oldauth; + parent::teardown(); } - function test_ismanager(){ + function test_ismanager_insensitive(){ + $this->setInSensitive(); global $conf; - $conf['superuser'] = 'john,@admin'; - $conf['manager'] = 'john,@managers,doe'; + $conf['superuser'] = 'john,@admin,@Mötly Görls, Dörte'; + $conf['manager'] = 'john,@managers,doe, @Mötly Böys, Dänny'; // anonymous user $this->assertEqual(auth_ismanager('jill', null,false), false); @@ -25,12 +52,19 @@ class auth_admin_test extends UnitTestCase { $this->assertEqual(auth_ismanager('john', null,false), true); $this->assertEqual(auth_ismanager('doe', null,false), true); + $this->assertEqual(auth_ismanager('dörte', null,false), true); + $this->assertEqual(auth_ismanager('dänny', null,false), true); + // admin or manager groups $this->assertEqual(auth_ismanager('jill', array('admin'),false), true); $this->assertEqual(auth_ismanager('jill', array('managers'),false), true); + + $this->assertEqual(auth_ismanager('jill', array('mötly görls'),false), true); + $this->assertEqual(auth_ismanager('jill', array('mötly böys'),false), true); } - function test_isadmin(){ + function test_isadmin_insensitive(){ + $this->setInSensitive(); global $conf; $conf['superuser'] = 'john,@admin,doe,@roots'; @@ -48,6 +82,50 @@ class auth_admin_test extends UnitTestCase { $this->assertEqual(auth_ismanager('doe', array('admin'),true), true); } + function test_ismanager_sensitive(){ + $this->setSensitive(); + global $conf; + $conf['superuser'] = 'john,@admin,@Mötly Görls, Dörte'; + $conf['manager'] = 'john,@managers,doe, @Mötly Böys, Dänny'; + + // anonymous user + $this->assertEqual(auth_ismanager('jill', null,false), false); + + // admin or manager users + $this->assertEqual(auth_ismanager('john', null,false), true); + $this->assertEqual(auth_ismanager('doe', null,false), true); + + $this->assertEqual(auth_ismanager('dörte', null,false), false); + $this->assertEqual(auth_ismanager('dänny', null,false), false); + + // admin or manager groups + $this->assertEqual(auth_ismanager('jill', array('admin'),false), true); + $this->assertEqual(auth_ismanager('jill', array('managers'),false), true); + + $this->assertEqual(auth_ismanager('jill', array('mötly görls'),false), false); + $this->assertEqual(auth_ismanager('jill', array('mötly böys'),false), false); + } + + function test_isadmin_sensitive(){ + $this->setSensitive(); + global $conf; + $conf['superuser'] = 'john,@admin,doe,@roots'; + + // anonymous user + $this->assertEqual(auth_ismanager('jill', null,true), false); + + // admin user + $this->assertEqual(auth_ismanager('john', null,true), true); + $this->assertEqual(auth_ismanager('Doe', null,true), false); + + // admin groups + $this->assertEqual(auth_ismanager('jill', array('admin'),true), true); + $this->assertEqual(auth_ismanager('jill', array('roots'),true), true); + $this->assertEqual(auth_ismanager('john', array('admin'),true), true); + $this->assertEqual(auth_ismanager('doe', array('admin'),true), true); + $this->assertEqual(auth_ismanager('Doe', array('admin'),true), true); + } + } //Setup VIM: ex: et ts=4 : diff --git a/_test/cases/inc/parser/xhtml_links.test.php b/_test/cases/inc/parser/xhtml_links.test.php index 6a74445b0..0ad96c793 100644 --- a/_test/cases/inc/parser/xhtml_links.test.php +++ b/_test/cases/inc/parser/xhtml_links.test.php @@ -12,7 +12,7 @@ class xhtml_links_test extends UnitTestCase { $p = new Doku_Renderer_xhtml(); $p->emaillink('foo@example.com','<script>alert(\'"alert"\');</script>'); - $expect = '<a href="mailto:foo%20%5Bat%5D%20example%20%5Bdot%5D%20com" class="mail JSnocheck" title="foo [at] example [dot] com"><script>alert('"alert"');</script></a>'; + $expect = '<a href="mailto:foo%20%5Bat%5D%20example%20%5Bdot%5D%20com" class="mail" title="foo [at] example [dot] com"><script>alert('"alert"');</script></a>'; $this->assertEqual($p->doc,$expect); } @@ -36,7 +36,7 @@ class xhtml_links_test extends UnitTestCase { $p = new Doku_Renderer_xhtml(); $p->emaillink('foo@example.com',$image); - $expect = '<a href="mailto:foo%20%5Bat%5D%20example%20%5Bdot%5D%20com" class="media JSnocheck" title="foo [at] example [dot] com"><img src="'.DOKU_BASE.'lib/exe/fetch.php/img.gif?w=10&h=20&cache=nocache" class="media" title="Some Image" alt="Some Image" width="10" height="20" /></a>'; + $expect = '<a href="mailto:foo%20%5Bat%5D%20example%20%5Bdot%5D%20com" class="media" title="foo [at] example [dot] com"><img src="'.DOKU_BASE.'lib/exe/fetch.php/img.gif?w=10&h=20&cache=nocache" class="media" title="Some Image" alt="Some Image" width="10" height="20" /></a>'; $this->assertEqual($p->doc,$expect); } diff --git a/_test/cases/lib/exe/css_css_loadfile.test.php b/_test/cases/lib/exe/css_css_loadfile.test.php new file mode 100644 index 000000000..a444d0086 --- /dev/null +++ b/_test/cases/lib/exe/css_css_loadfile.test.php @@ -0,0 +1,57 @@ +<?php + +require_once DOKU_INC.'lib/exe/css.php'; + +class css_css_loadfile_test extends UnitTestCase { + public function setUp() { + $this->file = tempnam('/tmp', 'css'); + parent::setUp(); + } + + private function csstest($input, $output = null, $location = 'http://www.example.com/') { + io_saveFile($this->file, $input); + $this->assertEqual(css_loadfile($this->file, $location), (is_null($output) ? $input : $output)); + } + + public function test_url_relative() { + $this->csstest('#test { background: url("test/test.png"); }', '#test { background: url("http://www.example.com/test/test.png"); }'); + $this->csstest('#test { background: url(\'test/test.png\'); }', '#test { background: url(\'http://www.example.com/test/test.png\'); }'); + } + + public function test_url_absolute() { + $this->csstest('#test { background: url("/test/test.png"); }'); + $this->csstest('#test { background: url(\'/test/test.png\'); }'); + } + + public function test_url_with_protocol() { + $this->csstest('#test { background: url("http://www.test.com/test/test.png"); }'); + $this->csstest('#test { background: url("https://www.test.com/test/test.png"); }'); + $this->csstest('#test { background: url(\'http://www.test.com/test/test.png\'); }'); + $this->csstest('#test { background: url(\'https://www.test.com/test/test.png\'); }'); + } + + public function test_import_relative() { + $this->csstest('@import "test/test.png";', '@import "http://www.example.com/test/test.png";'); + $this->csstest('@import \'test/test.png\';', '@import \'http://www.example.com/test/test.png\';'); + } + + public function test_import_absolute() { + $this->csstest('@import "/test/test.png";'); + $this->csstest('@import \'/test/test.png\';'); + } + + public function test_import_with_protocol() { + $this->csstest('@import "http://www.test.com/test/test.png";'); + $this->csstest('@import "https://www.test.com/test/test.png";'); + $this->csstest('@import \'http://www.test.com/test/test.png\';'); + $this->csstest('@import \'https://www.test.com/test/test.png\';'); + } + + public function tearDown() { + unlink($this->file); + unset($this->file); + parent::tearDown(); + } +} + +//Setup VIM: ex: et ts=4 sw=4 : |