test_tls.py (1028:2201c3f83ae3) test_tls.py (1029:687f7cc7aae2)
1import re
2import ssl
3import time
4import subprocess
5import unittest
6from unit.applications.tls import TestApplicationTLS
7
8

--- 397 unchanged lines hidden (view full) ---

406 200,
407 'certificate chain intermediate server',
408 )
409
410 @unittest.expectedFailure
411 def test_tls_reconfigure(self):
412 self.load('empty')
413
1import re
2import ssl
3import time
4import subprocess
5import unittest
6from unit.applications.tls import TestApplicationTLS
7
8

--- 397 unchanged lines hidden (view full) ---

406 200,
407 'certificate chain intermediate server',
408 )
409
410 @unittest.expectedFailure
411 def test_tls_reconfigure(self):
412 self.load('empty')
413
414 self.assertEqual(self.get()['status'], 200, 'init')
415
414 self.certificate()
415
416 (resp, sock) = self.get(
417 headers={'Host': 'localhost', 'Connection': 'keep-alive'},
418 start=True,
416 self.certificate()
417
418 (resp, sock) = self.get(
419 headers={'Host': 'localhost', 'Connection': 'keep-alive'},
420 start=True,
421 read_timeout=1,
419 )
420
421 self.assertEqual(resp['status'], 200, 'initial status')
422
423 self.add_tls()
424
425 self.assertEqual(
426 self.get(sock=sock)['status'], 200, 'reconfigure status'
427 )
428 self.assertEqual(
429 self.get_ssl()['status'], 200, 'reconfigure tls status'
430 )
431
432 def test_tls_keepalive(self):
433 self.load('mirror')
434
422 )
423
424 self.assertEqual(resp['status'], 200, 'initial status')
425
426 self.add_tls()
427
428 self.assertEqual(
429 self.get(sock=sock)['status'], 200, 'reconfigure status'
430 )
431 self.assertEqual(
432 self.get_ssl()['status'], 200, 'reconfigure tls status'
433 )
434
435 def test_tls_keepalive(self):
436 self.load('mirror')
437
438 self.assertEqual(self.get()['status'], 200, 'init')
439
435 self.certificate()
436
437 self.add_tls(application='mirror')
438
439 (resp, sock) = self.post_ssl(
440 headers={
441 'Host': 'localhost',
442 'Connection': 'keep-alive',
443 'Content-Type': 'text/html',
444 },
445 start=True,
446 body='0123456789',
440 self.certificate()
441
442 self.add_tls(application='mirror')
443
444 (resp, sock) = self.post_ssl(
445 headers={
446 'Host': 'localhost',
447 'Connection': 'keep-alive',
448 'Content-Type': 'text/html',
449 },
450 start=True,
451 body='0123456789',
452 read_timeout=1,
447 )
448
449 self.assertEqual(resp['body'], '0123456789', 'keepalive 1')
450
451 resp = self.post_ssl(
452 headers={
453 'Host': 'localhost',
454 'Connection': 'close',

--- 4 unchanged lines hidden (view full) ---

459 )
460
461 self.assertEqual(resp['body'], '0123456789', 'keepalive 2')
462
463 @unittest.expectedFailure
464 def test_tls_keepalive_certificate_remove(self):
465 self.load('empty')
466
453 )
454
455 self.assertEqual(resp['body'], '0123456789', 'keepalive 1')
456
457 resp = self.post_ssl(
458 headers={
459 'Host': 'localhost',
460 'Connection': 'close',

--- 4 unchanged lines hidden (view full) ---

465 )
466
467 self.assertEqual(resp['body'], '0123456789', 'keepalive 2')
468
469 @unittest.expectedFailure
470 def test_tls_keepalive_certificate_remove(self):
471 self.load('empty')
472
473 self.assertEqual(self.get()['status'], 200, 'init')
474
467 self.certificate()
468
469 self.add_tls()
470
471 (resp, sock) = self.get_ssl(
472 headers={'Host': 'localhost', 'Connection': 'keep-alive'},
473 start=True,
475 self.certificate()
476
477 self.add_tls()
478
479 (resp, sock) = self.get_ssl(
480 headers={'Host': 'localhost', 'Connection': 'keep-alive'},
481 start=True,
482 read_timeout=1,
474 )
475
476 self.conf({"application": "empty"}, 'listeners/*:7080')
477 self.conf_delete('/certificates/default')
478
479 try:
480 resp = self.get_ssl(
481 headers={'Host': 'localhost', 'Connection': 'close'}, sock=sock

--- 14 unchanged lines hidden (view full) ---

496 self.conf_delete('/certificates'),
497 'remove all certificates',
498 )
499
500 def test_tls_application_respawn(self):
501 self.skip_alerts.append(r'process \d+ exited on signal 9')
502 self.load('mirror')
503
483 )
484
485 self.conf({"application": "empty"}, 'listeners/*:7080')
486 self.conf_delete('/certificates/default')
487
488 try:
489 resp = self.get_ssl(
490 headers={'Host': 'localhost', 'Connection': 'close'}, sock=sock

--- 14 unchanged lines hidden (view full) ---

505 self.conf_delete('/certificates'),
506 'remove all certificates',
507 )
508
509 def test_tls_application_respawn(self):
510 self.skip_alerts.append(r'process \d+ exited on signal 9')
511 self.load('mirror')
512
513 self.assertEqual(self.get()['status'], 200, 'init')
514
504 self.certificate()
505
506 self.conf('1', 'applications/mirror/processes')
507
508 self.add_tls(application='mirror')
509
510 (resp, sock) = self.post_ssl(
511 headers={
512 'Host': 'localhost',
513 'Connection': 'keep-alive',
514 'Content-Type': 'text/html',
515 },
516 start=True,
517 body='0123456789',
515 self.certificate()
516
517 self.conf('1', 'applications/mirror/processes')
518
519 self.add_tls(application='mirror')
520
521 (resp, sock) = self.post_ssl(
522 headers={
523 'Host': 'localhost',
524 'Connection': 'keep-alive',
525 'Content-Type': 'text/html',
526 },
527 start=True,
528 body='0123456789',
529 read_timeout=1,
518 )
519
520 app_id = self.findall(r'(\d+)#\d+ "mirror" application started')[0]
521
522 subprocess.call(['kill', '-9', app_id])
523
524 self.wait_for_record(
525 re.compile(

--- 54 unchanged lines hidden ---
530 )
531
532 app_id = self.findall(r'(\d+)#\d+ "mirror" application started')[0]
533
534 subprocess.call(['kill', '-9', app_id])
535
536 self.wait_for_record(
537 re.compile(

--- 54 unchanged lines hidden ---