summaryrefslogtreecommitdiff
path: root/test/authentication
diff options
context:
space:
mode:
authorFlorian Wininger <fw.centrale@gmail.com>2019-08-22 21:27:45 +0200
committerFlorian Wininger <fw.centrale@gmail.com>2019-08-22 21:58:40 +0200
commitbd9c07f1a872beef61c5cb1974be77f3d85e92d2 (patch)
tree7db40c164e6757042077a238c0129815d2941902 /test/authentication
parentc08da5d4f4dc8b2a806987baeec56e0651953df0 (diff)
downloadnet-ssh-bd9c07f1a872beef61c5cb1974be77f3d85e92d2.tar.gz
Remove defined?(OpenSSL::PKey::EC) and defined?(OpenSSL::Digest::SHA256)
Signed-off-by: Florian Wininger <fw.centrale@gmail.com>
Diffstat (limited to 'test/authentication')
-rw-r--r--test/authentication/test_agent.rb2
-rw-r--r--test/authentication/test_key_manager.rb58
2 files changed, 27 insertions, 33 deletions
diff --git a/test/authentication/test_agent.rb b/test/authentication/test_agent.rb
index 9ec93f4..faa6ef4 100644
--- a/test/authentication/test_agent.rb
+++ b/test/authentication/test_agent.rb
@@ -288,7 +288,6 @@ EOF
end
def test_add_ecdsa_identity
- return unless defined?(OpenSSL::PKey::EC)
ecdsa = OpenSSL::PKey::EC.new("prime256v1").generate_key
socket.expect do |s,type,buffer|
assert_equal SSH2_AGENT_ADD_IDENTITY, type
@@ -306,7 +305,6 @@ EOF
end
def test_add_ecdsa_cert_identity
- return unless defined?(OpenSSL::PKey::EC)
cert = make_cert(OpenSSL::PKey::EC.new("prime256v1").generate_key)
socket.expect do |s,type,buffer|
assert_equal SSH2_AGENT_ADD_IDENTITY, type
diff --git a/test/authentication/test_key_manager.rb b/test/authentication/test_key_manager.rb
index 860851b..9266900 100644
--- a/test/authentication/test_key_manager.rb
+++ b/test/authentication/test_key_manager.rb
@@ -92,26 +92,24 @@ module Authentication
assert_equal({ from: :agent }, manager.known_identities[dsa])
end
- if defined?(OpenSSL::PKey::EC)
- def test_identities_with_ecdsa_should_load_from_agent
- manager.stubs(:agent).returns(agent_with_ecdsa_keys)
-
- identities = []
- manager.each_identity { |identity| identities << identity }
- assert_equal 5, identities.length
-
- assert_equal rsa.to_blob, identities[0].to_blob
- assert_equal dsa.to_blob, identities[1].to_blob
- assert_equal ecdsa_sha2_nistp256.to_blob, identities[2].to_blob
- assert_equal ecdsa_sha2_nistp384.to_blob, identities[3].to_blob
- assert_equal ecdsa_sha2_nistp521.to_blob, identities[4].to_blob
-
- assert_equal({ from: :agent }, manager.known_identities[rsa])
- assert_equal({ from: :agent }, manager.known_identities[dsa])
- assert_equal({ from: :agent }, manager.known_identities[ecdsa_sha2_nistp256])
- assert_equal({ from: :agent }, manager.known_identities[ecdsa_sha2_nistp384])
- assert_equal({ from: :agent }, manager.known_identities[ecdsa_sha2_nistp521])
- end
+ def test_identities_with_ecdsa_should_load_from_agent
+ manager.stubs(:agent).returns(agent_with_ecdsa_keys)
+
+ identities = []
+ manager.each_identity { |identity| identities << identity }
+ assert_equal 5, identities.length
+
+ assert_equal rsa.to_blob, identities[0].to_blob
+ assert_equal dsa.to_blob, identities[1].to_blob
+ assert_equal ecdsa_sha2_nistp256.to_blob, identities[2].to_blob
+ assert_equal ecdsa_sha2_nistp384.to_blob, identities[3].to_blob
+ assert_equal ecdsa_sha2_nistp521.to_blob, identities[4].to_blob
+
+ assert_equal({ from: :agent }, manager.known_identities[rsa])
+ assert_equal({ from: :agent }, manager.known_identities[dsa])
+ assert_equal({ from: :agent }, manager.known_identities[ecdsa_sha2_nistp256])
+ assert_equal({ from: :agent }, manager.known_identities[ecdsa_sha2_nistp384])
+ assert_equal({ from: :agent }, manager.known_identities[ecdsa_sha2_nistp521])
end
def test_only_identities_with_key_files_should_load_from_agent_of_keys_only_set
@@ -203,7 +201,7 @@ module Authentication
# do not override OpenSSL::PKey::EC#public_key
# (it will be called in transport/openssl.rb.)
- key.stubs(:public_key).returns(key) unless defined?(OpenSSL::PKey::EC) && key.public_key.kind_of?(OpenSSL::PKey::EC::Point)
+ key.stubs(:public_key).returns(key) unless key.public_key.is_a?(OpenSSL::PKey::EC::Point)
end
def stub_file_public_key(name, key)
@@ -237,18 +235,16 @@ module Authentication
@dsa ||= OpenSSL::PKey::DSA.new(512)
end
- if defined?(OpenSSL::PKey::EC)
- def ecdsa_sha2_nistp256
- @ecdsa_sha2_nistp256 ||= OpenSSL::PKey::EC.new("prime256v1").generate_key
- end
+ def ecdsa_sha2_nistp256
+ @ecdsa_sha2_nistp256 ||= OpenSSL::PKey::EC.new('prime256v1').generate_key
+ end
- def ecdsa_sha2_nistp384
- @ecdsa_sha2_nistp384 ||= OpenSSL::PKey::EC.new("secp384r1").generate_key
- end
+ def ecdsa_sha2_nistp384
+ @ecdsa_sha2_nistp384 ||= OpenSSL::PKey::EC.new('secp384r1').generate_key
+ end
- def ecdsa_sha2_nistp521
- @ecdsa_sha2_nistp521 ||= OpenSSL::PKey::EC.new("secp521r1").generate_key
- end
+ def ecdsa_sha2_nistp521
+ @ecdsa_sha2_nistp521 ||= OpenSSL::PKey::EC.new('secp521r1').generate_key
end
def agent