Skip to content

Central account table replace user manager when testing - #27276

Merged
PVince81 merged 10 commits into
masterfrom
central-account-table-replace-user-manager-when-testing
Mar 23, 2017
Merged

PVince81 merged 10 commits into
masterfrom
central-account-table-replace-user-manager-when-testing

Conversation

@DeepDiver1975

@DeepDiver1975 DeepDiver1975 commented Feb 28, 2017 •

Copy link
Copy Markdown
Contributor

Related Issue

fixes #23558

Missing

  • unit test execution is 3 times slower compared to the implementation we had before 😢
  • handle permission flags like: can set display et
  • store password reset token in the account table
  • store language setting in the account table as well
  • migration of local users
  • migration of ldap users
  • migration of saml users
  • migration or ..... users
  • ldap integration

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@mention-bot

Copy link
Copy Markdown

@DeepDiver1975, thanks for your PR! By analyzing the history of the files in this pull request, we identified @butonic, @PVince81 and @bantu to be potential reviewers.

@DeepDiver1975
DeepDiver1975 force-pushed the central-account-table-replace-user-manager-when-testing branch from 5c85d2b to 347a631 Compare March 8, 2017 11:20
@DeepDiver1975 DeepDiver1975 mentioned this pull request Mar 8, 2017
3 of 9 tasks
@DeepDiver1975
DeepDiver1975 force-pushed the central-account-table-replace-user-manager-when-testing branch from 347a631 to 8419ae6 Compare March 17, 2017 18:57
@DeepDiver1975 DeepDiver1975 added this to the 10.0 milestone Mar 20, 2017
@DeepDiver1975
DeepDiver1975 force-pushed the central-account-table-replace-user-manager-when-testing branch 4 times, most recently from ab79244 to 57ade34 Compare March 20, 2017 14:20
@DeepDiver1975
DeepDiver1975 requested a review from PVince81 March 20, 2017 19:32
@DeepDiver1975 DeepDiver1975 changed the title [WIP] Central account table replace user manager when testing Central account table replace user manager when testing Mar 20, 2017
]);

$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['email']);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can already hear the "internal server error" returned to the UI when someone is trying to set a duplicate email address 😉

This will need to be caught properly (separate PR).

Comment thread lib/private/User/Manager.php Outdated
// if (isset($this->cachedUsers[$uid])) {
// return $this->cachedUsers[$uid];
// }
// }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove?

use OCP\IImage;
use OCP\IUser;

class RemoteUser implements IUser {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comment: what on earth is a remote user ?

Comment thread lib/private/User/RemoteUser.php Outdated
* get the display name for the user, if no specific display name is set it will fallback to the user id
*
* @return string
* @since 8.0.0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and remove @since because they don't apply for this private class

Comment thread tests/PendingUserListener.php Outdated
* See the COPYING-README file.
*/

class PendingUserListener implements PHPUnit_Framework_TestListener {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this, why is it needed and what does it do ? answer in PHPDoc because that's the question future devs will ask themselves when seeing this 😄

Comment thread tests/PendingUserListener.php Outdated
public function endTest(PHPUnit_Framework_Test $test, $time) {
}

public function startTestSuite(PHPUnit_Framework_TestSuite $suite) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it wasn't possible to put this logic into the 'TestCase` base class ?

Comment thread tests/PendingUserListener.php Outdated
$diff = array_diff($currentUsers, $this->knownUsers);
if (!empty($diff)) {
$test = $suite->getName();
PHPUnit_Framework_Assert::assertEquals($this->knownUsers, $currentUsers, "$test: Users have not been clean up properly: " . implode(' ', $diff));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! Now I get it!

Maybe rename the class to UncleantUsersDetector ?

Comment thread tests/lib/Traits/UserTrait.php Outdated
}
}

class DummyUserBackend extends Backend implements \OCP\IUserBackend {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one upon at time there was a developer who always said that even test classes need to be split into individual PHP files

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

who was that? 😉

$backend = $this->createMock('\OC\User\Database');

$backend->expects($this->any())
->method('implementsActions')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems we lost many tests here. Is the another test that covers this directly for the "\OC\User\Database" class ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I implemented some of these tests using data providers to reduce code

Comment thread tests/phpunit-autotest.xml Outdated
</filter>
<listeners>
<listener class="StartSessionListener" file="startsessionlistener.php" />
<!--<listener class="PendingUserListener" file="PendingUserListener.php" />-->

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete the class if we don't want this any more...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a comment

@DeepDiver1975
DeepDiver1975 force-pushed the central-account-table-replace-user-manager-when-testing branch 2 times, most recently from 12f317f to ae553b4 Compare March 21, 2017 09:38
Comment thread core/Command/User/SyncBackend.php Outdated

@PVince81 PVince81 Mar 21, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an additional short version "-b" could be nice for easier typing out 😉

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah never mind, it's already a pain to type the escaped class name, so the additional pain of typing out "backend-class" is fine

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the additional pain of typing out "backend-class" is fine

you dont need to - its an argument not an option

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeeeeent

Comment thread lib/private/User/SyncService.php Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would callForAllUsers work here which comes with its own pagination ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since I only want to interate over all users there is no proper callForAllUsers available.
i also didn't want to add yet another argument to callForAllUsers

Comment thread lib/private/User/SyncService.php Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log a debug entry, just in case ?

@PVince81

Copy link
Copy Markdown
Contributor

Some minor comments on the sync commit ae553b4

Looks good in general, up to you to decide for the changes (I hope you fix the indent though 😉).

Please do a quick test before merging to make sure this still works after the little changes that were made to make tests pass.

@DeepDiver1975
DeepDiver1975 force-pushed the central-account-table-replace-user-manager-when-testing branch from ae553b4 to 592e76d Compare March 21, 2017 12:40
@DeepDiver1975
DeepDiver1975 force-pushed the central-account-table-replace-user-manager-when-testing branch from 592e76d to c21f44d Compare March 21, 2017 12:42
@DeepDiver1975

Copy link
Copy Markdown
Contributor Author

@davitol 1feec08 should address the shib issue - mind testing - thx

@davitol

davitol commented Mar 22, 2017

Copy link
Copy Markdown
Contributor

@DeepDiver1975

@davitol 1feec08 should address the shib issue - mind testing - thx

I still can reproduce it

@DeepDiver1975
DeepDiver1975 force-pushed the central-account-table-replace-user-manager-when-testing branch 2 times, most recently from b4787e2 to a51d0ef Compare March 22, 2017 16:21
@DeepDiver1975

Copy link
Copy Markdown
Contributor Author

rebased again 😢

@DeepDiver1975
DeepDiver1975 force-pushed the central-account-table-replace-user-manager-when-testing branch from 539c070 to 0f5241b Compare March 23, 2017 08:27
@PVince81

Copy link
Copy Markdown
Contributor

👍

@PVince81
PVince81 merged commit 82ee84e into master Mar 23, 2017
@PVince81
PVince81 deleted the central-account-table-replace-user-manager-when-testing branch March 23, 2017 11:22
individual-it added a commit that referenced this pull request Apr 3, 2017
since commit 9489104
PR #27276
The email address is not stored in the preferences table anymore but in the user account
9489104#diff-3030ca4989f892c50dea24eaa3f1ae38R151

So need to get it from there also

Fixes #27554
DeepDiver1975 pushed a commit that referenced this pull request Apr 4, 2017
since commit 9489104
PR #27276
The email address is not stored in the preferences table anymore but in the user account
9489104#diff-3030ca4989f892c50dea24eaa3f1ae38R151

So need to get it from there also

Fixes #27554
@PVince81

PVince81 commented Apr 7, 2017

Copy link
Copy Markdown
Contributor

doc ticket: owncloud-archive/documentation#2991

@lock

lock Bot commented Aug 3, 2019

Copy link
Copy Markdown

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock Bot locked as resolved and limited conversation to collaborators Aug 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

User account table and user locking/blacklist

4 participants