Skip to content

Commit

Permalink
rubocop -a
Browse files Browse the repository at this point in the history
  • Loading branch information
walro committed Aug 21, 2023
1 parent 0a3b7f3 commit b65f17a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/sparoid_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def test_that_it_has_a_version_number
end

def test_it_resolves_public_ip
assert Sparoid.send(:public_ip).to_s =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/
assert_match(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/, Sparoid.send(:public_ip).to_s)
end

def test_it_creates_a_message
Expand All @@ -17,13 +17,15 @@ def test_it_creates_a_message

def test_it_encrypts_messages
key = "0000000000000000000000000000000000000000000000000000000000000000"

assert_equal 64, Sparoid.send(:encrypt, key, Sparoid.send(:message, Sparoid.send(:public_ip))).bytesize
end

def test_it_adds_hmac
key = "0000000000000000000000000000000000000000000000000000000000000000"
msg = Sparoid.send(:encrypt, key, Sparoid.send(:message, Sparoid.send(:public_ip)))
hmac_key = "0000000000000000000000000000000000000000000000000000000000000000"

assert_equal 96, Sparoid.send(:prefix_hmac, hmac_key, msg).bytesize
end

Expand All @@ -35,6 +37,7 @@ def test_it_sends_message
port = server.addr[1]
Sparoid.auth(key, hmac_key, "127.0.0.1", port)
msg, = server.recvfrom(512)

assert_equal 96, msg.bytesize
end
end
Expand Down Expand Up @@ -74,6 +77,7 @@ def test_it_raises_resolve_error_on_dns_socket_error
key = "0000000000000000000000000000000000000000000000000000000000000000"
hmac_key = "0000000000000000000000000000000000000000000000000000000000000000"
error = ->(*_) { raise SocketError, "getaddrinfo: Name or service not known" }

Addrinfo.stub(:getaddrinfo, error) do
assert_raises(Sparoid::ResolvError) do
Sparoid::Instance.new.auth(key, hmac_key, "127.0.0.1", 1337)
Expand All @@ -90,6 +94,7 @@ def test_instance_sends_message
port = server.addr[1]
s.auth(key, hmac_key, "127.0.0.1", port)
msg, = server.recvfrom(512)

assert_equal 96, msg.bytesize
end
end
Expand Down

0 comments on commit b65f17a

Please sign in to comment.