Commit 6bf4720243b9115741ad652f2f46e767960a594e
Committed by
gabrielamayoli
1 parent
64e36f3f
Exists in
master
and in
1 other branch
Atualização de primeiros testes do primeiro controller da nova coleta.
Showing
2 changed files
with
24 additions
and
10 deletions
Show diff stats
src/Cacic/WSBundle/Controller/NeoController.php
| ... | ... | @@ -19,7 +19,8 @@ use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag; |
| 19 | 19 | |
| 20 | 20 | use Cacic\CommonBundle\Entity\Computador; |
| 21 | 21 | use Cacic\CommonBundle\Entity\LogAcesso; |
| 22 | -use Cacic\CommonBundle\Entity\SoRepository; | |
| 22 | +use Cacic\CommonBundle\Entity\So; | |
| 23 | + | |
| 23 | 24 | |
| 24 | 25 | class NeoController extends Controller { |
| 25 | 26 | |
| ... | ... | @@ -61,18 +62,25 @@ class NeoController extends Controller { |
| 61 | 62 | // JSON Serialization |
| 62 | 63 | //$usuario = $serializer->deserialize($data, 'Usuario', 'json'); |
| 63 | 64 | $usuario = json_decode($data); |
| 64 | - $logger->debug("JSON login received data".print_r($usuario, true)); | |
| 65 | + $logger->debug("JSON login received data".print_r($usuario, true)); //user e password | |
| 65 | 66 | $_SERVER['SERVER_ADDR'] = $this->getRequest()->getUri(); |
| 66 | 67 | |
| 67 | 68 | $auth = $this->forward('CacicCommonBundle:Security:login', array( |
| 68 | - 'username' => $usuario->user, | |
| 69 | - 'password' => $usuario->password, | |
| 69 | + "username" => $usuario->user, | |
| 70 | + "password" => $usuario->password, | |
| 70 | 71 | )); |
| 72 | + $logger->debug("JSON login received data".print_r($auth, true)); //dados .twig | |
| 73 | + | |
| 71 | 74 | |
| 72 | 75 | $session = $request->getSession(); |
| 73 | 76 | |
| 77 | + //Gera chave criptografada | |
| 78 | + $chave = "123456"; | |
| 79 | + $chavecrip = md5($chave); | |
| 80 | + | |
| 74 | 81 | $auth->setContent(json_encode(array( |
| 75 | - 'session' => $session->getId() | |
| 82 | + 'session' => $session->getId(), | |
| 83 | + 'chavecrip' => $chavecrip | |
| 76 | 84 | ))); |
| 77 | 85 | |
| 78 | 86 | return $auth; | ... | ... |
src/Cacic/WSBundle/Tests/Controller/NeoControllerTest.php
| ... | ... | @@ -12,7 +12,8 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; |
| 12 | 12 | use Symfony\Component\HttpFoundation\Session; |
| 13 | 13 | use Symfony\Component\Serializer\Serializer; |
| 14 | 14 | use Symfony\Component\Serializer\Encoder\JsonEncoder; |
| 15 | -use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer; | |
| 15 | + | |
| 16 | + | |
| 16 | 17 | |
| 17 | 18 | class NeoControllerTest extends WebTestCase |
| 18 | 19 | { |
| ... | ... | @@ -69,17 +70,22 @@ class NeoControllerTest extends WebTestCase |
| 69 | 70 | "password": "123456" |
| 70 | 71 | }' |
| 71 | 72 | ); |
| 72 | - $logger->debug("Dados JSON de login enviados \n".$this->client->getRequest()->getcontent()); | |
| 73 | + $logger->debug("Dados JSON de login enviados\n".$this->client->getRequest()->getcontent());//user e password | |
| 73 | 74 | |
| 74 | 75 | $response = $this->client->getResponse(); |
| 76 | + $logger->debug("Response:\n".print_r($response,true)); // arrays session e chavecrip | |
| 75 | 77 | $data = $response->getContent(); |
| 76 | - $logger->debug("Response data: \n".print_r($data,true)); | |
| 78 | + $logger->debug("Response data:\n".print_r($data,true)); //session e chavecrip | |
| 77 | 79 | // JSON Serialization |
| 78 | 80 | $json = json_decode($data, true); |
| 81 | + $logger->debug("Response json: \n".print_r($json,true)); //session e chavecrip | |
| 79 | 82 | $session = $json['session']; |
| 83 | + $chavecrip= $json['chavecrip']; | |
| 80 | 84 | |
| 81 | 85 | $this->assertTrue(is_string($session)); |
| 82 | 86 | |
| 87 | + $this->assertTrue(is_string($chavecrip)); | |
| 88 | + | |
| 83 | 89 | |
| 84 | 90 | } |
| 85 | 91 | |
| ... | ... | @@ -105,7 +111,7 @@ class NeoControllerTest extends WebTestCase |
| 105 | 111 | |
| 106 | 112 | $response = $this->client->getResponse(); |
| 107 | 113 | $data = $response->getContent(); |
| 108 | - $logger->debug("Response data: \n".print_r($data,true)); | |
| 114 | + | |
| 109 | 115 | // JSON Serialization |
| 110 | 116 | $json = json_decode($data, true); |
| 111 | 117 | $session = $json['session']; |
| ... | ... | @@ -162,7 +168,7 @@ class NeoControllerTest extends WebTestCase |
| 162 | 168 | |
| 163 | 169 | $response = $this->client->getResponse(); |
| 164 | 170 | $status = $response->getStatusCode(); |
| 165 | - $logger->debug("Response status: $status"); | |
| 171 | + $logger->debug("Response status AAAAAAAAAAAAAAAAAAAAAAAAAAAA: $status"); | |
| 166 | 172 | |
| 167 | 173 | $this->assertEquals($status, 200); |
| 168 | 174 | ... | ... |