diff --git a/lib/net/ber/core_ext/true_class.rb b/lib/net/ber/core_ext/true_class.rb
index ac66c926..bf199d1e 100644
--- a/lib/net/ber/core_ext/true_class.rb
+++ b/lib/net/ber/core_ext/true_class.rb
@@ -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
diff --git a/test/ber/test_ber.rb b/test/ber/test_ber.rb
index 6f641bb4..7eade7c2 100644
--- a/test/ber/test_ber.rb
+++ b/test/ber/test_ber.rb
@@ -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
diff --git a/test/integration/test_ber.rb b/test/integration/test_ber.rb
new file mode 100644
index 00000000..8fb4d374
--- /dev/null
+++ b/test/integration/test_ber.rb
@@ -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