The police are not perfect, and this is definitely a teaching moment. Random searches are not permissible period.
Some great advice from a fellow Counselor.
1 Pull over in a safe spot
2 Turn the dome light on
3 Roll window down all the way
4 Put hand on steering wheel 10 and 2 am
5 Plead ignorance if asked why you are...