Skip to content

Commit

Permalink
remove superfluous tests
Browse files Browse the repository at this point in the history
- user_ldap is not exposed to public api, it is always behind ldap_proxy
- this is too much for a unit test
- integration tests cover userExists implicitly

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
  • Loading branch information
blizzz committed Dec 5, 2019
1 parent 51ea660 commit d3fd735
Showing 1 changed file with 0 additions and 58 deletions.
58 changes: 0 additions & 58 deletions apps/user_ldap/tests/User_LDAPTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,64 +586,6 @@ public function testUserExistsPublicAPI() {
$this->assertTrue($result);
}

public function testUserExistsPublicAPIForDeleted() {
$backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
$this->prepareMockForUserExists();
\OC_User::useBackend($backend);

$mapper = $this->createMock(UserMapping::class);
$mapper->expects($this->any())
->method('getUUIDByDN')
->with('dnOfFormerUser,dc=test')
->willReturn('45673458748');

$this->access->expects($this->any())
->method('readAttribute')
->will($this->returnCallback(function($dn) {
if($dn === 'dnOfRoland,dc=test') {
return array();
}
return false;
}));
$this->access->expects($this->any())
->method('getUserMapper')
->willReturn($mapper);
$this->access->expects($this->once())
->method('getUserDnByUuid')
->willThrowException(new \Exception());

$user = $this->createMock(User::class);
$user->expects($this->any())
->method('getDN')
->willReturn('dnOfFormerUser,dc=test');

$this->userManager->expects($this->atLeastOnce())
->method('get')
->willReturn($user);

//test for deleted user – always returns true as long as we have the user in DB
$this->assertTrue(\OC::$server->getUserManager()->userExists('formerUser'));
}

public function testUserExistsPublicAPIForNeverExisting() {
$backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
$this->prepareMockForUserExists();
\OC_User::useBackend($backend);

$this->access->expects($this->any())
->method('readAttribute')
->will($this->returnCallback(function($dn) {
if($dn === 'dnOfRoland,dc=test') {
return array();
}
return false;
}));

//test for never-existing user
$result = \OC::$server->getUserManager()->userExists('mallory');
$this->assertFalse($result);
}

public function testDeleteUserExisting() {
$backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);

Expand Down

0 comments on commit d3fd735

Please sign in to comment.