The secret to remaining steadfast under trials is knowing the God who is with you to exalt you through trials.

Resources:

Genesis 39-41
Word Biblical Commentary, Genesis 16-50, Gordon Wenham
Preach the Word (Genesis) by Kent Hughes