Admiral Chegwidden becomes suspicious and tests the imposter by asking about a fictional case, which Palmer-as-Harm fails to recognize as fake.
Where to the episode on platforms like Paramount+ or Amazon Prime Video. "JAG" Imposter (TV Episode 1998) - IMDb [S3E20] Imposter
Palmer leaves the real Harm bound to a chair in his apartment, which he has booby-trapped with a motion sensor bomb. The bomb is set to detonate if Harm moves or after eight hours. Admiral Chegwidden becomes suspicious and tests the imposter
Played both the real Harm and the imposter (Palmer in disguise). Clark Palmer [S3E20] Imposter