|
404 | 404 | it "uses ssl if it enabled using the ssl: true parameter" do |
405 | 405 | expect(OpenSSL::SSL::SSLSocket).to receive(:new).and_return(ssl_socket) |
406 | 406 | expect(ssl_socket).to receive(:connect) |
| 407 | + expect(ssl_socket).to receive(:post_connection_check).with("mqtt.example.com") |
407 | 408 |
|
408 | 409 | client = MQTT::Client.new("mqtt.example.com", ssl: true) |
409 | 410 | allow(client).to receive(:receive_connack) |
|
413 | 414 | it "uses ssl if it enabled using the mqtts:// scheme" do |
414 | 415 | expect(OpenSSL::SSL::SSLSocket).to receive(:new).and_return(ssl_socket) |
415 | 416 | expect(ssl_socket).to receive(:connect) |
| 417 | + expect(ssl_socket).to receive(:post_connection_check).with("mqtt.example.com") |
416 | 418 |
|
417 | 419 | client = MQTT::Client.new("mqtts://mqtt.example.com") |
418 | 420 | allow(client).to receive(:receive_connack) |
|
422 | 424 | it "uses set the SSL version, if the :ssl parameter is a symbol" do |
423 | 425 | expect(OpenSSL::SSL::SSLSocket).to receive(:new).and_return(ssl_socket) |
424 | 426 | expect(ssl_socket).to receive(:connect) |
| 427 | + expect(ssl_socket).to receive(:post_connection_check).with("mqtt.example.com") |
425 | 428 |
|
426 | 429 | client = MQTT::Client.new("mqtt.example.com", ssl: :TLSv1) |
427 | 430 | expect(client.ssl_context).to receive("ssl_version=").with(:TLSv1) |
|
432 | 435 | it "uses set hostname on the SSL socket for SNI" do |
433 | 436 | expect(OpenSSL::SSL::SSLSocket).to receive(:new).and_return(ssl_socket) |
434 | 437 | expect(ssl_socket).to receive(:hostname=).with("mqtt.example.com") |
| 438 | + expect(ssl_socket).to receive(:post_connection_check).with("mqtt.example.com") |
435 | 439 |
|
436 | 440 | client = MQTT::Client.new("mqtts://mqtt.example.com") |
437 | 441 | allow(client).to receive(:receive_connack) |
438 | 442 | client.connect |
439 | 443 | end |
| 444 | + |
| 445 | + it "skips host verification" do |
| 446 | + expect(OpenSSL::SSL::SSLSocket).to receive(:new).and_return(ssl_socket) |
| 447 | + expect(ssl_socket).to receive(:connect) |
| 448 | + |
| 449 | + client = MQTT::Client.new("mqtt.example.com", ssl: true, verify_host: false) |
| 450 | + allow(client).to receive(:receive_connack) |
| 451 | + client.connect |
| 452 | + end |
440 | 453 | end |
441 | 454 |
|
442 | 455 | context "with a last will and testament set" do |
|
0 commit comments