summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2018-11-02 14:54:46 +0100
committerGitHub <noreply@github.com>2018-11-02 14:54:46 +0100
commit30a1237f8115683fc375395d842f3f4fc555b1e0 (patch)
tree5ed2518c0d581fa565b6f286bc2350a69e614891 /tests
parent337cd251872371f064968cdd8731929124ac4fb3 (diff)
parentf57b07e2c2c6a2ff7cc027eeeeab6ab8da123ad5 (diff)
downloadnextcloud-server-30a1237f8115683fc375395d842f3f4fc555b1e0.tar.gz
nextcloud-server-30a1237f8115683fc375395d842f3f4fc555b1e0.zip
Merge pull request #11875 from nextcloud/add-support-for-sending-the-password-for-a-link-share-by-nextcloud-talk
Add support for sending the password for a link share by Nextcloud Talk
Diffstat (limited to 'tests')
-rw-r--r--tests/acceptance/features/app-files.feature4
-rw-r--r--tests/acceptance/features/bootstrap/FilesAppContext.php93
-rw-r--r--tests/lib/Share20/DefaultShareProviderTest.php61
3 files changed, 156 insertions, 2 deletions
diff --git a/tests/acceptance/features/app-files.feature b/tests/acceptance/features/app-files.feature
index 70e085ca665..33bed4a3ef2 100644
--- a/tests/acceptance/features/app-files.feature
+++ b/tests/acceptance/features/app-files.feature
@@ -218,6 +218,10 @@ Feature: app-files
When I protect the shared link with the password "abcdef"
Then I see that the working icon for password protect is shown
And I see that the working icon for password protect is eventually not shown
+ And I see that the link share is password protected
+ # As Talk is not enabled in the acceptance tests of the server the checkbox
+ # is never shown.
+ And I see that the checkbox to protect the password of the link share by Talk is not shown
Scenario: access a shared link protected by password with a valid password
Given I act as John
diff --git a/tests/acceptance/features/bootstrap/FilesAppContext.php b/tests/acceptance/features/bootstrap/FilesAppContext.php
index 459028813b5..4a7af441e57 100644
--- a/tests/acceptance/features/bootstrap/FilesAppContext.php
+++ b/tests/acceptance/features/bootstrap/FilesAppContext.php
@@ -279,6 +279,15 @@ class FilesAppContext implements Context, ActorAwareInterface {
/**
* @return Locator
*/
+ public static function passwordProtectCheckboxInput() {
+ return Locator::forThe()->checkbox("Password protect")->
+ descendantOf(self::shareLinkMenu())->
+ describedAs("Password protect checkbox input in the details view in Files app");
+ }
+
+ /**
+ * @return Locator
+ */
public static function passwordProtectField() {
return Locator::forThe()->css(".linkPassText")->descendantOf(self::shareLinkMenu())->
describedAs("Password protect field in the details view in Files app");
@@ -293,6 +302,27 @@ class FilesAppContext implements Context, ActorAwareInterface {
}
/**
+ * @return Locator
+ */
+ public static function passwordProtectByTalkCheckbox() {
+ // forThe()->checkbox("Password protect by Talk") can not be used here;
+ // that would return the checkbox itself, but the element that the user
+ // interacts with is the label.
+ return Locator::forThe()->xpath("//label[normalize-space() = 'Password protect by Talk']")->
+ descendantOf(self::shareLinkMenu())->
+ describedAs("Password protect by Talk checkbox in the details view in Files app");
+ }
+
+ /**
+ * @return Locator
+ */
+ public static function passwordProtectByTalkCheckboxInput() {
+ return Locator::forThe()->checkbox("Password protect by Talk")->
+ descendantOf(self::shareLinkMenu())->
+ describedAs("Password protect by Talk checkbox input in the details view in Files app");
+ }
+
+ /**
* @Given I close the details view
*/
public function iCloseTheDetailsView() {
@@ -395,6 +425,28 @@ class FilesAppContext implements Context, ActorAwareInterface {
}
/**
+ * @When I set the password of the shared link as protected by Talk
+ */
+ public function iSetThePasswordOfTheSharedLinkAsProtectedByTalk() {
+ $this->showShareLinkMenuIfNeeded();
+
+ $this->iSeeThatThePasswordOfTheLinkShareIsNotProtectedByTalk();
+
+ $this->actor->find(self::passwordProtectByTalkCheckbox(), 2)->click();
+ }
+
+ /**
+ * @When I set the password of the shared link as not protected by Talk
+ */
+ public function iSetThePasswordOfTheSharedLinkAsNotProtectedByTalk() {
+ $this->showShareLinkMenuIfNeeded();
+
+ $this->iSeeThatThePasswordOfTheLinkShareIsProtectedByTalk();
+
+ $this->actor->find(self::passwordProtectByTalkCheckbox(), 2)->click();
+ }
+
+ /**
* @Then I see that the current page is the Files app
*/
public function iSeeThatTheCurrentPageIsTheFilesApp() {
@@ -538,6 +590,47 @@ class FilesAppContext implements Context, ActorAwareInterface {
}
/**
+ * @Then I see that the link share is password protected
+ */
+ public function iSeeThatTheLinkShareIsPasswordProtected() {
+ $this->showShareLinkMenuIfNeeded();
+
+ PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::passwordProtectCheckboxInput(), 10)->isChecked(), "Password protect checkbox is checked");
+ PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::passwordProtectField(), 10)->isVisible(), "Password protect field is visible");
+ }
+
+ /**
+ * @Then I see that the password of the link share is protected by Talk
+ */
+ public function iSeeThatThePasswordOfTheLinkShareIsProtectedByTalk() {
+ $this->showShareLinkMenuIfNeeded();
+
+ PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::passwordProtectByTalkCheckboxInput(), 10)->isChecked());
+ }
+
+ /**
+ * @Then I see that the password of the link share is not protected by Talk
+ */
+ public function iSeeThatThePasswordOfTheLinkShareIsNotProtectedByTalk() {
+ $this->showShareLinkMenuIfNeeded();
+
+ PHPUnit_Framework_Assert::assertFalse($this->actor->find(self::passwordProtectByTalkCheckboxInput(), 10)->isChecked());
+ }
+
+ /**
+ * @Then I see that the checkbox to protect the password of the link share by Talk is not shown
+ */
+ public function iSeeThatTheCheckboxToProtectThePasswordOfTheLinkShareByTalkIsNotShown() {
+ $this->showShareLinkMenuIfNeeded();
+
+ try {
+ PHPUnit_Framework_Assert::assertFalse(
+ $this->actor->find(self::passwordProtectByTalkCheckbox())->isVisible());
+ } catch (NoSuchElementException $exception) {
+ }
+ }
+
+ /**
* @Given I share the link for :fileName protected by the password :password
*/
public function iShareTheLinkForProtectedByThePassword($fileName, $password) {
diff --git a/tests/lib/Share20/DefaultShareProviderTest.php b/tests/lib/Share20/DefaultShareProviderTest.php
index 19f37160627..578225840b6 100644
--- a/tests/lib/Share20/DefaultShareProviderTest.php
+++ b/tests/lib/Share20/DefaultShareProviderTest.php
@@ -363,6 +363,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
->values([
'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK),
'password' => $qb->expr()->literal('password'),
+ 'password_by_talk' => $qb->expr()->literal(true),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
'item_type' => $qb->expr()->literal('file'),
@@ -392,6 +393,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals(\OCP\Share::SHARE_TYPE_LINK, $share->getShareType());
$this->assertNull($share->getSharedWith());
$this->assertEquals('password', $share->getPassword());
+ $this->assertEquals(true, $share->getSendPasswordByTalk());
$this->assertEquals('sharedBy', $share->getSharedBy());
$this->assertEquals('shareOwner', $share->getShareOwner());
$this->assertEquals($ownerPath, $share->getNode());
@@ -775,6 +777,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share->setNode($path);
$share->setPermissions(1);
$share->setPassword('password');
+ $share->setSendPasswordByTalk(true);
$share->setToken('token');
$expireDate = new \DateTime();
$share->setExpirationDate($expireDate);
@@ -792,6 +795,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertLessThanOrEqual(new \DateTime(), $share2->getShareTime());
$this->assertSame($path, $share2->getNode());
$this->assertSame('password', $share2->getPassword());
+ $this->assertSame(true, $share2->getSendPasswordByTalk());
$this->assertSame('token', $share2->getToken());
$this->assertEquals($expireDate->getTimestamp(), $share2->getExpirationDate()->getTimestamp());
}
@@ -803,6 +807,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
->values([
'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK),
'password' => $qb->expr()->literal('password'),
+ 'password_by_talk' => $qb->expr()->literal(true),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
'item_type' => $qb->expr()->literal('file'),
@@ -825,6 +830,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertSame('sharedBy', $share->getSharedBy());
$this->assertSame('secrettoken', $share->getToken());
$this->assertSame('password', $share->getPassword());
+ $this->assertSame(true, $share->getSendPasswordByTalk());
$this->assertSame(null, $share->getSharedWith());
}
@@ -1788,6 +1794,14 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertSame('user4', $share2->getSharedBy());
$this->assertSame('user5', $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());
+
+ $share2 = $this->provider->getShareById($id);
+
+ $this->assertEquals($id, $share2->getId());
+ $this->assertSame('user3', $share2->getSharedWith());
+ $this->assertSame('user4', $share2->getSharedBy());
+ $this->assertSame('user5', $share2->getShareOwner());
+ $this->assertSame(1, $share2->getPermissions());
}
public function testUpdateLink() {
@@ -1825,6 +1839,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = $this->provider->getShareById($id);
$share->setPassword('password');
+ $share->setSendPasswordByTalk(true);
$share->setSharedBy('user4');
$share->setShareOwner('user5');
$share->setNode($file2);
@@ -1833,7 +1848,17 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share2 = $this->provider->update($share);
$this->assertEquals($id, $share2->getId());
- $this->assertEquals('password', $share->getPassword());
+ $this->assertEquals('password', $share2->getPassword());
+ $this->assertSame(true, $share2->getSendPasswordByTalk());
+ $this->assertSame('user4', $share2->getSharedBy());
+ $this->assertSame('user5', $share2->getShareOwner());
+ $this->assertSame(1, $share2->getPermissions());
+
+ $share2 = $this->provider->getShareById($id);
+
+ $this->assertEquals($id, $share2->getId());
+ $this->assertEquals('password', $share2->getPassword());
+ $this->assertSame(true, $share2->getSendPasswordByTalk());
$this->assertSame('user4', $share2->getSharedBy());
$this->assertSame('user5', $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());
@@ -1843,6 +1868,12 @@ class DefaultShareProviderTest extends \Test\TestCase {
$id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_LINK, 'foo', 'user1', 'user2',
'file', 42, 'target', 31, null, null);
+ $qb = $this->dbConn->getQueryBuilder();
+ $qb->update('share');
+ $qb->where($qb->expr()->eq('id', $qb->createNamedParameter($id)));
+ $qb->set('password', $qb->createNamedParameter('password'));
+ $this->assertEquals(1, $qb->execute());
+
$users = [];
for($i = 0; $i < 6; $i++) {
$user = $this->createMock(IUser::class);
@@ -1882,7 +1913,15 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share2 = $this->provider->update($share);
$this->assertEquals($id, $share2->getId());
- $this->assertEquals(null, $share->getPassword());
+ $this->assertEquals(null, $share2->getPassword());
+ $this->assertSame('user4', $share2->getSharedBy());
+ $this->assertSame('user5', $share2->getShareOwner());
+ $this->assertSame(1, $share2->getPermissions());
+
+ $share2 = $this->provider->getShareById($id);
+
+ $this->assertEquals($id, $share2->getId());
+ $this->assertEquals(null, $share2->getPassword());
$this->assertSame('user4', $share2->getSharedBy());
$this->assertSame('user5', $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());
@@ -1949,6 +1988,15 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertSame('user4', $share2->getSharedBy());
$this->assertSame('user5', $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());
+
+ $share2 = $this->provider->getShareById($id);
+
+ $this->assertEquals($id, $share2->getId());
+ // Group shares do not allow updating the recipient
+ $this->assertSame('group0', $share2->getSharedWith());
+ $this->assertSame('user4', $share2->getSharedBy());
+ $this->assertSame('user5', $share2->getShareOwner());
+ $this->assertSame(1, $share2->getPermissions());
}
public function testUpdateGroupSubShares() {
@@ -2019,6 +2067,15 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertSame('user5', $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());
+ $share2 = $this->provider->getShareById($id);
+
+ $this->assertEquals($id, $share2->getId());
+ // Group shares do not allow updating the recipient
+ $this->assertSame('group0', $share2->getSharedWith());
+ $this->assertSame('user4', $share2->getSharedBy());
+ $this->assertSame('user5', $share2->getShareOwner());
+ $this->assertSame(1, $share2->getPermissions());
+
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->select('*')
->from('share')