-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
77 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ class FeatureContext implements Context | |
*/ | ||
public function __construct() | ||
{ | ||
exec('wp --allow-root core install --url=localhost --title=Example --admin_user=lccaladmin --admin_password=P@ssw0rd [email protected]'); | ||
exec('wp --allow-root core install --url=localhost --title=Example --admin_user=localadmin --admin_password=P@ssw0rd [email protected]'); | ||
exec('wp --allow-root plugin activate authldap'); | ||
} | ||
|
||
|
@@ -57,7 +57,7 @@ public function configurationValueIsSetTo($arg1, $arg2) | |
exec(sprintf( | ||
'wp --allow-root option patch update authLDAPOptions %1$s %2$s --format=json', | ||
$arg1, | ||
$arg2 | ||
"'" . json_encode($arg2) . "'" | ||
)); | ||
} | ||
|
||
|
@@ -225,7 +225,7 @@ public function theWordpressUserIsMemberOfRole($arg1, $arg2) | |
public function ldapUserIsMemberOfLdapGroup($arg1, $arg2) | ||
{ | ||
exec(sprintf( | ||
'ldapmodify -x -H %1$s -D "%2$s" -w %3$s <<LDIF | ||
'ldapmodify -x -H %1$s -D "%2$s" -w %3$s 2>&1 <<LDIF | ||
%4$s | ||
LDIF', | ||
'ldap://openldap', | ||
|
@@ -237,7 +237,8 @@ public function ldapUserIsMemberOfLdapGroup($arg1, $arg2) | |
add: uniqueMember | ||
uniqueMember: uid=$arg1,dc=example,dc=org | ||
LDIF | ||
)); } | ||
)); | ||
} | ||
|
||
/** | ||
* @Given a WordPress user :arg1 does not exist | ||
|
@@ -249,4 +250,41 @@ public function aWordpressUserDoesNotExist($arg1) | |
$arg1, | ||
)); | ||
} | ||
|
||
/** | ||
* @Given configuration value :arg1 is set to :arg2 and :arg3 | ||
*/ | ||
public function configurationValueIsSetToAnd($arg1, $arg2, $arg3) | ||
{ | ||
$roles = []; | ||
foreach ([$arg2, $arg3] as $arg) { | ||
$access = explode('=', $arg); | ||
$roles[$access[0]] = $access[1]; | ||
} | ||
|
||
exec(sprintf( | ||
'echo %2$s | wp --allow-root option patch update authLDAPOptions %1$s --format=json', | ||
$arg1, | ||
"'" . json_encode($roles) . "'" | ||
), $result); | ||
var_dump($result); | ||
} | ||
|
||
/** | ||
* @Then the WordPress user :arg1 is not member of role :arg2 | ||
*/ | ||
public function theWordpressUserIsNotMemberOfRole($arg1, $arg2) | ||
{ | ||
exec(sprintf( | ||
'wp --allow-root user get %1$s --format=json 2> /dev/null', | ||
$arg1, | ||
), $output, $result); | ||
Assert::eq(0, $result); | ||
$user = json_decode($output[0], true); | ||
$roles = array_map(function($item): string { | ||
return trim($item); | ||
}, explode(',', $user['roles'])); | ||
Assert::false(in_array($arg2, $roles)); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
Feature: Log in without group assignment | ||
Scenario: Login without group assignement with | ||
Scenario: Login without group assignment with | ||
Given a default configuration | ||
And configuration value "GroupEnable" is set to "false" | ||
And configuration value "DefaultRole" is set to "subscriber" | ||
And an LDAP user "ldapuser" with name "LDAP User", password "P@ssw0rd" and email "[email protected]" exists | ||
And an LDAP group "ldapgroup" exists | ||
And LDAP user "ldapuser" is member of LDAP group "ldapgroup" | ||
|
@@ -13,3 +14,25 @@ Feature: Log in without group assignment | |
Then the login suceeds | ||
And a new WordPress user "ldapuser" was created with name "LDAP User" and email "[email protected]" | ||
And the WordPress user "ldapuser" is member of role "subscriber" | ||
|
||
Scenario: Login with group assignment to one group where only first wordpress group is used | ||
Given a default configuration | ||
And configuration value "GroupEnable" is set to "true" | ||
And configuration value "DefaultRole" is set to "subscriber" | ||
And configuration value "Groups" is set to "administrator=ldapgroup" and "editor=ldapgroup" | ||
And configuration value "GroupAttr" is set to "cn" | ||
And configuration value "GroupFilter" is set to "uniquemember=%dn%" | ||
And configuration value "GroupOverUser" is set to "true" | ||
And an LDAP user "ldapuser" with name "LDAP User", password "P@ssw0rd" and email "[email protected]" exists | ||
And an LDAP group "ldapgroup" exists | ||
And LDAP user "ldapuser" is member of LDAP group "ldapgroup" | ||
And a WordPress user "wordpressuser" with name "WordPress_User" and email "[email protected]" exists | ||
And a WordPress role "wordpressrole" exists | ||
And WordPress user "wordpressuser" has role "wordpressrole" | ||
And a WordPress user "ldapuser" does not exist | ||
When LDAP user "ldapuser" logs in with password "P@ssw0rd" | ||
Then the login suceeds | ||
And a new WordPress user "ldapuser" was created with name "LDAP User" and email "[email protected]" | ||
And the WordPress user "ldapuser" is member of role "administrator" | ||
And the WordPress user "ldapuser" is not member of role "editor" | ||
And the WordPress user "ldapuser" is not member of role "subscriber" |