Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-36977 Add more unit tests for moodle1 backup conversion

  • Loading branch information...
commit 02a6f3b04fce67c14e5a753258d4c642a9e52a21 1 parent 5050a19
David Mudrák mudrd8mz authored danpoltawski committed

Showing 1 changed file with 13 additions and 0 deletions. Show diff stats Hide diff stats

  1. +13 0 backup/converter/moodle1/tests/lib_test.php
13 backup/converter/moodle1/tests/lib_test.php
@@ -273,6 +273,15 @@ public function test_migrate_file() {
273 273 $fileids = $fileman->get_fileids();
274 274 $this->assertEquals(gettype($fileids), 'array');
275 275 $this->assertEquals(0, count($fileids));
  276 + // try to migrate an invalid file
  277 + $fileman->itemid = 1;
  278 + $thrown = false;
  279 + try {
  280 + $fileman->migrate_file('/../../../../../../../../../../../../../../etc/passwd');
  281 + } catch (moodle1_convert_exception $e) {
  282 + $thrown = true;
  283 + }
  284 + $this->assertTrue($thrown);
276 285 // migrate a single file
277 286 $fileman->itemid = 4;
278 287 $fileman->migrate_file('moddata/unittest/4/icon.gif');
@@ -435,6 +444,8 @@ public function test_referenced_course_files() {
435 444
436 445 $text = 'This is a text containing links to file.php
437 446 as it is parsed from the backup file. <br /><br /><img border="0" width="110" vspace="0" hspace="0" height="92" title="News" alt="News" src="$@FILEPHP@$$@SLASH@$pics$@SLASH@$news.gif" /><a href="$@FILEPHP@$$@SLASH@$pics$@SLASH@$news.gif$@FORCEDOWNLOAD@$">download image</a><br />
  447 + <div><a href=\'$@FILEPHP@$/../../../../../../../../../../../../../../../etc/passwd\'>download passwords</a></div>
  448 + <div><a href=\'$@FILEPHP@$$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$etc$@SLASH@$shadow\'>download shadows</a></div>
438 449 <br /><a href=\'$@FILEPHP@$$@SLASH@$MANUAL.DOC$@FORCEDOWNLOAD@$\'>download manual</a><br />';
439 450
440 451 $files = moodle1_converter::find_referenced_files($text);
@@ -446,6 +457,8 @@ public function test_referenced_course_files() {
446 457 $text = moodle1_converter::rewrite_filephp_usage($text, array('/pics/news.gif', '/another/file/notused.txt'));
447 458 $this->assertEquals($text, 'This is a text containing links to file.php
448 459 as it is parsed from the backup file. <br /><br /><img border="0" width="110" vspace="0" hspace="0" height="92" title="News" alt="News" src="@@PLUGINFILE@@/pics/news.gif" /><a href="@@PLUGINFILE@@/pics/news.gif?forcedownload=1">download image</a><br />
  460 + <div><a href=\'$@FILEPHP@$/../../../../../../../../../../../../../../../etc/passwd\'>download passwords</a></div>
  461 + <div><a href=\'$@FILEPHP@$$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$etc$@SLASH@$shadow\'>download shadows</a></div>
449 462 <br /><a href=\'$@FILEPHP@$$@SLASH@$MANUAL.DOC$@FORCEDOWNLOAD@$\'>download manual</a><br />');
450 463 }
451 464

0 comments on commit 02a6f3b

Please sign in to comment.
Something went wrong with that request. Please try again.