From c77146a2722e877655d8f66ea2668e6c3098baa3 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Fri, 13 Oct 2017 13:34:12 -0400 Subject: [PATCH] Check for login earlier Ensure that assertLogin is called early to avoid confusing error messages. --- hub/kojihub.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hub/kojihub.py b/hub/kojihub.py index 10eed1b..05b83a1 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -8533,6 +8533,7 @@ class RootExports(object): channel: the channel to allocate the task to Returns the task id """ + context.session.assertLogin() if not opts: opts = {} taskOpts = {} @@ -8558,6 +8559,7 @@ class RootExports(object): channel: the channel to allocate the task to Returns a list of all the dependent task ids """ + context.session.assertLogin() if not opts: opts = {} taskOpts = {} @@ -8583,6 +8585,7 @@ class RootExports(object): Returns the task ID """ + context.session.assertLogin() if not context.opts.get('EnableMaven'): raise koji.GenericError("Maven support not enabled") if not opts: @@ -8613,6 +8616,7 @@ class RootExports(object): returns the task ID """ + context.session.assertLogin() if not context.opts.get('EnableMaven'): raise koji.GenericError("Maven support not enabled") @@ -8650,6 +8654,7 @@ class RootExports(object): Returns the task ID """ + context.session.assertLogin() if not context.opts.get('EnableMaven'): raise koji.GenericError("Maven support not enabled") taskOpts = {} @@ -8678,6 +8683,7 @@ class RootExports(object): Returns the task ID """ + context.session.assertLogin() if not context.opts.get('EnableWin'): raise koji.GenericError("Windows support not enabled") targ_info = self.getBuildTarget(target) @@ -9246,6 +9252,7 @@ class RootExports(object): The return value is the task id """ + context.session.assertLogin() #first some lookups and basic sanity checks build = get_build(build, strict=True) tag = get_tag(tag, strict=True) @@ -9295,6 +9302,7 @@ class RootExports(object): Unlike tagBuild, this does not create a task No return value""" #we can't staticmethod this one -- we're limiting the options + context.session.assertLogin() user_id = context.session.user_id tag_id = get_tag(tag, strict=True)['id'] build_id = get_build(build, strict=True)['id'] @@ -9332,6 +9340,7 @@ class RootExports(object): Returns the task id of the task performing the move""" + context.session.assertLogin() #lookups and basic sanity checks pkg_id = get_package_id(package, strict=True) tag1_id = get_tag_id(tag1, strict=True) @@ -9498,6 +9507,7 @@ class RootExports(object): If the build is associated with a task, cancel the task as well. Return True if the build was successfully canceled, False if not.""" + context.session.assertLogin() build = get_build(buildID) if build == None: return False @@ -9539,6 +9549,7 @@ class RootExports(object): def cancelTaskChildren(self, task_id): """Cancel a task's children, but not the task itself""" + context.session.assertLogin() task = Task(task_id) if not task.verifyOwner() and not task.verifyHost(): if not context.session.hasPerm('admin'): @@ -10545,6 +10556,7 @@ class RootExports(object): def resubmitTask(self, taskID): """Retry a canceled or failed task, using the same parameter as the original task. The logged-in user must be the owner of the original task or an admin.""" + context.session.assertLogin() task = Task(taskID) if not (task.isCanceled() or task.isFailed()): raise koji.GenericError('only canceled or failed tasks may be resubmitted') -- 2.9.5