From 1f6e92fa1bf9bf1d01cd159a9495657661ea6f4f Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Fri, 25 Oct 2013 13:30:27 +0100 Subject: unittests for auth_loadACL --- _test/tests/inc/auth_loadacl.test.php | 121 ++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 _test/tests/inc/auth_loadacl.test.php (limited to '_test') diff --git a/_test/tests/inc/auth_loadacl.test.php b/_test/tests/inc/auth_loadacl.test.php new file mode 100644 index 000000000..5e7ac3acf --- /dev/null +++ b/_test/tests/inc/auth_loadacl.test.php @@ -0,0 +1,121 @@ +assertEquals($expect, $this->auth_loadACL_testwrapper($acls)); + } + + function test_user_substitution() { + $acls = <<assertEquals($expect, $this->auth_loadACL_testwrapper($acls)); + } + + function test_group_substitution() { + $acls = <<assertEquals($expect, $this->auth_loadACL_testwrapper($acls)); + } + + function test_both_substitution() { + $acls = <<assertEquals($expect, $this->auth_loadACL_testwrapper($acls)); + } + + // put it all together - read the standard acl provided with the test suite + function test_standardtestacls(){ + $expect = array( + "*\t@ALL 8", + "private:*\t@ALL 0", + "users:*\t@ALL 1", + "users:testuser:*\ttestuser 16", + "groups:*\t@ALL 1", + "groups:foo:*\t@foo 16", + "groups:bar:*\t@bar 16", + ); + $this->assertEquals($expect, auth_loadACL()); + } + + // FS#2867, '\s' in php regular expressions may match non-space characters utf8 strings + // this is due to locale setting on the server, which may match bytes '\xA0' and '\x85' + // these two bytes are present in valid multi-byte UTF-8 characters. + // this test will use one, 'ठ' (DEVANAGARI LETTER TTHA, e0 a4 a0). There are many others. + function test_FS2867() { + global $USERINFO; + + setlocale(LC_ALL, "English_United States.1252"); // should only succeed on windows systems + setlocale(LC_ALL, "en_US.UTF-8"); // should succeed on other systems + + $_SERVER['REMOTE_USER'] = 'utfठ8'; + $USERINFO['grps'] = array('utfठ16','utfठa'); + + $acls = <<assertEquals($expect, $this->auth_loadACL_testwrapper($acls)); + } +} + +//Setup VIM: ex: et ts=4 : -- cgit v1.2.3