In Luke 22:31-32, Jesus said to the disciple Peter: "Simon, Simon, Satan has asked to sift you as wheat. But I have prayed for you, Simon, that your faith may not fail. And when you have turned back, strengthen your brothers." As a backdrop to understanding this passage, wheat in ancient times was sifted in order to remove the chaff and the dirt, as well as to eliminate the broken and withered grains. The sifting process revealed the impure elements that had to be removed from the good wheat. In like manner, Satan often tempts believers with a view to revealing and emphasizing their weaknesses. This is what Satan sought to do to Peter.
Contextually, it seems clear from Luke 22:31-32 that Satan is "on a leash." He cannot go beyond what our sovereign God will allow him. We see this not only in Luke 22 but also in the Book of Job where Satan had to obtain permission from God before afflicting Job (see Job 1:9-12).
We should all rest secure in the fact that God is in control of the universe, and that Satan cannot simply do as he pleases in our lives. The trials and testings that come to God's people are only those which He allows.
Another observation we can make is that Jesus, fully aware that Satan wanted to tempt Peter, prayed for Peter before the temptation even began that Peter's faith would not fail (Luke 22:32). What a wonderful Savior we have. Hebrews 7:25 tells us, "He is able to save completely those who come to God through him, because he always lives to intercede for them."