Imam Ali(AS) says:
“A friend cannot be considered a friend unless he is tested on three occasions: in time of need, behind your back and after your death.”
Source: Nahjul Balagha
This hadith from Imam Ali(AS) helps us identify a true friend. A friend should be willing to do anything for his/her friend. When you need a friend, that friend of yours should be there for you. Friendship is not only being together in good times, but rather also in the hard times.
If people are sitting and backbiting about you, the person who gets up and leaves or defends you is your true friend. A true friend is one who acts the same whether its behind your back or to your face.
We often find in history that when someone is alive, his/her “friend” acts like (s)he is his/her best friend, but when death approaches the person, the “friend” puts the friendship away. We see this happening to Prophet Muhammad(saw) where after his passing away, a lot of his closest companions completely put aside the teachings of the Prophet and denied them.
These are the keys to identifying a friend, however we also have to remember to be a good friend by helping our friends in times of need and supporting them behind their back and after their death.