diff --git a/test/class/user.class.php b/test/class/user.class.php index 74d15feb0c..597ae5ca64 100755 --- a/test/class/user.class.php +++ b/test/class/user.class.php @@ -1037,4 +1037,26 @@ class userTest return $oldRandom != $newRandom ? 1 : 0; } + + /** + * Identify user by PHP_AUTH_USER. + * + * @access public + * @return bool + */ + public function identifyByPhpAuthTest() + { + return $this->objectModel->identifyByPhpAuth(); + } + + /** + * Identify user by cookie. + * + * @access public + * @return bool + */ + public function identifyByCookieTest() + { + return $this->objectModel->identifyByCookie(); + } } diff --git a/test/model/user/identifybycookie.php b/test/model/user/identifybycookie.php new file mode 100755 index 0000000000..4ad344d1c6 --- /dev/null +++ b/test/model/user/identifybycookie.php @@ -0,0 +1,39 @@ +#!/usr/bin/env php +gen(300); + +/** + +title=测试 userModel->identifyByCookie(); +cid=1 +pid=1 + +验证admin用户 >> 1 +验证游客用户 >> 0 +获取不存在的用户 >> 0 + +*/ + +$user = new userTest(); + +$_COOKIE['za'] = 'admin'; +$_COOKIE['zp'] = 'a0933c1218a4e745bacdcf572b10eba7'; +$normalUser = $user->identifyByCookieTest('admin'); + +$_COOKIE['za'] = 'guest'; +$_COOKIE['zp'] = ''; +$guest = $user->identifyByCookieTest('guest'); + +$_COOKIE['za'] = 'asdqwe'; +$_COOKIE['zp'] = 'a0933c1218a4e745bacdcf572b10eba7'; +$notExistUser = $user->identifyByCookieTest('asdqwe'); + +r($normalUser) && p() && e('1'); //验证admin用户 +r($guest) && p() && e('0'); //验证游客用户 +r($notExistsUser) && p() && e('0'); //获取不存在的用户 diff --git a/test/model/user/identifybyphpauth.php b/test/model/user/identifybyphpauth.php new file mode 100755 index 0000000000..6fa43cb924 --- /dev/null +++ b/test/model/user/identifybyphpauth.php @@ -0,0 +1,39 @@ +#!/usr/bin/env php +gen(300); + +/** + +title=测试 userModel->identifyByPhpAuth(); +cid=1 +pid=1 + +验证admin用户 >> 1 +验证游客用户 >> 0 +获取不存在的用户 >> 0 + +*/ + +$user = new userTest(); + +$_SERVER['PHP_AUTH_USER'] = 'admin'; +$_SERVER['PHP_AUTH_PW'] = 'a0933c1218a4e745bacdcf572b10eba7'; +$normalUser = $user->identifyByPhpAuthTest('admin'); + +$_SERVER['PHP_AUTH_USER'] = 'guest'; +$_SERVER['PHP_AUTH_PW'] = ''; +$guest = $user->identifyByPhpAuthTest('guest'); + +$_SERVER['PHP_AUTH_USER'] = 'asdqwe'; +$_SERVER['PHP_AUTH_PW'] = 'a0933c1218a4e745bacdcf572b10eba7'; +$notExistUser = $user->identifyByPhpAuthTest('asdqwe'); + +r($normalUser) && p() && e('1'); //验证admin用户 +r($guest) && p() && e('0'); //验证游客用户 +r($notExistsUser) && p() && e('0'); //获取不存在的用户