Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix deprecated hash methods #254

Merged
merged 1 commit into from
Jan 12, 2016
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
9 changes: 0 additions & 9 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,6 @@ Style/ConstantName:
- 'test/test_ldif.rb'
- 'testserver/ldapserver.rb'

# Offense count: 18
# Cop supports --auto-correct.
Style/DeprecatedHashMethods:
Exclude:
- 'lib/net/snmp.rb'
- 'test/test_ldap_connection.rb'
- 'test/test_ldif.rb'
- 'test/test_search.rb'

# Offense count: 21
# Configuration parameters: Exclude.
Style/Documentation:
Expand Down
2 changes: 1 addition & 1 deletion lib/net/snmp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def pdu_type= t
end

def error_status= es
unless ErrorStatusCodes.has_key?(es)
unless ErrorStatusCodes.key?(es)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Today I learned ;)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

me too, thanks!

raise Error.new("unknown error-status: #{es}")
end
@error_status = es
Expand Down
18 changes: 9 additions & 9 deletions test/test_ldap_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ def test_write_net_ldap_connection_event

# a write event
payload, result = events.pop
assert payload.has_key?(:result)
assert payload.has_key?(:content_length)
assert payload.key?(:result)
assert payload.key?(:content_length)
end

def test_read_net_ldap_connection_event
Expand All @@ -416,7 +416,7 @@ def test_read_net_ldap_connection_event

# a read event
payload, result = events.pop
assert payload.has_key?(:result)
assert payload.key?(:result)
assert_equal read_result, result
end

Expand All @@ -433,9 +433,9 @@ def test_parse_pdu_net_ldap_connection_event

# a parse_pdu event
payload, result = events.pop
assert payload.has_key?(:pdu)
assert payload.has_key?(:app_tag)
assert payload.has_key?(:message_id)
assert payload.key?(:pdu)
assert payload.key?(:app_tag)
assert payload.key?(:message_id)
assert_equal Net::LDAP::PDU::BindResult, payload[:app_tag]
assert_equal 1, payload[:message_id]
pdu = payload[:pdu]
Expand All @@ -455,7 +455,7 @@ def test_bind_net_ldap_connection_event

# a read event
payload, result = events.pop
assert payload.has_key?(:result)
assert payload.key?(:result)
assert result.success?, "should be success"
end

Expand All @@ -482,8 +482,8 @@ def test_search_net_ldap_connection_event

# a search event
payload, result = events.pop
assert payload.has_key?(:result)
assert payload.has_key?(:filter)
assert payload.key?(:result)
assert payload.key?(:filter)
assert_equal "(uid=user1)", payload[:filter].to_s
assert result

Expand Down
12 changes: 6 additions & 6 deletions test/test_ldif.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,31 @@ def test_ldif_with_password

def test_ldif_with_continuation_lines
ds = Net::LDAP::Dataset::read_ldif(StringIO.new("dn: abcdefg\r\n hijklmn\r\n\r\n"))
assert_equal(true, ds.has_key?("abcdefghijklmn"))
assert_equal(true, ds.key?("abcdefghijklmn"))
end

def test_ldif_with_continuation_lines_and_extra_whitespace
ds1 = Net::LDAP::Dataset::read_ldif(StringIO.new("dn: abcdefg\r\n hijklmn\r\n\r\n"))
assert_equal(true, ds1.has_key?("abcdefg hijklmn"))
assert_equal(true, ds1.key?("abcdefg hijklmn"))
ds2 = Net::LDAP::Dataset::read_ldif(StringIO.new("dn: abcdefg\r\n hij klmn\r\n\r\n"))
assert_equal(true, ds2.has_key?("abcdefghij klmn"))
assert_equal(true, ds2.key?("abcdefghij klmn"))
end

def test_ldif_tab_is_not_continuation
ds = Net::LDAP::Dataset::read_ldif(StringIO.new("dn: key\r\n\tnotcontinued\r\n\r\n"))
assert_equal(true, ds.has_key?("key"))
assert_equal(true, ds.key?("key"))
end

def test_ldif_with_base64_dn
str = "dn:: Q049QmFzZTY0IGRuIHRlc3QsT1U9VGVzdCxPVT1Vbml0cyxEQz1leGFtcGxlLERDPWNvbQ==\r\n\r\n"
ds = Net::LDAP::Dataset::read_ldif(StringIO.new(str))
assert_equal(true, ds.has_key?("CN=Base64 dn test,OU=Test,OU=Units,DC=example,DC=com"))
assert_equal(true, ds.key?("CN=Base64 dn test,OU=Test,OU=Units,DC=example,DC=com"))
end

def test_ldif_with_base64_dn_and_continuation_lines
str = "dn:: Q049QmFzZTY0IGRuIHRlc3Qgd2l0aCBjb250aW51YXRpb24gbGluZSxPVT1UZXN0LE9VPVVua\r\n XRzLERDPWV4YW1wbGUsREM9Y29t\r\n\r\n"
ds = Net::LDAP::Dataset::read_ldif(StringIO.new(str))
assert_equal(true, ds.has_key?("CN=Base64 dn test with continuation line,OU=Test,OU=Units,DC=example,DC=com"))
assert_equal(true, ds.key?("CN=Base64 dn test with continuation line,OU=Test,OU=Units,DC=example,DC=com"))
end

# TODO, INADEQUATE. We need some more tests
Expand Down
4 changes: 2 additions & 2 deletions test/test_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def test_instrumentation_publishes_event
@connection.search(:filter => "test")

payload, result = events.pop
assert payload.has_key?(:result)
assert payload.has_key?(:filter)
assert payload.key?(:result)
assert payload.key?(:filter)
assert_equal "test", payload[:filter]
end
end