示例#1
0
 public function load(ObjectManager $manager)
 {
     $goodKey = $this->container->getParameter('test_config')['api_keys']['good_corp_key'];
     $corpManager = $this->container->get('app.corporation.manager');
     $apiManager = $this->container->get('app.apikey.manager');
     $key = new ApiCredentials();
     $key->setApiKey($goodKey['key'])->setVerificationCode($goodKey['code']);
     $res = $apiManager->validateAndUpdateApiKey($key, 'Corporation', '134217727');
     $apiManager->updateCorporationKey($key, $res);
     $corp = $corpManager->createNewCorporation($key);
     $manager->persist($corp);
     $manager->flush();
     $corpManager->checkCorporationDetails($corp);
     $manager->persist($corp);
     $manager->flush();
 }
 /**
  * @Route("/{id}/api_credentials", name="api.corporation.apicredentials.update", options={"expose"=true})
  * @ParamConverter(name="credentials", class="AppBundle:ApiCredentials")
  * @Secure(roles="ROLE_CEO")
  * @Method("PATCH")
  */
 public function updateAction(Request $request, ApiCredentials $credentials)
 {
     $this->denyAccessUnlessGranted(AccessTypes::EDIT, $credentials->getCorporation(), 'Unauthorized access!');
     $em = $this->getDoctrine()->getManager();
     if ($request->query->get('delete', false) && $credentials->getIsActive()) {
         $credentials->setIsActive(false);
         $em->persist($credentials);
         $em->flush();
     }
     if ($request->query->get('enable', false) && !$credentials->getIsActive()) {
         $credentials->setIsActive(true);
         $em->persist($credentials);
         $em->flush();
     }
     $json = $this->get('serializer')->serialize($credentials, 'json');
     return $this->jsonResponse($json);
 }
 protected function tryCall($manager, $function, $arg, ApiCredentials $key)
 {
     try {
         $this->registry->get($manager)->{$function}($arg);
         return true;
     } catch (\Exception $e) {
         $this->log->error(sprintf('Error syncing data for %s  on call %s with: %s', $arg->getCorporationDetails()->getName(), $function, $e->getMessage()));
         $count = $key->getErrorCount();
         $key->setErrorCount($count + 1);
         return false;
     }
 }
示例#4
0
 public function getClient(ApiCredentials $key, $scope = 'corp')
 {
     $client = $this->pheal->createEveOnline($key->getApiKey(), $key->getVerificationCode());
     $client->scope = $scope;
     return $client;
 }
 public function testGoodCorpKey()
 {
     $this->loadFixtures(['AppBundle\\DataFixtures\\Test\\LoadUserData']);
     $config = $this->getContainer()->getParameter('test_config');
     $key = new ApiCredentials();
     $api_key = $config['api_keys']['good_corp_key']['key'];
     $verification_code = $config['api_keys']['good_corp_key']['code'];
     $key->setApiKey($api_key)->setVerificationCode($verification_code);
     $res = $this->manager->validateKey($key, 'Corporation', '134217727');
     $this->manager->updateCorporationKey($key, $res);
     $this->assertSame('Corporation', $key->getType());
     $this->assertSame('134217727', $key->getAccessMask());
 }
示例#6
0
 public function buildInstanceFromRequest(ParameterBag $content)
 {
     $creds = new ApiCredentials();
     $creds->setVerificationCode($content->get('verification_code'))->setApiKey($content->get('api_key'));
     return $creds;
 }