Пример #1
0
 protected function setUp()
 {
     //$mockCapture = new MockCapture('tests/PSX/Webfinger/webfinger_http_fixture.xml');
     $mock = Mock::getByXmlDefinition('tests/PSX/Webfinger/webfinger_http_fixture.xml');
     $this->http = new Http($mock);
     $this->webfinger = new Webfinger($this->http);
 }
Пример #2
0
 protected function setUp()
 {
     //$mockCapture = new MockCapture('tests/PSX/Hostmeta/hostmeta_http_fixture.xml');
     $mock = Mock::getByXmlDefinition('tests/PSX/Hostmeta/hostmeta_http_fixture.xml');
     $this->http = new Http($mock);
     $this->hostmeta = new Hostmeta($this->http);
 }
Пример #3
0
 /**
  * @expectedException \RuntimeException
  */
 public function testParseInvalidHttpRef()
 {
     $handler = Http\Handler\Mock::getByXmlDefinition(__DIR__ . '/http_mock.xml');
     $http = new Http($handler);
     $resolver = JsonSchema\RefResolver::createDefault($http);
     $parser = new JsonSchema(__DIR__, $resolver);
     $parser->parse(file_get_contents(__DIR__ . '/invalid_http_ref_schema.json'));
 }
Пример #4
0
 public function testPostGoogle()
 {
     $handler = new Mock();
     $handler->add('GET', 'https://www.googleapis.com/plus/v1/people/me/openIdConnect', function (RequestInterface $request) {
         $this->assertEquals('Bearer e72e16c7e42f292c6912e7710c838347ae178b4a', $request->getHeader('Authorization'));
         $response = 'HTTP/1.1 200 OK' . "\r\n";
         $response .= 'Content-Type: application/json' . "\r\n";
         $response .= "\r\n";
         $response .= json_encode(['sub' => 1, 'name' => 'octocat', 'email' => '*****@*****.**']);
         return $response;
     });
     $handler->add('POST', 'https://accounts.google.com/o/oauth2/token', function (RequestInterface $request) {
         $body = (string) $request->getBody();
         $this->assertEquals('code=foo&client_id=bar&client_secret=google&redirect_uri=http%3A%2F%2Fgoogle.com&grant_type=authorization_code', $body);
         $response = 'HTTP/1.1 200 OK' . "\r\n";
         $response .= 'Content-Type: application/json' . "\r\n";
         $response .= "\r\n";
         $response .= json_encode(['access_token' => 'e72e16c7e42f292c6912e7710c838347ae178b4a']);
         return $response;
     });
     Environment::getService('http_client')->setHandler($handler);
     Environment::getService('connection')->update('fusio_config', ['value' => 'google'], ['id' => 8]);
     $response = $this->sendRequest('http://127.0.0.1/consumer/provider/google', 'POST', array('User-Agent' => 'Fusio TestCase'), json_encode(['code' => 'foo', 'clientId' => 'bar', 'redirectUri' => 'http://google.com']));
     $body = (string) $response->getBody();
     $data = json_decode($body);
     $this->assertEquals(200, $response->getStatusCode(), $body);
     $this->assertToken($data->token, ProviderInterface::PROVIDER_GOOGLE);
 }