You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

errorHandler.php 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * ownCloud
  4. *
  5. * @author Bjoern Schiessle
  6. * @copyright 2014 Bjoern Schiessle <schiessle@owncloud.com>
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. class Test_ErrorHandler extends \Test\TestCase {
  23. /**
  24. * provide username, password combinations for testRemovePassword
  25. * @return array
  26. */
  27. function passwordProvider() {
  28. return array(
  29. array('user', 'password'),
  30. array('user@owncloud.org', 'password'),
  31. array('user', 'pass@word'),
  32. array('us:er', 'password'),
  33. array('user', 'pass:word'),
  34. );
  35. }
  36. /**
  37. * @dataProvider passwordProvider
  38. * @param string $username
  39. * @param string $password
  40. */
  41. function testRemovePassword($username, $password) {
  42. $url = 'http://'.$username.':'.$password.'@owncloud.org';
  43. $expectedResult = 'http://xxx:xxx@owncloud.org';
  44. $result = TestableErrorHandler::testRemovePassword($url);
  45. $this->assertEquals($expectedResult, $result);
  46. }
  47. }
  48. /**
  49. * dummy class to access protected methods of \OC\Log\ErrorHandler
  50. */
  51. class TestableErrorHandler extends \OC\Log\ErrorHandler {
  52. /**
  53. * @param string $msg
  54. */
  55. public static function testRemovePassword($msg) {
  56. return self::removePassword($msg);
  57. }
  58. }