public function testWillAcceptBothProtocolsIfConfiguredTo()
{
$event = $this->getEventMock(['authentication' => ['protocol' => 'both']]);
$privateKey = 'foobar';
$baseUrl = '//imbo.host/users/some-user/imgUrl.png?t[]=smartSize:width=320,height=240';
foreach (['http', 'https'] as $signedProtocol) {
$token = hash_hmac('sha256', $signedProtocol . ':' . $baseUrl, $privateKey);
foreach (['http', 'https'] as $protocol) {
$url = $protocol . ':' . $baseUrl . '&accessToken=' . $token;
$this->query->expects($this->any())->method('has')->with('accessToken')->will($this->returnValue(true));
$this->query->expects($this->any())->method('get')->with('accessToken')->will($this->returnValue($token));
$this->request->expects($this->any())->method('getRawUri')->will($this->returnValue(urldecode($url)));
$this->request->expects($this->any())->method('getUriAsIs')->will($this->returnValue($url));
$this->accessControl->expects($this->any())->method('getPrivateKey')->will($this->returnValue($privateKey));
$this->listener->checkAccessToken($event);
}
}
}