Пример #1
0
 public function testSignSymfonyRequest()
 {
     $request = Symfony\Component\HttpFoundation\Request::create('http://somesite.com/sample/url', 'GET', ['foo' => 'bar']);
     $generator = new Generator();
     $request = $generator->addSignatureToSymfonyRequest($request, 'myapi123', 'mysecret456');
     $nonce = $request->headers->get('X-TOKENLY-AUTH-NONCE');
     PHPUnit::assertGreaterThanOrEqual(time(), $nonce);
     PHPUnit::assertEquals('myapi123', $request->headers->get('X-TOKENLY-AUTH-API-TOKEN'));
     $expected_signature = $this->expectedSignature($nonce);
     PHPUnit::assertEquals($expected_signature, $request->headers->get('X-TOKENLY-AUTH-SIGNATURE'));
 }
Пример #2
0
 public function callAPIWithAuthentication($method, $uri, $parameters = [], $cookies = [], $files = [], $server = [], $content = null)
 {
     $request = $this->createAPIRequest($method, $uri, $parameters, $cookies, $files, $server, $content);
     $generator = new Generator();
     $api_token = 'TESTAPITOKEN';
     $secret = 'TESTAPISECRET';
     $generator->addSignatureToSymfonyRequest($request, $api_token, $secret);
     return $this->app->make('Illuminate\\Contracts\\Http\\Kernel')->handle($request);
 }
Пример #3
0
 public function callAPIWithAuthentication($method, $uri, $parameters = [], $cookies = [], $files = [], $server = [], $content = null)
 {
     $request = $this->createAPIRequest($method, $uri, $parameters, $cookies, $files, $server, $content);
     $generator = new Generator();
     $user = $this->getUser();
     $api_token = $user['apitoken'];
     $secret = $user['apisecretkey'];
     $generator->addSignatureToSymfonyRequest($request, $api_token, $secret);
     return $this->sendRequest($request);
 }