|
@@ 1509-1554 (lines=46) @@
|
| 1506 |
|
* |
| 1507 |
|
* Test modification of invaid share |
| 1508 |
|
*/ |
| 1509 |
|
public function testSetPasswordInvalidShare() { |
| 1510 |
|
$user = $this->getMockBuilder('\OCP\IUser') |
| 1511 |
|
->disableOriginalConstructor() |
| 1512 |
|
->getMock(); |
| 1513 |
|
$user->method('getUID')->willReturn('user'); |
| 1514 |
|
|
| 1515 |
|
$userSession = $this->getMockBuilder('\OCP\IUserSession') |
| 1516 |
|
->disableOriginalConstructor() |
| 1517 |
|
->getMock(); |
| 1518 |
|
$userSession->method('getUser')->willReturn($user); |
| 1519 |
|
|
| 1520 |
|
|
| 1521 |
|
$ex = $this->getMockBuilder('\OC\DB\QueryBuilder\ExpressionBuilder') |
| 1522 |
|
->disableOriginalConstructor() |
| 1523 |
|
->getMock(); |
| 1524 |
|
$qb = $this->getMockBuilder('\OC\DB\QueryBuilder\QueryBuilder') |
| 1525 |
|
->disableOriginalConstructor() |
| 1526 |
|
->getMock(); |
| 1527 |
|
$qb->method('update')->will($this->returnSelf()); |
| 1528 |
|
$qb->method('set')->will($this->returnSelf()); |
| 1529 |
|
$qb->method('where')->will($this->returnSelf()); |
| 1530 |
|
$qb->method('andWhere')->will($this->returnSelf()); |
| 1531 |
|
$qb->method('select')->will($this->returnSelf()); |
| 1532 |
|
$qb->method('from')->will($this->returnSelf()); |
| 1533 |
|
$qb->method('setParameter')->will($this->returnSelf()); |
| 1534 |
|
$qb->method('expr')->willReturn($ex); |
| 1535 |
|
|
| 1536 |
|
$ret = $this->getMockBuilder('\Doctrine\DBAL\Driver\ResultStatement') |
| 1537 |
|
->disableOriginalConstructor() |
| 1538 |
|
->getMock(); |
| 1539 |
|
$ret->method('fetch')->willReturn([]); |
| 1540 |
|
$qb->method('execute')->willReturn($ret); |
| 1541 |
|
|
| 1542 |
|
|
| 1543 |
|
$connection = $this->getMockBuilder('\OC\DB\Connection') |
| 1544 |
|
->disableOriginalConstructor() |
| 1545 |
|
->getMock(); |
| 1546 |
|
$connection->method('getQueryBuilder')->willReturn($qb); |
| 1547 |
|
|
| 1548 |
|
$config = $this->getMockBuilder('\OCP\IConfig') |
| 1549 |
|
->disableOriginalConstructor() |
| 1550 |
|
->getMock(); |
| 1551 |
|
|
| 1552 |
|
|
| 1553 |
|
\OC\Share\Share::setPassword($userSession, $connection, $config, 1, 'pass'); |
| 1554 |
|
} |
| 1555 |
|
|
| 1556 |
|
/** |
| 1557 |
|
* @expectedException Exception |
|
@@ 1562-1607 (lines=46) @@
|
| 1559 |
|
* |
| 1560 |
|
* Test modification of share of another user |
| 1561 |
|
*/ |
| 1562 |
|
public function testSetPasswordShareOtherUser() { |
| 1563 |
|
$user = $this->getMockBuilder('\OCP\IUser') |
| 1564 |
|
->disableOriginalConstructor() |
| 1565 |
|
->getMock(); |
| 1566 |
|
$user->method('getUID')->willReturn('user'); |
| 1567 |
|
|
| 1568 |
|
$userSession = $this->getMockBuilder('\OCP\IUserSession') |
| 1569 |
|
->disableOriginalConstructor() |
| 1570 |
|
->getMock(); |
| 1571 |
|
$userSession->method('getUser')->willReturn($user); |
| 1572 |
|
|
| 1573 |
|
|
| 1574 |
|
$ex = $this->getMockBuilder('\OC\DB\QueryBuilder\ExpressionBuilder') |
| 1575 |
|
->disableOriginalConstructor() |
| 1576 |
|
->getMock(); |
| 1577 |
|
$qb = $this->getMockBuilder('\OC\DB\QueryBuilder\QueryBuilder') |
| 1578 |
|
->disableOriginalConstructor() |
| 1579 |
|
->getMock(); |
| 1580 |
|
$qb->method('update')->will($this->returnSelf()); |
| 1581 |
|
$qb->method('set')->will($this->returnSelf()); |
| 1582 |
|
$qb->method('where')->will($this->returnSelf()); |
| 1583 |
|
$qb->method('andWhere')->will($this->returnSelf()); |
| 1584 |
|
$qb->method('select')->will($this->returnSelf()); |
| 1585 |
|
$qb->method('from')->will($this->returnSelf()); |
| 1586 |
|
$qb->method('setParameter')->will($this->returnSelf()); |
| 1587 |
|
$qb->method('expr')->willReturn($ex); |
| 1588 |
|
|
| 1589 |
|
$ret = $this->getMockBuilder('\Doctrine\DBAL\Driver\ResultStatement') |
| 1590 |
|
->disableOriginalConstructor() |
| 1591 |
|
->getMock(); |
| 1592 |
|
$ret->method('fetch')->willReturn(['uid_owner' => 'user2']); |
| 1593 |
|
$qb->method('execute')->willReturn($ret); |
| 1594 |
|
|
| 1595 |
|
|
| 1596 |
|
$connection = $this->getMockBuilder('\OC\DB\Connection') |
| 1597 |
|
->disableOriginalConstructor() |
| 1598 |
|
->getMock(); |
| 1599 |
|
$connection->method('getQueryBuilder')->willReturn($qb); |
| 1600 |
|
|
| 1601 |
|
$config = $this->getMockBuilder('\OCP\IConfig') |
| 1602 |
|
->disableOriginalConstructor() |
| 1603 |
|
->getMock(); |
| 1604 |
|
|
| 1605 |
|
|
| 1606 |
|
\OC\Share\Share::setPassword($userSession, $connection, $config, 1, 'pass'); |
| 1607 |
|
} |
| 1608 |
|
|
| 1609 |
|
/** |
| 1610 |
|
* Make sure that a user cannot have multiple identical shares to remote users |