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.

ErrorHandlerTest.php 1.7KB

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. namespace Test;
  23. class ErrorHandlerTest extends \Test\TestCase {
  24. /**
  25. * provide username, password combinations for testRemovePassword
  26. * @return array
  27. */
  28. public function passwordProvider() {
  29. return [
  30. ['user', 'password'],
  31. ['user@owncloud.org', 'password'],
  32. ['user', 'pass@word'],
  33. ['us:er', 'password'],
  34. ['user', 'pass:word'],
  35. ];
  36. }
  37. /**
  38. * @dataProvider passwordProvider
  39. * @param string $username
  40. * @param string $password
  41. */
  42. public function testRemovePassword($username, $password) {
  43. $url = 'http://'.$username.':'.$password.'@owncloud.org';
  44. $expectedResult = 'http://xxx:xxx@owncloud.org';
  45. $result = TestableErrorHandler::testRemovePassword($url);
  46. $this->assertEquals($expectedResult, $result);
  47. }
  48. }
  49. /**
  50. * dummy class to access protected methods of \OC\Log\ErrorHandler
  51. */
  52. class TestableErrorHandler extends \OC\Log\ErrorHandler {
  53. /**
  54. * @param string $msg
  55. */
  56. public static function testRemovePassword($msg) {
  57. return self::removePassword($msg);
  58. }
  59. }