Skip to content

Commit

Permalink
Implement ssl_version and cipher on the StubSocket
Browse files Browse the repository at this point in the history
  • Loading branch information
rzane committed Aug 5, 2022
1 parent 0eb3a7b commit 5abd2f5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/webmock/http_lib_adapters/net_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ class StubIO
def setsockopt(*args); end
def peer_cert; end
def peeraddr; ["AF_INET", 443, "127.0.0.1", "127.0.0.1"] end
def ssl_version; "TLSv1.3" end
def cipher; ["TLS_AES_128_GCM_SHA256", "TLSv1.3", 128, 128] end
end
end

Expand Down
8 changes: 8 additions & 0 deletions spec/acceptance/net_http/net_http_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@ class TestMarshalingInWebMockNetHTTP
end
end

it "defines common socket methods" do
Net::HTTP.start("http://example.com") do |http|
socket = http.instance_variable_get(:@socket)
expect(socket.io.ssl_version).to eq("TLSv1.3")
expect(socket.io.cipher).to eq(["TLS_AES_128_GCM_SHA256", "TLSv1.3", 128, 128])
end
end

describe "connecting on Net::HTTP.start" do
before(:each) do
@http = Net::HTTP.new('www.google.com', 443)
Expand Down

0 comments on commit 5abd2f5

Please sign in to comment.