-
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.
Add controls for modify and add operations (#426)
* Allow controls for add and modify * Add tests for add and modify --------- Co-authored-by: Kevin McCormack <[email protected]>
- Loading branch information
1 parent
a515dad
commit 75c0bcb
Showing
2 changed files
with
46 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -502,6 +502,40 @@ def test_search_net_ldap_connection_event | |
assert unread.empty?, "should not have any leftover unread messages" | ||
end | ||
|
||
def test_add_with_controls | ||
dacl_flag = 0x4 # DACL_SECURITY_INFORMATION | ||
control_values = [dacl_flag].map(&:to_ber).to_ber_sequence.to_s.to_ber | ||
controls = [] | ||
# LDAP_SERVER_SD_FLAGS constant definition, taken from https://ldapwiki.com/wiki/LDAP_SERVER_SD_FLAGS_OID | ||
ldap_server_sd_flags = '1.2.840.113556.1.4.801'.freeze | ||
controls << [ldap_server_sd_flags.to_ber, true.to_ber, control_values].to_ber_sequence | ||
|
||
ber = Net::BER::BerIdentifiedArray.new([Net::LDAP::ResultCodeSuccess, "", ""]) | ||
ber.ber_identifier = Net::LDAP::PDU::AddResponse | ||
@tcp_socket.should_receive(:read_ber).and_return([1, ber]) | ||
|
||
result = @connection.add(:dn => "uid=added-user1,ou=People,dc=rubyldap,dc=com", :controls => controls) | ||
assert result.success?, "should be success" | ||
assert_equal "", result.error_message | ||
end | ||
|
||
def test_modify_with_controls | ||
dacl_flag = 0x4 # DACL_SECURITY_INFORMATION | ||
control_values = [dacl_flag].map(&:to_ber).to_ber_sequence.to_s.to_ber | ||
controls = [] | ||
# LDAP_SERVER_SD_FLAGS constant definition, taken from https://ldapwiki.com/wiki/LDAP_SERVER_SD_FLAGS_OID | ||
ldap_server_sd_flags = '1.2.840.113556.1.4.801'.freeze | ||
controls << [ldap_server_sd_flags.to_ber, true.to_ber, control_values].to_ber_sequence | ||
|
||
ber = Net::BER::BerIdentifiedArray.new([Net::LDAP::ResultCodeSuccess, "", ""]) | ||
ber.ber_identifier = Net::LDAP::PDU::ModifyResponse | ||
@tcp_socket.should_receive(:read_ber).and_return([1, ber]) | ||
|
||
result = @connection.modify(:dn => "1", :operations => [[:replace, "mail", "[email protected]"]], :controls => controls) | ||
assert result.success?, "should be success" | ||
assert_equal "", result.error_message | ||
end | ||
|
||
def test_search_with_controls | ||
# search data | ||
search_data_ber = Net::BER::BerIdentifiedArray.new([1, [ | ||
|