|
203 | 203 | end
|
204 | 204 | end
|
205 | 205 |
|
| 206 | + context "when given the min_version: keyword argument" do |
| 207 | + subject { described_class } |
| 208 | + |
| 209 | + let(:context) { double(OpenSSL::SSL::SSLContext) } |
| 210 | + |
| 211 | + context "and it's 1" do |
| 212 | + it "must call OpenSSL::SSL::SSLContext#min_version= with OpenSSL::SSL::TLS1_VERSION" do |
| 213 | + expect(OpenSSL::SSL::SSLContext).to receive(:new).and_return(context) |
| 214 | + expect(context).to receive(:min_version=).with(OpenSSL::SSL::TLS1_VERSION) |
| 215 | + allow(context).to receive(:verify_mode=).with(0) |
| 216 | + |
| 217 | + subject.context(min_version: 1) |
| 218 | + end |
| 219 | + end |
| 220 | + |
| 221 | + context "and it's 1.1" do |
| 222 | + it "must call OpenSSL::SSL::SSLContext#min_version= with OpenSSL::SSL::TLS1_1_VERSION" do |
| 223 | + expect(OpenSSL::SSL::SSLContext).to receive(:new).and_return(context) |
| 224 | + expect(context).to receive(:min_version=).with(OpenSSL::SSL::TLS1_1_VERSION) |
| 225 | + allow(context).to receive(:verify_mode=).with(0) |
| 226 | + |
| 227 | + subject.context(min_version: 1.1) |
| 228 | + end |
| 229 | + end |
| 230 | + |
| 231 | + context "and it's 1_2" do |
| 232 | + it "must call OpenSSL::SSL::SSLContext#min_version= with OpenSSL::SSL::TLS1_2_VERSION" do |
| 233 | + expect(OpenSSL::SSL::SSLContext).to receive(:new).and_return(context) |
| 234 | + expect(context).to receive(:min_version=).with(OpenSSL::SSL::TLS1_2_VERSION) |
| 235 | + allow(context).to receive(:verify_mode=).with(0) |
| 236 | + |
| 237 | + subject.context(min_version: 1.2) |
| 238 | + end |
| 239 | + end |
| 240 | + |
| 241 | + context "and it's a Symbol" do |
| 242 | + let(:symbol) { :TLS1 } |
| 243 | + |
| 244 | + it "must call OpenSSL::SSL::SSLContext#min_version= with the Symbol" do |
| 245 | + expect(OpenSSL::SSL::SSLContext).to receive(:new).and_return(context) |
| 246 | + expect(context).to receive(:min_version=).with(symbol) |
| 247 | + allow(context).to receive(:verify_mode=).with(0) |
| 248 | + |
| 249 | + subject.context(min_version: symbol) |
| 250 | + end |
| 251 | + |
| 252 | + context "but it's :TLSv1" do |
| 253 | + it "must call OpenSSL::SSL::SSLContext#min_version= with OpenSSL::SSL::TLS1_VERSION" do |
| 254 | + expect(OpenSSL::SSL::SSLContext).to receive(:new).and_return(context) |
| 255 | + expect(context).to receive(:min_version=).with(OpenSSL::SSL::TLS1_VERSION) |
| 256 | + allow(context).to receive(:verify_mode=).with(0) |
| 257 | + |
| 258 | + subject.context(min_version: :TLSv1) |
| 259 | + end |
| 260 | + end |
| 261 | + |
| 262 | + context "but it's :TLSv1_1" do |
| 263 | + it "must call OpenSSL::SSL::SSLContext#min_version= with OpenSSL::SSL::TLS1_1_VERSION" do |
| 264 | + expect(OpenSSL::SSL::SSLContext).to receive(:new).and_return(context) |
| 265 | + expect(context).to receive(:min_version=).with(OpenSSL::SSL::TLS1_1_VERSION) |
| 266 | + allow(context).to receive(:verify_mode=).with(0) |
| 267 | + |
| 268 | + subject.context(min_version: :TLSv1_1) |
| 269 | + end |
| 270 | + end |
| 271 | + |
| 272 | + context "but it's :TLSv1_2" do |
| 273 | + it "must call OpenSSL::SSL::SSLContext#min_version= with OpenSSL::SSL::TLS1_2_VERSION" do |
| 274 | + expect(OpenSSL::SSL::SSLContext).to receive(:new).and_return(context) |
| 275 | + expect(context).to receive(:min_version=).with(OpenSSL::SSL::TLS1_2_VERSION) |
| 276 | + allow(context).to receive(:verify_mode=).with(0) |
| 277 | + |
| 278 | + subject.context(min_version: :TLSv1_2) |
| 279 | + end |
| 280 | + end |
| 281 | + end |
| 282 | + end |
| 283 | + |
| 284 | + context "when given the max_version: keyword argument" do |
| 285 | + subject { described_class } |
| 286 | + |
| 287 | + let(:context) { double(OpenSSL::SSL::SSLContext) } |
| 288 | + |
| 289 | + context "and it's 1" do |
| 290 | + it "must call OpenSSL::SSL::SSLContext#max_version= with OpenSSL::SSL::TLS1_VERSION" do |
| 291 | + expect(OpenSSL::SSL::SSLContext).to receive(:new).and_return(context) |
| 292 | + expect(context).to receive(:max_version=).with(OpenSSL::SSL::TLS1_VERSION) |
| 293 | + allow(context).to receive(:verify_mode=).with(0) |
| 294 | + |
| 295 | + subject.context(max_version: 1) |
| 296 | + end |
| 297 | + end |
| 298 | + |
| 299 | + context "and it's 1.1" do |
| 300 | + it "must call OpenSSL::SSL::SSLContext#max_version= with OpenSSL::SSL::TLS1_1_VERSION" do |
| 301 | + expect(OpenSSL::SSL::SSLContext).to receive(:new).and_return(context) |
| 302 | + expect(context).to receive(:max_version=).with(OpenSSL::SSL::TLS1_1_VERSION) |
| 303 | + allow(context).to receive(:verify_mode=).with(0) |
| 304 | + |
| 305 | + subject.context(max_version: 1.1) |
| 306 | + end |
| 307 | + end |
| 308 | + |
| 309 | + context "and it's 1_2" do |
| 310 | + it "must call OpenSSL::SSL::SSLContext#max_version= with OpenSSL::SSL::TLS1_2_VERSION" do |
| 311 | + expect(OpenSSL::SSL::SSLContext).to receive(:new).and_return(context) |
| 312 | + expect(context).to receive(:max_version=).with(OpenSSL::SSL::TLS1_2_VERSION) |
| 313 | + allow(context).to receive(:verify_mode=).with(0) |
| 314 | + |
| 315 | + subject.context(max_version: 1.2) |
| 316 | + end |
| 317 | + end |
| 318 | + |
| 319 | + context "and it's a Symbol" do |
| 320 | + let(:symbol) { :TLS1 } |
| 321 | + |
| 322 | + it "must call OpenSSL::SSL::SSLContext#max_version= with the Symbol" do |
| 323 | + expect(OpenSSL::SSL::SSLContext).to receive(:new).and_return(context) |
| 324 | + expect(context).to receive(:max_version=).with(symbol) |
| 325 | + allow(context).to receive(:verify_mode=).with(0) |
| 326 | + |
| 327 | + subject.context(max_version: symbol) |
| 328 | + end |
| 329 | + |
| 330 | + context "but it's :TLSv1" do |
| 331 | + it "must call OpenSSL::SSL::SSLContext#max_version= with OpenSSL::SSL::TLS1_VERSION" do |
| 332 | + expect(OpenSSL::SSL::SSLContext).to receive(:new).and_return(context) |
| 333 | + expect(context).to receive(:max_version=).with(OpenSSL::SSL::TLS1_VERSION) |
| 334 | + allow(context).to receive(:verify_mode=).with(0) |
| 335 | + |
| 336 | + subject.context(max_version: :TLSv1) |
| 337 | + end |
| 338 | + end |
| 339 | + |
| 340 | + context "but it's :TLSv1_1" do |
| 341 | + it "must call OpenSSL::SSL::SSLContext#max_version= with OpenSSL::SSL::TLS1_1_VERSION" do |
| 342 | + expect(OpenSSL::SSL::SSLContext).to receive(:new).and_return(context) |
| 343 | + expect(context).to receive(:max_version=).with(OpenSSL::SSL::TLS1_1_VERSION) |
| 344 | + allow(context).to receive(:verify_mode=).with(0) |
| 345 | + |
| 346 | + subject.context(max_version: :TLSv1_1) |
| 347 | + end |
| 348 | + end |
| 349 | + |
| 350 | + context "but it's :TLSv1_2" do |
| 351 | + it "must call OpenSSL::SSL::SSLContext#max_version= with OpenSSL::SSL::TLS1_2_VERSION" do |
| 352 | + expect(OpenSSL::SSL::SSLContext).to receive(:new).and_return(context) |
| 353 | + expect(context).to receive(:max_version=).with(OpenSSL::SSL::TLS1_2_VERSION) |
| 354 | + allow(context).to receive(:verify_mode=).with(0) |
| 355 | + |
| 356 | + subject.context(max_version: :TLSv1_2) |
| 357 | + end |
| 358 | + end |
| 359 | + end |
| 360 | + end |
| 361 | + |
206 | 362 | context "when given the verify: keyword argument" do
|
207 | 363 | subject { described_class.context(verify: :peer) }
|
208 | 364 |
|
|
0 commit comments