Skip to content

Commit 672bf4f

Browse files
add user sync tests
1 parent 71b41d7 commit 672bf4f

File tree

3 files changed

+68
-239
lines changed

3 files changed

+68
-239
lines changed

tests/acceptance/config/ldap-users.ldif

-239
This file was deleted.

tests/acceptance/features/bootstrap/UserLdapGeneralContext.php

+27
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,33 @@ public function ldapConfigHasTheseSettings($configId, TableNode $table) {
122122
}
123123
}
124124

125+
/**
126+
* @When LDAP user :user is resynced
127+
*
128+
* @param string $user
129+
*
130+
* @throws Exception
131+
* @return void
132+
*/
133+
public function ldapUserIsSynced($user) {
134+
$occResult = SetupHelper::runOcc(
135+
['user:sync', 'OCA\User_LDAP\User_Proxy', '-u', $user, '-m', 'remove']
136+
);
137+
if ($occResult['code'] !== "0") {
138+
throw new \Exception("could not sync LDAP user {$user} " . $occResult['stdErr']);
139+
}
140+
}
141+
142+
/**
143+
* @When the admin lists the enabled user backends using the occ command
144+
*
145+
* @return void
146+
* @throws Exception
147+
*/
148+
public function theAdminListsTheEnabledBackendsUsingTheOccCommand() {
149+
$this->featureContext->runOcc(["user:sync -l"]);
150+
}
151+
125152
/**
126153
* @When the administrator sets the ldap attribute :attribute of the entry :entry to :value
127154
*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
@cli
2+
Feature: sync a user using occ command
3+
4+
As an administrator
5+
I want to be able to sync a user via the command line
6+
So that I can easily manage users when user LDAP is enabled
7+
8+
Background:
9+
Given these users have been created with default attributes and without skeleton files:
10+
| username |
11+
| user0 |
12+
| user1 |
13+
14+
@skipOnOcV10.3
15+
Scenario: admin deletes ldap users and syncs only one of them
16+
When the administrator deletes user "user0" using the occ command
17+
And the administrator deletes user "user1" using the occ command
18+
Then user "user0" should not exist
19+
And user "user1" should not exist
20+
When LDAP user "user0" is resynced
21+
Then user "user0" should exist
22+
And user "user1" should not exist
23+
24+
@skipOnOcV10.3
25+
Scenario: admin edits ldap users email and syncs only one of them
26+
When the administrator changes the email of user "user0" to "[email protected]" using the occ command
27+
And the administrator changes the email of user "user1" to "[email protected]" using the occ command
28+
Then user "user0" should exist
29+
And user "user1" should exist
30+
When LDAP user "user0" is resynced
31+
Then the email address of user "user0" should be "[email protected]"
32+
And the email address of user "user1" should be "[email protected]"
33+
34+
Scenario: admin lists all the enabled backends
35+
When the admin lists the enabled user backends using the occ command
36+
Then the command should have been successful
37+
And the command output should be:
38+
"""
39+
OC\User\Database
40+
OCA\User_LDAP\User_Proxy
41+
"""

0 commit comments

Comments
 (0)