LUXEMBOURG (Reuters) - Hungarian immigration officials should not have put a Nigerian asylum seeker through psychological tests to determine whether he was telling the truth that he was gay, the EU’s top court ruled on Thursday.

Effectively barring use of sexual orientation testing as an invasion of “the most intimate aspects” of life, the Court of Justice found that the unidentified man from Nigeria should not have been pressured into examinations that included drawing a picture of a person in the rain and the Rorschach ink-blot test.

The unnamed man filed a request for refugee status in the Hungarian city of Szeged in April 2015. At the time Hungary was starting to face a surge in illegal migrants from Africa and the Middle East crossing the EU border from Serbia.

The man based his claim on the fact that, as a homosexual, he faced persecution in his home country.

The EU court ruled: “The performance of such a test amounts to a disproportionate interference in the private life of the asylum seeker.” The Luxembourg-based judges noted that the EU executive has disputed the reliability of such tests.

In the Rorschach test a participant’s perceptions of inkblots are recorded and are then analyzed for clues about his or her personality characteristics and emotional functioning.

On the basis of the tests, the Hungarian state-appointed psychologist concluded that the Nigerian man was not homosexual and his claim was rejected, prompting an appeal.

In responding to the Hungarian court which referred the case, the ECJ said it was acceptable to seek expert opinion but this must be obtained in ways consistent with human rights and should not be the sole basis of a ruling.

Hungary’s right-wing government has been in the forefront of efforts, particularly among ex-communist states in the east, to stiffen the European Union’s frontiers against asylum seekers.

It was among the first countries hit by a wave of more than a million people who entered the EU via Greece in 2015 after taking to flimsy boats crossing the Mediterranean from Turkey.

That crisis shook the EU’s cohesion, and efforts to reform a common asylum policy remain a source of deep discord.