@@ -52,7 +52,7 @@ public function testNonAdminAccountIsAuthenticated()
5252 $ this ->userRepository ->shouldReceive ('setColumns ' )->with (['id ' , 'root_admin ' , 'password ' ])->once ()->andReturnSelf ();
5353 $ this ->userRepository ->shouldReceive ('findFirstWhere ' )->with ([['username ' , '= ' , $ user ->username ]])->once ()->andReturn ($ user );
5454
55- $ this ->repository ->shouldReceive ('setColumns ' )->with (['id ' , 'node_id ' , 'owner_id ' , 'uuid ' ])->once ()->andReturnSelf ();
55+ $ this ->repository ->shouldReceive ('setColumns ' )->with (['id ' , 'node_id ' , 'owner_id ' , 'uuid ' , ' installed ' , ' suspended ' ])->once ()->andReturnSelf ();
5656 $ this ->repository ->shouldReceive ('getByUuid ' )->with ($ server ->uuidShort )->once ()->andReturn ($ server );
5757
5858 $ this ->keyProviderService ->shouldReceive ('handle ' )->with ($ server , $ user )->once ()->andReturn ('server_token ' );
@@ -77,7 +77,7 @@ public function testAdminAccountIsAuthenticated()
7777 $ this ->userRepository ->shouldReceive ('setColumns ' )->with (['id ' , 'root_admin ' , 'password ' ])->once ()->andReturnSelf ();
7878 $ this ->userRepository ->shouldReceive ('findFirstWhere ' )->with ([['username ' , '= ' , $ user ->username ]])->once ()->andReturn ($ user );
7979
80- $ this ->repository ->shouldReceive ('setColumns ' )->with (['id ' , 'node_id ' , 'owner_id ' , 'uuid ' ])->once ()->andReturnSelf ();
80+ $ this ->repository ->shouldReceive ('setColumns ' )->with (['id ' , 'node_id ' , 'owner_id ' , 'uuid ' , ' installed ' , ' suspended ' ])->once ()->andReturnSelf ();
8181 $ this ->repository ->shouldReceive ('getByUuid ' )->with ($ server ->uuidShort )->once ()->andReturn ($ server );
8282
8383 $ this ->keyProviderService ->shouldReceive ('handle ' )->with ($ server , $ user )->once ()->andReturn ('server_token ' );
@@ -104,7 +104,7 @@ public function testExceptionIsThrownIfNoServerIsProvided()
104104 * Test that an exception is thrown if the user account exists but the wrong
105105 * credentials are passed.
106106 *
107- * @expectedException \Illuminate\Auth\AuthenticationException
107+ * @expectedException \Pterodactyl\Exceptions\Repository\RecordNotFoundException
108108 */
109109 public function testExceptionIsThrownIfUserDetailsAreIncorrect ()
110110 {
@@ -119,7 +119,7 @@ public function testExceptionIsThrownIfUserDetailsAreIncorrect()
119119 /**
120120 * Test that an exception is thrown if no user account is found.
121121 *
122- * @expectedException \Illuminate\Auth\AuthenticationException
122+ * @expectedException \Pterodactyl\Exceptions\Repository\RecordNotFoundException
123123 */
124124 public function testExceptionIsThrownIfNoUserAccountIsFound ()
125125 {
@@ -143,7 +143,7 @@ public function testExceptionIsThrownIfUserDoesNotOwnServer()
143143 $ this ->userRepository ->shouldReceive ('setColumns ' )->with (['id ' , 'root_admin ' , 'password ' ])->once ()->andReturnSelf ();
144144 $ this ->userRepository ->shouldReceive ('findFirstWhere ' )->with ([['username ' , '= ' , $ user ->username ]])->once ()->andReturn ($ user );
145145
146- $ this ->repository ->shouldReceive ('setColumns ' )->with (['id ' , 'node_id ' , 'owner_id ' , 'uuid ' ])->once ()->andReturnSelf ();
146+ $ this ->repository ->shouldReceive ('setColumns ' )->with (['id ' , 'node_id ' , 'owner_id ' , 'uuid ' , ' installed ' , ' suspended ' ])->once ()->andReturnSelf ();
147147 $ this ->repository ->shouldReceive ('getByUuid ' )->with ($ server ->uuidShort )->once ()->andReturn ($ server );
148148
149149 $ this ->getService ()->handle ($ user ->username , 'password ' , 1 , $ server ->uuidShort );
@@ -163,7 +163,45 @@ public function testExceptionIsThrownIfServerDoesNotExistOnCurrentNode()
163163 $ this ->userRepository ->shouldReceive ('setColumns ' )->with (['id ' , 'root_admin ' , 'password ' ])->once ()->andReturnSelf ();
164164 $ this ->userRepository ->shouldReceive ('findFirstWhere ' )->with ([['username ' , '= ' , $ user ->username ]])->once ()->andReturn ($ user );
165165
166- $ this ->repository ->shouldReceive ('setColumns ' )->with (['id ' , 'node_id ' , 'owner_id ' , 'uuid ' ])->once ()->andReturnSelf ();
166+ $ this ->repository ->shouldReceive ('setColumns ' )->with (['id ' , 'node_id ' , 'owner_id ' , 'uuid ' , 'installed ' , 'suspended ' ])->once ()->andReturnSelf ();
167+ $ this ->repository ->shouldReceive ('getByUuid ' )->with ($ server ->uuidShort )->once ()->andReturn ($ server );
168+
169+ $ this ->getService ()->handle ($ user ->username , 'password ' , 1 , $ server ->uuidShort );
170+ }
171+
172+ /**
173+ * Test that a suspended server throws an exception.
174+ *
175+ * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
176+ */
177+ public function testSuspendedServer ()
178+ {
179+ $ user = factory (User::class)->make (['root_admin ' => 1 ]);
180+ $ server = factory (Server::class)->make (['node_id ' => 1 , 'owner_id ' => $ user ->id + 1 , 'suspended ' => 1 ]);
181+
182+ $ this ->userRepository ->shouldReceive ('setColumns ' )->with (['id ' , 'root_admin ' , 'password ' ])->once ()->andReturnSelf ();
183+ $ this ->userRepository ->shouldReceive ('findFirstWhere ' )->with ([['username ' , '= ' , $ user ->username ]])->once ()->andReturn ($ user );
184+
185+ $ this ->repository ->shouldReceive ('setColumns ' )->with (['id ' , 'node_id ' , 'owner_id ' , 'uuid ' , 'installed ' , 'suspended ' ])->once ()->andReturnSelf ();
186+ $ this ->repository ->shouldReceive ('getByUuid ' )->with ($ server ->uuidShort )->once ()->andReturn ($ server );
187+
188+ $ this ->getService ()->handle ($ user ->username , 'password ' , 1 , $ server ->uuidShort );
189+ }
190+
191+ /**
192+ * Test that a server that is not yet installed throws an exception.
193+ *
194+ * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
195+ */
196+ public function testNotInstalledServer ()
197+ {
198+ $ user = factory (User::class)->make (['root_admin ' => 1 ]);
199+ $ server = factory (Server::class)->make (['node_id ' => 1 , 'owner_id ' => $ user ->id + 1 , 'installed ' => 0 ]);
200+
201+ $ this ->userRepository ->shouldReceive ('setColumns ' )->with (['id ' , 'root_admin ' , 'password ' ])->once ()->andReturnSelf ();
202+ $ this ->userRepository ->shouldReceive ('findFirstWhere ' )->with ([['username ' , '= ' , $ user ->username ]])->once ()->andReturn ($ user );
203+
204+ $ this ->repository ->shouldReceive ('setColumns ' )->with (['id ' , 'node_id ' , 'owner_id ' , 'uuid ' , 'installed ' , 'suspended ' ])->once ()->andReturnSelf ();
167205 $ this ->repository ->shouldReceive ('getByUuid ' )->with ($ server ->uuidShort )->once ()->andReturn ($ server );
168206
169207 $ this ->getService ()->handle ($ user ->username , 'password ' , 1 , $ server ->uuidShort );
0 commit comments