|
328 | 328 | end
|
329 | 329 | end
|
330 | 330 |
|
| 331 | + describe 'with tls' do |
| 332 | + context 'enabled' do |
| 333 | + let :params do |
| 334 | + { |
| 335 | + tls: true, |
| 336 | + tls_mode: 'requireTLS', |
| 337 | + tls_key: '/etc/ssl/mongodb.pem' |
| 338 | + } |
| 339 | + end |
| 340 | + |
| 341 | + it { |
| 342 | + is_expected.to contain_file(config_file). |
| 343 | + with_content(%r{^net\.tls\.mode: requireTLS$}). |
| 344 | + with_content(%r{^net\.tls\.certificateKeyFile: /etc/ssl/mongodb.pem$}) |
| 345 | + } |
| 346 | + end |
| 347 | + |
| 348 | + context 'disabled' do |
| 349 | + let :params do |
| 350 | + { |
| 351 | + tls: false |
| 352 | + } |
| 353 | + end |
| 354 | + |
| 355 | + it { |
| 356 | + is_expected.not_to contain_file(config_file). |
| 357 | + with_content(%r{net\.tls\.mode}). |
| 358 | + with_content(%r{net\.tls\.certificateKeyFile}) |
| 359 | + } |
| 360 | + end |
| 361 | + end |
| 362 | + |
| 363 | + describe 'with tls and client certificate validation' do |
| 364 | + context 'enabled' do |
| 365 | + let :params do |
| 366 | + { |
| 367 | + tls: true, |
| 368 | + tls_mode: 'requireTLS', |
| 369 | + tls_key: '/etc/ssl/mongodb.pem', |
| 370 | + tls_ca: '/etc/ssl/caToValidateClientCertificates.pem' |
| 371 | + } |
| 372 | + end |
| 373 | + |
| 374 | + it { |
| 375 | + is_expected.to contain_file(config_file). |
| 376 | + with_content(%r{^net\.tls\.mode: requireTLS$}). |
| 377 | + with_content(%r{^net\.tls\.certificateKeyFile: /etc/ssl/mongodb.pem$}). |
| 378 | + with_content(%r{^net\.tls\.CAFile: /etc/ssl/caToValidateClientCertificates.pem$}) |
| 379 | + } |
| 380 | + end |
| 381 | + |
| 382 | + context 'client certificate validation disabled but tls enabled' do |
| 383 | + let :params do |
| 384 | + { |
| 385 | + tls: true, |
| 386 | + tls_mode: 'requireTLS', |
| 387 | + tls_key: '/etc/ssl/mongodb.pem' |
| 388 | + } |
| 389 | + end |
| 390 | + |
| 391 | + it { |
| 392 | + is_expected.to contain_file(config_file). |
| 393 | + with_content(%r{^net\.tls\.mode: requireTLS$}). |
| 394 | + with_content(%r{^net\.tls\.certificateKeyFile: /etc/ssl/mongodb.pem$}) |
| 395 | + is_expected.not_to contain_file(config_file). |
| 396 | + with_content(%r{net\.tls\.CAFile}) |
| 397 | + } |
| 398 | + end |
| 399 | + |
| 400 | + context 'disabled' do |
| 401 | + let :params do |
| 402 | + { |
| 403 | + tls: false |
| 404 | + } |
| 405 | + end |
| 406 | + |
| 407 | + it { is_expected.not_to contain_file(config_file).with_content(%r{net\.tls\.CAFile}) } |
| 408 | + end |
| 409 | + end |
| 410 | + |
| 411 | + describe 'with tls, client certificate validation and allow connection without certificates' do |
| 412 | + context 'enabled' do |
| 413 | + let :params do |
| 414 | + { |
| 415 | + tls: true, |
| 416 | + tls_mode: 'requireTLS', |
| 417 | + tls_key: '/etc/ssl/mongodb.pem', |
| 418 | + tls_ca: '/etc/ssl/caToValidateClientCertificates.pem', |
| 419 | + tls_conn_without_cert: true |
| 420 | + } |
| 421 | + end |
| 422 | + |
| 423 | + it { |
| 424 | + is_expected.to contain_file(config_file). |
| 425 | + with_content(%r{^net\.tls\.mode: requireTLS$}). |
| 426 | + with_content(%r{^net\.tls\.certificateKeyFile: /etc/ssl/mongodb.pem$}). |
| 427 | + with_content(%r{^net\.tls\.CAFile: /etc/ssl/caToValidateClientCertificates.pem$}). |
| 428 | + with_content(%r{^net\.tls\.allowConnectionsWithoutCertificates: true$}) |
| 429 | + } |
| 430 | + end |
| 431 | + |
| 432 | + context 'connection without certificates disabled but tls and client certificate validation enabled' do |
| 433 | + let :params do |
| 434 | + { |
| 435 | + tls: true, |
| 436 | + tls_mode: 'requireTLS', |
| 437 | + tls_key: '/etc/ssl/mongodb.pem', |
| 438 | + tls_ca: '/etc/ssl/caToValidateClientCertificates.pem', |
| 439 | + tls_conn_without_cert: false |
| 440 | + } |
| 441 | + end |
| 442 | + |
| 443 | + it { |
| 444 | + is_expected.to contain_file(config_file). |
| 445 | + with_content(%r{^net\.tls\.mode: requireTLS$}). |
| 446 | + with_content(%r{^net\.tls\.certificateKeyFile: /etc/ssl/mongodb.pem$}). |
| 447 | + with_content(%r{net\.tls\.CAFile}) |
| 448 | + is_expected.not_to contain_file(config_file). |
| 449 | + with_content(%r{net\.tls\.allowConnectionsWithoutCertificates:\s*true}) |
| 450 | + } |
| 451 | + end |
| 452 | + |
| 453 | + context 'disabled' do |
| 454 | + let :params do |
| 455 | + { |
| 456 | + tls: false |
| 457 | + } |
| 458 | + end |
| 459 | + |
| 460 | + it { is_expected.not_to contain_file(config_file).with_content(%r{net\.tls\.allowConnectionsWithoutCertificates:\s*true}) } |
| 461 | + end |
| 462 | + end |
| 463 | + |
| 464 | + describe 'with tls and allow invalid hostnames' do |
| 465 | + context 'enabled' do |
| 466 | + let :params do |
| 467 | + { |
| 468 | + tls: true, |
| 469 | + tls_mode: 'requireTLS', |
| 470 | + tls_key: '/etc/ssl/mongodb.pem', |
| 471 | + tls_invalid_hostnames: true |
| 472 | + } |
| 473 | + end |
| 474 | + |
| 475 | + it { |
| 476 | + is_expected.to contain_file(config_file). |
| 477 | + with_content(%r{^net\.tls\.mode: requireTLS$}). |
| 478 | + with_content(%r{^net\.tls\.certificateKeyFile: /etc/ssl/mongodb.pem$}). |
| 479 | + with_content(%r{^net\.tls\.allowInvalidHostnames: true$}) |
| 480 | + } |
| 481 | + end |
| 482 | + |
| 483 | + context 'disallow invalid hostnames but tls enabled' do |
| 484 | + let :params do |
| 485 | + { |
| 486 | + tls: true, |
| 487 | + tls_mode: 'requireTLS', |
| 488 | + tls_key: '/etc/ssl/mongodb.pem', |
| 489 | + tls_invalid_hostnames: false |
| 490 | + } |
| 491 | + end |
| 492 | + |
| 493 | + it { |
| 494 | + is_expected.to contain_file(config_file). |
| 495 | + with_content(%r{^net\.tls\.mode: requireTLS$}). |
| 496 | + with_content(%r{^net\.tls\.certificateKeyFile: /etc/ssl/mongodb.pem$}) |
| 497 | + is_expected.not_to contain_file(config_file). |
| 498 | + with_content(%r{net\.tls\.allowInvalidHostnames:\s*true}) |
| 499 | + } |
| 500 | + end |
| 501 | + |
| 502 | + context 'disabled' do |
| 503 | + let :params do |
| 504 | + { |
| 505 | + tls: false |
| 506 | + } |
| 507 | + end |
| 508 | + |
| 509 | + it { is_expected.not_to contain_file(config_file).with_content(%r{net\.tls\.allowInvalidHostnames:\s*true}) } |
| 510 | + end |
| 511 | + end |
| 512 | + |
331 | 513 | context 'setting nohttpinterface' do
|
332 | 514 | it "isn't set when undef" do
|
333 | 515 | is_expected.not_to contain_file(config_file).with_content(%r{net\.http\.enabled})
|
|
0 commit comments