the joke I heard growing up is they'd ask suspected spies to sing the Star Spangled Banner, and shoot them if they knew the lyrics beyond the first verse!
In Issac Asimov's 1980 short story "No Refuge Could Save", the suspected German spy is identified by a word association test based on the third verse of the national anthem. https://en.wikipedia.org/wiki/No_Refuge_Could_Save
I don't remember the name of the film, but there was one where (Soviet I think?) spies were caught because they threw away their copies of National Geographic.