Honour --force-auth for anonymous commands
Fixes: https://pagure.io/koji/issue/2657
This commit is contained in:
parent
1269317618
commit
5d86608931
7 changed files with 30 additions and 16 deletions
|
|
@ -24,7 +24,7 @@ class TestDownloadLogs(utils.CliTestCase):
|
|||
'koji_cli.commands.list_task_output_all_volumes').start()
|
||||
self.ensuredir = mock.patch('koji.ensuredir').start()
|
||||
self.download_file = mock.patch('koji_cli.commands.download_file').start()
|
||||
self.activate_session = mock.patch('koji_cli.commands.activate_session').start()
|
||||
self.ensure_connection = mock.patch('koji_cli.commands.ensure_connection').start()
|
||||
self.stdout = mock.patch('sys.stdout', new_callable=six.StringIO).start()
|
||||
self.stderr = mock.patch('sys.stderr', new_callable=six.StringIO).start()
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class TestCliListTargets(utils.CliTestCase):
|
|||
time.tzset()
|
||||
|
||||
@mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
@mock.patch('koji_cli.commands.ensure_connection')
|
||||
def test_list_targets_error_args(self, ensure_connection_mock, stderr):
|
||||
session = mock.MagicMock(getAPIVersion=lambda: koji.API_VERSION,
|
||||
getBuildTargets=lambda n: [])
|
||||
|
|
@ -47,7 +47,7 @@ class TestCliListTargets(utils.CliTestCase):
|
|||
self.assertExitCode(ex, 2)
|
||||
|
||||
@mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
@mock.patch('koji_cli.commands.ensure_connection')
|
||||
def test_list_targets_error_all_not_found(self, ensure_connection_mock, stderr):
|
||||
session = mock.MagicMock(getAPIVersion=lambda: koji.API_VERSION,
|
||||
getBuildTargets=lambda n: [])
|
||||
|
|
@ -60,7 +60,7 @@ class TestCliListTargets(utils.CliTestCase):
|
|||
@mock.patch('optparse.OptionParser.parse_args',
|
||||
return_value=(Values({'quiet': False, 'name': 'f50'}), []))
|
||||
@mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
@mock.patch('koji_cli.commands.ensure_connection')
|
||||
def test_list_targets_error_name_not_found(self, ensure_connection_mock, stderr, opt):
|
||||
session = mock.MagicMock(getAPIVersion=lambda: koji.API_VERSION,
|
||||
getBuildTargets=lambda n: [])
|
||||
|
|
@ -71,7 +71,7 @@ class TestCliListTargets(utils.CliTestCase):
|
|||
self.assertTrue('No such build target:' in stderr.getvalue())
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
@mock.patch('koji_cli.commands.ensure_connection')
|
||||
def test_list_targets_all(self, ensure_connection_mock, stdout):
|
||||
session = mock.MagicMock(getAPIVersion=lambda: koji.API_VERSION,
|
||||
getBuildTargets=lambda n: _mock_targets)
|
||||
|
|
@ -88,7 +88,7 @@ class TestCliListTargets(utils.CliTestCase):
|
|||
@mock.patch('optparse.OptionParser.parse_args',
|
||||
return_value=(Values({'quiet': False, 'name': 'f50'}), []))
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
@mock.patch('koji_cli.commands.ensure_connection')
|
||||
def test_list_targets_one(self, ensure_connection_mock, stdout, opt):
|
||||
session = mock.MagicMock(getAPIVersion=lambda: koji.API_VERSION,
|
||||
getBuildTargets=lambda n: _mock_targets)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import mock
|
|||
import six
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_list_volumes
|
||||
from koji_cli.commands import anon_handle_list_volumes
|
||||
from . import utils
|
||||
|
||||
|
||||
|
|
@ -13,12 +13,12 @@ class TestListVolumes(utils.CliTestCase):
|
|||
maxDiff = None
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
def test_handle_list_volumes(
|
||||
@mock.patch('koji_cli.commands.ensure_connection')
|
||||
def test_anon_handle_list_volumes(
|
||||
self,
|
||||
activate_session_mock,
|
||||
ensure_connection_mock,
|
||||
stdout):
|
||||
"""Test handle_list_volumes function"""
|
||||
"""Test anon_handle_list_volumes function"""
|
||||
session = mock.MagicMock()
|
||||
options = mock.MagicMock()
|
||||
vol_info = [
|
||||
|
|
@ -29,12 +29,12 @@ class TestListVolumes(utils.CliTestCase):
|
|||
|
||||
expected = "\n".join([v['name'] for v in vol_info]) + "\n"
|
||||
session.listVolumes.return_value = vol_info
|
||||
handle_list_volumes(options, session, [])
|
||||
anon_handle_list_volumes(options, session, [])
|
||||
self.assert_console_message(stdout, expected)
|
||||
|
||||
def test_handle_list_volumes_help(self):
|
||||
def test_anon_handle_list_volumes_help(self):
|
||||
self.assert_help(
|
||||
handle_list_volumes,
|
||||
anon_handle_list_volumes,
|
||||
"""Usage: %s list-volumes
|
||||
(Specify the --help global option for a list of other help options)
|
||||
|
||||
|
|
|
|||
|
|
@ -20,10 +20,12 @@ Available search types: package, build, tag, target, user, host, rpm, maven, win
|
|||
%s: error: {message}
|
||||
""" % (self.progname, self.progname)
|
||||
|
||||
@mock.patch('koji_cli.commands.ensure_connection')
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
def test_anon_handle_search(
|
||||
self,
|
||||
stdout):
|
||||
stdout,
|
||||
ensure_connection_mock):
|
||||
"""Test anon_handle_search function"""
|
||||
session = mock.MagicMock()
|
||||
options = mock.MagicMock()
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ class TestWaitRepo(utils.CliTestCase):
|
|||
|
||||
def setUpMocks(self):
|
||||
self.activate_session = mock.patch('koji_cli.commands.activate_session').start()
|
||||
self.ensure_connection = mock.patch('koji_cli.commands.ensure_connection').start()
|
||||
self.checkForBuilds = mock.patch('koji.util.checkForBuilds').start()
|
||||
|
||||
def tearDown(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue