Esempio n. 1
0
 protected function addContent()
 {
     $faker = Faker\Factory::create();
     $role = \Distilleries\Expendable\Models\Role::create(['libelle' => $faker->text(), 'initials' => $faker->name, 'overide_permission' => false]);
     $service = \Distilleries\Expendable\Models\Service::create(['action' => $faker->name() . '@' . $faker->name()]);
     $permission = \Distilleries\Expendable\Models\Permission::create(['role_id' => $role->id, 'service_id' => $service->id]);
     return [$role, $service, $permission];
 }
Esempio n. 2
0
 public function testHasAccess()
 {
     $faker = Faker\Factory::create();
     $role = \Distilleries\Expendable\Models\Role::create(['libelle' => $faker->text(), 'initials' => $faker->name, 'overide_permission' => false]);
     $service = \Distilleries\Expendable\Models\Service::create(['action' => $faker->name() . '@' . $faker->name()]);
     $permission = \Distilleries\Expendable\Models\Permission::create(['role_id' => $role->id, 'service_id' => $service->id]);
     $user = \Distilleries\Expendable\Models\User::create(['email' => $faker->email, 'password' => \Hash::make('test'), 'status' => true, 'role_id' => $role->id]);
     $this->assertFalse($user->hasAccess('test'));
 }
Esempio n. 3
0
 protected function addContent()
 {
     $faker = Faker\Factory::create();
     $role = \Distilleries\Expendable\Models\Role::create(['libelle' => $faker->text(), 'initials' => $faker->name, 'overide_permission' => false]);
     $service = \Distilleries\Expendable\Models\Service::create(['action' => $faker->name() . '@' . $faker->name()]);
     $permission = \Distilleries\Expendable\Models\Permission::create(['role_id' => $role->id, 'service_id' => $service->id]);
     $user = \Distilleries\Expendable\Models\User::create(['email' => $faker->email, 'password' => \Hash::make('test'), 'status' => true, 'role_id' => $role->id]);
     return [$role, $service, $permission, $user];
 }
 public function testDestroy()
 {
     $faker = Faker\Factory::create();
     $role = \Distilleries\Expendable\Models\Role::create(['libelle' => $faker->name, 'initials' => $faker->name, 'overide_permission' => true]);
     $service = \Distilleries\Expendable\Models\Service::create(['action' => $faker->name]);
     $permission = \Distilleries\Expendable\Models\Permission::create(['role_id' => $role->id, 'service_id' => $service->id]);
     $this->call('PUT', action($this->controller . '@putDestroy'), ['id' => $permission->id]);
     $newService = \Distilleries\Expendable\Models\Permission::find($permission->id);
     $this->assertEquals(null, $newService);
 }
 public function setUp()
 {
     parent::setUp();
     \Distilleries\Expendable\Models\Role::create(['libelle' => 'admin', 'initials' => '@a', 'overide_permission' => true]);
     \Distilleries\Expendable\Models\Service::create(['action' => 'test']);
     $faker = Faker\Factory::create();
     $email = $faker->email;
     $user = \Distilleries\Expendable\Models\User::create(['email' => $email, 'password' => \Hash::make('test'), 'status' => true, 'role_id' => 1]);
     \Distilleries\Expendable\Models\Permission::create(['role_id' => 1, 'service_id' => 1]);
     $this->be($user);
 }
 public function setUp()
 {
     parent::setUp();
     $this->artisan('migrate', ['--database' => 'testbench', '--realpath' => realpath(__DIR__ . '/../../../../vendor/distilleries/mailersaver/src/database/migrations')]);
     \Distilleries\Expendable\Models\Role::create(['libelle' => 'admin', 'initials' => '@a', 'overide_permission' => true]);
     \Distilleries\Expendable\Models\Service::create(['action' => 'test']);
     $faker = Faker\Factory::create();
     $email = $faker->email;
     $user = \Distilleries\Expendable\Models\User::create(['email' => $email, 'password' => \Hash::make('test'), 'status' => true, 'role_id' => 1]);
     \Distilleries\Expendable\Models\Permission::create(['role_id' => 1, 'service_id' => 1]);
     $this->be($user);
 }
Esempio n. 7
0
 public function testExceptionNoCatche()
 {
     $faker = Faker\Factory::create();
     $role = \Distilleries\Expendable\Models\Role::create(['libelle' => $faker->name, 'initials' => $faker->name, 'overide_permission' => true]);
     $service = \Distilleries\Expendable\Models\Service::create(['action' => $faker->name]);
     $email = $faker->email;
     $user = \Distilleries\Expendable\Models\User::create(['email' => str_replace('\'', '', $email), 'password' => \Hash::make('test'), 'status' => true, 'role_id' => $role->id]);
     \Distilleries\Expendable\Models\Permission::create(['role_id' => $role->id, 'service_id' => $service->id]);
     $this->be($user);
     $response = $this->call('GET', '/test');
     $this->assertEquals(404, $response->getStatusCode());
     $this->assertNotContains('page-404', $response->getContent());
     $this->assertContains('<h1>Sorry, the page you are looking for could not be found.</h1>', $response->getContent());
 }
Esempio n. 8
0
 public function testListenerDispatcherUserLoginWithRole()
 {
     \Distilleries\Expendable\Models\Role::create(['libelle' => 'admin', 'initials' => '@a', 'overide_permission' => false]);
     \Distilleries\Expendable\Models\Service::create(['action' => 'test']);
     $faker = Faker\Factory::create();
     \Distilleries\Expendable\Models\User::create(['email' => $faker->email, 'password' => \Hash::make('test'), 'status' => true, 'role_id' => 1]);
     \Distilleries\Expendable\Models\Permission::create(['role_id' => 1, 'service_id' => 1]);
     global $firedTestListener;
     $firedTestListener = false;
     $listener = new TestListener();
     $listener->listen();
     new \Distilleries\Expendable\Events\UserEvent(\Distilleries\Expendable\Events\UserEvent::LOGIN_EVENT, \Distilleries\Expendable\Models\User::find(1));
     $this->assertEquals(true, $firedTestListener);
 }
 public function testPostResetValid()
 {
     $token = 'bEJa3ysNqVCOv4SkGkcrJnJWqAOmh93UZrmv1IM171zAJ82WylyXh7c4CRHW';
     $faker = Faker\Factory::create();
     \Distilleries\Expendable\Models\Role::create(['libelle' => 'admin', 'initials' => '@a', 'overide_permission' => true]);
     \Distilleries\Expendable\Models\Service::create(['action' => 'test']);
     $faker = Faker\Factory::create();
     $email = $faker->email;
     $user = \Distilleries\Expendable\Models\User::create(['email' => $email, 'password' => \Hash::make('test'), 'status' => true, 'role_id' => 1]);
     \DB::table('password_resets')->insert(array('email' => $email, 'token' => $token, 'created_at' => date('Y-m-d H:i:s')));
     \Distilleries\Expendable\Models\Permission::create(['role_id' => 1, 'service_id' => 1]);
     $this->call('POST', action('Admin\\LoginController@postReset'), ['token' => $token, 'email' => $email, 'password' => 'testtesttesttest', 'password_confirmation' => 'testtesttesttest']);
     $this->assertRedirectedToAction('Admin\\LoginController@getIndex');
 }
Esempio n. 10
0
 public function testPermissionService()
 {
     list($role, $service, $permission) = $this->addContent();
     $expected = \Distilleries\Expendable\Models\Service::find($service->id);
     $this->assertEquals($expected, $permission->service);
 }
 public function testSearchWithRole()
 {
     $faker = Faker\Factory::create();
     $role = \Distilleries\Expendable\Models\Role::create(['libelle' => $faker->name, 'initials' => $faker->name, 'overide_permission' => true]);
     $service = \Distilleries\Expendable\Models\Service::create(['action' => $faker->name]);
     $email = $faker->email;
     $user = \Distilleries\Expendable\Models\User::create(['email' => $email, 'password' => \Hash::make('test'), 'status' => true, 'role_id' => $role->id]);
     \Distilleries\Expendable\Models\Permission::create(['role_id' => $role->id, 'service_id' => $service->id]);
     $response = $this->call('POST', action($this->controller . '@postSearchWithRole'), ['ids' => [$user->id], 'role' => $role->id]);
     $result = json_decode($response->getContent());
     $this->assertEquals($user->id, $result[0]->id);
     $this->assertEquals($user->email, $result[0]->email);
     $response = $this->call('POST', action($this->controller . '@postSearchWithRole'), ['ids' => [$user->id], 'role' => -1]);
     $result = json_decode($response->getContent());
     $this->assertEquals(0, count($result));
 }
 public function testSynchronise()
 {
     \DB::table('services')->truncate();
     $this->call('GET', action($this->controller . '@getSynchronize'), ['router' => $this->app->make('Illuminate\\Contracts\\Routing\\Registrar')]);
     $this->assertTrue(\Distilleries\Expendable\Models\Service::count() > 0);
 }