Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable10] update user-sync help description #31691

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions core/Command/User/SyncBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
use Symfony\Component\Console\Input\InputArgument;

class SyncBackend extends Command {

const VALID_ACTIONS = ['disable', 'remove'];

/** @var AccountMapper */
Expand Down Expand Up @@ -78,31 +77,34 @@ protected function configure() {
->addArgument(
'backend-class',
InputArgument::OPTIONAL,
'The PHP class name - e.g., "OCA\User_LDAP\User_Proxy". Please wrap the class name in double quotes. You can use the option --list to list all known backend classes.'
"The quoted PHP class name for the backend, eg\n"
." - LDAP:\t\t\"OCA\User_LDAP\User_Proxy\"\n"
." - Samba:\t\t\"OCA\User\SMB\"\n"
." - Shibboleth:\t\"OCA\User_Shibboleth\UserBackend\""
)
->addOption(
'list',
'l',
InputOption::VALUE_NONE,
'List all known backend classes'
'List all enabled backend classes'
)
->addOption(
'uid',
'u',
InputOption::VALUE_REQUIRED,
'sync only the user with the given user id'
'Sync only the user with the given user id'
)
->addOption(
'seenOnly',
's',
InputOption::VALUE_NONE,
'sync only seen users'
'Sync only seen users'
)
->addOption(
'showCount',
'c',
InputOption::VALUE_NONE,
'calculate user count before syncing'
'Calculate user count before syncing'
)
->addOption(
'missing-account-action',
Expand Down Expand Up @@ -207,7 +209,7 @@ private function syncMultipleUsers (
}

$output->writeln('');
$backendClass = get_class($backend);
$backendClass = \get_class($backend);
if ($input->getOption('seenOnly')) {
$output->writeln("Updating seen accounts from $backendClass ...");
$iterator = new SeenUsersIterator($this->accountMapper, $backendClass);
Expand Down Expand Up @@ -415,7 +417,5 @@ function ($uid) use ($output) {
}
);
}


}
}
15 changes: 6 additions & 9 deletions tests/lib/Command/User/SyncBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ public function testInvalidAccountActionShowsError() {
$this->assertEquals(1, static::invokePrivate($this->command, 'execute', [$inputInterface, $outputInterface]));
}


public function executeProvider() {
return [
['foo', 'Syncing foo ...'],
Expand Down Expand Up @@ -310,8 +309,8 @@ public function testSingleUserSyncExistingUser() {
$syncService->expects($this
->once())->method('run')->with(
$this->dummyBackend,
$this->callback(function($subject){
return count($subject) === 1 && $subject[0] === 'existing-uid';
$this->callback(function ($subject) {
return \count($subject) === 1 && $subject[0] === 'existing-uid';
}),
$this->anything()
);
Expand Down Expand Up @@ -397,13 +396,13 @@ public function testSyncMultipleUsersExistingUsers() {
$syncService->expects($this
->once())->method('run')->with(
$this->dummyBackend,
$this->callback(function(\Iterator $iterator) use ($uids) {
$this->callback(function (\Iterator $iterator) use ($uids) {
// convert to array so we can test better
$items = [];
foreach ($iterator as $item) {
$items[] = $item;
}
return count(array_diff($items, $uids)) === 0;
return \count(\array_diff($items, $uids)) === 0;
}),
$this->anything()
);
Expand Down Expand Up @@ -437,13 +436,13 @@ public function testSyncMultipleUsersRemovedUsers($action, $method, $isEnabled,
$syncService->expects($this
->once())->method('run')->with(
$this->dummyBackend,
$this->callback(function(\Iterator $iterator) use ($uids) {
$this->callback(function (\Iterator $iterator) use ($uids) {
// convert to array so we can test better
$items = [];
foreach ($iterator as $item) {
$items[] = $item;
}
return count(array_diff($items, $uids)) === 0;
return \count(\array_diff($items, $uids)) === 0;
}),
$this->anything()
);
Expand Down Expand Up @@ -481,6 +480,4 @@ public function testReEnableAction() {
$this->userManager->expects($this->once())->method('get')->willReturn($user);
static::invokePrivate($this->command, 'reEnableUsers', [$reappearedUsers, $nullOutput]);
}


}
25 changes: 12 additions & 13 deletions tests/lib/User/SyncServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,14 @@ public function testAnalyseExistingUsers() {
$s = new SyncService($this->config, $this->logger, $this->mapper);
$this->mapper->expects($this->once())
->method('callForAllUsers')
->with($this->callback(function($param) {
return is_callable($param);
->with($this->callback(function ($param) {
return \is_callable($param);
}));
$backend = $this->createMock(UserInterface::class);
$result = $s->analyzeExistingUsers($backend, function() {});
$this->assertTrue(is_array($result));
$this->assertEquals(2, count($result));
$result = $s->analyzeExistingUsers($backend, function () {
});
$this->assertInternalType('array', $result);
$this->assertCount(2, $result);
}

/**
Expand All @@ -202,10 +203,9 @@ public function testReAppearingAccountsAreDetected() {
$account->expects($this->exactly(2))->method('getUserId')->willReturn('test');
$s = new SyncService($this->config, $this->logger, $this->mapper);
$response = static::invokePrivate($s, 'checkIfAccountReappeared', [$account, $backend, $backendClass]);
$this->assertTrue(is_array($response));
$this->assertEquals(0, count($response[0]));
$this->assertEquals(1, count($response[1]));

$this->assertInternalType('array', $response);
$this->assertCount(0, $response[0]);
$this->assertCount(1, $response[1]);
}

/**
Expand All @@ -222,9 +222,9 @@ public function testRemovedAccountsAreDetected() {
$account->expects($this->exactly(2))->method('getUserId')->willReturn('test');
$s = new SyncService($this->config, $this->logger, $this->mapper);
$response = static::invokePrivate($s, 'checkIfAccountReappeared', [$account, $backend, $backendClass]);
$this->assertTrue(is_array($response));
$this->assertEquals(1, count($response[0]));
$this->assertEquals(0, count($response[1]));
$this->assertInternalType('array', $response);
$this->assertCount(1, $response[0]);
$this->assertCount(0, $response[1]);
}

public function providesSyncQuota() {
Expand Down Expand Up @@ -275,5 +275,4 @@ public function testSyncQuota($backendProvidesQuota, $backendQuota, $preferences
$s = new SyncService($this->config, $this->logger, $this->mapper);
static::invokePrivate($s, 'syncQuota', [$a, $backend]);
}

}