There was a case recently of a NASA scientist being hassled at the border for his phone. He initially refused on the basis that handing it over would compromise his obligations to his employer. It did not work.
https://www.theverge.com/2017/2/12/14583124/nasa-sidd-bikkan...
Are allowed to? Maybe, maybe not. Will do anyway? Probably yes.