-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
121 additions
and
59 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
31 changes: 31 additions & 0 deletions
31
features/log in as LDAP user without wpaccount take over.feature
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Feature: log in as LDAP user when WP users can not log in | ||
Scenario: When existing wordpress users are not allowed to be overwritten | ||
an LDAP user that logs in will be created and log in. | ||
Given a default configuration | ||
And configuration value "DoNotOverwriteNonLdapUsers" is set to "true" | ||
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 a WordPress user "ldapuser" does not exist | ||
When user "ldapuser" logs in with password "P@ssw0rd" | ||
Then the login suceeds | ||
Scenario: When existing wordpress users are not allowed to be overwritten | ||
a WordPress user will still be able to log in. | ||
Given a default configuration | ||
And configuration value "DoNotOverwriteNonLdapUsers" is set to "true" | ||
And configuration value "DefaultRole" is set to "subscriber" | ||
And a WordPress user "wordpressuser" with name "WordPress_User", email "[email protected]" and password "P@ssw0rd" exists | ||
And a WordPress role "wordpressrole" exists | ||
And WordPress user "wordpressuser" has role "wordpressrole" | ||
When user "wordpressuser" logs in with password "P@ssw0rd" | ||
Then the login suceeds | ||
Scenario: When existing wordpress users are not allowed to be overwritten | ||
an LDAP user that logs in that has the same username as an existing WordPress | ||
userwill not be created and login fails | ||
Given a default configuration | ||
And configuration value "DoNotOverwriteNonLdapUsers" is set to "true" | ||
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 a WordPress user "ldapuser" with name "WordPress_User" and email "[email protected]" exists | ||
When user "ldapuser" logs in with password "P@ssw0rd" | ||
Then the login fails | ||
|
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 |
---|---|---|
|
@@ -10,7 +10,7 @@ Feature: Log in without group assignment | |
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" | ||
When 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 "subscriber" | ||
|
@@ -30,7 +30,7 @@ Feature: Log in without group assignment | |
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" | ||
When 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" | ||
|
@@ -52,10 +52,10 @@ Feature: Log in without group assignment | |
And a WordPress role "wordpressrole" exists | ||
And WordPress user "wordpressuser" has role "wordpressrole" | ||
And a WordPress user "ldapuser" does not exist | ||
And LDAP user "ldapuser" logs in with password "P@ssw0rd" | ||
And user "ldapuser" logs in with password "P@ssw0rd" | ||
And WordPress user "ldapuser" has role "wordpressrole" | ||
And the WordPress user "ldapuser" is member of role "wordpressrole" | ||
When LDAP user "ldapuser" logs in with password "P@ssw0rd" | ||
When user "ldapuser" logs in with password "P@ssw0rd" | ||
Then the login suceeds | ||
And the WordPress user "ldapuser" is member of role "administrator" | ||
And the WordPress user "ldapuser" is member of role "wordpressrole" | ||
|
@@ -74,10 +74,10 @@ Feature: Log in without group assignment | |
And an LDAP group "ldapgroup1" exists | ||
And an LDAP group "ldapgroup2" exists | ||
And LDAP user "ldapuser" is member of LDAP group "ldapgroup1" | ||
And LDAP user "ldapuser" logs in with password "P@ssw0rd" | ||
And user "ldapuser" logs in with password "P@ssw0rd" | ||
And LDAP user "ldapuser" is member of LDAP group "ldapgroup2" | ||
And LDAP user "ldapuser" is not member of LDAP group "ldapgroup1" | ||
When LDAP user "ldapuser" logs in with password "P@ssw0rd" | ||
When user "ldapuser" logs in with password "P@ssw0rd" | ||
Then the login suceeds | ||
And the WordPress user "ldapuser" is member of role "editor" | ||
And the WordPress user "ldapuser" is not member of role "administrator" | ||
|
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 |
---|---|---|
@@ -1,39 +1,37 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
bootstrap="tests/bootstrap.php" | ||
testdox="true" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd" | ||
> | ||
<coverage> | ||
<include> | ||
<directory suffix=".php">src</directory> | ||
<file>authLdap.php</file> | ||
</include> | ||
<exclude> | ||
<directory>src/Wrapper</directory> | ||
</exclude> | ||
<report> | ||
<html outputDirectory="build/coverage" lowUpperBound="35" highLowerBound="70"/> | ||
</report> | ||
</coverage> | ||
<testsuite name="authLdap Test-Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
<groups> | ||
<exclude> | ||
<group>disable</group> | ||
</exclude> | ||
</groups> | ||
<logging> | ||
<!--log type="coverage-xml" target="../report/coverage.xml"/--> | ||
<!--log type="graphviz" target="../report/logfile.dot"/--> | ||
<!--log type="json" target="../report/logfile.json"/--> | ||
<!--log type="metrics-xml" target="../report/metrics.xml"/--> | ||
<!--log type="plain" target="../report/logfile.txt"/--> | ||
<!--log type="pmd-xml" target="../report/pmd.xml" cpdMinLines="5" cpdMinMatches="70"/--> | ||
<!--log type="tap" target="../report/logfile.tap"/--> | ||
<!--log type="test-xml" target="../report/logfile.xml" logIncompleteSkipped="false"/--> | ||
<!--log type="testdox-html" target="../report/testdox.html"/--> | ||
<!--log type="testdox-text" target="../report/testdox.txt"/--> | ||
</logging> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/bootstrap.php" testdox="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.3/phpunit.xsd"> | ||
<coverage> | ||
<report> | ||
<html outputDirectory="build/coverage" lowUpperBound="35" highLowerBound="70"/> | ||
</report> | ||
</coverage> | ||
<testsuite name="authLdap Test-Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
<groups> | ||
<exclude> | ||
<group>disable</group> | ||
</exclude> | ||
</groups> | ||
<logging> | ||
<!--log type="coverage-xml" target="../report/coverage.xml"/--> | ||
<!--log type="graphviz" target="../report/logfile.dot"/--> | ||
<!--log type="json" target="../report/logfile.json"/--> | ||
<!--log type="metrics-xml" target="../report/metrics.xml"/--> | ||
<!--log type="plain" target="../report/logfile.txt"/--> | ||
<!--log type="pmd-xml" target="../report/pmd.xml" cpdMinLines="5" cpdMinMatches="70"/--> | ||
<!--log type="tap" target="../report/logfile.tap"/--> | ||
<!--log type="test-xml" target="../report/logfile.xml" logIncompleteSkipped="false"/--> | ||
<!--log type="testdox-html" target="../report/testdox.html"/--> | ||
<!--log type="testdox-text" target="../report/testdox.txt"/--> | ||
</logging> | ||
<source> | ||
<include> | ||
<directory suffix=".php">src</directory> | ||
<file>authLdap.php</file> | ||
</include> | ||
<exclude> | ||
<directory>src/Wrapper</directory> | ||
</exclude> | ||
</source> | ||
</phpunit> |
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 |
---|---|---|
|
@@ -64,7 +64,7 @@ public function testExceptionsWhenInstantiatingLdapClass(string $expected) | |
new Ldap(new LdapFactory(), LdapUri::fromString($expected)); | ||
} | ||
|
||
public function dpInstantiateLdapClass(): Generator | ||
public static function dpInstantiateLdapClass(): Generator | ||
{ | ||
yield [ | ||
'ldap://uid=jondoe,cn=users,cn=example,c=org:[email protected]/cn=example,c=org', | ||
|
@@ -140,7 +140,7 @@ public function dpInstantiateLdapClass(): Generator | |
]; | ||
} | ||
|
||
public function dpExceptionsWhenInstantiatingLdapClass(): Generator | ||
public static function dpExceptionsWhenInstantiatingLdapClass(): Generator | ||
{ | ||
yield ['ldap://ldap.example.org']; | ||
yield ['ldap://foo:bar@/cn=example,c=org']; | ||
|
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 |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
|
||
class LdapUriTest extends TestCase | ||
{ | ||
public function toStringProvider(): Generator | ||
public static function toStringProvider(): Generator | ||
{ | ||
yield ['ldaps://foo:[email protected]/baz', 'ldaps://foo.bar:636', 'foo', 'bar', 'baz']; | ||
yield ['env:LDAP_URI', 'ldaps://foo.bar:636', 'foo', 'bar', 'baz', [ | ||
|
@@ -27,7 +27,7 @@ public function toStringProvider(): Generator | |
]]; | ||
} | ||
|
||
public function fromStringProvider(): Generator | ||
public static function fromStringProvider(): Generator | ||
{ | ||
yield ['ldaps://foo:[email protected]/baz', false]; | ||
yield ['env:LDAP_URI', false]; | ||
|
@@ -82,7 +82,7 @@ public function testUriIsAnonymous(string $uri): void | |
Assert::assertTrue($uri->isAnonymous()); | ||
} | ||
|
||
public function anonymousProvider(): Generator | ||
public static function anonymousProvider(): Generator | ||
{ | ||
yield ['ldaps://test.example.com/dc=com']; | ||
yield ['ldaps://[email protected]/dc=com']; | ||
|
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 was deleted.
Oops, something went wrong.