Made host to be the mandatory parameter for overload requests as well
This commit is contained in:
parent
9f5b675700
commit
239c36c868
@ -139,9 +139,10 @@ def validate_params(user, password, params):
|
||||
raise_error(403)
|
||||
return False
|
||||
if 'reason' not in params or \
|
||||
params['reason'] == 1 and 'vm_uuids' not in params or \
|
||||
params['reason'] == 0 and 'host' not in params or \
|
||||
'time' not in params:
|
||||
'host' not in params or \
|
||||
'time' not in params or \
|
||||
params['reason'] not in [0, 1] or \
|
||||
params['reason'] == 1 and 'vm_uuids' not in params:
|
||||
raise_error(400)
|
||||
return False
|
||||
if params['time'] + 5 < time.time():
|
||||
|
@ -68,15 +68,15 @@ class GlobalManager(TestCase):
|
||||
sha1('test2').hexdigest(),
|
||||
{'username': sha1('test1').hexdigest(),
|
||||
'password': sha1('test2').hexdigest(),
|
||||
'reason': 0,
|
||||
'host': 'test'})
|
||||
'host': 'test',
|
||||
'reason': 0})
|
||||
manager.validate_params(
|
||||
sha1('test1').hexdigest(),
|
||||
sha1('test').hexdigest(),
|
||||
{'username': sha1('test1').hexdigest(),
|
||||
'password': sha1('test2').hexdigest(),
|
||||
'reason': 0,
|
||||
'host': 'test'})
|
||||
'host': 'test',
|
||||
'reason': 0})
|
||||
|
||||
assert manager.validate_params(
|
||||
sha1('test1').hexdigest(),
|
||||
@ -84,6 +84,7 @@ class GlobalManager(TestCase):
|
||||
{'username': sha1('test1').hexdigest(),
|
||||
'password': sha1('test2').hexdigest(),
|
||||
'time': time.time(),
|
||||
'host': 'test',
|
||||
'reason': 1,
|
||||
'vm_uuids': ['qwe', 'asd']})
|
||||
|
||||
@ -93,11 +94,11 @@ class GlobalManager(TestCase):
|
||||
{'username': sha1('test1').hexdigest(),
|
||||
'password': sha1('test2').hexdigest(),
|
||||
'time': time.time(),
|
||||
'reason': 0,
|
||||
'host': 'test'})
|
||||
'host': 'test',
|
||||
'reason': 0})
|
||||
|
||||
with MockTransaction:
|
||||
expect(manager).raise_error(400).exactly(6).times()
|
||||
expect(manager).raise_error(400).exactly(7).times()
|
||||
manager.validate_params('test', 'test', {'username': 'test',
|
||||
'password': 'test',
|
||||
'time': time.time()})
|
||||
@ -123,6 +124,10 @@ class GlobalManager(TestCase):
|
||||
'password': 'test',
|
||||
'reason': 0,
|
||||
'vm_uuids': []})
|
||||
manager.validate_params('test', 'test', {'username': 'test',
|
||||
'password': 'test',
|
||||
'reason': 1,
|
||||
'vm_uuids': []})
|
||||
|
||||
with MockTransaction:
|
||||
expect(manager).raise_error(412).exactly(2).times()
|
||||
|
Loading…
x
Reference in New Issue
Block a user