Beispiel #1
0
 def test_renew_certificates(self, generate_key, generate_csr, generate_crt):
     generate_key.return_value = "secret-key"
     generate_csr.return_value = "domain-csr"
     renewer = le_renewer.LeRenewer(self.config)
     renewer.start()
     time.sleep(1)
     renewer.stop()
     self.assertEqual([mock.call()] * 5, generate_key.mock_calls)
     expected_csr_calls = [mock.call("secret-key", "i0.tsuru.io"),
                           mock.call("secret-key", "i1.tsuru.io"),
                           mock.call("secret-key", "i4.tsuru.io"),
                           mock.call("secret-key", "i5.tsuru.io"),
                           mock.call("secret-key", "i6.tsuru.io")]
     self.assertEqual(expected_csr_calls, generate_csr.mock_calls)
     expected_crt_calls = [mock.call(self.config, "instance0", "le", "domain-csr",
                                     "secret-key", "i0.tsuru.io"),
                           mock.call(self.config, "instance1", "le", "domain-csr",
                                     "secret-key", "i1.tsuru.io"),
                           mock.call(self.config, "instance4", "le", "domain-csr",
                                     "secret-key", "i4.tsuru.io"),
                           mock.call(self.config, "instance5", "le", "domain-csr",
                                     "secret-key", "i5.tsuru.io"),
                           mock.call(self.config, "instance6", "le", "domain-csr",
                                     "secret-key", "i6.tsuru.io")]
     self.assertEqual(expected_crt_calls, generate_crt.mock_calls)
Beispiel #2
0
api = Flask(__name__)
api.register_blueprint(router_api.router)
api.debug = check_option_enable(os.environ.get("API_DEBUG"))
handler = logging.StreamHandler()
if api.debug:
    logging.basicConfig(level=logging.DEBUG)
    handler.setLevel(logging.DEBUG)
else:
    handler.setLevel(logging.WARN)
api.logger.addHandler(handler)
hm.log.set_handler(handler)

if check_option_enable(os.environ.get("RUN_LE_RENEWER")):
    from rpaas.ssl_plugins import le_renewer
    le_renewer.LeRenewer().start()

SENTRY_DSN = os.environ.get("SENTRY_DSN")
if SENTRY_DSN:
    api.config['SENTRY_DSN'] = SENTRY_DSN
    sentry = Sentry(api)

if check_option_enable(os.environ.get("RUN_RESTORE_MACHINE")):
    from rpaas.healing import RestoreMachine
    RestoreMachine().start()

if check_option_enable(os.environ.get("RUN_RESTORE_MACHINE")) and \
   check_option_enable(os.environ.get("RUN_CHECK_MACHINE")):
    from rpaas.healing import CheckMachine
    CheckMachine().start()