コード例 #1
0
 def test_calling_refresh_cert_script_with_dead_instance(
         self, subprocess_mock):
     with mock.patch('os.path.exists', mock.Mock(return_value=True)):
         with mock.patch('os.listdir',
                         mock.Mock(return_value=[TEST_DOMAIN])):
             HostingRefreshSecureCustomDomainCertTask.delay()
     self.assertEqual(subprocess_mock.call_args[0][0],
                      [REMOVE_SSL_CERT_SCRIPT, TEST_DOMAIN])
コード例 #2
0
    def test_calling_refresh_cert_script_with_fresh_domain(self, utime_mock):
        with ignore_signal(pre_save, post_save):
            self.instance.domains = [TEST_DOMAIN]
            self.instance.save()

            self.hosting.domains = [TEST_DOMAIN]
            self.hosting.ssl_status = Hosting.SSL_STATUSES.ON
            self.hosting.save()

        with mock.patch('os.path.exists', mock.Mock(return_value=True)):
            with mock.patch('os.listdir',
                            mock.Mock(return_value=[TEST_DOMAIN])):
                HostingRefreshSecureCustomDomainCertTask.delay()
        set_current_instance(self.instance)
        utime_mock.assert_called_once()
コード例 #3
0
    def test_calling_refresh_cert_script(self, subprocess_mock):
        with ignore_signal(pre_save, post_save):
            self.instance.domains = [TEST_DOMAIN]
            self.instance.save()

            self.hosting.domains = [TEST_DOMAIN]
            self.hosting.ssl_status = Hosting.SSL_STATUSES.ON
            self.hosting.save()

        with mock.patch('os.path.exists', mock.Mock(return_value=True)):
            with mock.patch(
                    'os.listdir',
                    mock.Mock(
                        return_value=['.last_update', 'pem', TEST_DOMAIN])):
                HostingRefreshSecureCustomDomainCertTask.delay()
        self.assertEqual(subprocess_mock.call_args[0][0],
                         [RENEW_SSL_CERT_SCRIPT, TEST_DOMAIN])
        set_current_instance(self.instance)
        self.hosting.refresh_from_db()
        self.assertEqual(self.hosting.ssl_status, Hosting.SSL_STATUSES.ON)