Beispiel #1
0
 def test_apply_config_calls_disable_ssl_config_when_no_ssl_params_are_present(self):
     config = {
         "app_name": "myapp",
     }
     mock_verify = self.setUpPatch('hypernode.nodeconfig.sslcerts.verify_ssl')
     mock_disable = self.setUpPatch('hypernode.nodeconfig.sslcerts.disable_ssl')
     ssl.apply_config(config)
     assert not mock_verify.called
     assert mock_disable.called
Beispiel #2
0
 def test_apply_config_raises_exception_when_not_all_ssl_params_present(self):
     config = self.fixture.copy()
     del config["ssl_body"]
     self.assertRaises(Exception, ssl.apply_config, config)
     config = self.fixture.copy()
     del config["ssl_common_name"]
     self.assertRaises(Exception, ssl.apply_config, config)
     config = self.fixture.copy()
     del config["ssl_certificate"]
     self.assertRaises(Exception, ssl.apply_config, config)
     config = self.fixture.copy()
     config["ssl_key_chain"] = ''
     ssl.apply_config(config)  # No exception!
Beispiel #3
0
    def test_apply_config_writes_certificate_if_valid(self):
        self.setUpPatch('hypernode.nodeconfig.sslcerts.verify_ssl', mock.Mock(return_value=True))
        ret = ssl.apply_config(self.fixture)

        self.mock_writefile.assert_any_call("/etc/ssl/private/hypernode.ca", self.fixture['ssl_key_chain'], umask=0077)
        self.mock_writefile.assert_any_call("/etc/ssl/private/hypernode.crt", "%s\n\n%s" %
                                            (self.fixture['ssl_certificate'],
                                             self.fixture['ssl_body']), umask=0077)
Beispiel #4
0
 def test_apply_config_verifies_ssl_certificate(self):
     mock_verify = self.setUpPatch('hypernode.nodeconfig.sslcerts.verify_ssl', mock.Mock(return_value=True))
     ssl.apply_config(self.fixture)
     mock_verify.assert_called_once_with(self.fixture['ssl_certificate'],
                                         self.fixture['ssl_body'],
                                         self.fixture['ssl_key_chain'])
Beispiel #5
0
 def test_apply_config_doesnt_raise_exception_when_no_ssl_params_present(self):
     config = {
         "app_name": "myapp",
     }
     self.setUpPatch('hypernode.nodeconfig.sslcerts.disable_ssl')
     ssl.apply_config(config)
Beispiel #6
0
 def test_apply_config_checks_appname_var(self):
     self.setUpPatch('hypernode.nodeconfig.sslcerts.verify_ssl')
     ssl.apply_config(self.fixture)
     self.mock_checkvars.assert_called_once_with(self.fixture, ["app_name"])
Beispiel #7
0
    def test_apply_config_restarts_apache_if_certificate_is_valid(self):
        self.setUpPatch('hypernode.nodeconfig.sslcerts.verify_ssl')

        ssl.apply_config(self.fixture)
        self.mock_call.assert_called_once_with(["service", "apache2", "restart"])