Skip to content

Commit aebf574

Browse files
committed
Remove tests that just prove mocked calls and don't actually validate anything useful
Signed-off-by: Julius Härtl <jus@bitgrid.net>
1 parent 0ab2383 commit aebf574

File tree

1 file changed

+0
-91
lines changed

1 file changed

+0
-91
lines changed

tests/lib/Security/CredentialsManagerTest.php

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -21,102 +21,11 @@
2121

2222
namespace Test\Security;
2323

24-
use OC\DB\ConnectionAdapter;
25-
use OC\Security\CredentialsManager;
26-
use OC\SystemConfig;
27-
use OCP\IDBConnection;
28-
use OCP\ILogger;
29-
use OCP\Security\ICrypto;
30-
3124
/**
3225
* @group DB
3326
*/
3427
class CredentialsManagerTest extends \Test\TestCase {
3528

36-
/** @var ICrypto */
37-
protected $crypto;
38-
39-
/** @var IDBConnection */
40-
protected $dbConnection;
41-
42-
/** @var ConnectionAdapter */
43-
protected $dbConnectionAdapter;
44-
45-
/** @var CredentialsManager */
46-
protected $manager;
47-
48-
protected function setUp(): void {
49-
parent::setUp();
50-
$this->crypto = $this->createMock(ICrypto::class);
51-
$this->dbConnection = $this->getMockBuilder(IDBConnection::class)
52-
->disableOriginalConstructor()
53-
->getMock();
54-
$this->dbConnectionAdapter = $this->getMockBuilder(ConnectionAdapter::class)
55-
->disableOriginalConstructor()
56-
->getMock();
57-
$this->manager = new CredentialsManager($this->crypto, $this->dbConnection);
58-
}
59-
60-
private function getQueryResult($row) {
61-
$result = $this->getMockBuilder('\Doctrine\DBAL\Driver\Statement')
62-
->disableOriginalConstructor()
63-
->getMock();
64-
65-
$result->expects($this->any())
66-
->method('fetch')
67-
->willReturn($row);
68-
69-
return $result;
70-
}
71-
72-
public function testStore() {
73-
$userId = 'abc';
74-
$identifier = 'foo';
75-
$credentials = 'bar';
76-
77-
$this->crypto->expects($this->once())
78-
->method('encrypt')
79-
->with(json_encode($credentials))
80-
->willReturn('baz');
81-
82-
$this->dbConnection->expects($this->once())
83-
->method('setValues')
84-
->with(CredentialsManager::DB_TABLE,
85-
['user' => $userId, 'identifier' => $identifier],
86-
['credentials' => 'baz']
87-
);
88-
89-
$this->manager->store($userId, $identifier, $credentials);
90-
}
91-
92-
public function testRetrieve() {
93-
$userId = 'abc';
94-
$identifier = 'foo';
95-
96-
$this->crypto->expects($this->once())
97-
->method('decrypt')
98-
->with('baz')
99-
->willReturn(json_encode('bar'));
100-
101-
$qb = $this->getMockBuilder(\OC\DB\QueryBuilder\QueryBuilder::class)
102-
->setConstructorArgs([
103-
$this->dbConnectionAdapter,
104-
$this->createMock(SystemConfig::class),
105-
$this->createMock(ILogger::class),
106-
])
107-
->setMethods(['execute'])
108-
->getMock();
109-
$qb->expects($this->once())
110-
->method('execute')
111-
->willReturn($this->getQueryResult(['credentials' => 'baz']));
112-
113-
$this->dbConnectionAdapter->expects($this->once())
114-
->method('getQueryBuilder')
115-
->willReturn($qb);
116-
117-
$this->manager->retrieve($userId, $identifier);
118-
}
119-
12029
/**
12130
* @dataProvider credentialsProvider
12231
*/

0 commit comments

Comments
 (0)