Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/net/ber/core_ext/true_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ module Net::BER::Extensions::TrueClass
##
# Converts +true+ to the BER wireline representation of +true+.
def to_ber
# 20100319 AZ: Note that this may not be the completely correct value,
# per some test documentation. We need to determine the truth of this.
"\001\001\001"
# http://tools.ietf.org/html/rfc4511#section-5.1
"\001\001\xFF".force_encoding("ASCII-8BIT")
end
end
3 changes: 2 additions & 1 deletion test/ber/test_ber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ def test_array
assert_equal ary, encoded_ary.read_ber
end

# http://tools.ietf.org/html/rfc4511#section-5.1
def test_true
assert_equal "\x01\x01\x01", true.to_ber
assert_equal "\x01\x01\xFF".b, true.to_ber
end

def test_false
Expand Down
30 changes: 30 additions & 0 deletions test/integration/test_ber.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require_relative '../test_helper'

class TestBERIntegration < LDAPIntegrationTestCase
# Test whether the TRUE boolean value is encoded correctly by performing a
# search operation.
def test_true_ber_encoding
# request these attrs to simplify test; use symbols to match Entry#attribute_names
attrs = [:dn, :uid, :cn, :mail]

assert types_entry = @ldap.search(
base: "dc=rubyldap,dc=com",
filter: "(uid=user1)",
size: 1,
attributes: attrs,
attributes_only: true
).first

# matches attributes we requested
assert_equal attrs, types_entry.attribute_names

# assert values are empty
types_entry.each do |name, values|
next if name == :dn
assert values.empty?
end

assert_includes Net::LDAP::ResultCodesSearchSuccess,
@ldap.get_operation_result.code, "should be a successful search operation"
end
end