diff --git a/docker-compose.yml.example b/docker-compose.yml.example index 92ab32f40d535d68057ad8eeb4980c2d4e8180fb..2b02d27fc5e020c51d1a67c1de0e2289aa6b3e88 100644 --- a/docker-compose.yml.example +++ b/docker-compose.yml.example @@ -104,7 +104,6 @@ services: - ./simple-saml-idp/config:/var/simplesamlphp-idp/config - ./simple-saml-idp/metadata:/var/simplesamlphp-idp/metadata ports: - - "9000:9000" - "8000:8000" logging: options: diff --git a/php/dev.ini b/php/dev.ini index a1a02ec9c1f1a98f7215760852ac823aefd3d2ac..8d0917ab891fb36b5fc50bcbdcd948187b2f827a 100644 --- a/php/dev.ini +++ b/php/dev.ini @@ -4,7 +4,7 @@ display_errors = On xdebug.remote_enable=1 xdebug.remote_connect_back=1 xdebug.idekey="PHPSTORM" -xdebug.remote_port=9999 +xdebug.remote_port=9000 xdebug.remote_autostart=1 # DockerNAT gateway IP xdebug.remote.host=host.docker.internal diff --git a/src/backend/src/Gateways/Schedules/LocalSchedulesRepository.php b/src/backend/src/Gateways/Schedules/LocalSchedulesRepository.php index 5e4d32278f9bcb2bee2a553d0b3b3fb669d0875e..7dd72576c0f35e62eb4a84b87a128f7842a438bb 100644 --- a/src/backend/src/Gateways/Schedules/LocalSchedulesRepository.php +++ b/src/backend/src/Gateways/Schedules/LocalSchedulesRepository.php @@ -9,6 +9,9 @@ use Source\Gateways\Groups\LocalGroupsRepository; class LocalSchedulesRepository extends InMemorySchedulesRepository { + /** + * @throws \Source\Exceptions\EntityNotFoundException + */ public function __construct() { $this->create(new Schedule( diff --git a/src/backend/tests/Feature/Door/DoorAccessTest.php b/src/backend/tests/Feature/Door/DoorAccessTest.php index a3c9578cc9f673cdc83b4eccdbf494adddceb5a8..42e70ab1d445ed723dfb50b49a7f3c17117d1f87 100644 --- a/src/backend/tests/Feature/Door/DoorAccessTest.php +++ b/src/backend/tests/Feature/Door/DoorAccessTest.php @@ -4,8 +4,10 @@ namespace Tests\Feature\Door; use Carbon\Carbon; +use Source\Entities\User; use Source\Entities\Schedule; use Illuminate\Testing\TestResponse; +use Source\Entities\HashedSearchable; use Tests\Feature\AuthenticatesWithApplicationTestCase; use Source\Gateways\DoorSchedule\DoorScheduleRepository; use Source\Gateways\DoorSchedule\InMemoryDoorScheduleRepository; @@ -84,4 +86,51 @@ RSET; $this->response->assertStatus(200); } + + /** + * @test + * @throws \Source\Exceptions\EntityExistsException + */ + public function it_denies_invalid_users(): void + { + $this->authenticateAsDoor(); + + $this->authorizer->setNext(true); + + $this->handleTest('asdf'); + + $this->response->assertStatus(403); + } + + /** + * @test + * @throws \Source\Exceptions\EntityExistsException + */ + public function it_denies_users_who_are_not_allowed(): void + { + $this->authenticateAsDoor(); + + $this->authorizer->setNext(false); + + $this->handleTest('asdf'); + + $this->response->assertStatus(403); + } + + /** + * @test + * @throws \Source\Exceptions\EntityExistsException + */ + public function it_allows_valid_users(): void + { + $this->authenticateAsDoor(); + + $this->usersRepository->create(new User(0, '', '', '', '', null, null, HashedSearchable::hash(config('app.key'), 'asdf'))); + + $this->authorizer->setNext(true); + + $this->handleTest('asdf'); + + $this->response->assertStatus(200); + } }