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
222
Issues
222
List
Boards
Labels
Service Desk
Milestones
Merge Requests
33
Merge Requests
33
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
0044723c
Commit
0044723c
authored
7 minutes ago
by
Mark Harding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(chore): spec test for signed uri component
parent
fe1f22d9
feat-permissioned-cdn
1 merge request
!323
Permissioned cdn
Pipeline
#82363972
running with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
5 deletions
+47
-5
SignedUriSpec.php
Spec/Core/Security/SignedUriSpec.php
+47
-5
No files found.
Spec/Core/Security/SignedUriSpec.php
View file @
0044723c
...
...
@@ -3,6 +3,11 @@
namespace
Spec\Minds\Core\Security
;
use
Minds\Core\Security\SignedUri
;
use
Minds\Entities\User
;
use
Minds\Core\Config
;
use
Lcobucci\JWT
;
use
Lcobucci\JWT\Signer\Key
;
use
Lcobucci\JWT\Signer\Hmac\Sha256
;
use
PhpSpec\ObjectBehavior
;
use
Prophecy\Argument
;
...
...
@@ -13,9 +18,46 @@ class SignedUriSpec extends ObjectBehavior
$this
->
shouldHaveType
(
SignedUri
::
class
);
}
// public function it_sign_a_uri()
// {
// $this->sign("https://minds-dev/foo")
// ->shouldBe("https://minds-dev/fo");
// }
public
function
it_sign_a_uri
(
Config
$config
)
{
$user
=
new
User
();
$user
->
set
(
'guid'
,
123
);
$user
->
set
(
'username'
,
'phpspec'
);
\Minds\Core\Session
::
setUser
(
$user
);
$this
->
beConstructedWith
(
null
,
null
,
$config
);
$config
->
get
(
'sessions'
)
->
willReturn
([
'private_key'
=>
'priv-key'
]);
$this
->
sign
(
"https://minds-dev/foo"
)
->
shouldContain
(
"https://minds-dev/foo?jwtsig="
);
}
public
function
it_should_verify_a_uri_was_signed
(
Config
$config
)
{
$this
->
beConstructedWith
(
null
,
null
,
$config
);
$config
->
get
(
'sessions'
)
->
willReturn
([
'private_key'
=>
'priv-key'
]);
$uri
=
"https://minds-dev/foo?jwtsig=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NzI1NjY0MDAsInVyaSI6Imh0dHBzOlwvXC9taW5kcy1kZXZcL2ZvbyIsInVzZXJfZ3VpZCI6IjEyMyJ9.jqOq0k-E4h1I0PHnc_WkmWqXonRU4yWq_ymoOYoaDvc"
;
$this
->
confirm
(
$uri
)
->
shouldBe
(
true
);
}
public
function
it_should_not_very_a_wrongly_signed_uri
(
Config
$config
)
{
$this
->
beConstructedWith
(
null
,
null
,
$config
);
$config
->
get
(
'sessions'
)
->
willReturn
([
'private_key'
=>
'priv-key'
]);
$uri
=
"https://minds-dev/bar?jwtsig=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NzI1NjY0MDAsInVyaSI6Imh0dHBzOlwvXC9taW5kcy1kZXZcL2ZvbyIsInVzZXJfZ3VpZCI6IjEyMyJ9.jqOq0k-E4h1I0PHnc_WkmWqXonRU4yWq_ymoOYoaDvc"
;
$this
->
confirm
(
$uri
)
->
shouldBe
(
false
);
}
}
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