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
d9a27ebb
Commit
d9a27ebb
authored
8 years ago
by
vrioux
Browse files
Options
Downloads
Patches
Plain Diff
first try at writing tests
parent
0d27fbc2
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/modules/consent/lib/Auth/Process/ConsentTest.php
+109
-0
109 additions, 0 deletions
tests/modules/consent/lib/Auth/Process/ConsentTest.php
with
109 additions
and
0 deletions
tests/modules/consent/lib/Auth/Process/ConsentTest.php
0 → 100644
+
109
−
0
View file @
d9a27ebb
<?php
/**
* Test for the consent:Process filter.
*
* @author Vincent Rioux <vrioux@ctech.ca>
* @package SimpleSAMLphp
*/
namespace
SimpleSAML\Test\Module\consent\Auth\Process
;
class
ProcessTest
extends
\PHPUnit_Framework_TestCase
{
/*
* Helper function to run the filter with a given configuration.
*
* @param array $config The filter configuration.
* @param array $request The request state.
* @return array The state array after processing.
*/
private
function
processFilter
(
array
$config
,
array
$request
)
{
//$filter = new \SimpleSAML\Module\saml\consent\Process\FilterScopes($config, null);
$filter
=
new
sspmod_consent_Auth_Process_Consent
(
$config
,
null
);
$filter
->
process
(
$request
);
return
$request
;
}
/**
* Test valid consent disable.
*/
public
function
testValidConsentDisableRegex
()
{
// test consent disable regex with match
$config
=
array
(
'consent.disable'
=>
array
(
'type'
=>
'regex'
,
'pattern'
=>
'/.*\.example\.org.*/i'
,
),
);
$request
=
array
(
'Source'
=>
array
(
'SingleSignOnService'
=>
array
(
array
(
'Binding'
=>
'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect'
,
'Location'
=>
'https://www.example.org/saml2/idp/SSOService.php'
,
),
),
),
'Attributes'
=>
array
(
'eduPersonPrincipalName'
=>
array
(
'jdoe@example.com'
),
),
);
$result
=
$this
->
processFilter
(
$config
,
$request
);
$this
->
assertEquals
(
$request
[
'Attributes'
],
$result
[
'Attributes'
]);
// test consent disable regex without match
$config
=
array
(
'consent.disable'
=>
array
(
'type'
=>
'regex'
,
'pattern'
=>
'/.*\.otherexample\.org.*/i'
,
),
);
$request
=
array
(
'Source'
=>
array
(
'SingleSignOnService'
=>
array
(
array
(
'Binding'
=>
'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect'
,
'Location'
=>
'https://www.example.org/saml2/idp/SSOService.php'
,
),
),
),
'Attributes'
=>
array
(
'eduPersonPrincipalName'
=>
array
(
'jdoe@example.com'
),
),
);
$result
=
$this
->
processFilter
(
$config
,
$request
);
$this
->
assertEquals
(
array
(),
$result
[
'Attributes'
]);
}
/**
* Test invalid consent disable.
*/
public
function
testInvalidConsentDisable
()
{
// test consent disable regex with wrong value format in config
$config
=
array
(
'consent.disable'
=>
array
(
'type'
=>
'regex'
,
'/.*\.example\.org.*/i'
,
),
);
$request
=
array
(
'Source'
=>
array
(
'SingleSignOnService'
=>
array
(
array
(
'Binding'
=>
'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect'
,
'Location'
=>
'https://www.example.org/saml2/idp/SSOService.php'
,
),
),
),
'Attributes'
=>
array
(
'eduPersonPrincipalName'
=>
array
(
'jdoe@example.com'
),
),
);
$result
=
$this
->
processFilter
(
$config
,
$request
);
$this
->
assertEquals
(
array
(),
$result
[
'Attributes'
]);
}
}
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