Being undercover is disguising
Deception, beguilement, deceit, bluff, mystification, bad faith, and subterfuge are acts to propagate beliefs that are not true, or not the whole truth . Deception can involve dissimulation, propaganda, and sleight of hand. It can employ distraction, camouflage or concealment...

 one's own identity or using an assumed identity for the purposes of gaining the trust of an individual or organization to learn secret information or to gain the trust of targeted individuals in order to gain information or evidence. Traditionally it is a technique employed by law enforcement agencies around the world and a person who works in such a role is commonly referred to as an undercover agent
Espionage or spying involves an individual obtaining information that is considered secret or confidential without the permission of the holder of the information. Espionage is inherently clandestine, lest the legitimate holder of the information change plans or take other countermeasures once it...

Undercover work has been used in a variety of ways throughout the course of history, but the first organized undercover program was first employed in France by Eugène François Vidocq
Eugène François Vidocq
Eugène François Vidocq was a French criminal and criminalist whose life story inspired several writers, including Victor Hugo and Honoré de Balzac...

 in the early 19th century.