Esempio n. 1
0
    def test_authcheck(self):
        rpc = RpcProcessor()

        func = RpcFunction(authcheck, 'authcheck', 'Returns rpcinfo content as string',
                'string', 'Returns a string to prove we got the authentication information')
        func.require_rpcinfo()

        rpc.add_function(func)
        rpcinfo = {'authenticated': True, 'username': '******'}
        reply = rpc.process_request('{"method": "authcheck", "params": [], "id": 1}',
                rpcinfo)
        self.assertEqual(reply['error'], None)
        self.assertEqual(reply['result'], 'Authenticated: True; Username: unittest')
Esempio n. 2
0
    def test_authcheck(self):
        rpc = RpcProcessor()

        func = RpcFunction(
            authcheck, 'authcheck', 'Returns rpcinfo content as string',
            'string',
            'Returns a string to prove we got the authentication information')
        func.require_rpcinfo()

        rpc.add_function(func)
        rpcinfo = {'authenticated': True, 'username': '******'}
        reply = rpc.process_request(
            '{"method": "authcheck", "params": [], "id": 1}', rpcinfo)
        self.assertEqual(reply['error'], None)
        self.assertEqual(reply['result'],
                         'Authenticated: True; Username: unittest')
Esempio n. 3
0

# Create service object
jsonrpc = RpcProcessor()
jsonrpc.set_description(
    "JSON Store Service",
    "JSON-RPC service for storing JSON objects in a PostgreSQL database",
    reflectrpc.version)

# Register functions
get_object_func = RpcFunction(get_object, 'get_object',
                              'Gets a JSON object by its UUID', 'hash',
                              'JSON object')
get_object_func.add_param('string', 'uuid',
                          'UUID of the JSON object to retrieve')
get_object_func.require_rpcinfo()
jsonrpc.add_function(get_object_func)

get_object_by_name_func = RpcFunction(get_object_by_name, 'get_object_by_name',
                                      'Gets a JSON object by its name', 'hash',
                                      'JSON object')
get_object_by_name_func.add_param('string', 'name',
                                  'Name of the JSON object to retrieve')
get_object_by_name_func.require_rpcinfo()
jsonrpc.add_function(get_object_by_name_func)

find_objects_func = RpcFunction(find_objects, 'find_objects',
                                'Finds JSON objects which match a filter',
                                'array<hash>', 'List of matching JSON object')
find_objects_func.add_param(
    'string', 'filter',
Esempio n. 4
0
        return True

    return d


# Create service object
jsonrpc = RpcProcessor()
jsonrpc.set_description("JSON Store Service",
        "JSON-RPC service for storing JSON objects in a PostgreSQL database",
        reflectrpc.version)

# Register functions
get_object_func = RpcFunction(get_object, 'get_object', 'Gets a JSON object by its UUID',
        'hash', 'JSON object')
get_object_func.add_param('string', 'uuid', 'UUID of the JSON object to retrieve')
get_object_func.require_rpcinfo()
jsonrpc.add_function(get_object_func)

get_object_by_name_func = RpcFunction(get_object_by_name, 'get_object_by_name', 'Gets a JSON object by its name', 'hash', 'JSON object')
get_object_by_name_func.add_param('string', 'name', 'Name of the JSON object to retrieve')
get_object_by_name_func.require_rpcinfo()
jsonrpc.add_function(get_object_by_name_func)

find_objects_func = RpcFunction(find_objects, 'find_objects', 'Finds JSON objects which match a filter', 'array<hash>', 'List of matching JSON object')
find_objects_func.add_param('string', 'filter', 'Filter for the JSON objects to retrieve (e.g. "field1 = \'test\' AND score > 3")')
find_objects_func.require_rpcinfo()
jsonrpc.add_function(find_objects_func)

insert_object_func = RpcFunction(insert_object, 'insert_object', 'Inserts a new JSON object',
        'bool', 'true on success, false on failure')
insert_object_func.add_param('hash', 'obj', 'The JSON object to insert')