Skip to content

Commit

Permalink
Merge branch 'master' into fix-paged-search
Browse files Browse the repository at this point in the history
  • Loading branch information
HarlemSquirrel authored Oct 29, 2024
2 parents 94abe52 + 75c0bcb commit 4e90d44
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 35 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ jobs:
strategy:
matrix:
ruby:
- "2.6"
- "2.7"
- "3.0"
- "3.1"
- "3.2"
- "jruby-9.3"
- "3.3"
- "jruby-9.4"
- "truffleruby-22"
- "truffleruby"
steps:
- uses: actions/checkout@v2
- name: Run tests with Ruby ${{ matrix.ruby }}
run: docker-compose run ci-${{ matrix.ruby }}
run: docker compose run ci-${{ matrix.ruby }}
2 changes: 1 addition & 1 deletion README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ the most recent LDAP RFCs (4510–4519, plus portions of 4520–4532).

== Synopsis

See {Net::LDAP on rubydoc.info}[https://www.rubydoc.info/github/ruby-ldap/ruby-net-ldap] for documentation and usage samples.
See {Net::LDAP on rubydoc.info}[https://www.rubydoc.info/github/ruby-ldap/ruby-net-ldap/Net/LDAP] for documentation and usage samples.

== Requirements

Expand Down
36 changes: 10 additions & 26 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.8"

networks:
integration_test_network:

Expand All @@ -24,22 +22,8 @@ services:
volumes:
- ./test/fixtures/ldif:/ldif:ro

ci-2.6:
image: ruby:2.7
entrypoint: /code/ci-run.sh
environment:
INTEGRATION: openldap
INTEGRATION_HOST: ldap.example.org
depends_on:
- openldap
networks:
integration_test_network:
volumes:
- .:/code
working_dir: /code

ci-2.7:
image: ruby:2.7
ci-3.0:
image: ruby:3.0
entrypoint: /code/ci-run.sh
environment:
INTEGRATION: openldap
Expand All @@ -52,8 +36,8 @@ services:
- .:/code
working_dir: /code

ci-3.0:
image: ruby:3.0
ci-3.1:
image: ruby:3.1
entrypoint: /code/ci-run.sh
environment:
INTEGRATION: openldap
Expand All @@ -66,8 +50,8 @@ services:
- .:/code
working_dir: /code

ci-3.1:
image: ruby:3.1
ci-3.2:
image: ruby:3.2
entrypoint: /code/ci-run.sh
environment:
INTEGRATION: openldap
Expand All @@ -80,8 +64,8 @@ services:
- .:/code
working_dir: /code

ci-3.2:
image: ruby:3.2
ci-3.3:
image: ruby:3.3
entrypoint: /code/ci-run.sh
environment:
INTEGRATION: openldap
Expand All @@ -95,8 +79,8 @@ services:
working_dir: /code

# https://github.com/flavorjones/truffleruby/pkgs/container/truffleruby
ci-truffleruby-22:
image: ghcr.io/flavorjones/truffleruby:22.3.1
ci-truffleruby:
image: ghcr.io/flavorjones/truffleruby:stable
entrypoint: /code/ci-run.sh
environment:
INTEGRATION: openldap
Expand Down
14 changes: 12 additions & 2 deletions lib/net/ldap/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,12 @@ def modify(args)
ops.to_ber_sequence,
].to_ber_appsequence(Net::LDAP::PDU::ModifyRequest)

write(request, nil, message_id)
controls = args.fetch(:controls, nil)
unless controls.nil?
controls = controls.to_ber_contextspecific(0)
end

write(request, controls, message_id)
pdu = queued_read(message_id)

if !pdu || pdu.app_tag != Net::LDAP::PDU::ModifyResponse
Expand Down Expand Up @@ -641,7 +646,12 @@ def add(args)
message_id = next_msgid
request = [add_dn.to_ber, add_attrs.to_ber_sequence].to_ber_appsequence(Net::LDAP::PDU::AddRequest)

write(request, nil, message_id)
controls = args.fetch(:controls, nil)
unless controls.nil?
controls = controls.to_ber_contextspecific(0)
end

write(request, controls, message_id)
pdu = queued_read(message_id)

if !pdu || pdu.app_tag != Net::LDAP::PDU::AddResponse
Expand Down
3 changes: 2 additions & 1 deletion net-ldap.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ the most recent LDAP RFCs (4510-4519, plutions of 4520-4532).}
s.homepage = %q{http://github.com/ruby-ldap/ruby-net-ldap}
s.rdoc_options = ["--main", "README.rdoc"]
s.require_paths = ["lib"]
s.required_ruby_version = ">= 2.0.0"
s.required_ruby_version = ">= 3.0.0"
s.summary = %q{Net::LDAP for Ruby (also called net-ldap) implements client access for the Lightweight Directory Access Protocol (LDAP), an IETF standard protocol for accessing distributed directory services}

s.add_dependency("ostruct")
s.add_development_dependency("flexmock", "~> 1.3")
s.add_development_dependency("rake", "~> 12.3.3")
s.add_development_dependency("rubocop", "~> 1.48")
Expand Down
34 changes: 34 additions & 0 deletions test/test_ldap_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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, [
Expand Down

0 comments on commit 4e90d44

Please sign in to comment.