The South African and Iranian foreign ministers have signed a cooperation deal ahead of the BRICS summit in Johannesburg, which Iranian President Ibrahim Raisi will attend.