public function testCreate()
 {
     $container = ContainerLoader::buildTestContainer();
     $em = $container->get('doctrine.orm.entity_manager');
     $client = new Client();
     $client->setClientId($token = 'test-client-' . rand());
     $client->setClientSecret('very-secure');
     $client->setRedirectUri(array('http://brentertainment.com'));
     $em->persist($client);
     $em->flush();
     $public_key = new ClientPublicKey();
     $public_key->setClient($client);
     // create and set the public key
     $res = openssl_pkey_new();
     // Extract the public key from $res to $pubKey
     $pubKeyDetails = openssl_pkey_get_details($res);
     $pubKey = $pubKeyDetails['key'];
     $public_key->setPublicKey($pubKey);
     $em->persist($public_key);
     $em->flush();
     // test direct access
     $stored = $em->find('OAuth2\\ServerBundle\\Entity\\ClientPublicKey', array('client_id' => $client->getClientId()));
     $this->assertNotNull($stored);
     $this->assertEquals($pubKey, $stored->getPublicKey());
 }
예제 #2
0
 public function testCreate()
 {
     $container = ContainerLoader::buildTestContainer();
     $em = $container->get('doctrine.orm.entity_manager');
     $client = new Client();
     $client->setClientId($client_id = 'This Is My Client ID ' . rand());
     $client->setClientSecret('very-secure');
     $client->setRedirectUri(array('http://brentertainment.com'));
     $em->persist($client);
     $em->flush();
     $stored = $em->find('OAuth2\\ServerBundle\\Entity\\Client', array('client_id' => $client_id));
     $this->assertNotNull($stored);
     $this->assertEquals($client_id, $stored->getClientId());
     $this->assertEquals($client->getClientSecret(), $stored->getClientSecret());
     $this->assertEquals($client->getRedirectUri(), $stored->getRedirectUri());
 }