Preheat the oven to 180°C (Gas Mark 4 / 350°F).
Heat a little oil in a frying pan, and add the finely diced onion. Cook over a medium heat for a couple of minutes, until slightly soft. Add the garlic and diced mushrooms, and cook for a further 5 minutes, or until the mushrooms are soft and any excess liquid has evaporated.
In a large bowl, combine the drained kidney beans, spices, and a very generous pinch of salt and pepper. Mash thoroughly with a potato masher or fork - it's okay to leave some texture, but you don't want any full beans remaining.
Add the mushrooms to the mashed beans, and mix well.
Lightly grease a baking tray. Use clean hands to form the bean mixture into balls - I made 8 in total. Place the koftas on the tray, and spray again with oil. Bake for around 45 mins - 1 hour, or until the koftas are firm and crispy.
Meanwhile, add the pesto ingredients to a mini food processor, and blitz until fairly smooth.
When the koftas are cooked, serve them with the pesto and your choice of sides.