fakehub --exclusive option
This commit is contained in:
parent
39db0015fe
commit
c4b5c5a107
1 changed files with 8 additions and 3 deletions
|
|
@ -38,7 +38,7 @@ def handle_rpc(self, environ):
|
|||
# Fake session for authenticated calls
|
||||
class FakeSession(auth.Session):
|
||||
|
||||
def __init__(self, user):
|
||||
def __init__(self, user, exclusive=False):
|
||||
user = kojihub.get_user(user, strict=True)
|
||||
self.logged_in = True
|
||||
self.id = 1
|
||||
|
|
@ -48,7 +48,7 @@ class FakeSession(auth.Session):
|
|||
self.master = None
|
||||
self.callnum = 1
|
||||
self.message = 'THIS IS A FAKE SESSION'
|
||||
self.exclusive = False
|
||||
self.exclusive = exclusive
|
||||
self.user_data = user
|
||||
self.session_data = {'msg': 'this is a fake session'}
|
||||
self._perms = None
|
||||
|
|
@ -62,7 +62,8 @@ original_check_session = kojixmlrpc.ModXMLRPCRequestHandler.check_session
|
|||
# alternate check_session, used to emulate auth
|
||||
def check_session(self):
|
||||
if 'KOJI_FAKEHUB_USER' in context.environ:
|
||||
context.session = FakeSession(context.environ['KOJI_FAKEHUB_USER'])
|
||||
context.session = FakeSession(context.environ['KOJI_FAKEHUB_USER'],
|
||||
context.environ.get('KOJI_FAKEHUB_EXCLUSIVE', False))
|
||||
else:
|
||||
original_check_session(self)
|
||||
|
||||
|
|
@ -101,6 +102,8 @@ def get_options():
|
|||
parser.add_option('--pdb', action='store_true',
|
||||
help='drop into pdb on error')
|
||||
parser.add_option('--user', '-u', help='execute as user')
|
||||
parser.add_option('--exclusive', '-x', action='store_true',
|
||||
help='emulate an exclusive session')
|
||||
opts, args = parser.parse_args()
|
||||
|
||||
# parse request from args
|
||||
|
|
@ -161,6 +164,8 @@ def main():
|
|||
if options.user:
|
||||
environ['KOJI_FAKEHUB_USER'] = options.user
|
||||
kojixmlrpc.ModXMLRPCRequestHandler.check_session = check_session
|
||||
if options.exclusive:
|
||||
environ['KOJI_FAKEHUB_EXCLUSIVE'] = True
|
||||
|
||||
set_config(environ)
|
||||
print('RESULT:')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue