كتاب المقدمات
The Book of Miscellany
(51)
Chapter: Hope in Allah's Mercy
(51)
- باب الرجاء
Riyad as-Salihin 427
Bara' bin 'Azib (May Allah be pleased with them) reported:
The Prophet (ﷺ) said, "When a believer is questioned in the grave, he testifies that, 'there is no true god except Allah and Muhammad is the Messenger of Allah.' About him the Words of Allah, the Exalted, are: 'Allah will keep firm those who believe, with the firm statement (The Testimony of Faith) in this world and the Hereafter)". (14:27)

[Al-Bukhari and Muslim].

وعن البراء بن عازب، رضي الله عنهما، عن النبي، صلى الله عليه وسلم، قال‏:‏ “المسلم إذا سئل في القبر يشهد أن لا إله إلا الله، وأن محمداً رسول الله، فذلك قوله تعالى‏:‏ ‏{‏يثبت الله الذين آمنوا بالقول الثابت في الحياة الدنيا وفي الآخرة‏}‏ ‏(‏‏(‏إبراهيم‏:‏27‏)‏‏)‏ ‏(‏‏(‏متفق عليه‏)‏‏)‏ ‏.‏
Reference : Riyad as-Salihin 427
In-book reference : Introduction, Hadith 427