|
9 | 9 |
|
10 | 10 | namespace Tests\Core\Sharing\Property; |
11 | 11 |
|
| 12 | +use OC\Core\AppInfo\Application; |
| 13 | +use OC\Core\AppInfo\ConfigLexicon; |
12 | 14 | use OC\Core\Sharing\Property\PasswordSharePropertyType; |
| 15 | +use OCP\IAppConfig; |
13 | 16 | use OCP\IUser; |
14 | 17 | use OCP\IUserManager; |
| 18 | +use OCP\L10N\IFactory; |
15 | 19 | use OCP\Security\IHasher; |
16 | 20 | use OCP\Server; |
17 | 21 | use OCP\Sharing\Property\ShareProperty; |
@@ -64,6 +68,23 @@ private function createDummyShare(?ShareProperty $property): Share { |
64 | 68 | ); |
65 | 69 | } |
66 | 70 |
|
| 71 | + public function testGetDefaultValue(): void { |
| 72 | + $appConfig = Server::get(IAppConfig::class); |
| 73 | + $appConfig->deleteKey(Application::APP_ID, ConfigLexicon::SHARE_LINK_PASSWORD_ENFORCED); |
| 74 | + |
| 75 | + $this->assertNull($this->propertyType->getDefaultValue()); |
| 76 | + |
| 77 | + $appConfig->setValueBool(Application::APP_ID, ConfigLexicon::SHARE_LINK_PASSWORD_ENFORCED, true); |
| 78 | + |
| 79 | + $value = $this->propertyType->getDefaultValue(); |
| 80 | + $this->assertNotNull($value); |
| 81 | + /** @psalm-suppress RedundantCastGivenDocblockType psalm:strict and rector:strict fight over the cast -_- */ |
| 82 | + $this->assertGreaterThan(1, strlen((string)$value)); |
| 83 | + $this->assertTrue($this->propertyType->validateValue(Server::get(IFactory::class), $value)); |
| 84 | + |
| 85 | + $appConfig->deleteKey(Application::APP_ID, ConfigLexicon::SHARE_LINK_PASSWORD_ENFORCED); |
| 86 | + } |
| 87 | + |
67 | 88 | public function testIsFiltered(): void { |
68 | 89 | $this->assertFalse($this->propertyType->isFiltered(new ShareAccessContext(arguments: [$this->propertyType::class => '123']), $this->createDummyShare(new ShareProperty($this->propertyType::class, Server::get(IHasher::class)->hash('123'))))); |
69 | 90 | $this->assertFalse($this->propertyType->isFiltered(new ShareAccessContext(arguments: [$this->propertyType::class => '123']), $this->createDummyShare(new ShareProperty($this->propertyType::class, null)))); |
|
0 commit comments