The German parliament has passed a law enabling federal states to offer drug-checking projects in June.