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.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. ['us:er', 'pass@word'],
  31. ['us:er', 'password'],
  32. ['user', '-C:R,w)@6*}'],
  33. ['user', 'pass:word'],
  34. ['user', 'pass@word'],
  35. ['user', 'password'],
  36. ['user:test@cloud', 'password'],
  37. ['user@owncloud.org', 'password'],
  38. ['user@test@owncloud.org', 'password'],
  39. ];
  40. }
  41. /**
  42. * @dataProvider passwordProvider
  43. * @param string $username
  44. * @param string $password
  45. */
  46. public function testRemovePassword($username, $password) {
  47. $url = 'http://'.$username.':'.$password.'@owncloud.org';
  48. $expectedResult = 'http://xxx:xxx@owncloud.org';
  49. $result = TestableErrorHandler::testRemovePassword($url);
  50. $this->assertEquals($expectedResult, $result);
  51. }
  52. }
  53. /**
  54. * dummy class to access protected methods of \OC\Log\ErrorHandler
  55. */
  56. class TestableErrorHandler extends \OC\Log\ErrorHandler {
  57. /**
  58. * @param string $msg
  59. */
  60. public static function testRemovePassword($msg) {
  61. return self::removePassword($msg);
  62. }
  63. }