def _test_certonly_csr_common(self, extra_args=None):
    certr = 'certr'
    chain = 'chain'
    mock_client = mock.MagicMock()
    mock_client.obtain_certificate_from_csr.return_value = (certr, chain)
    cert_path = os.path.normpath(os.path.join(self.config.config_dir, 'live/example.com/cert_512.pem'))
    full_path = os.path.normpath(os.path.join(self.config.config_dir, 'live/example.com/fullchain.pem'))
    mock_client.save_certificate.return_value = (cert_path, None, full_path)
    with mock.patch('certbot._internal.main._init_le_client') as mock_init:
        mock_init.return_value = mock_client
        with test_util.patch_get_utility() as mock_get_utility:
            chain_path = os.path.normpath(os.path.join(self.config.config_dir, 'live/example.com/chain.pem'))
            args = '-a standalone certonly --csr {0} --cert-path {1} --chain-path {2} --fullchain-path {3}'.format(CSR, cert_path, chain_path, full_path).split()
            if extra_args:
                args += extra_args
            with mock.patch('certbot._internal.main.crypto_util'):
                self._call(args)
    if ('--dry-run' in args):
        self.assertFalse(mock_client.save_certificate.called)
    else:
        mock_client.save_certificate.assert_called_once_with(certr, chain, cert_path, chain_path, full_path)
    return mock_get_utility
def _test_certonly_csr_common(self, extra_args=None):
    certr = 'certr'
    chain = 'chain'
    mock_client = mock.MagicMock()
    mock_client.obtain_certificate_from_csr.return_value = (certr, chain)
    cert_path = os.path.normpath(os.path.join(self.config.config_dir, 'live/example.com/cert_512.pem'))
    full_path = os.path.normpath(os.path.join(self.config.config_dir, 'live/example.com/fullchain.pem'))
    mock_client.save_certificate.return_value = (cert_path, None, full_path)
    with mock.patch('certbot._internal.main._init_le_client') as mock_init:
        mock_init.return_value = mock_client
        with test_util.patch_get_utility() as mock_get_utility:
            chain_path = os.path.normpath(os.path.join(self.config.config_dir, 'live/example.com/chain.pem'))
            args = '-a standalone certonly --csr {0} --cert-path {1} --chain-path {2} --fullchain-path {3}'.format(CSR, cert_path, chain_path, full_path).split()
            if extra_args:
                args += extra_args
            with mock.patch('certbot._internal.main.crypto_util'):
                self._call(args)
    if ('--dry-run' in args):
        self.assertFalse(mock_client.save_certificate.called)
    else:
        mock_client.save_certificate.assert_called_once_with(certr, chain, cert_path, chain_path, full_path)
    return mock_get_utility