d3ltcod /
LaravelTube
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | use App\User; |
||
| 4 | use Chrisbjr\ApiGuard\Models\ApiKey; |
||
| 5 | use Illuminate\Foundation\Testing\DatabaseMigrations; |
||
| 6 | use Illuminate\Support\Facades\Hash; |
||
| 7 | |||
| 8 | /** |
||
| 9 | * Class AcachaAdminLTELaravelTest. |
||
| 10 | */ |
||
| 11 | class AcachaAdminLTELaravelTest extends TestCase |
||
|
0 ignored issues
–
show
|
|||
| 12 | { |
||
| 13 | use DatabaseMigrations; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @param User $user |
||
| 17 | * |
||
| 18 | * @return mixed |
||
| 19 | */ |
||
| 20 | private function createUserApiKey(User $user) |
||
| 21 | { |
||
| 22 | $apiKey = ApiKey::make($user->id); |
||
| 23 | $apiKey->save(); |
||
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Test Landing Page. |
||
| 28 | * |
||
| 29 | * @return void |
||
| 30 | */ |
||
| 31 | public function testLandingPage() |
||
| 32 | { |
||
| 33 | // $this->visit('/') |
||
| 34 | // ->see('Acacha') |
||
| 35 | // ->see('adminlte-laravel') |
||
| 36 | // ->see('Pratt'); |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Test Landing Page. |
||
| 41 | * |
||
| 42 | * @return void |
||
| 43 | */ |
||
| 44 | public function testLandingPageWithUserLogged() |
||
| 45 | { |
||
| 46 | // $user = factory(App\User::class)->create(); |
||
| 47 | // |
||
| 48 | // $this->actingAs($user) |
||
| 49 | // ->visit('/') |
||
| 50 | // ->see('Acacha') |
||
| 51 | // ->see('adminlte-laravel') |
||
| 52 | // ->see('Pratt') |
||
| 53 | // ->see($user->name); |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Test Login Page. |
||
| 58 | * |
||
| 59 | * @return void |
||
| 60 | */ |
||
| 61 | public function testLoginPage() |
||
| 62 | { |
||
| 63 | $this->visit('/login') |
||
| 64 | ->see('Sign in to start your session'); |
||
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Test Login. |
||
| 69 | * |
||
| 70 | * @return void |
||
| 71 | */ |
||
| 72 | public function testLogin() |
||
| 73 | { |
||
| 74 | $user = factory(App\User::class)->create(['password' => Hash::make('passw0RD')]); |
||
| 75 | $this->createUserApiKey($user); |
||
| 76 | |||
| 77 | $this->visit('/login') |
||
| 78 | ->type($user->email, 'email') |
||
| 79 | ->type('passw0RD', 'password') |
||
| 80 | ->press('Sign In') |
||
| 81 | ->seePageIs('/upload') |
||
| 82 | ->see($user->name); |
||
| 83 | } |
||
| 84 | |||
| 85 | /** |
||
| 86 | * Test Login. |
||
| 87 | * |
||
| 88 | * @return void |
||
| 89 | */ |
||
| 90 | public function testLoginRequiredFields() |
||
| 91 | { |
||
| 92 | $this->visit('/login') |
||
| 93 | ->press('Sign In') |
||
| 94 | ->see('The email field is required') |
||
| 95 | ->see('The password field is required'); |
||
| 96 | } |
||
| 97 | |||
| 98 | /** |
||
| 99 | * Test Register Page. |
||
| 100 | * |
||
| 101 | * @return void |
||
| 102 | */ |
||
| 103 | public function testRegisterPage() |
||
| 104 | { |
||
| 105 | $this->visit('/register') |
||
| 106 | ->see('Register a new membership'); |
||
| 107 | } |
||
| 108 | |||
| 109 | /** |
||
| 110 | * Test Password reset Page. |
||
| 111 | * |
||
| 112 | * @return void |
||
| 113 | */ |
||
| 114 | public function testPasswordResetPage() |
||
| 115 | { |
||
| 116 | $this->visit('/password/reset') |
||
| 117 | ->see('Reset Password'); |
||
| 118 | } |
||
| 119 | |||
| 120 | /** |
||
| 121 | * Test home page is only for authorized Users. |
||
| 122 | * |
||
| 123 | * @return void |
||
| 124 | */ |
||
| 125 | public function testHomePageForUnauthenticatedUsers() |
||
| 126 | { |
||
| 127 | $this->visit('/upload') |
||
| 128 | ->seePageIs('/login'); |
||
| 129 | } |
||
| 130 | |||
| 131 | /** |
||
| 132 | * Test home page works with Authenticated Users. |
||
| 133 | * |
||
| 134 | * @return void |
||
| 135 | */ |
||
| 136 | public function testHomePageForAuthenticatedUsers() |
||
| 137 | { |
||
| 138 | $user = factory(App\User::class)->create(); |
||
| 139 | $this->createUserApiKey($user); |
||
| 140 | |||
| 141 | $this->actingAs($user) |
||
| 142 | ->visit('/upload') |
||
| 143 | ->see($user->name); |
||
| 144 | } |
||
| 145 | |||
| 146 | /** |
||
| 147 | * Test log out. |
||
| 148 | * |
||
| 149 | * @return void |
||
| 150 | */ |
||
| 151 | public function testLogout() |
||
| 152 | { |
||
| 153 | $user = factory(App\User::class)->create(); |
||
| 154 | |||
| 155 | $this->actingAs($user) |
||
| 156 | ->visit('/logout') |
||
| 157 | ->seePageIs('/'); |
||
| 158 | } |
||
| 159 | |||
| 160 | /** |
||
| 161 | * Test 404 Error page. |
||
| 162 | * |
||
| 163 | * @return void |
||
| 164 | */ |
||
| 165 | public function test404Page() |
||
| 166 | { |
||
| 167 | $this->get('asdasdjlapmnnk') |
||
| 168 | ->seeStatusCode(404) |
||
| 169 | ->see('404'); |
||
| 170 | } |
||
| 171 | |||
| 172 | /** |
||
| 173 | * Test user registration. |
||
| 174 | * |
||
| 175 | * @return void |
||
| 176 | */ |
||
| 177 | public function testNewUserRegistration() |
||
| 178 | { |
||
| 179 | $this->visit('/register') |
||
| 180 | ->type('Sergi Tur Badenas', 'name') |
||
| 181 | ->type('[email protected]', 'email') |
||
| 182 | // ->check('terms') TODO |
||
| 183 | ->type('passw0RD', 'password') |
||
| 184 | ->type('passw0RD', 'password_confirmation') |
||
| 185 | ->press('Register') |
||
| 186 | ->seePageIs('/upload') |
||
| 187 | ->seeInDatabase('users', ['email' => '[email protected]', |
||
| 188 | 'name' => 'Sergi Tur Badenas', ]); |
||
| 189 | } |
||
| 190 | |||
| 191 | /** |
||
| 192 | * Test required fields on registration page. |
||
| 193 | * |
||
| 194 | * @return void |
||
| 195 | */ |
||
| 196 | public function testRequiredFieldsOnRegistrationPage() |
||
| 197 | { |
||
| 198 | $this->visit('/register') |
||
| 199 | ->press('Register') |
||
| 200 | ->see('The name field is required') |
||
| 201 | ->see('The email field is required') |
||
| 202 | ->see('The password field is required'); |
||
| 203 | } |
||
| 204 | |||
| 205 | /** |
||
| 206 | * Test send password reset. |
||
| 207 | * |
||
| 208 | * @return void |
||
| 209 | */ |
||
| 210 | public function testSendPasswordReset() |
||
| 211 | { |
||
| 212 | $user = factory(App\User::class)->create(['email' => '[email protected]']); |
||
| 213 | |||
| 214 | $this->visit('password/reset') |
||
| 215 | ->type($user->email, 'email') |
||
| 216 | ->press('Send Password Reset Link') |
||
| 217 | ->see('We have e-mailed your password reset link!'); |
||
| 218 | } |
||
| 219 | |||
| 220 | /** |
||
| 221 | * Test send password reset user not exists. |
||
| 222 | * |
||
| 223 | * @return void |
||
| 224 | */ |
||
| 225 | public function testSendPasswordResetUserNotExists() |
||
| 226 | { |
||
| 227 | $this->visit('password/reset') |
||
| 228 | ->type('[email protected]', 'email') |
||
| 229 | ->press('Send Password Reset Link') |
||
| 230 | ->see('There were some problems with your input'); |
||
| 231 | } |
||
| 232 | } |
||
| 233 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.