test cases repaired
This commit is contained in:
parent
691ed7afab
commit
a275bb034d
@ -125,6 +125,7 @@ class ClusterHandler(JSONHandler):
|
||||
# /additional validation needed?
|
||||
for key, value in data.iteritems():
|
||||
if key == "nodes":
|
||||
map(cluster.nodes.remove, cluster.nodes)
|
||||
nodes = web.ctx.orm.query(Node).filter(
|
||||
Node.id.in_(value)
|
||||
)
|
||||
@ -366,7 +367,9 @@ class RoleCollectionHandler(JSONHandler):
|
||||
|
||||
def GET(self):
|
||||
web.header('Content-Type', 'application/json')
|
||||
data = Role.validate_json(web.data())
|
||||
data = web.data() if web.data() else {}
|
||||
if data:
|
||||
data = Role.validate_json(data)
|
||||
if 'release_id' in data:
|
||||
return json.dumps(map(
|
||||
RoleHandler.render,
|
||||
|
@ -167,6 +167,8 @@ class Node(Base, BasicValidator):
|
||||
d = cls.validate_json(data)
|
||||
if not "mac" in d:
|
||||
raise web.webapi.badrequest(message="No mac address specified")
|
||||
if "id" in d:
|
||||
raise web.webapi.badrequest(message="Manual ID setting is prohibited")
|
||||
return d
|
||||
|
||||
@classmethod
|
||||
@ -174,6 +176,8 @@ class Node(Base, BasicValidator):
|
||||
d = cls.validate_json(data)
|
||||
if "status" in d and d["status"] not in cls.NODE_STATUSES:
|
||||
raise web.webapi.badrequest(message="Invalid status for node")
|
||||
if "id" in d:
|
||||
raise web.webapi.badrequest(message="Manual ID setting is prohibited")
|
||||
return d
|
||||
|
||||
|
||||
|
@ -12,10 +12,13 @@ class BasicValidator(object):
|
||||
res = json.loads(data)
|
||||
except:
|
||||
raise web.webapi.badrequest(
|
||||
message="Invalid json format!"
|
||||
message="Invalid json format"
|
||||
)
|
||||
return res
|
||||
return data
|
||||
else:
|
||||
raise web.webapi.badrequest(
|
||||
message="Empty request received"
|
||||
)
|
||||
return res
|
||||
|
||||
@classmethod
|
||||
def validate(cls, data):
|
||||
|
Loading…
Reference in New Issue
Block a user