The Buddha explains to King Pasenadi of Kosala how to recognize the character of another person.

Sattajaṭila sutta - Seven Matted-Hair Ascetics

Thus have I heard - At one time, the Blessed One was dwelling in Sāvatthi, in the Eastern Park, at Migāramāta's mansion. Now, at that time, the Blessed One, having emerged from seclusion in the early evening, was sitting outside by the door entrance. Then, King Pasenadi of Kosala approached the Blessed One; having approached, he paid homage to the Blessed One and sat to one side.

Now, at that time, seven matted-hair ascetics, seven Jain ascetics, seven unclothed ascetics, seven single-cloth ascetics, and seven wandering ascetics, with grown-out body hair and nails, carrying various kinds of equipment, were passing by not far from the Blessed One.

King Pasenadi of Kosala saw those seven matted-hair ascetics, seven Jain ascetics, seven single-cloth ascetics, and seven wandering ascetics, with grown-out body hair and nails, carrying various kinds of equipment, passing by not far from the Blessed One. Seeing them, he rose from his seat, arranged his robe over one shoulder, placed his right knee on the ground, and, with hands joined in reverential salutation toward them, three times he declared his name: "Venerable sirs, I am King Pasenadi of Kosala; I am King Pasenadi of Kosala; I am King Pasenadi of Kosala."

Then, shortly after those seven matted-hair ascetics, seven Jain ascetics, seven unclothed ascetics, seven single-cloth ascetics, and seven wandering ascetics had departed, King Pasenadi of Kosala approached the Blessed One. Having approached, he paid homage to the Blessed One and sat down to one side. While seated to one side, King Pasenadi of Kosala said this to the Blessed One: "Venerable sir, those in the world who are either Arahants or have attained the path to Arahantship these individuals are among them."

"It is hard for you to know this, great king, a householder who enjoys sensual pleasures, who lives amidst family, who uses sandalwood from Kāsi, who wears garlands, fragrances, and ointments, and who accepts gold and money whether these individuals are Arahants or have attained the path to Arahantship.

Through living together, great king, virtue can be known. But that is only known over a long time, not a short time; by one who is attentive, not inattentive; by one who is wise, not undiscerning. Through dealings, great king, integrity can be known. But that too is only known over a long time, not a short time; by one who is attentive, not inattentive; by one who is wise, not undiscerning. Through adversity, great king, resilience can be known. But that too is only known over a long time, not a short time; by one who is attentive, not inattentive; by one who is wise, not undiscerning. Through discussion, great king, wisdom can be known. But that too is known only over a long time, not a short time; by one who is attentive, not inattentive; by one who is wise, not undiscerning."

"Wonderful, venerable sir! Amazing, venerable sir! How well spoken this is by the Blessed One: 'It is hard for you to know this, great king, a householder who enjoys sensual pleasures, who lives amidst family, who uses sandalwood from Kāsi, who wears garlands, fragrances, and ointments, and who accepts gold and money whether these individuals are Arahants or have attained the path to Arahantship. Through living together, ethical conduct can be known. But that is only known over a long time, not a short time; by one who is attentive, not inattentive; by one who is wise, not undiscerning. Through dealings, integrity can be known. But that too is only known over a long time, not a short time; by one who is attentive, not inattentive; by one who is wise, not undiscerning. Through adversity, resilience can be known. But that too is only known over a long time, not a short time; by one who is attentive, not inattentive; by one who is wise, not undiscerning. Through discussion, wisdom can be known. But that too is known only over a long time, not a short time; by one who is attentive, not inattentive; by one who is wise, not undiscerning.'

Venerable sir, these men of mine are thieves, spies, who go undercover to roam and scout the countryside. Once they have scouted, I will then advance. Now, venerable sir, having brushed off the dust and dirt, bathed, applied ointments, with neatly trimmed hair and beards, and dressed in white clothes, they will indulge themselves, fully supplied and engaged with the five chords of sensual pleasure."

Then, understanding the significance of this, the Blessed One at that time expressed this inspired utterance:

"One should not strive indiscriminately, nor should one be subject to another; One should not live relying on another, nor should one trade against the Dhamma."