There is no indication in the text that Joseph sinned in the way he treated his brothers. In fact, the whole purpose of that scenario was to test the brothers to see if they had changed in their attitude toward each other and toward the other son of Rachel, whom the father now favored since he assumed that Joseph was dead.
So, during the feast when Joseph gave Benjamin a double portion, his brothers “were merry with him.” Their reaction showed that they were no longer jealous of any favoritism towards the other son of Rachel. Furthermore, they were not willing to leave Benjamin in Egypt. Judah even offered to become the replacement prisoner for the sake of Benjamin and for the love of the father. All of these actions showed that they had developed a strong sense of family loyalty, and that Benjamin would not be abandoned in the way that Joseph had been abandoned.
I think it was a valid test, and the Bible does not condemn Joseph for his actions.