summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorKlap-in <klapinklapin@gmail.com>2013-06-09 21:22:12 +0200
committerKlap-in <klapinklapin@gmail.com>2013-06-09 21:22:12 +0200
commit9b6fa49c06b538c53c9cf3e404ade82d6c003f79 (patch)
tree68771b589052382f9e4824bf3a4857f5648fdf3d /_test
parenta38a6f25d7e46f47a8f358bb16c766f5b96dae45 (diff)
parent62765857f84626449d6c53b1a46c462a37e5083a (diff)
downloadrpg-9b6fa49c06b538c53c9cf3e404ade82d6c003f79.tar.gz
rpg-9b6fa49c06b538c53c9cf3e404ade82d6c003f79.tar.bz2
Merge remote-tracking branch 'origin/master' into fetchimagetokexternal
Diffstat (limited to '_test')
-rw-r--r--_test/tests/inc/PassHash.test.php22
-rw-r--r--_test/tests/inc/common_ml.test.php53
-rw-r--r--_test/tests/inc/pageutils_clean_id.test.php4
3 files changed, 71 insertions, 8 deletions
diff --git a/_test/tests/inc/PassHash.test.php b/_test/tests/inc/PassHash.test.php
new file mode 100644
index 000000000..b6cb07090
--- /dev/null
+++ b/_test/tests/inc/PassHash.test.php
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * Class PassHash_test
+ *
+ * most tests are in auth_password.test.php
+ */
+class PassHash_test extends PHPUnit_Framework_TestCase {
+
+ function test_hmac(){
+ // known hashes taken from https://code.google.com/p/yii/issues/detail?id=1942
+ $this->assertEquals('df08aef118f36b32e29d2f47cda649b6', PassHash::hmac('md5','data','secret'));
+ $this->assertEquals('9818e3306ba5ac267b5f2679fe4abd37e6cd7b54', PassHash::hmac('sha1','data','secret'));
+
+ // known hashes from https://en.wikipedia.org/wiki/Hash-based_message_authentication_code
+ $this->assertEquals('74e6f7298a9c2d168935f58c001bad88', PassHash::hmac('md5','',''));
+ $this->assertEquals('fbdb1d1b18aa6c08324b7d64b71fb76370690e1d', PassHash::hmac('sha1','',''));
+ $this->assertEquals('80070713463e7749b90c2dc24911e275', PassHash::hmac('md5','The quick brown fox jumps over the lazy dog','key'));
+ $this->assertEquals('de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9', PassHash::hmac('sha1','The quick brown fox jumps over the lazy dog','key'));
+
+ }
+} \ No newline at end of file
diff --git a/_test/tests/inc/common_ml.test.php b/_test/tests/inc/common_ml.test.php
index 0abfde37a..6f3b71db4 100644
--- a/_test/tests/inc/common_ml.test.php
+++ b/_test/tests/inc/common_ml.test.php
@@ -20,8 +20,8 @@ class common_ml_test extends DokuWikiTest {
$args = array('a' => 'b', 'c' => 'd', 'q' => '&ä');
- $expect = DOKU_BASE . $this->script . '?a=b&amp;c=d&amp;q=%26%C3%A4&amp;media=some:';
- $this->assertEquals($expect, ml('some:', $args));
+ $expect = DOKU_BASE . $this->script . '?a=b&amp;c=d&amp;q=%26%C3%A4&amp;media=some:img.jpg';
+ $this->assertEquals($expect, ml('some:img.jpg', $args));
}
function test_ml_args_string() {
@@ -31,8 +31,8 @@ class common_ml_test extends DokuWikiTest {
$args = 'a=b&c=d';
- $expect = DOKU_BASE . $this->script . '?a=b&c=d&amp;media=some:';
- $this->assertEquals($expect, ml('some:', $args));
+ $expect = DOKU_BASE . $this->script . '?a=b&c=d&amp;media=some:img.png';
+ $this->assertEquals($expect, ml('some:img.png', $args));
}
function test_ml_args_comma_string() {
@@ -42,8 +42,8 @@ class common_ml_test extends DokuWikiTest {
$args = 'a=b,c=d';
- $expect = DOKU_BASE . $this->script . '?a=b&amp;c=d&amp;media=some:';
- $this->assertEquals($expect, ml('some:', $args));
+ $expect = DOKU_BASE . $this->script . '?a=b&amp;c=d&amp;media=some:img.gif';
+ $this->assertEquals($expect, ml('some:img.gif', $args));
}
@@ -52,7 +52,7 @@ class common_ml_test extends DokuWikiTest {
$conf['useslash'] = 0;
$conf['userewrite'] = 0;
- $id = 'some:';
+ $id = 'some:img.png';
$w = 80;
$args = array('w' => $w);
$tok = media_get_token($id,$w,0);
@@ -66,7 +66,7 @@ class common_ml_test extends DokuWikiTest {
$conf['useslash'] = 0;
$conf['userewrite'] = 0;
- $id = 'some:';
+ $id = 'some:img.png';
$w = 80;
$args = 'w='.$w;
$tok = media_get_token($id,$w,0);
@@ -74,4 +74,41 @@ class common_ml_test extends DokuWikiTest {
$expect = DOKU_BASE . $this->script . '?w='.$w.'&amp;tok='.$tok.'&amp;media='.$id;
$this->assertEquals($expect, ml($id, $args));
}
+
+ function test_ml_imgresize_array_rootid() {
+ global $conf;
+ $conf['useslash'] = 0;
+ $conf['userewrite'] = 0;
+
+ $id = ':wiki:dokuwiki-128.png';
+ $cleanid = 'wiki:dokuwiki-128.png';
+ $w = 80;
+ $args = array('w' => $w);
+ $tok = media_get_token($cleanid, $w, 0);
+
+ $expect = DOKU_BASE.$this->script.'?w='.$w.'&amp;tok='.$tok.'&amp;media='.$cleanid;
+ $this->assertEquals($expect, ml($id, $args));
+ }
+
+ function test_ml_imgresize_array_external() {
+ global $conf;
+ $conf['useslash'] = 0;
+ $conf['userewrite'] = 0;
+
+ $ids = array(
+ 'https://example.com/lib/tpl/dokuwiki/images/logo.png',
+ 'http://example.com/lib/tpl/dokuwiki/images/logo.png',
+ 'ftp://example.com/lib/tpl/dokuwiki/images/logo.png'
+ );
+ $w = 80;
+ $args = array('w' => $w);
+
+ foreach($ids as $id) {
+ $tok = media_get_token($id, $w, 0);
+ $hash = substr(PassHash::hmac('md5', $id, auth_cookiesalt()), 0, 6);
+
+ $expect = DOKU_BASE.$this->script.'?hash='.$hash.'&amp;w='.$w.'&amp;tok='.$tok.'&amp;media='.rawurlencode($id);
+ $this->assertEquals($expect, ml($id, $args));
+ }
+ }
}
diff --git a/_test/tests/inc/pageutils_clean_id.test.php b/_test/tests/inc/pageutils_clean_id.test.php
index 9c5781b24..478fd2bc4 100644
--- a/_test/tests/inc/pageutils_clean_id.test.php
+++ b/_test/tests/inc/pageutils_clean_id.test.php
@@ -43,6 +43,10 @@ class init_clean_id_test extends DokuWikiTest {
$tests[] = array('ns._#!ns:page','false','ns._ns:page');
$tests[] = array('ns_:page',false,'ns:page');
$tests[] = array('page...page','false','page...page');
+ $tests[] = array(':page',false,'page');
+ $tests[] = array(':ns:page',false,'ns:page');
+ $tests[] = array('page:',false,'page');
+ $tests[] = array('ns:page:',false,'ns:page');
$conf['useslash'] = 0;
$tests[] = array('page/page',false,'page_page');