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
4e67137f
Unverified
Commit
4e67137f
authored
7 years ago
by
Matt Schwager
Browse files
Options
Downloads
Patches
Plain Diff
Added tests for sspmod_core_Auth_Process_AttributeMap
parent
425aa2ba
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/modules/core/lib/Auth/Process/AttributeMapTest.php
+155
-0
155 additions, 0 deletions
tests/modules/core/lib/Auth/Process/AttributeMapTest.php
with
155 additions
and
0 deletions
tests/modules/core/lib/Auth/Process/AttributeMapTest.php
0 → 100644
+
155
−
0
View file @
4e67137f
<?php
use
PHPUnit\Framework\TestCase
;
/**
* Test for the core:AttributeMap filter.
*/
class
Test_Core_Auth_Process_AttributeMap
extends
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
static
function
processFilter
(
array
$config
,
array
$request
)
{
$filter
=
new
sspmod_core_Auth_Process_AttributeMap
(
$config
,
null
);
$filter
->
process
(
$request
);
return
$request
;
}
public
function
testBasic
()
{
$config
=
[
'attribute1'
=>
'attribute2'
,
];
$request
=
[
'Attributes'
=>
[
'attribute1'
=>
[
'value'
],
],
];
$processed
=
self
::
processFilter
(
$config
,
$request
);
$result
=
$processed
[
'Attributes'
];
$expected
=
[
'attribute2'
=>
[
'value'
],
];
$this
->
assertEquals
(
$expected
,
$result
);
}
public
function
testDuplicate
()
{
$config
=
[
'attribute1'
=>
'attribute2'
,
'%duplicate'
,
];
$request
=
[
'Attributes'
=>
[
'attribute1'
=>
[
'value'
],
],
];
$processed
=
self
::
processFilter
(
$config
,
$request
);
$result
=
$processed
[
'Attributes'
];
$expected
=
[
'attribute1'
=>
[
'value'
],
'attribute2'
=>
[
'value'
],
];
$this
->
assertEquals
(
$expected
,
$result
);
}
public
function
testMultiple
()
{
$config
=
[
'attribute1'
=>
[
'attribute2'
,
'attribute3'
],
];
$request
=
[
'Attributes'
=>
[
'attribute1'
=>
[
'value'
],
],
];
$processed
=
self
::
processFilter
(
$config
,
$request
);
$result
=
$processed
[
'Attributes'
];
$expected
=
[
'attribute2'
=>
[
'value'
],
'attribute3'
=>
[
'value'
],
];
$this
->
assertEquals
(
$expected
,
$result
);
}
public
function
testMultipleDuplicate
()
{
$config
=
[
'attribute1'
=>
[
'attribute2'
,
'attribute3'
],
'%duplicate'
,
];
$request
=
[
'Attributes'
=>
[
'attribute1'
=>
[
'value'
],
],
];
$processed
=
self
::
processFilter
(
$config
,
$request
);
$result
=
$processed
[
'Attributes'
];
$expected
=
[
'attribute1'
=>
[
'value'
],
'attribute2'
=>
[
'value'
],
'attribute3'
=>
[
'value'
],
];
$this
->
assertEquals
(
$expected
,
$result
);
}
public
function
testInvalidOriginalAttributeType
()
{
$config
=
[
10
=>
'attribute2'
,
];
$request
=
[
'Attributes'
=>
[
'attribute1'
=>
[
'value'
],
],
];
$this
->
setExpectedException
(
'\Exception'
);
self
::
processFilter
(
$config
,
$request
);
}
public
function
testInvalidMappedAttributeType
()
{
$config
=
[
'attribute1'
=>
10
,
];
$request
=
[
'Attributes'
=>
[
'attribute1'
=>
[
'value'
],
],
];
$this
->
setExpectedException
(
'\Exception'
);
self
::
processFilter
(
$config
,
$request
);
}
public
function
testMissingMapFile
()
{
$config
=
[
'non_existant_mapfile'
,
];
$request
=
[
'Attributes'
=>
[
'attribute1'
=>
[
'value'
],
],
];
$this
->
setExpectedException
(
'\Exception'
);
self
::
processFilter
(
$config
,
$request
);
}
}
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