summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--_test/conf/acl.auth.php6
-rw-r--r--_test/core/TestRequest.php70
-rw-r--r--_test/tests/conf/title.test.php19
-rw-r--r--_test/tests/inc/auth_aclcheck.test.php27
-rw-r--r--_test/tests/inc/events_nested.test.php36
-rw-r--r--_test/tests/test/basic.test.php83
-rw-r--r--inc/auth.php29
-rw-r--r--lib/plugins/acl/admin.php4
-rw-r--r--lib/tpl/dokuwiki/css/design.css47
-rw-r--r--lib/tpl/dokuwiki/images/sitetools.pngbin2225 -> 0 bytes
-rw-r--r--lib/tpl/dokuwiki/images/usertools.pngbin0 -> 1541 bytes
-rw-r--r--lib/tpl/dokuwiki/tpl_header.php3
12 files changed, 277 insertions, 47 deletions
diff --git a/_test/conf/acl.auth.php b/_test/conf/acl.auth.php
index 14344d778..8a1b01f23 100644
--- a/_test/conf/acl.auth.php
+++ b/_test/conf/acl.auth.php
@@ -19,3 +19,9 @@
# delete 16
* @ALL 8
+
+# for testing wildcards:
+users:* @ALL 1
+users:%USER%:* %USER% 16
+groups:* @ALL 1
+groups:%GROUP%:* %GROUP% 16
diff --git a/_test/core/TestRequest.php b/_test/core/TestRequest.php
index 66760b1e0..172821576 100644
--- a/_test/core/TestRequest.php
+++ b/_test/core/TestRequest.php
@@ -36,9 +36,10 @@ class TestRequest {
/**
* Executes the request
*
+ * @param string $url end URL to simulate, needs to start with /doku.php currently
* @return TestResponse the resulting output of the request
*/
- public function execute() {
+ public function execute($uri='/doku.php') {
// save old environment
$server = $_SERVER;
$session = $_SESSION;
@@ -46,6 +47,9 @@ class TestRequest {
$post = $_POST;
$request = $_REQUEST;
+ // prepare the right URI
+ $this->setUri($uri);
+
// import all defined globals into the function scope
foreach(array_keys($GLOBALS) as $glb){
global $$glb;
@@ -84,4 +88,68 @@ class TestRequest {
return $response;
}
+
+ /**
+ * Set the virtual URI the request works against
+ *
+ * This parses the given URI and sets any contained GET variables
+ * but will not overwrite any previously set ones (eg. set via setGet()).
+ *
+ * It initializes the $_SERVER['REQUEST_URI'] and $_SERVER['QUERY_STRING']
+ * with all set GET variables.
+ *
+ * @param string $url end URL to simulate, needs to start with /doku.php currently
+ * @todo make this work with other end points
+ */
+ protected function setUri($uri){
+ if(substr($uri,0,9) != '/doku.php'){
+ throw new Exception("only '/doku.php' is supported currently");
+ }
+
+ $params = array();
+ list($uri, $query) = explode('?',$uri,2);
+ if($query) parse_str($query, $params);
+
+ $this->get = array_merge($params, $this->get);
+ if(count($this->get)){
+ $query = '?'.http_build_query($this->get, '', '&');
+ $query = str_replace(
+ array('%3A', '%5B', '%5D'),
+ array(':', '[', ']'),
+ $query
+ );
+ $uri = $uri.$query;
+ }
+
+ $this->setServer('QUERY_STRING', $query);
+ $this->setServer('REQUEST_URI', $uri);
+ }
+
+ /**
+ * Simulate a POST request with the given variables
+ *
+ * @param array $post all the POST parameters to use
+ * @param string $url end URL to simulate, needs to start with /doku.php currently
+ * @param return TestResponse
+ */
+ public function post($post=array(), $uri='/doku.php') {
+ $this->post = array_merge($this->post, $post);
+ $this->setServer('REQUEST_METHOD', 'POST');
+ return $this->execute($uri);
+ }
+
+ /**
+ * Simulate a GET request with the given variables
+ *
+ * @param array $GET all the POST parameters to use
+ * @param string $url end URL to simulate, needs to start with /doku.php currently
+ * @param return TestResponse
+ */
+ public function get($get=array(), $uri='/doku.php') {
+ $this->get = array_merge($this->get, $get);
+ $this->setServer('REQUEST_METHOD', 'GET');
+ return $this->execute($uri);
+ }
+
+
}
diff --git a/_test/tests/conf/title.test.php b/_test/tests/conf/title.test.php
new file mode 100644
index 000000000..7cae040e7
--- /dev/null
+++ b/_test/tests/conf/title.test.php
@@ -0,0 +1,19 @@
+<?php
+
+class conf_title_test extends DokuWikiTest {
+
+ function testTitle() {
+ global $conf;
+
+ $request = new TestRequest();
+ $response = $request->get();
+ $content = $response->queryHTML('title');
+ $this->assertTrue(strpos($content,$conf['title']) > 0);
+
+ $conf['title'] = 'Foo';
+ $request = new TestRequest();
+ $response = $request->get();
+ $content = $response->queryHTML('title');
+ $this->assertTrue(strpos($content,'Foo') > 0);
+ }
+}
diff --git a/_test/tests/inc/auth_aclcheck.test.php b/_test/tests/inc/auth_aclcheck.test.php
index ea48ec6a5..991f82da7 100644
--- a/_test/tests/inc/auth_aclcheck.test.php
+++ b/_test/tests/inc/auth_aclcheck.test.php
@@ -235,6 +235,33 @@ class auth_acl_test extends DokuWikiTest {
$this->assertEquals(auth_aclcheck('namespace:*', 'jill',array('foo','roots')), AUTH_ADMIN);
}
+ function test_wildcards(){
+ global $conf;
+ global $AUTH_ACL;
+ global $USERINFO;
+ $conf['useacl'] = 1;
+
+ $_SERVER['REMOTE_USER'] = 'john';
+ $USERINFO['grps'] = array('test','töst','foo bar');
+ $AUTH_ACL = auth_loadACL(); // default test file
+
+ // default setting
+ $this->assertEquals(AUTH_UPLOAD, auth_aclcheck('page', $_SERVER['REMOTE_USER'], $USERINFO['grps']));
+
+ // user namespace
+ $this->assertEquals(AUTH_DELETE, auth_aclcheck('users:john:foo', $_SERVER['REMOTE_USER'], $USERINFO['grps']));
+ $this->assertEquals(AUTH_READ, auth_aclcheck('users:john:foo', 'schmock', array()));
+
+ // group namespace
+ $this->assertEquals(AUTH_DELETE, auth_aclcheck('groups:test:foo', $_SERVER['REMOTE_USER'], $USERINFO['grps']));
+ $this->assertEquals(AUTH_READ, auth_aclcheck('groups:test:foo', 'schmock', array()));
+ $this->assertEquals(AUTH_DELETE, auth_aclcheck('groups:toest:foo', $_SERVER['REMOTE_USER'], $USERINFO['grps']));
+ $this->assertEquals(AUTH_READ, auth_aclcheck('groups:toest:foo', 'schmock', array()));
+ $this->assertEquals(AUTH_DELETE, auth_aclcheck('groups:foo_bar:foo', $_SERVER['REMOTE_USER'], $USERINFO['grps']));
+ $this->assertEquals(AUTH_READ, auth_aclcheck('groups:foo_bar:foo', 'schmock', array()));
+
+ }
+
}
//Setup VIM: ex: et ts=4 :
diff --git a/_test/tests/inc/events_nested.test.php b/_test/tests/inc/events_nested.test.php
new file mode 100644
index 000000000..fe5e395bb
--- /dev/null
+++ b/_test/tests/inc/events_nested.test.php
@@ -0,0 +1,36 @@
+<?php
+
+/**
+ * This tests if event handlers can trigger the same event again.
+ * This is used by plugins that modify cache handling and use metadata
+ * for checking cache validity which triggers another cache use event.
+ */
+class events_nested_test extends DokuWikiTest {
+ function test_nested_events() {
+ global $EVENT_HANDLER;
+ $firstcount = 0;
+ $secondcount = 0;
+
+ $EVENT_HANDLER->register_hook('NESTED_EVENT', 'BEFORE', null,
+ function() use (&$firstcount) {
+ $firstcount++;
+ if ($firstcount == 1) {
+ $param = array();
+ trigger_event('NESTED_EVENT', $param);
+ }
+ }
+ );
+
+ $EVENT_HANDLER->register_hook('NESTED_EVENT', 'BEFORE', null,
+ function() use (&$secondcount) {
+ $secondcount++;
+ }
+ );
+
+ $param = array();
+ trigger_event('NESTED_EVENT', $param);
+
+ $this->assertEquals(2, $firstcount);
+ $this->assertEquals(2, $secondcount);
+ }
+}
diff --git a/_test/tests/test/basic.test.php b/_test/tests/test/basic.test.php
index b4926d2ba..a0ea48a3a 100644
--- a/_test/tests/test/basic.test.php
+++ b/_test/tests/test/basic.test.php
@@ -19,4 +19,87 @@ class InttestsBasicTest extends DokuWikiTest {
'DokuWiki was not a word in the output'
);
}
+
+ function testPost() {
+ $request = new TestRequest();
+
+ $input = array(
+ 'string' => 'A string',
+ 'array' => array(1, 2, 3),
+ 'id' => 'wiki:dokuwiki'
+ );
+
+ $response = $request->post($input);
+
+ // server var check
+ $this->assertEquals('POST',$request->getServer('REQUEST_METHOD'));
+ $this->assertEquals('',$request->getServer('QUERY_STRING'));
+ $this->assertEquals('/doku.php',$request->getServer('REQUEST_URI'));
+
+ // variable setup check
+ $this->assertEquals('A string', $request->getPost('string'));
+ $this->assertEquals(array(1, 2, 3), $request->getPost('array'));
+ $this->assertEquals('wiki:dokuwiki', $request->getPost('id'));
+
+ // output check
+ $this->assertTrue(strpos($response->getContent(), 'Andreas Gohr') >= 0);
+ }
+
+ function testPostGet() {
+ $request = new TestRequest();
+
+ $input = array(
+ 'string' => 'A string',
+ 'array' => array(1, 2, 3),
+ );
+
+ $response = $request->post($input,'/doku.php?id=wiki:dokuwiki');
+
+ // server var check
+ $this->assertEquals('POST',$request->getServer('REQUEST_METHOD'));
+ $this->assertEquals('?id=wiki:dokuwiki',$request->getServer('QUERY_STRING'));
+ $this->assertEquals('/doku.php?id=wiki:dokuwiki',$request->getServer('REQUEST_URI'));
+
+ // variable setup check
+ $this->assertEquals('A string', $request->getPost('string'));
+ $this->assertEquals(array(1, 2, 3), $request->getPost('array'));
+ $this->assertEquals('wiki:dokuwiki', $request->getGet('id'));
+
+ // output check
+ $this->assertTrue(strpos($response->getContent(), 'Andreas Gohr') >= 0);
+ }
+
+ function testGet() {
+ $request = new TestRequest();
+
+ $input = array(
+ 'string' => 'A string',
+ 'array' => array(1, 2, 3),
+ 'test' => 'bar'
+ );
+
+ $response = $request->get($input,'/doku.php?id=wiki:dokuwiki&test=foo');
+
+ // server var check
+ $this->assertEquals('GET',$request->getServer('REQUEST_METHOD'));
+ $this->assertEquals(
+ '?id=wiki:dokuwiki&test=bar&string=A+string&array[0]=1&array[1]=2&array[2]=3',
+ $request->getServer('QUERY_STRING')
+ );
+ $this->assertEquals(
+ '/doku.php?id=wiki:dokuwiki&test=bar&string=A+string&array[0]=1&array[1]=2&array[2]=3',
+ $request->getServer('REQUEST_URI')
+ );
+
+ // variable setup check
+ $this->assertEquals('A string', $request->getGet('string'));
+ $this->assertEquals(array(1, 2, 3), $request->getGet('array'));
+ $this->assertEquals('wiki:dokuwiki', $request->getGet('id'));
+ $this->assertEquals('bar', $request->getGet('test'));
+
+ // output check
+ $this->assertTrue(strpos($response->getContent(), 'Andreas Gohr') >= 0);
+ }
+
+
}
diff --git a/inc/auth.php b/inc/auth.php
index d0f21c825..cedfdee36 100644
--- a/inc/auth.php
+++ b/inc/auth.php
@@ -123,23 +123,33 @@ function auth_setup() {
*/
function auth_loadACL() {
global $config_cascade;
+ global $USERINFO;
if(!is_readable($config_cascade['acl']['default'])) return array();
$acl = file($config_cascade['acl']['default']);
//support user wildcard
- if(isset($_SERVER['REMOTE_USER'])) {
- $len = count($acl);
- for($i = 0; $i < $len; $i++) {
- if($acl[$i]{0} == '#') continue;
- list($id, $rest) = preg_split('/\s+/', $acl[$i], 2);
- $id = str_replace('%USER%', cleanID($_SERVER['REMOTE_USER']), $id);
- $rest = str_replace('%USER%', auth_nameencode($_SERVER['REMOTE_USER']), $rest);
- $acl[$i] = "$id\t$rest";
+ $out = array();
+ foreach($acl as $line) {
+ $line = trim($line);
+ if($line{0} == '#') continue;
+ list($id,$rest) = preg_split('/\s+/',$line,2);
+
+ if(strstr($line, '%GROUP%')){
+ foreach((array) $USERINFO['grps'] as $grp){
+ $nid = str_replace('%GROUP%',cleanID($grp),$id);
+ $nrest = str_replace('%GROUP%','@'.auth_nameencode($grp),$rest);
+ $out[] = "$nid\t$nrest";
+ }
+ } else {
+ $id = str_replace('%USER%',cleanID($_SERVER['REMOTE_USER']),$id);
+ $rest = str_replace('%USER%',auth_nameencode($_SERVER['REMOTE_USER']),$rest);
+ $out[] = "$id\t$rest";
}
}
- return $acl;
+
+ return $out;
}
/**
@@ -632,6 +642,7 @@ function auth_nameencode($name, $skip_group = false) {
// never encode wildcard FS#1955
if($name == '%USER%') return $name;
+ if($name == '%GROUP%') return $name;
if(!isset($cache[$name][$skip_group])) {
if($skip_group && $name{0} == '@') {
diff --git a/lib/plugins/acl/admin.php b/lib/plugins/acl/admin.php
index c3461b78b..1f88c6ff9 100644
--- a/lib/plugins/acl/admin.php
+++ b/lib/plugins/acl/admin.php
@@ -84,7 +84,7 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
$this->who = '@'.ltrim($auth->cleanGroup($who),'@');
}elseif($_REQUEST['acl_t'] == '__u__' && $who){
$this->who = ltrim($who,'@');
- if($this->who != '%USER%'){ #keep wildcard as is
+ if($this->who != '%USER%' && $this->who != '%GROUP%'){ #keep wildcard as is
$this->who = $auth->cleanUser($this->who);
}
}elseif($_REQUEST['acl_t'] &&
@@ -140,7 +140,7 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
if ($who!='@ALL') {
$who = '@'.ltrim($auth->cleanGroup($who),'@');
}
- } elseif ($who != '%USER%'){ #keep wildcard as is
+ } elseif ($who != '%USER%' && $who != '%GROUP%'){ #keep wildcard as is
$who = $auth->cleanUser($who);
}
$who = auth_nameencode($who,true);
diff --git a/lib/tpl/dokuwiki/css/design.css b/lib/tpl/dokuwiki/css/design.css
index 059decf49..4f18b79e8 100644
--- a/lib/tpl/dokuwiki/css/design.css
+++ b/lib/tpl/dokuwiki/css/design.css
@@ -95,13 +95,11 @@
text-overflow: ellipsis;
}
-#dokuwiki__usertools a.action,
-#dokuwiki__sitetools a.action {
+#dokuwiki__usertools a.action {
padding-left: 20px;
- background: transparent url(images/sitetools.png) no-repeat 0 0;
+ background: transparent url(images/usertools.png) no-repeat 0 0;
}
-[dir=rtl] #dokuwiki__usertools a.action,
-[dir=rtl] #dokuwiki__sitetools a.action {
+[dir=rtl] #dokuwiki__usertools a.action {
padding-left: 0;
padding-right: 20px;
}
@@ -133,34 +131,34 @@
}
#dokuwiki__usertools a.action.admin {
- background-position: left -96px;
+ background-position: left 0;
}
[dir=rtl] #dokuwiki__usertools a.action.admin {
- background-position: right -96px;
+ background-position: right 0;
}
#dokuwiki__usertools a.action.profile {
- background-position: left -128px;
+ background-position: left -32px;
}
[dir=rtl] #dokuwiki__usertools a.action.profile {
- background-position: right -128px;
+ background-position: right -32px;
}
#dokuwiki__usertools a.action.register {
- background-position: left -160px;
+ background-position: left -64px;
}
[dir=rtl] #dokuwiki__usertools a.action.register {
- background-position: right -160px;
+ background-position: right -64px;
}
#dokuwiki__usertools a.action.login {
- background-position: left -192px;
+ background-position: left -96px;
}
[dir=rtl] #dokuwiki__usertools a.action.login {
- background-position: right -192px;
+ background-position: right -96px;
}
#dokuwiki__usertools a.action.logout {
- background-position: left -224px;
+ background-position: left -128px;
}
[dir=rtl] #dokuwiki__usertools a.action.logout {
- background-position: right -224px;
+ background-position: right -128px;
}
@@ -207,25 +205,6 @@
#dokuwiki__sitetools li {
}
-#dokuwiki__sitetools a.action.recent {
- background-position: left 0;
-}
-[dir=rtl] #dokuwiki__sitetools a.action.recent {
- background-position: right 0;
-}
-#dokuwiki__sitetools a.action.media {
- background-position: left -32px;
-}
-[dir=rtl] #dokuwiki__sitetools a.action.media {
- background-position: right -32px;
-}
-#dokuwiki__sitetools a.action.index {
- background-position: left -64px;
-}
-[dir=rtl] #dokuwiki__sitetools a.action.index {
- background-position: right -64px;
-}
-
/*____________ breadcrumbs ____________*/
.dokuwiki div.breadcrumbs {
diff --git a/lib/tpl/dokuwiki/images/sitetools.png b/lib/tpl/dokuwiki/images/sitetools.png
deleted file mode 100644
index dc5764647..000000000
--- a/lib/tpl/dokuwiki/images/sitetools.png
+++ /dev/null
Binary files differ
diff --git a/lib/tpl/dokuwiki/images/usertools.png b/lib/tpl/dokuwiki/images/usertools.png
new file mode 100644
index 000000000..e99b6596e
--- /dev/null
+++ b/lib/tpl/dokuwiki/images/usertools.png
Binary files differ
diff --git a/lib/tpl/dokuwiki/tpl_header.php b/lib/tpl/dokuwiki/tpl_header.php
index 1d2517ee1..f2e720308 100644
--- a/lib/tpl/dokuwiki/tpl_header.php
+++ b/lib/tpl/dokuwiki/tpl_header.php
@@ -1,7 +1,6 @@
<!-- ********** HEADER ********** -->
<div id="dokuwiki__header"><div class="pad group">
- <?php html_msgarea() ?>
<?php tpl_includeFile('header.html') ?>
<div class="headings group">
@@ -77,5 +76,7 @@
</div>
<?php endif ?>
+ <?php html_msgarea() ?>
+
<hr class="a11y" />
</div></div><!-- /header -->