From 4326a3a75eb0fe0c381c129a6111dbaac359480d Mon Sep 17 00:00:00 2001
From: Chenxiong Qi <cqi@redhat.com>
Date: Jul 10 2017 10:04:25 +0000
Subject: Support reading koji config from profile


rpkg now is able to read Koji configuration by profile name. Original
kojiconfig is still available for use to keep original behavior, which
is deprecated and will be removed.

kojiconfig can be used by downstream client built on top of rpkg, that
will get deprecation message.

This change does not break Commands.__init__ and
Commands.container_build_koji in case they are reused in downstream
client whatever every argument is listed or *args and **kwargs are used.

Fix #187
Fix #197

Signed-off-by: Chenxiong Qi <cqi@redhat.com>

---

diff --git a/doc/use-kojiprofile.rst b/doc/use-kojiprofile.rst
new file mode 100644
index 0000000..38fae90
--- /dev/null
+++ b/doc/use-kojiprofile.rst
@@ -0,0 +1,20 @@
+Use kojiprofile
+===============
+
+``kojiprofile`` is supported from version 1.50, and ``kojiconfig`` is
+deprecated at same time. To migrate to ``kojiprofile``, please follow these
+steps below.
+
+* Add ``kojiprofile`` in your application's configuration file. For example,
+
+  ::
+
+    [myapp]
+    kojiprofile = koji
+
+* Remove deprecated ``kojiconfig`` from configuration file.
+
+* Replace argument ``kojiconfig`` with ``kojiprofile`` in ``Commands.__init__``.
+
+* Remove argument ``kojiconfig`` from ``Commands.container_build_koji``
+  argument list.
diff --git a/etc/rpkg/rpkg.conf b/etc/rpkg/rpkg.conf
index 40b6f15..eedc2c7 100644
--- a/etc/rpkg/rpkg.conf
+++ b/etc/rpkg/rpkg.conf
@@ -5,7 +5,7 @@ lookaside_cgi = https://localhost/repo/pkgs/upload.cgi
 gitbaseurl = ssh://%(user)s@localhost/%(module)s
 anongiturl = git://localhost/%(module)s
 branchre = f\d$|f\d\d$|el\d$|olpc\d$|master$
-kojiconfig = /etc/koji.conf
+kojiprofile = koji
 build_client = koji
 clone_config =
   bz.default-component %(module)s
diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py
index 0d6918b..3a7c2bc 100644
--- a/pyrpkg/__init__.py
+++ b/pyrpkg/__init__.py
@@ -71,7 +71,8 @@ class Commands(object):
 
     def __init__(self, path, lookaside, lookasidehash, lookaside_cgi,
                  gitbaseurl, anongiturl, branchre, kojiconfig,
-                 build_client, user=None,
+                 build_client,
+                 koji_config_type='kojiconfig', user=None,
                  dist=None, target=None, quiet=False,
                  distgit_namespaced=False, realms=None):
         """Init the object and some configuration details."""
@@ -92,7 +93,12 @@ class Commands(object):
         # The regex of branches we care about
         self.branchre = branchre
         # The location of the buildsys config file
-        self.kojiconfig = os.path.expanduser(kojiconfig)
+        self._compat_kojiconfig = koji_config_type == 'config'
+        if self._compat_kojiconfig:
+            self.kojiconfig = os.path.expanduser(kojiconfig)
+        else:
+            self.kojiprofile = kojiconfig
+        # Koji profile of buildsys to build packages
         # The buildsys client to use
         self.build_client = build_client
         # A way to override the discovered "distribution"
@@ -226,6 +232,13 @@ class Commands(object):
         return self._anon_kojisession
 
     def read_koji_config(self):
+        """Read Koji config from Koji configuration files or profile"""
+        if self._compat_kojiconfig:
+            return self._deprecated_read_koji_config()
+        else:
+            return koji.read_config(self.kojiprofile)
+
+    def _deprecated_read_koji_config(self):
         """Read Koji config from Koji configuration files"""
 
         # Stealing a bunch of code from /usr/bin/koji here, too bad it isn't
@@ -312,7 +325,7 @@ class Commands(object):
 
         session_opts = {}
         for name in opt_names:
-            if koji_config[name] is not None:
+            if name in koji_config and koji_config[name] is not None:
                 session_opts[name] = koji_config[name]
         return session_opts
 
@@ -2561,15 +2574,24 @@ class Commands(object):
             raise RuntimeError("Build has failed.")
 
     def container_build_koji(self, target_override=False, opts={},
-                             kojiconfig=None, build_client=None,
+                             kojiconfig=None, kojiprofile=None,
+                             build_client=None,
                              koji_task_watcher=None,
                              nowait=False):
         # check if repo is dirty and all commits are pushed
         self.check_repo()
         container_target = self.target if target_override else self.container_build_target
 
-        koji_session_backup = (self.build_client, self.kojiconfig)
-        (self.build_client, self.kojiconfig) = (build_client, kojiconfig)
+        # This is for backward-compatibility of deprecated kojiconfig.
+        # Signature of container_build_koji is not changed in case someone
+        # reuses this method in his app and keep it unbroken.
+        # Why to check names of kojiconfig and kojiprofile on Commands? Please
+        # see also Commands.__init__
+        if self._compat_kojiconfig:
+            koji_session_backup = (self.build_client, self.kojiconfig)
+        else:
+            koji_session_backup = (self.build_client, self.kojiprofile)
+
         try:
             self.load_kojisession()
             if "buildContainer" not in self.kojisession.system.listMethods():
@@ -2616,7 +2638,10 @@ class Commands(object):
                     log_result(self.log.info, result)
 
         finally:
-            (self.build_client, self.kojiconfig) = koji_session_backup
+            if self._compat_kojiconfig:
+                self.build_client, self.kojiconfig = koji_session_backup
+            else:
+                self.build_client, self.kojiprofile = koji_session_backup
             self.load_kojisession()
 
     def container_build_setup(self, get_autorebuild=None,
diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py
index 22fd77f..2b060e1 100644
--- a/pyrpkg/cli.py
+++ b/pyrpkg/cli.py
@@ -120,6 +120,25 @@ class cliClient(object):
                   for realm in items.get("kerberos_realms", '').split(',')
                   if realm]
 
+        kojiconfig = None
+
+        if self.config.has_option(self.name, 'kojiconfig'):
+            kojiconfig = self.config.get(self.name, 'kojiconfig')
+            koji_config_type = 'config'
+            warnings.warn(
+                'kojiconfig is deprecated. Instead, kojiprofile should be used.',
+                DeprecationWarning)
+
+        # kojiprofile has higher priority to be used if both kojiconfig and
+        # kojiprofile exist at same time.
+        if self.config.has_option(self.name, 'kojiprofile'):
+            kojiconfig = self.config.get(self.name, 'kojiprofile')
+            koji_config_type = 'profile'
+
+        if not kojiconfig:
+            raise rpkgError('Missing kojiconfig and kojiprofile to load Koji '
+                            'session. One of them must be specified.')
+
         # Create the cmd object
         self._cmd = self.site.Commands(self.args.path,
                                        items['lookaside'],
@@ -128,8 +147,9 @@ class cliClient(object):
                                        items['gitbaseurl'],
                                        items['anongiturl'],
                                        items['branchre'],
-                                       items['kojiconfig'],
+                                       kojiconfig,
                                        items['build_client'],
+                                       koji_config_type=koji_config_type,
                                        user=self.args.user,
                                        dist=self.args.dist or self.args.release,
                                        target=target,
@@ -1165,20 +1185,30 @@ see API KEY section of copr-cli(1) man page.
 
         if self.config.has_option(section_name, "kojiconfig"):
             kojiconfig = self.config.get(section_name, "kojiconfig")
+            kojiprofile = None
         else:
             err_args["option"] = "kojiconfig"
             self.log.debug(err_msg % err_args)
-            kojiconfig = self.config.get(self.name, "kojiconfig")
+            kojiprofile = self.config.get(self.name, "kojiconfig")
+
+        if self.config.has_option(section_name, "kojiprofile"):
+            kojiconfig = None
+            kojiprofile = self.config.get(section_name, "kojiprofile")
+        else:
+            err_args["option"] = "kojiprofile"
+            self.log.debug(err_msg % err_args)
+            kojiprofile = self.config.get(self.name, "kojiprofile")
 
         if self.config.has_option(section_name, "build_client"):
             build_client = self.config.get(section_name, "build_client")
         else:
-            err_args["option"] = "kojiconfig"
+            err_args["option"] = "build_client"
             self.log.debug(err_msg % err_args)
             build_client = self.config.get(self.name, "build_client")
 
         self.cmd.container_build_koji(target_override, opts=opts,
                                       kojiconfig=kojiconfig,
+                                      kojiprofile=kojiprofile,
                                       build_client=build_client,
                                       koji_task_watcher=self._watch_koji_tasks,
                                       nowait=self.args.nowait)
diff --git a/tests/commands/__init__.py b/tests/commands/__init__.py
index 2a8035e..388d2e0 100644
--- a/tests/commands/__init__.py
+++ b/tests/commands/__init__.py
@@ -23,7 +23,7 @@ class CommandTestCase(unittest.TestCase):
         self.lookasidehash = 'md5'
         self.lookaside_cgi = 'TODO'
         self.gitbaseurl = 'TODO'
-        self.kojiconfig = 'TODO'
+        self.kojiprofile = 'TODO'
         self.build_client = 'TODO'
         self.clone_config = '''
             bz.default-component %(module)s
diff --git a/tests/commands/test_add_tag.py b/tests/commands/test_add_tag.py
index e618f02..49dce86 100644
--- a/tests/commands/test_add_tag.py
+++ b/tests/commands/test_add_tag.py
@@ -25,7 +25,7 @@ class CommandAddTagTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
         cmd.clone(self.module, anon=True)
@@ -52,7 +52,7 @@ class CommandAddTagTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
         cmd.clone(self.module, anon=True)
@@ -74,7 +74,7 @@ class CommandAddTagTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
         cmd.clone(self.module, anon=True)
@@ -101,7 +101,7 @@ class CommandAddTagTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
         cmd.clone(self.module, anon=True)
@@ -127,7 +127,7 @@ class CommandAddTagTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
         cmd.clone(self.module, anon=True)
@@ -153,7 +153,7 @@ class CommandAddTagTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
         cmd.clone(self.module, anon=True)
diff --git a/tests/commands/test_check_repo.py b/tests/commands/test_check_repo.py
index 3cc2768..9f11d6f 100644
--- a/tests/commands/test_check_repo.py
+++ b/tests/commands/test_check_repo.py
@@ -29,7 +29,7 @@ class CheckRepoCase(CommandTestCase):
         self.cmd = pyrpkg.Commands(
             self.clonedir, self.lookaside, self.lookasidehash,
             self.lookaside_cgi, self.gitbaseurl,
-            self.anongiturl, self.branchre, self.kojiconfig,
+            self.anongiturl, self.branchre, self.kojiprofile,
             self.build_client, self.user, self.dist,
             self.target, self.quiet
         )
diff --git a/tests/commands/test_clone.py b/tests/commands/test_clone.py
index 5541a9b..2109e37 100644
--- a/tests/commands/test_clone.py
+++ b/tests/commands/test_clone.py
@@ -20,7 +20,7 @@ class CommandCloneTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
         cmd.clone_config = CLONE_CONFIG
@@ -40,7 +40,7 @@ class CommandCloneTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet, distgit_namespaced=True)
         cmd.clone_config = CLONE_CONFIG
@@ -61,7 +61,7 @@ class CommandCloneTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
         cmd.clone(self.module, anon=True, path=altpath)
@@ -81,7 +81,7 @@ class CommandCloneTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
         cmd.clone(self.module, anon=True, branch='rpkg-tests-1')
@@ -96,7 +96,7 @@ class CommandCloneTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
         cmd.clone(self.module, anon=True, bare_dir='%s.git' % self.module)
@@ -112,7 +112,7 @@ class CommandCloneTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
 
@@ -128,7 +128,7 @@ class CommandCloneTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
         cmd.clone(
@@ -146,7 +146,7 @@ class CommandCloneTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet, distgit_namespaced=True)
         cmd.clone(
diff --git a/tests/commands/test_delete_tag.py b/tests/commands/test_delete_tag.py
index fe67a4a..722ece7 100644
--- a/tests/commands/test_delete_tag.py
+++ b/tests/commands/test_delete_tag.py
@@ -13,7 +13,7 @@ class CommandDeleteTagTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
         cmd.clone(self.module, anon=True)
@@ -39,7 +39,7 @@ class CommandDeleteTagTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
         cmd.clone(self.module, anon=True)
diff --git a/tests/commands/test_list_tag.py b/tests/commands/test_list_tag.py
index 9827867..39dcb56 100644
--- a/tests/commands/test_list_tag.py
+++ b/tests/commands/test_list_tag.py
@@ -10,7 +10,7 @@ class CommandListTagTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
         cmd.clone(self.module, anon=True)
@@ -33,7 +33,7 @@ class CommandListTagTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
         cmd.clone(self.module, anon=True)
@@ -61,7 +61,7 @@ class CommandListTagTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
         cmd.clone(self.module, anon=True)
@@ -89,7 +89,7 @@ class CommandListTagTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
         cmd.clone(self.module, anon=True)
@@ -117,7 +117,7 @@ class CommandListTagTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
         cmd.clone(self.module, anon=True)
@@ -145,7 +145,7 @@ class CommandListTagTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
         cmd.clone(self.module, anon=True)
diff --git a/tests/commands/test_package_name.py b/tests/commands/test_package_name.py
index 69cf45a..6c61856 100644
--- a/tests/commands/test_package_name.py
+++ b/tests/commands/test_package_name.py
@@ -12,7 +12,7 @@ class CommandPackageNameTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
         cmd.clone(self.module, anon=True)
diff --git a/tests/commands/test_patch.py b/tests/commands/test_patch.py
index 878871a..672d2f3 100644
--- a/tests/commands/test_patch.py
+++ b/tests/commands/test_patch.py
@@ -22,7 +22,7 @@ class CommandPatchTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
         line, offset = cmd._byte_offset_to_line_number(self.text_ascii, 10)
@@ -34,7 +34,7 @@ class CommandPatchTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
 
@@ -47,7 +47,7 @@ class CommandPatchTestCase(CommandTestCase):
         import pyrpkg
         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
         text = self.text_utf8.decode('UTF-8', 'ignore')
diff --git a/tests/commands/test_push.py b/tests/commands/test_push.py
index 0c681f7..bb2d711 100644
--- a/tests/commands/test_push.py
+++ b/tests/commands/test_push.py
@@ -49,7 +49,7 @@ class CommandPushTestCase(CommandTestCase):
         cmd = pyrpkg.Commands(self.path, self.lookaside,
                               self.lookasidehash,
                               self.lookaside_cgi, self.gitbaseurl,
-                              self.anongiturl, self.branchre, self.kojiconfig,
+                              self.anongiturl, self.branchre, self.kojiprofile,
                               self.build_client, self.user, self.dist,
                               self.target, self.quiet)
         cmd.clone_config = CLONE_CONFIG
@@ -81,7 +81,7 @@ class TestPushWithPatches(CommandTestCase):
                                    self.lookasidehash,
                                    self.lookaside_cgi, self.gitbaseurl,
                                    self.anongiturl, self.branchre,
-                                   self.kojiconfig,
+                                   self.kojiprofile,
                                    self.build_client, self.user, self.dist,
                                    self.target, self.quiet)
         self.cmd.clone_config = CLONE_CONFIG
diff --git a/tests/fixtures/rpkg-ns.conf b/tests/fixtures/rpkg-ns.conf
index e3c49e1..22ab315 100644
--- a/tests/fixtures/rpkg-ns.conf
+++ b/tests/fixtures/rpkg-ns.conf
@@ -5,7 +5,7 @@ lookaside_cgi = https://localhost/repo/pkgs/upload.cgi
 gitbaseurl = ssh://%(user)s@localhost/%(module)s
 anongiturl = git://localhost/%(module)s
 branchre = f\d$|f\d\d$|el\d$|olpc\d$|master$
-kojiconfig = /etc/koji.conf
+kojiprofile = koji
 build_client = koji
 clone_config =
   bz.default-component %(module)s
diff --git a/tests/fixtures/rpkg.conf b/tests/fixtures/rpkg.conf
index 40b6f15..eedc2c7 100644
--- a/tests/fixtures/rpkg.conf
+++ b/tests/fixtures/rpkg.conf
@@ -5,7 +5,7 @@ lookaside_cgi = https://localhost/repo/pkgs/upload.cgi
 gitbaseurl = ssh://%(user)s@localhost/%(module)s
 anongiturl = git://localhost/%(module)s
 branchre = f\d$|f\d\d$|el\d$|olpc\d$|master$
-kojiconfig = /etc/koji.conf
+kojiprofile = koji
 build_client = koji
 clone_config =
   bz.default-component %(module)s
diff --git a/tests/utils.py b/tests/utils.py
index be25206..452219a 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -19,6 +19,7 @@ anongiturl = 'git://dist-git-qa.server/rpms/%(module)s'
 lookasidehash = 'md5'
 branchre = 'rhel'
 kojiconfig = '/path/to/koji.conf'
+kojiprofile = 'koji'
 build_client = 'koji'
 
 spec_file = '''

