Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
213
Issues
213
List
Boards
Labels
Service Desk
Milestones
Merge Requests
35
Merge Requests
35
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Commits
d321c14d
Commit
d321c14d
authored
1 hour ago
by
Emiliano Balbuena
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(test): Spec tests
parent
8cffd4c9
epic/minds-pro
1 merge request
!308
WIP: (feat): Minds Pro
Pipeline
#82841696
failed with stages
in 4 minutes and 11 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
166 additions
and
2 deletions
+166
-2
TraefikDynamoDb.php
Core/Pro/Domain/EdgeRouters/TraefikDynamoDb.php
+6
-2
TraefikDynamoDbSpec.php
Spec/Core/Pro/Domain/EdgeRouters/TraefikDynamoDbSpec.php
+64
-0
SecuritySpec.php
Spec/Core/Pro/Domain/SecuritySpec.php
+96
-0
No files found.
Core/Pro/Domain/EdgeRouters/TraefikDynamoDb.php
View file @
d321c14d
...
...
@@ -24,16 +24,20 @@ class TraefikDynamoDb implements EdgeRouterInterface
/**
* TraefikDynamoDb constructor.
* @param Config $config
* @param DynamoDbClient $dynamoDb
*/
public
function
__construct
(
$config
=
null
$config
=
null
,
$dynamoDb
=
null
)
{
$this
->
config
=
$config
?:
Di
::
_
()
->
get
(
'Config'
);
$this
->
dynamoDb
=
$dynamoDb
;
}
public
function
initialize
()
:
EdgeRouterInterface
{
$awsConfig
=
$this
->
config
->
get
(
'aws'
);
$opts
=
[
'region'
=>
$awsConfig
[
'region'
]
];
...
...
@@ -64,7 +68,7 @@ class TraefikDynamoDb implements EdgeRouterInterface
return
false
;
}
$userGuid
=
$settings
->
getUserGuid
();
$userGuid
=
(
string
)
$settings
->
getUserGuid
();
$marshaler
=
new
Marshaler
();
$entry
=
$marshaler
->
marshalJson
(
json_encode
([
...
...
This diff is collapsed.
Click to expand it.
Spec/Core/Pro/Domain/EdgeRouters/TraefikDynamoDbSpec.php
0 → 100644
View file @
d321c14d
<?php
namespace
Spec\Minds\Core\Pro\Domain\EdgeRouters
;
use
Aws\DynamoDb\DynamoDbClient
;
use
Minds\Core\Config
;
use
Minds\Core\Pro\Domain\EdgeRouters\TraefikDynamoDb
;
use
Minds\Core\Pro\Settings
;
use
PhpSpec\ObjectBehavior
;
use
Prophecy\Argument
;
class
TraefikDynamoDbSpec
extends
ObjectBehavior
{
/** @var Config */
protected
$config
;
/** @var DynamoDbClient */
protected
$dynamoDb
;
public
function
let
(
Config
$config
,
DynamoDbClient
$dynamoDbClient
)
{
$this
->
config
=
$config
;
$this
->
dynamoDb
=
$dynamoDbClient
;
$this
->
beConstructedWith
(
$config
,
$dynamoDbClient
);
}
public
function
it_is_initializable
()
{
$this
->
shouldHaveType
(
TraefikDynamoDb
::
class
);
}
// NOTE: Cannot mock $this->initialize()
public
function
it_should_put_endpoint
(
Settings
$settings
)
{
$settings
->
getDomain
()
->
shouldBeCalled
()
->
willReturn
(
'phpspec.test'
);
$settings
->
getUserGuid
()
->
shouldBeCalled
()
->
willReturn
(
1000
);
$this
->
config
->
get
(
'pro'
)
->
shouldBeCalled
()
->
willReturn
([
'dynamodb_table_name'
=>
'phpspec'
]);
$this
->
dynamoDb
->
putItem
(
Argument
::
that
(
function
(
$args
)
{
return
$args
[
'TableName'
]
===
'phpspec'
;
}))
->
shouldBeCalled
()
->
willReturn
(
true
);
$this
->
putEndpoint
(
$settings
)
->
shouldReturn
(
true
);
}
}
This diff is collapsed.
Click to expand it.
Spec/Core/Pro/Domain/SecuritySpec.php
0 → 100644
View file @
d321c14d
<?php
namespace
Spec\Minds\Core\Pro\Domain
;
use
Minds\Common\Cookie
;
use
Minds\Common\Jwt
;
use
Minds\Core\Config
;
use
Minds\Core\Pro\Domain\Security
;
use
PhpSpec\ObjectBehavior
;
use
Prophecy\Argument
;
class
SecuritySpec
extends
ObjectBehavior
{
/** @var Cookie */
protected
$cookie
;
/** @var Jwt */
protected
$jwt
;
/** @var Config */
protected
$config
;
public
function
let
(
Cookie
$cookie
,
Jwt
$jwt
,
Config
$config
)
{
$this
->
cookie
=
$cookie
;
$this
->
jwt
=
$jwt
;
$this
->
config
=
$config
;
$this
->
beConstructedWith
(
$cookie
,
$jwt
,
$config
);
}
public
function
it_is_initializable
()
{
$this
->
shouldHaveType
(
Security
::
class
);
}
public
function
it_should_set_up
()
{
$this
->
jwt
->
randomString
()
->
shouldBeCalled
()
->
willReturn
(
'~random~'
);
$this
->
config
->
get
(
'oauth'
)
->
shouldBeCalled
()
->
willReturn
([
'encryption_key'
=>
'phpspec'
]);
$this
->
jwt
->
setKey
(
'phpspec'
)
->
shouldBeCalled
()
->
willReturn
(
$this
->
jwt
);
$this
->
jwt
->
encode
(
Argument
::
type
(
'array'
))
->
shouldBeCalled
()
->
willReturn
(
'~encoded~'
);
$this
->
cookie
->
setName
(
Security
::
JWT_COOKIE_NAME
)
->
shouldBeCalled
()
->
willReturn
(
$this
->
cookie
);
$this
->
cookie
->
setName
(
Security
::
XSRF_COOKIE_NAME
)
->
shouldBeCalled
()
->
willReturn
(
$this
->
cookie
);
$this
->
cookie
->
setValue
(
'~encoded~'
)
->
shouldBeCalled
()
->
willReturn
(
$this
->
cookie
);
$this
->
cookie
->
setValue
(
'~random~'
)
->
shouldBeCalled
()
->
willReturn
(
$this
->
cookie
);
$this
->
cookie
->
setExpire
(
Argument
::
type
(
'int'
))
->
shouldBeCalledTimes
(
2
)
->
willReturn
(
$this
->
cookie
);
$this
->
cookie
->
setPath
(
'/'
)
->
shouldBeCalledTimes
(
2
)
->
willReturn
(
$this
->
cookie
);
$this
->
cookie
->
setHttpOnly
(
false
)
->
shouldBeCalledTimes
(
2
)
->
willReturn
(
$this
->
cookie
);
$this
->
cookie
->
create
()
->
shouldBeCalledTimes
(
2
)
->
willReturn
(
true
);
$this
->
setUp
(
'phpspec.test'
)
->
shouldReturn
(
'~encoded~'
);
}
}
This diff is collapsed.
Click to expand it.
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