From ab196040b426c4273cc0e4f75e805f42c8a59b12 Mon Sep 17 00:00:00 2001 From: Jamstah Date: Tue, 11 Jan 2011 14:23:15 +0000 Subject: [PATCH] Add breaking tests. --- spec/unit/ldap/filter_spec.rb | 6 +++--- test/test_filter.rb | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/spec/unit/ldap/filter_spec.rb b/spec/unit/ldap/filter_spec.rb index 623f032..9c08436 100644 --- a/spec/unit/ldap/filter_spec.rb +++ b/spec/unit/ldap/filter_spec.rb @@ -76,8 +76,8 @@ describe Net::LDAP::Filter do end end describe "<- .escape(str)" do - it "should escape !, &, *, :, | and ~" do - Net::LDAP::Filter.escape('!&*:|~').should == "\\21\\26\\2A\\3A\\7C\\7E" + it "should escape nul, *, (, ) and \\" do + Net::LDAP::Filter.escape("\0*()\\").should == "\\00\\2A\\28\\29\\5C" end end -end \ No newline at end of file +end diff --git a/test/test_filter.rb b/test/test_filter.rb index 88495f1..faa42c4 100644 --- a/test/test_filter.rb +++ b/test/test_filter.rb @@ -24,6 +24,13 @@ class TestFilter < Test::Unit::TestCase assert_equal("(uid=george *)", Filter.eq("uid", "george *").to_s) end + def test_convenience_filters + assert_equal("(uid=\\2A)", Filter.equals("uid", "*").to_s) + assert_equal("(uid=\\28*)", Filter.begins("uid", "(").to_s) + assert_equal("(uid=*\\29)", Filter.ends("uid", ")").to_s) + assert_equal("(uid=*\\5C*)", Filter.contains("uid", "\\").to_s) + end + def test_c2 assert_equal("(uid=george *)", Filter.from_rfc2254("uid=george *").to_rfc2254)