Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
Doorcode
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Guardians of the Kretschmar Elock System
Doorcode
Commits
b3d1e5b0
Commit
b3d1e5b0
authored
Apr 09, 2020
by
Jacob Priddy
👌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests and add tests to make sure door entries get logged
parent
9a0f9d7a
Pipeline
#5601
canceled with stages
in 23 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
5 deletions
+55
-5
src/web/backend/app/User.php
src/web/backend/app/User.php
+1
-1
src/web/backend/database/migrations/2020_01_10_083534_create_entries_table.php
...ase/migrations/2020_01_10_083534_create_entries_table.php
+1
-1
src/web/backend/src/Gateways/Attempts/InMemoryAttemptsRepository.php
...kend/src/Gateways/Attempts/InMemoryAttemptsRepository.php
+8
-0
src/web/backend/src/Gateways/Entries/InMemoryEntriesRepository.php
...ackend/src/Gateways/Entries/InMemoryEntriesRepository.php
+8
-0
src/web/backend/tests/Database/DoorDatabaseTest.php
src/web/backend/tests/Database/DoorDatabaseTest.php
+1
-0
src/web/backend/tests/Unit/Source/UseCases/Door/Access/UseCaseTest.php
...nd/tests/Unit/Source/UseCases/Door/Access/UseCaseTest.php
+36
-3
No files found.
src/web/backend/app/User.php
View file @
b3d1e5b0
...
...
@@ -37,7 +37,7 @@ class User extends Authenticatable
*/
public
function
entries
():
HasMany
{
$this
->
hasMany
(
Entry
::
class
);
return
$this
->
hasMany
(
Entry
::
class
);
}
/**
...
...
src/web/backend/database/migrations/2020_01_10_083534_create_entries_table.php
View file @
b3d1e5b0
...
...
@@ -4,7 +4,7 @@ use Illuminate\Support\Facades\Schema;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Database\Migrations\Migration
;
class
Create
Log
Table
extends
Migration
class
Create
Entries
Table
extends
Migration
{
/**
* Run the migrations.
...
...
src/web/backend/src/Gateways/Attempts/InMemoryAttemptsRepository.php
View file @
b3d1e5b0
...
...
@@ -13,6 +13,14 @@ class InMemoryAttemptsRepository implements AttemptsRepository
*/
protected
array
$attempts
=
[];
/**
* @return \Source\Entities\Attempt[]
*/
public
function
all
():
array
{
return
$this
->
attempts
;
}
/**
* @inheritDoc
*/
...
...
src/web/backend/src/Gateways/Entries/InMemoryEntriesRepository.php
View file @
b3d1e5b0
...
...
@@ -13,6 +13,14 @@ class InMemoryEntriesRepository implements EntriesRepository
*/
protected
array
$entries
=
[];
/**
* @return \Source\Entities\Entry[]
*/
public
function
all
():
array
{
return
$this
->
entries
;
}
/**
* @inheritDoc
*/
...
...
src/web/backend/tests/Database/DoorDatabaseTest.php
View file @
b3d1e5b0
...
...
@@ -21,6 +21,7 @@ class DoorDatabaseTest extends DatabaseTestCase
/**
* @test
* @throws \Source\Exceptions\EntityExistsException
*/
public
function
it_creates_and_finds_doors
():
void
{
...
...
src/web/backend/tests/Unit/Source/UseCases/Door/Access/UseCaseTest.php
View file @
b3d1e5b0
...
...
@@ -10,7 +10,9 @@ use Source\UseCases\Door\Access\Access;
use
Source\Exceptions\AuthorizationException
;
use
Source\Exceptions\AuthenticationException
;
use
Source\Gateways\Users\InMemoryUsersRepository
;
use
Source\Gateways\Entries\InMemoryEntriesRepository
;
use
Source\Gateways\DoorUser\InMemoryDoorUserRepository
;
use
Source\Gateways\Attempts\InMemoryAttemptsRepository
;
class
UseCaseTest
extends
TestCase
{
...
...
@@ -33,16 +35,30 @@ class UseCaseTest extends TestCase
*/
protected
Access
$useCase
;
/**
* @var \Source\Gateways\Attempts\InMemoryAttemptsRepository
*/
protected
InMemoryAttemptsRepository
$attempts
;
/**
* @var \Source\Gateways\Entries\InMemoryEntriesRepository
*/
protected
InMemoryEntriesRepository
$entries
;
public
function
setUp
():
void
{
parent
::
setUp
();
$this
->
users
=
new
InMemoryUsersRepository
();
$this
->
doorUser
=
new
InMemoryDoorUserRepository
();
$this
->
attempts
=
new
InMemoryAttemptsRepository
();
$this
->
entries
=
new
InMemoryEntriesRepository
();
$this
->
useCase
=
new
Access
(
self
::
EXPECTED_ACCESS_DOOR_ID
,
$this
->
users
,
$this
->
doorUser
$this
->
doorUser
,
$this
->
attempts
,
$this
->
entries
);
}
...
...
@@ -78,7 +94,13 @@ class UseCaseTest extends TestCase
public
function
it_will_not_check_for_non_existent_doors
():
void
{
$this
->
expectException
(
AuthenticationException
::
class
);
$this
->
useCase
=
new
Access
(
null
,
$this
->
users
,
$this
->
doorUser
);
$this
->
useCase
=
new
Access
(
null
,
$this
->
users
,
$this
->
doorUser
,
$this
->
attempts
,
$this
->
entries
);
$this
->
handleTest
(
''
);
}
...
...
@@ -92,6 +114,9 @@ class UseCaseTest extends TestCase
$this
->
expectException
(
AuthorizationException
::
class
);
$this
->
users
->
create
(
self
::
createValidUser
(
'doorcode'
));
$this
->
handleTest
(
'asdf'
);
$this
->
assertCount
(
1
,
$this
->
attempts
->
all
());
$this
->
assertEquals
(
self
::
EXPECTED_ACCESS_DOOR_ID
,
$this
->
attempts
->
all
()[
0
]
->
getDoorId
());
}
/**
...
...
@@ -104,6 +129,9 @@ class UseCaseTest extends TestCase
$this
->
expectException
(
AuthorizationException
::
class
);
$this
->
users
->
create
(
self
::
createValidUser
(
'doorcode'
));
$this
->
handleTest
(
'doorcode'
);
$this
->
assertCount
(
1
,
$this
->
entries
->
all
());
$this
->
assertFalse
(
$this
->
entries
->
all
()[
0
]
->
wasSuccessful
());
}
/**
...
...
@@ -118,6 +146,9 @@ class UseCaseTest extends TestCase
$this
->
doorUser
->
addGroupToDoor
(
self
::
EXPECTED_ACCESS_DOOR_ID
,
5
);
$this
->
doorUser
->
addGroupToUser
(
self
::
USER_ID
,
9
);
$this
->
handleTest
(
'doorcode'
);
$this
->
assertCount
(
1
,
$this
->
entries
->
all
());
$this
->
assertFalse
(
$this
->
entries
->
all
()[
0
]
->
wasSuccessful
());
}
/**
...
...
@@ -131,6 +162,8 @@ class UseCaseTest extends TestCase
$this
->
doorUser
->
addGroupToDoor
(
self
::
EXPECTED_ACCESS_DOOR_ID
,
1
);
$this
->
doorUser
->
addGroupToUser
(
self
::
USER_ID
,
1
);
$this
->
handleTest
(
'doorcode'
);
$this
->
assertTrue
(
true
);
$this
->
assertCount
(
1
,
$this
->
entries
->
all
());
$this
->
assertTrue
(
$this
->
entries
->
all
()[
0
]
->
wasSuccessful
());
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment