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
ccb58bd8
Commit
ccb58bd8
authored
Mar 03, 2020
by
Jacob Priddy
👌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add door tests
parent
60b655cc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
11 deletions
+40
-11
src/web/backend/app/Door.php
src/web/backend/app/Door.php
+0
-3
src/web/backend/src/Gateways/Doors/DatabaseDoorsRepository.php
...eb/backend/src/Gateways/Doors/DatabaseDoorsRepository.php
+8
-8
src/web/backend/tests/Database/DoorDatabaseTest.php
src/web/backend/tests/Database/DoorDatabaseTest.php
+32
-0
No files found.
src/web/backend/app/Door.php
View file @
ccb58bd8
...
...
@@ -2,13 +2,10 @@
namespace
App
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
use
Illuminate\Foundation\Auth\User
as
Authenticatable
;
class
Door
extends
Authenticatable
{
use
SoftDeletes
;
protected
$fillable
=
[
'*'
];
...
...
src/web/backend/src/Gateways/Doors/DatabaseDoorsRepository.php
View file @
ccb58bd8
...
...
@@ -12,13 +12,13 @@ class DatabaseDoorsRepository implements DoorsRepository
*/
public
function
create
(
Door
$door
):
Door
{
$dbDoor
=
\
App\Door
::
create
(
[
'location'
=>
$door
->
getLocation
(),
'name'
=>
$door
->
getName
(),
'token'
=>
hash
(
'sha256'
,
$door
->
getToken
()),
]
);
$dbDoor
=
new
\
App\Door
();
$dbDoor
->
location
=
$door
->
getLocation
();
$dbDoor
->
name
=
$door
->
getName
();
$dbDoor
->
api_token
=
hash
(
'sha512'
,
$door
->
getToken
());
$dbDoor
->
save
(
);
return
new
Door
(
$dbDoor
->
id
,
...
...
@@ -35,7 +35,7 @@ class DatabaseDoorsRepository implements DoorsRepository
*/
public
function
getByToken
(
string
$token
):
?Door
{
$dbDoor
=
\
App\Door
::
where
(
'api_token'
,
hash
(
'sha
256
'
,
$token
))
->
first
();
$dbDoor
=
\
App\Door
::
where
(
'api_token'
,
hash
(
'sha
512
'
,
$token
))
->
first
();
if
(
!
$dbDoor
)
{
return
null
;
...
...
src/web/backend/tests/Database/DoorDatabaseTest.php
0 → 100644
View file @
ccb58bd8
<?php
namespace
Tests\Database
;
use
Source\Entities\Door
;
use
Tests\DatabaseTestCase
;
use
Source\Gateways\Doors\DatabaseDoorsRepository
;
class
DoorDatabaseTest
extends
DatabaseTestCase
{
protected
DatabaseDoorsRepository
$doors
;
public
function
setUp
():
void
{
parent
::
setUp
();
$this
->
doors
=
new
DatabaseDoorsRepository
();
}
/**
* @test
*/
public
function
it_creates_and_finds_doors
():
void
{
$door
=
$this
->
doors
->
create
(
new
Door
(
0
,
'loc'
,
'name'
,
'token'
));
$this
->
assertEquals
(
$door
,
$this
->
doors
->
getByToken
(
'token'
));
$this
->
assertNull
(
$this
->
doors
->
getByToken
(
'reee'
));
}
}
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