-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #178 from mynameisrufus/feature/rfc3062
Support for rfc3062 Password Modify, closes #163
- Loading branch information
Showing
7 changed files
with
204 additions
and
4 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
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
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,80 @@ | ||
require_relative '../test_helper' | ||
|
||
class TestPasswordModifyIntegration < LDAPIntegrationTestCase | ||
def setup | ||
super | ||
@ldap.authenticate 'cn=admin,dc=rubyldap,dc=com', 'passworD1' | ||
|
||
@dn = 'uid=modify-password-user1,ou=People,dc=rubyldap,dc=com' | ||
|
||
attrs = { | ||
objectclass: %w(top inetOrgPerson organizationalPerson person), | ||
uid: 'modify-password-user1', | ||
cn: 'modify-password-user1', | ||
sn: 'modify-password-user1', | ||
mail: 'modify-password-user1@rubyldap.com', | ||
userPassword: 'passworD1' | ||
} | ||
unless @ldap.search(base: @dn, scope: Net::LDAP::SearchScope_BaseObject) | ||
assert @ldap.add(dn: @dn, attributes: attrs), @ldap.get_operation_result.inspect | ||
end | ||
assert @ldap.search(base: @dn, scope: Net::LDAP::SearchScope_BaseObject) | ||
|
||
@auth = { | ||
method: :simple, | ||
username: @dn, | ||
password: 'passworD1' | ||
} | ||
end | ||
|
||
def test_password_modify | ||
assert @ldap.password_modify(dn: @dn, | ||
auth: @auth, | ||
old_password: 'passworD1', | ||
new_password: 'passworD2') | ||
|
||
assert @ldap.get_operation_result.extended_response.nil?, | ||
'Should not have generated a new password' | ||
|
||
refute @ldap.bind(username: @dn, password: 'passworD1', method: :simple), | ||
'Old password should no longer be valid' | ||
|
||
assert @ldap.bind(username: @dn, password: 'passworD2', method: :simple), | ||
'New password should be valid' | ||
end | ||
|
||
def test_password_modify_generate | ||
assert @ldap.password_modify(dn: @dn, | ||
auth: @auth, | ||
old_password: 'passworD1') | ||
|
||
generated_password = @ldap.get_operation_result.extended_response[0][0] | ||
|
||
assert generated_password, 'Should have generated a password' | ||
|
||
refute @ldap.bind(username: @dn, password: 'passworD1', method: :simple), | ||
'Old password should no longer be valid' | ||
|
||
assert @ldap.bind(username: @dn, password: generated_password, method: :simple), | ||
'New password should be valid' | ||
end | ||
|
||
def test_password_modify_generate_no_old_password | ||
assert @ldap.password_modify(dn: @dn, | ||
auth: @auth) | ||
|
||
generated_password = @ldap.get_operation_result.extended_response[0][0] | ||
|
||
assert generated_password, 'Should have generated a password' | ||
|
||
refute @ldap.bind(username: @dn, password: 'passworD1', method: :simple), | ||
'Old password should no longer be valid' | ||
|
||
assert @ldap.bind(username: @dn, password: generated_password, method: :simple), | ||
'New password should be valid' | ||
end | ||
|
||
def teardown | ||
@ldap.delete dn: @dn | ||
end | ||
end |