protected function setUser() { FakeAccess::$superUser = false; FakeAccess::$idSitesAdmin = array(); FakeAccess::$idSitesView = array(99); FakeAccess::$identity = 'aUser'; }
/** * @dataProvider getPermissionsFailData */ public function testMethodPermissions($hasAdminAccess, $hasViewAccess, $request, $checkException, $failMessage) { // create fake access that denies user access FakeAccess::$superUser = false; FakeAccess::$idSitesAdmin = $hasAdminAccess ? array(self::$fixture->idSite1) : array(); FakeAccess::$idSitesView = $hasViewAccess ? array(self::$fixture->idSite1) : array(); if ($checkException) { try { $request = new Request($request); $request->process(); $this->fail($failMessage); } catch (Exception $ex) { // pass } } else { $request = new Request($request); $request->process(); } }
protected function setUser() { FakeAccess::clearAccess(false); FakeAccess::$idSitesView = array(1); FakeAccess::$idSitesAdmin = array(); FakeAccess::$identity = 'aUser'; }
return $previous; } }), 'Piwik\\Access' => DI\decorate(function ($previous, ContainerInterface $c) { $testUseMockAuth = $c->get('test.vars.testUseMockAuth'); if ($testUseMockAuth) { $idSitesAdmin = $c->get('test.vars.idSitesAdminAccess'); $idSitesView = $c->get('test.vars.idSitesViewAccess'); $access = new FakeAccess(); if (!empty($idSitesView)) { FakeAccess::$superUser = false; FakeAccess::$idSitesView = $idSitesView; FakeAccess::$idSitesAdmin = !empty($idSitesAdmin) ? $idSitesAdmin : array(); FakeAccess::$identity = 'viewUserLogin'; } elseif (!empty($idSitesAdmin)) { FakeAccess::$superUser = false; FakeAccess::$idSitesAdmin = $idSitesAdmin; FakeAccess::$identity = 'adminUserLogin'; } else { FakeAccess::$superUser = true; FakeAccess::$superUserLogin = '******'; } return $access; } else { return $previous; } }), 'observers.global' => DI\add(array(array('AssetManager.getStylesheetFiles', function (&$stylesheets) { $useOverrideCss = \Piwik\Container\StaticContainer::get('test.vars.useOverrideCss'); if ($useOverrideCss) { $stylesheets[] = 'tests/resources/screenshot-override/override.css'; } }), array('AssetManager.getJavaScriptFiles', function (&$jsFiles) {