It happened to my wife and I many years ago.
We had recently married and as she was pregnant we decided to have an holiday before we had the kids and forced to live in poverty until they left home.
We had a great holiday and were coming through customs when a male guard stopped us and escorted into a room. He asked us tons of questions, some of which we could not understand but you could tell something was wrong. He left us and we heard the lock turn. He returned an hour of so later with another male dressed in a white coat and speaking in better English he explained that drug suppliers were using couples with a pregnant women to export drugs. He apologized but said he had not choice other than go give us both a cavity search. My wife did not know what one was, but I did and protested, but the next thing I knew was that the guard had struck me on the back of my leg with his night stick.
The doctor then asked us both to address. When I told him that I wanted the male guard to go, he refused. We both started to undressed, my wife who was very shy was shaking with fear and embarrassment. By know I was naked, and my wife in her undies, seeing her bulging belly everyone could see that she was genuinely pregnant. He waited until my wife was naked and then run his fingers through our hair, checked under our arms and even made my wife lift one breast at a time to see that she was not concealing anything.
Putting on two pairs of rubber gloves he told me to bend over and support myself on the table. I did and the next thing I knew was he had his finger up my anus. Withdrawing it he took the glove off but my wife was now fully aware what was going to happen to her. She started to cry and I tried to cuddle her but I got beaten again. The doctor told her to assume the same position as I had, she did and I had to watch as he inserted a finger into her vagina and she cried even more, he then inserted his finger into her anus. When he was satisfied that we were both innocent, he simply took the glove off, threw it in the bin and walked out with the guard following him We were badly shaken but got dressed and thankfully got the next plane out.
It was of course a very distressing incident. What made it worse that as my wife's pregnancy progressed she need more exams many of them as intimate as the search. Back then men going to their wife's pre/post natal exams was a real taboo even though my wife asked them for me to be with her. A few doctors refused be fore me to come in the room with her, but after she got hysterical they let me in. It got so bad that she went to a physiologist until about a year after our first was born.
I accept the procedure has to be done, but it robs so many innocent people of their dignity.