コード例 #1
0
    def fromRawObject(obj):
        if obj.get("jsonrpc") != "2.0":
            raise exception.JsonRpcInvalidRequestError(
                "Wrong protocol version",
                request=obj
            )

        method = obj.get("method")
        if method is None:
            raise exception.JsonRpcInvalidRequestError(
                "missing method header in method",
                request=obj
            )

        reqId = obj.get("id")
        # when sending notifications id is not provided

        params = obj.get('params', [])
        if not isinstance(params, (list, dict)):
            raise exception.JsonRpcInvalidRequestError(
                "wrong params type",
                request=obj
            )

        return JsonRpcRequest(method, protect_passwords(params), reqId)
コード例 #2
0
ファイル: __init__.py プロジェクト: nirs/vdsm
    def fromRawObject(obj):
        if obj.get("jsonrpc") != "2.0":
            raise exception.JsonRpcInvalidRequestError(
                "Wrong protocol version",
                request=obj
            )

        method = obj.get("method")
        if method is None:
            raise exception.JsonRpcInvalidRequestError(
                "missing method header in method",
                request=obj
            )

        reqId = obj.get("id")
        # when sending notifications id is not provided

        params = obj.get('params', [])
        if not isinstance(params, (list, dict)):
            raise exception.JsonRpcInvalidRequestError(
                "wrong params type",
                request=obj
            )

        return JsonRpcRequest(method, protect_passwords(params), reqId)
コード例 #3
0
 def test_protect_lists_of_dicts(self):
     unprotected = lists_of_dicts_unprotected()
     protected = lists_of_dicts_protected()
     self.assertEqual(protected, protect_passwords(unprotected))
コード例 #4
0
 def test_protect_nested_dicts(self):
     unprotected = nested_dicts_unprotected()
     protected = nested_dicts_protected()
     self.assertEqual(protected, protect_passwords(unprotected))
コード例 #5
0
 def test_protect_dict(self):
     unprotected = dict_unprotedted()
     protected = dict_protected()
     self.assertEqual(protected, protect_passwords(unprotected))
コード例 #6
0
 def test_protect_empty(self, params):
     self.assertEqual(params, protect_passwords(params))
コード例 #7
0
ファイル: passwords_test.py プロジェクト: nirs/vdsm
 def test_protect_nested_dicts(self):
     unprotected = nested_dicts_unprotected()
     protected = nested_dicts_protected()
     self.assertEqual(protected, protect_passwords(unprotected))
コード例 #8
0
ファイル: passwords_test.py プロジェクト: nirs/vdsm
 def test_protect_dict(self):
     unprotected = dict_unprotedted()
     protected = dict_protected()
     self.assertEqual(protected, protect_passwords(unprotected))