PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/tests/system/suite/acl/acl0005Test.php

https://bitbucket.org/talueses/joomla-cms
PHP | 428 lines | 304 code | 115 blank | 9 comment | 0 complexity | 87ef81a88971d88d0b7aa9b063b74451 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, JSON
  1. <?php
  2. /**
  3. * @package Joomla.SystemTest
  4. * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
  5. * @license GNU General Public License version 2 or later; see LICENSE.txt
  6. * Tests admin login permissions per global configuration permission settings.
  7. */
  8. require_once 'SeleniumJoomlaTestCase.php';
  9. class Acl0005Test extends SeleniumJoomlaTestCase
  10. {
  11. function testAdminLoginPermissions()
  12. {
  13. $this->setUp();
  14. $this->gotoAdmin();
  15. $this->doAdminLogin();
  16. //Set random salt
  17. $salt = mt_rand();
  18. //Set message to be checked
  19. $message='You do not have access to the administrator section of this site.';
  20. //Define test user
  21. $username = 'ACL Test User' . $salt;
  22. $password = 'password' . $salt;
  23. $login = 'acltestuser' . $salt;
  24. $email = $login . '@test.com';
  25. $group = 'Public';
  26. echo "Create $username and add to $group group.\n";
  27. $this->createUser($username, $login, $password, $email, $group);
  28. echo "Removing $username from Registered group.\n";
  29. $this->changeAssignedGroup($username,$group="Registered");
  30. echo "Setting all roles to inherit.\n";
  31. $actions = array('Site Login', 'Admin Login', 'Configure', 'Access Component', 'Create', 'Delete', 'Edit', 'Edit State');
  32. $permissions = array('Inherited', 'Inherited', 'Inherited', 'Inherited', 'Inherited', 'Inherited', 'Inherited', 'Inherited');
  33. $this->setPermissions('Global Configuration', $group, $actions, $permissions);
  34. $group = 'Public';
  35. $action="Admin Login";
  36. $permission="Allowed";
  37. $this->setPermissions('Global Configuration', $group, $action, $permission);
  38. $this->doAdminLogout();
  39. $this->doAdminLogin($login,$password);
  40. try {
  41. $this->assertTrue($this->isElementPresent("link=Log out"));
  42. } catch (PHPUnit_Framework_AssertionFailedError $e){
  43. array_push($this->verificationErrors, $this->getTraceFiles($e));
  44. }
  45. $this->doAdminLogout();
  46. $this->doAdminLogin();
  47. $this->gotoAdmin();
  48. $permission="Denied";
  49. $this->setPermissions('Global Configuration', $group, $action, $permission);
  50. $this->doAdminLogout();
  51. $this->doAdminLogin($login,$password);
  52. $this->checkMessage($message);
  53. $this->doAdminLogin();
  54. $permission="Not Set";
  55. $this->setPermissions('Global Configuration', $group, $action, $permission);
  56. $this->doAdminLogout();
  57. $this->doAdminLogin($login,$password);
  58. $this->checkMessage($message);
  59. $this->doAdminLogin();
  60. $group='Manager';
  61. $this->changeAssignedGroup($username,$group);
  62. $this->gotoAdmin();
  63. $permission="Allowed";
  64. $this->setPermissions('Global Configuration', $group, $action, $permission);
  65. $this->doAdminLogout();
  66. $this->doAdminLogin($login,$password);
  67. try {
  68. $this->assertTrue($this->isElementPresent("link=Log out"));
  69. } catch (PHPUnit_Framework_AssertionFailedError $e){
  70. array_push($this->verificationErrors, $this->getTraceFiles($e));
  71. }
  72. $this->doAdminLogout();
  73. $this->doAdminLogin();
  74. $permission="Denied";
  75. $this->setPermissions('Global Configuration', $group, $action, $permission);
  76. $this->doAdminLogout();
  77. $this->doAdminLogin($login,$password);
  78. $this->checkMessage($message);
  79. $this->doAdminLogin();
  80. $permission="Inherited";
  81. $this->setPermissions('Global Configuration', $group, $action, $permission);
  82. $this->doAdminLogout();
  83. $this->doAdminLogin($login,$password);
  84. $this->checkMessage($message);
  85. $this->doAdminLogin();
  86. $group='Administrator';
  87. $this->changeAssignedGroup($username,$group);
  88. $this->gotoAdmin();
  89. $permission="Allowed";
  90. $this->setPermissions('Global Configuration', $group, $action, $permission);
  91. $this->doAdminLogout();
  92. $this->doAdminLogin($login,$password);
  93. try {
  94. $this->assertTrue($this->isElementPresent("link=Log out"));
  95. } catch (PHPUnit_Framework_AssertionFailedError $e){
  96. array_push($this->verificationErrors, $this->getTraceFiles($e));
  97. }
  98. $this->doAdminLogout();
  99. $this->doAdminLogin();
  100. $permission="Denied";
  101. $this->setPermissions('Global Configuration', $group, $action, $permission);
  102. $this->doAdminLogout();
  103. $this->doAdminLogin($login,$password);
  104. $this->checkMessage($message);
  105. $this->doAdminLogin();
  106. $permission="Inherited";
  107. $this->setPermissions('Global Configuration', $group, $action, $permission);
  108. $this->doAdminLogout();
  109. $this->doAdminLogin($login,$password);
  110. $this->checkMessage($message);
  111. $this->doAdminLogin();
  112. $group='Super Users';
  113. $this->changeAssignedGroup($username,$group);
  114. $permission="Allowed";
  115. $this->setPermissions('Global Configuration', $group, $action, $permission);
  116. $this->doAdminLogout();
  117. $this->doAdminLogin($login,$password);
  118. try {
  119. $this->assertTrue($this->isElementPresent("link=Log out"));
  120. } catch (PHPUnit_Framework_AssertionFailedError $e){
  121. array_push($this->verificationErrors, $this->getTraceFiles($e));
  122. }
  123. $this->doAdminLogout();
  124. $this->doAdminLogin();
  125. $permission="Denied";
  126. $this->setPermissions('Global Configuration', $group, $action, $permission);
  127. $this->doAdminLogout();
  128. echo "Logging in to front end.\n";
  129. $this->doAdminLogin($login,$password);
  130. $this->doAdminLogin($login,$password);
  131. try {
  132. $this->assertTrue($this->isElementPresent("link=Log out"));
  133. } catch (PHPUnit_Framework_AssertionFailedError $e){
  134. array_push($this->verificationErrors, $this->getTraceFiles($e));
  135. }
  136. $this->doAdminLogout();
  137. $this->doAdminLogin();
  138. $permission="Inherited";
  139. $this->setPermissions('Global Configuration', $group, $action, $permission);
  140. $this->doAdminLogout();
  141. $this->doAdminLogin($login,$password);
  142. try {
  143. $this->assertTrue($this->isElementPresent("link=Log out"));
  144. } catch (PHPUnit_Framework_AssertionFailedError $e){
  145. array_push($this->verificationErrors, $this->getTraceFiles($e));
  146. }
  147. $this->doAdminLogout();
  148. $this->doAdminLogin();
  149. $group='Super Users';
  150. $this->changeAssignedGroup($username,$group);
  151. $group='Administrator';
  152. $this->changeAssignedGroup($username,$group);
  153. $group='Manager';
  154. $this->changeAssignedGroup($username,$group);
  155. $group='Public';
  156. $this->changeAssignedGroup($username,$group);
  157. $group='Registered';
  158. $this->changeAssignedGroup($username,$group);
  159. $permission="Allowed";
  160. $this->setPermissions('Global Configuration', $group, $action, $permission);
  161. $this->doAdminLogout();
  162. $this->doAdminLogin($login,$password);
  163. try {
  164. $this->assertTrue($this->isElementPresent("link=Log out"));
  165. } catch (PHPUnit_Framework_AssertionFailedError $e){
  166. array_push($this->verificationErrors, $this->getTraceFiles($e));
  167. }
  168. $this->doAdminLogout();
  169. $this->doAdminLogin();
  170. $permission="Denied";
  171. $this->setPermissions('Global Configuration', $group, $action, $permission);
  172. $this->doAdminLogout();
  173. $this->doAdminLogin($login,$password);
  174. $this->checkMessage($message);
  175. $this->doAdminLogin();
  176. $permission="Inherited";
  177. $this->setPermissions('Global Configuration', $group, $action, $permission);
  178. $this->doAdminLogout();
  179. $this->doAdminLogin($login,$password);
  180. $this->checkMessage($message);
  181. $this->doAdminLogin();
  182. $group='Author';
  183. $this->changeAssignedGroup($username,$group);
  184. $permission="Allowed";
  185. $this->setPermissions('Global Configuration', $group, $action, $permission);
  186. $this->doAdminLogout();
  187. $this->doAdminLogin($login,$password);
  188. try {
  189. $this->assertTrue($this->isElementPresent("link=Log out"));
  190. } catch (PHPUnit_Framework_AssertionFailedError $e){
  191. array_push($this->verificationErrors, $this->getTraceFiles($e));
  192. }
  193. $this->doAdminLogout();
  194. $this->doAdminLogin();
  195. $permission="Denied";
  196. $this->setPermissions('Global Configuration', $group, $action, $permission);
  197. $this->doAdminLogout();
  198. $this->doAdminLogin($login,$password);
  199. $this->checkMessage($message);
  200. $this->doAdminLogin();
  201. $permission="Inherited";
  202. $this->setPermissions('Global Configuration', $group, $action, $permission);
  203. $this->doAdminLogout();
  204. $this->doAdminLogin($login,$password);
  205. $this->checkMessage($message);
  206. $this->doAdminLogin();
  207. $group='Editor';
  208. $this->changeAssignedGroup($username,$group);
  209. $permission="Allowed";
  210. $this->setPermissions('Global Configuration', $group, $action, $permission);
  211. $this->doAdminLogout();
  212. $this->doAdminLogin($login,$password);
  213. try {
  214. $this->assertTrue($this->isElementPresent("link=Log out"));
  215. } catch (PHPUnit_Framework_AssertionFailedError $e){
  216. array_push($this->verificationErrors, $this->getTraceFiles($e));
  217. }
  218. $this->doAdminLogout();
  219. $this->doAdminLogin();
  220. $permission="Denied";
  221. $this->setPermissions('Global Configuration', $group, $action, $permission);
  222. $this->doAdminLogout();
  223. $this->doAdminLogin($login,$password);
  224. $this->checkMessage($message);
  225. $this->doAdminLogin();
  226. $permission="Inherited";
  227. $this->setPermissions('Global Configuration', $group, $action, $permission);
  228. $this->doAdminLogout();
  229. $this->doAdminLogin($login,$password);
  230. $this->checkMessage($message);
  231. $this->doAdminLogin();
  232. $group='Publisher';
  233. $this->changeAssignedGroup($username,$group);
  234. $permission="Allowed";
  235. $this->setPermissions('Global Configuration', $group, $action, $permission);
  236. $this->doAdminLogout();
  237. $this->doAdminLogin($login,$password);
  238. try {
  239. $this->assertTrue($this->isElementPresent("link=Log out"));
  240. } catch (PHPUnit_Framework_AssertionFailedError $e){
  241. array_push($this->verificationErrors, $this->getTraceFiles($e));
  242. }
  243. $this->doAdminLogout();
  244. $this->doAdminLogin();
  245. $permission="Denied";
  246. $this->setPermissions('Global Configuration', $group, $action, $permission);
  247. $this->doAdminLogout();
  248. $this->doAdminLogin($login,$password);
  249. $this->checkMessage($message);
  250. $this->doAdminLogin();
  251. $permission="Inherited";
  252. $this->setPermissions('Global Configuration', $group, $action, $permission);
  253. $this->doAdminLogout();
  254. $this->doAdminLogin($login,$password);
  255. $this->checkMessage($message);
  256. $this->doAdminLogin();
  257. $group='Shop Suppliers';
  258. $this->changeAssignedGroup($username,$group);
  259. $permission="Allowed";
  260. $this->setPermissions('Global Configuration', $group, $action, $permission);
  261. $this->doAdminLogout();
  262. $this->doAdminLogin($login,$password);
  263. try {
  264. $this->assertTrue($this->isElementPresent("link=Log out"));
  265. } catch (PHPUnit_Framework_AssertionFailedError $e){
  266. array_push($this->verificationErrors, $this->getTraceFiles($e));
  267. }
  268. $this->doAdminLogout();
  269. $this->doAdminLogin();
  270. $permission="Denied";
  271. $this->setPermissions('Global Configuration', $group, $action, $permission);
  272. $this->doAdminLogout();
  273. $this->doAdminLogin($login,$password);
  274. $this->checkMessage($message);
  275. $this->doAdminLogin();
  276. $permission="Inherited";
  277. $this->setPermissions('Global Configuration', $group, $action, $permission);
  278. $this->doAdminLogout();
  279. $this->doAdminLogin($login,$password);
  280. $this->checkMessage($message);
  281. $this->doAdminLogin();
  282. $group='Customer Group';
  283. $this->changeAssignedGroup($username,$group);
  284. $permission="Allowed";
  285. $this->setPermissions('Global Configuration', $group, $action, $permission);
  286. $this->doAdminLogout();
  287. $this->doAdminLogin($login,$password);
  288. try {
  289. $this->assertTrue($this->isElementPresent("link=Log out"));
  290. } catch (PHPUnit_Framework_AssertionFailedError $e){
  291. array_push($this->verificationErrors, $this->getTraceFiles($e));
  292. }
  293. $this->doAdminLogout();
  294. $this->doAdminLogin();
  295. $permission="Denied";
  296. $this->setPermissions('Global Configuration', $group, $action, $permission);
  297. $this->doAdminLogout();
  298. $this->doAdminLogin($login,$password);
  299. $this->checkMessage($message);
  300. $this->doAdminLogin();
  301. $permission="Inherited";
  302. $this->setPermissions('Global Configuration', $group, $action, $permission);
  303. $this->doAdminLogout();
  304. $this->doAdminLogin($login,$password);
  305. $this->checkMessage($message);
  306. $this->gotoAdmin();
  307. $this->doAdminLogin();
  308. $this->deleteTestUsers();
  309. $this->restoreDefaultGlobalPermissions();
  310. $this->doAdminLogOut();
  311. $this->deleteAllVisibleCookies();
  312. }
  313. }