Skip to content

Consider adding support for mocha 2.7 or later #969

@loqs

Description

@loqs

Mocha 2.7 introduced a breaking change in d9a2254 Fail fast if invocation matches never expectation . Previously when an invocation matched an expectation which did not allow invocations (i.e. Expectation#never had been called on it), but the invocation also matched another expectation which did allow invocations, then the test would not fail with an unexpected invocation error. With the new bahavior there is one test failure:

Finished in 3.626117s, 440.6918 runs/s, 1475.1316 assertions/s.

  1) Failure:
Transport::TestAlgorithms#test_key_exchange_when_server_does_not_support_preferred_kex_should_fallback_to_secondary [lib/net/ssh/transport/algorithms.rb:450]:
unexpected invocation: Net::SSH::Transport::Kex::DiffieHellmanGroup14SHA1.new(#<Net::SSH::Transport::Algorithms:0x770>, #<MockTransport:0x7a0>, client_version_string: "SSH-2.0-Ruby/Net::SSH_7.3.0 x86_64-linux", server_version_string: "SSH-2.0-Ruby/Net::SSH::Test", server_algorithm_packet: "\x14\xA98\xF2<\x86%\xB3\b4x1\x89x}\xFC\xFD\x00\x00\x00\ediffie-hellman-group14-sha1\x00\x00\x00\x0Fssh-rsa,ssh-dss\x00\x00\x00raes256-ctr,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,idea-cbc\x00\x00\x00raes256-ctr,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,idea-cbc\x00\x00\x009hmac-sha2-256,hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96\x00\x00\x009hmac-sha2-256,hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96\x00\x00\x00\x1Anone,zlib@openssh.com,zlib\x00\x00\x00\x1Anone,zlib@openssh.com,zlib\x00\x00\x00\x00\x00\x00\x00\x00\x00", client_algorithm_packet: "\x14y\x8A\x13\x8Em\xE1\x15!\xEAT\xD9\xF7\x17\xCA}\x8F\x00\x00\x00\xC6curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1\x00\x00\x01?ssh-ed25519-cert-v01@openssh.com,ssh-ed25519,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,ssh-rsa-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512\x00\x00\x00Naes256-ctr,aes192-ctr,aes128-ctr,aes256-gcm@openssh.com,aes128-gcm@openssh.com\x00\x00\x00Naes256-ctr,aes192-ctr,aes128-ctr,aes256-gcm@openssh.com,aes128-gcm@openssh.com\x00\x00\x00ahmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-sha1\x00\x00\x00ahmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-sha1\x00\x00\x00\x1Anone,zlib@openssh.com,zlib\x00\x00\x00\x1Anone,zlib@openssh.com,zlib\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", need_bytes: 32, minimum_dh_bits: nil, logger: nil)
unsatisfied expectations:
- expected never, invoked once: Net::SSH::Transport::Kex::DiffieHellmanGroup14SHA1.new(any_parameters)
- expected exactly once, invoked never: Net::SSH::Transport::Kex::DiffieHellmanGroup1SHA1.new(#<Net::SSH::Transport::Algorithms:0x770>, #<MockTransport:0x7a0>, client_version_string: "SSH-2.0-Ruby/Net::SSH_7.3.0 x86_64-linux", server_version_string: "SSH-2.0-Ruby/Net::SSH::Test", server_algorithm_packet: "\x14\xA98\xF2<\x86%\xB3\b4x1\x89x}\xFC\xFD\x00\x00\x00\ediffie-hellman-group14-sha1\x00\x00\x00\x0Fssh-rsa,ssh-dss\x00\x00\x00raes256-ctr,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,idea-cbc\x00\x00\x00raes256-ctr,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,idea-cbc\x00\x00\x009hmac-sha2-256,hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96\x00\x00\x009hmac-sha2-256,hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96\x00\x00\x00\x1Anone,zlib@openssh.com,zlib\x00\x00\x00\x1Anone,zlib@openssh.com,zlib\x00\x00\x00\x00\x00\x00\x00\x00\x00", client_algorithm_packet: "\x14y\x8A\x13\x8Em\xE1\x15!\xEAT\xD9\xF7\x17\xCA}\x8F\x00\x00\x00\xC6curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1\x00\x00\x01?ssh-ed25519-cert-v01@openssh.com,ssh-ed25519,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,ssh-rsa-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512\x00\x00\x00Naes256-ctr,aes192-ctr,aes128-ctr,aes256-gcm@openssh.com,aes128-gcm@openssh.com\x00\x00\x00Naes256-ctr,aes192-ctr,aes128-ctr,aes256-gcm@openssh.com,aes128-gcm@openssh.com\x00\x00\x00ahmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-sha1\x00\x00\x00ahmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-sha1\x00\x00\x00\x1Anone,zlib@openssh.com,zlib\x00\x00\x00\x1Anone,zlib@openssh.com,zlib\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", need_bytes: 32, minimum_dh_bits: nil, logger: nil)
satisfied expectations:
- expected never, invoked never: Net::SSH::Transport::Kex::DiffieHellmanGroup14SHA256.new(any_parameters)
- expected never, invoked never: Net::SSH::Transport::Kex::DiffieHellmanGroupExchangeSHA1.new(any_parameters)
- expected never, invoked never: Net::SSH::Transport::Kex::DiffieHellmanGroupExchangeSHA256.new(any_parameters)
- expected never, invoked never: Net::SSH::Transport::Kex::EcdhSHA2NistP256.new(any_parameters)
- expected never, invoked never: Net::SSH::Transport::Kex::EcdhSHA2NistP384.new(any_parameters)
- expected never, invoked never: Net::SSH::Transport::Kex::EcdhSHA2NistP521.new(any_parameters)
- expected never, invoked never: Net::SSH::Transport::Kex::Curve25519Sha256.new(any_parameters)
- expected never, invoked never: Net::SSH::Transport::Kex::Curve25519Sha256.new(any_parameters)
- allowed any number of times, invoked never: #<Mock:kex>.exchange_keys(any_parameters)


1598 runs, 5349 assertions, 1 failures, 0 errors, 2 skips

Would it be possible to adapt the test to pass with Mocha 2.7?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions