mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-19 06:43:45 +02:00
update tests to use new factories
This commit is contained in:
@@ -14,7 +14,7 @@ class AuthenticateIPAccessTest extends MiddlewareTestCase
|
||||
*/
|
||||
public function testWithNoIPRestrictions()
|
||||
{
|
||||
$model = factory(ApiKey::class)->make(['allowed_ips' => []]);
|
||||
$model = ApiKey::factory()->make(['allowed_ips' => []]);
|
||||
$this->setRequestAttribute('api_key', $model);
|
||||
|
||||
$this->getMiddleware()->handle($this->request, $this->getClosureAssertions());
|
||||
@@ -26,7 +26,7 @@ class AuthenticateIPAccessTest extends MiddlewareTestCase
|
||||
*/
|
||||
public function testWithValidIP()
|
||||
{
|
||||
$model = factory(ApiKey::class)->make(['allowed_ips' => ['127.0.0.1']]);
|
||||
$model = ApiKey::factory()->make(['allowed_ips' => ['127.0.0.1']]);
|
||||
$this->setRequestAttribute('api_key', $model);
|
||||
|
||||
$this->request->shouldReceive('ip')->withNoArgs()->once()->andReturn('127.0.0.1');
|
||||
@@ -39,7 +39,7 @@ class AuthenticateIPAccessTest extends MiddlewareTestCase
|
||||
*/
|
||||
public function testValidIPAgainstCIDRRange()
|
||||
{
|
||||
$model = factory(ApiKey::class)->make(['allowed_ips' => ['192.168.1.1/28']]);
|
||||
$model = ApiKey::factory()->make(['allowed_ips' => ['192.168.1.1/28']]);
|
||||
$this->setRequestAttribute('api_key', $model);
|
||||
|
||||
$this->request->shouldReceive('ip')->withNoArgs()->once()->andReturn('192.168.1.15');
|
||||
@@ -55,7 +55,7 @@ class AuthenticateIPAccessTest extends MiddlewareTestCase
|
||||
{
|
||||
$this->expectException(AccessDeniedHttpException::class);
|
||||
|
||||
$model = factory(ApiKey::class)->make(['allowed_ips' => ['127.0.0.1']]);
|
||||
$model = ApiKey::factory()->make(['allowed_ips' => ['127.0.0.1']]);
|
||||
$this->setRequestAttribute('api_key', $model);
|
||||
|
||||
$this->request->shouldReceive('ip')->withNoArgs()->twice()->andReturn('127.0.0.2');
|
||||
|
||||
@@ -79,7 +79,7 @@ class AuthenticateKeyTest extends MiddlewareTestCase
|
||||
*/
|
||||
public function testValidToken()
|
||||
{
|
||||
$model = factory(ApiKey::class)->make();
|
||||
$model = ApiKey::factory()->make();
|
||||
|
||||
$this->request->shouldReceive('bearerToken')->withNoArgs()->twice()->andReturn($model->identifier . 'decrypted');
|
||||
$this->repository->shouldReceive('findFirstWhere')->with([
|
||||
@@ -102,7 +102,7 @@ class AuthenticateKeyTest extends MiddlewareTestCase
|
||||
*/
|
||||
public function testValidTokenWithUserKey()
|
||||
{
|
||||
$model = factory(ApiKey::class)->make();
|
||||
$model = ApiKey::factory()->make();
|
||||
|
||||
$this->request->shouldReceive('bearerToken')->withNoArgs()->twice()->andReturn($model->identifier . 'decrypted');
|
||||
$this->repository->shouldReceive('findFirstWhere')->with([
|
||||
@@ -126,7 +126,7 @@ class AuthenticateKeyTest extends MiddlewareTestCase
|
||||
*/
|
||||
public function testAccessWithoutToken()
|
||||
{
|
||||
$user = factory(User::class)->make(['id' => 123]);
|
||||
$user = User::factory()->make(['id' => 123]);
|
||||
|
||||
$this->request->shouldReceive('user')->andReturn($user);
|
||||
$this->request->shouldReceive('bearerToken')->withNoArgs()->twice()->andReturnNull();
|
||||
@@ -147,7 +147,7 @@ class AuthenticateKeyTest extends MiddlewareTestCase
|
||||
{
|
||||
$this->expectException(AccessDeniedHttpException::class);
|
||||
|
||||
$model = factory(ApiKey::class)->make();
|
||||
$model = ApiKey::factory()->make();
|
||||
|
||||
$this->request->shouldReceive('bearerToken')->withNoArgs()->twice()->andReturn($model->identifier . 'asdf');
|
||||
$this->repository->shouldReceive('findFirstWhere')->with([
|
||||
|
||||
@@ -92,7 +92,7 @@ class DaemonAuthenticateTest extends MiddlewareTestCase
|
||||
$this->expectException(AccessDeniedHttpException::class);
|
||||
|
||||
/** @var \Pterodactyl\Models\Node $model */
|
||||
$model = factory(Node::class)->make();
|
||||
$model = Node::factory()->make();
|
||||
|
||||
$this->request->expects('route->getName')->withNoArgs()->andReturn('random.route');
|
||||
$this->request->expects('bearerToken')->withNoArgs()->andReturn($model->daemon_token_id . '.random_string_123');
|
||||
@@ -125,7 +125,7 @@ class DaemonAuthenticateTest extends MiddlewareTestCase
|
||||
public function testSuccessfulMiddlewareProcess()
|
||||
{
|
||||
/** @var \Pterodactyl\Models\Node $model */
|
||||
$model = factory(Node::class)->make();
|
||||
$model = Node::factory()->make();
|
||||
|
||||
$this->request->expects('route->getName')->withNoArgs()->andReturn('random.route');
|
||||
$this->request->expects('bearerToken')->withNoArgs()->andReturn($model->daemon_token_id . '.' . decrypt($model->daemon_token));
|
||||
|
||||
Reference in New Issue
Block a user