Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp
Commits
aec9571d
Commit
aec9571d
authored
9 years ago
by
Jaime Perez Crespo
Browse files
Options
Downloads
Patches
Plain Diff
Add some tests for SimpleSAML\Utils\Crypto.
parent
4b6ea53f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/lib/SimpleSAML/Utils/CryptoTest.php
+48
-0
48 additions, 0 deletions
tests/lib/SimpleSAML/Utils/CryptoTest.php
with
48 additions
and
0 deletions
tests/lib/SimpleSAML/Utils/CryptoTest.php
0 → 100644
+
48
−
0
View file @
aec9571d
<?php
/**
* Tests for SimpleSAML\Utils\Crypto.
*/
class
CryptoTest
extends
PHPUnit_Framework_TestCase
{
/**
* Test invalid input provided to the aesDecrypt() method.
*
* @expectedException InvalidArgumentException
*/
public
function
testAesDecryptBadInput
()
{
SimpleSAML\Utils\Crypto
::
aesDecrypt
(
array
());
}
/**
* Test that aesDecrypt() works properly, being able to decrypt some previously known (and correct)
* ciphertext.
*/
public
function
testAesDecrypt
()
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
'secretsalt'
=>
'SUPER_SECRET_SALT'
,
));
$plaintext
=
'SUPER_SECRET_TEXT'
;
$ciphertext
=
'GA5lvW9TbAErqGvHFfZMUkdIg6zCJYmjFSGERAhByYNcMts70N4fWLjUm7/aVygPm55GbGhEG2himXJUHR1Ibg=='
;
$this
->
assertEquals
(
$plaintext
,
SimpleSAML\Utils\Crypto
::
aesDecrypt
(
base64_decode
(
$ciphertext
)));
}
/**
* Test that aesEncrypt() produces ciphertexts that aesDecrypt() can decrypt.
*/
public
function
testAesEncrypt
()
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
'secretsalt'
=>
'SUPER_SECRET_SALT'
,
));
$original_plaintext
=
'SUPER_SECRET_TEXT'
;
$ciphertext
=
SimpleSAML\Utils\Crypto
::
aesEncrypt
(
$original_plaintext
);
$decrypted_plaintext
=
SimpleSAML\Utils\Crypto
::
aesDecrypt
(
$ciphertext
);
$this
->
assertEquals
(
$original_plaintext
,
$decrypted_plaintext
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment