Skip to content

Commit

Permalink
dont set default expire date to public link, when expire date not enf…
Browse files Browse the repository at this point in the history
…orced
  • Loading branch information
karakayasemi committed Apr 3, 2019
1 parent b22bf45 commit df6795c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 23 deletions.
14 changes: 0 additions & 14 deletions lib/private/Share20/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,20 +329,6 @@ protected function validateExpirationDate(\OCP\Share\IShare $share) {
}
}

// If expiredate is empty set a default one if there is a default
$fullId = null;
try {
$fullId = $share->getFullId();
} catch (\UnexpectedValueException $e) {
// This is a new share
}

if ($fullId === null && $expirationDate === null && $this->shareApiLinkDefaultExpireDate()) {
$expirationDate = new \DateTime();
$expirationDate->setTime(0, 0, 0);
$expirationDate->add(new \DateInterval('P'.$this->shareApiLinkDefaultExpireDays().'D'));
}

// If we enforce the expiration date check that is does not exceed
if ($this->shareApiLinkDefaultExpireDateEnforced()) {
if ($expirationDate === null) {
Expand Down
14 changes: 5 additions & 9 deletions tests/lib/Share20/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -939,24 +939,19 @@ public function testvalidateExpirationDateEnforceButNotEnabledAndNotSet() {
$this->assertNull($share->getExpirationDate());
}

/**
* @expectedException \InvalidArgumentException
*/
public function testvalidateExpirationDateEnforceButNotSetNewShare() {
$share = $this->manager->newShare();

$this->config->method('getAppValue')
->will($this->returnValueMap([
['core', 'shareapi_enforce_expire_date', 'no', 'yes'],
['core', 'shareapi_expire_after_n_days', '7', '3'],
['core', 'shareapi_default_expire_date', 'no', 'yes'],
['core', 'shareapi_enforce_expire_date', 'no', 'yes'],
]));

$expected = new \DateTime();
$expected->setTime(0, 0, 0);
$expected->add(new \DateInterval('P3D'));

$this->invokePrivate($this->manager, 'validateExpirationDate', [$share]);

$this->assertNotNull($share->getExpirationDate());
$this->assertEquals($expected, $share->getExpirationDate());
}

public function testvalidateExpirationDateEnforceToFarIntoFuture() {
Expand All @@ -969,6 +964,7 @@ public function testvalidateExpirationDateEnforceToFarIntoFuture() {

$this->config->method('getAppValue')
->will($this->returnValueMap([
['core', 'shareapi_default_expire_date', 'no', 'yes'],
['core', 'shareapi_enforce_expire_date', 'no', 'yes'],
['core', 'shareapi_expire_after_n_days', '7', '3'],
]));
Expand Down

0 comments on commit df6795c

Please sign in to comment.