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
2d06c575
Commit
2d06c575
authored
9 years ago
by
Thijs Kinkhorst
Browse files
Options
Downloads
Patches
Plain Diff
Add more tests.
parent
2d6cf6ed
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/AttributeAlterTest.php
+266
-2
266 additions, 2 deletions
tests/modules/core/lib/Auth/Process/AttributeAlterTest.php
with
266 additions
and
2 deletions
tests/modules/core/lib/Auth/Process/AttributeAlterTest.php
+
266
−
2
View file @
2d06c575
...
...
@@ -33,20 +33,92 @@ class Test_Core_Auth_Process_AttributeAlter extends PHPUnit_Framework_TestCase
$request
=
array
(
'Attributes'
=>
array
(
'test'
=>
array
(
'wrong'
),
'test'
=>
array
(
'
somethingis
wrong'
),
),
);
$result
=
self
::
processFilter
(
$config
,
$request
);
$attributes
=
$result
[
'Attributes'
];
$this
->
assertArrayHasKey
(
'test'
,
$attributes
);
$this
->
assertEquals
(
$attributes
[
'test'
],
array
(
'right'
));
$this
->
assertEquals
(
$attributes
[
'test'
],
array
(
'somethingisright'
));
}
/**
* Test the most basic functionality.
*/
public
function
testWithTarget
()
{
$config
=
array
(
'subject'
=>
'test'
,
'target'
=>
'test2'
,
'pattern'
=>
'/wrong/'
,
'replacement'
=>
'right'
,
);
$request
=
array
(
'Attributes'
=>
array
(
'something'
=>
array
(
'somethingelse'
),
'test'
=>
array
(
'wrong'
),
),
);
$result
=
self
::
processFilter
(
$config
,
$request
);
$attributes
=
$result
[
'Attributes'
];
$this
->
assertArrayHasKey
(
'test2'
,
$attributes
);
$this
->
assertEquals
(
$attributes
[
'test'
],
array
(
'wrong'
));
$this
->
assertEquals
(
$attributes
[
'test2'
],
array
(
'right'
));
}
/**
* Module is a no op if subject attribute is not present.
*/
public
function
testNomatch
()
{
$config
=
array
(
'subject'
=>
'test'
,
'pattern'
=>
'/wrong/'
,
'replacement'
=>
'right'
,
);
$request
=
array
(
'Attributes'
=>
array
(
'something'
=>
array
(
'somevalue'
),
'somethingelse'
=>
array
(
'someothervalue'
),
),
);
$result
=
self
::
processFilter
(
$config
,
$request
);
$attributes
=
$result
[
'Attributes'
];
$this
->
assertEquals
(
$attributes
,
array
(
'something'
=>
array
(
'somevalue'
),
'somethingelse'
=>
array
(
'someothervalue'
)));
}
/**
* Test replacing attribute value.
*/
public
function
testReplaceMatch
()
{
$config
=
array
(
'subject'
=>
'source'
,
'pattern'
=>
'/wrong/'
,
'replacement'
=>
'right'
,
'%replace'
,
);
$request
=
array
(
'Attributes'
=>
array
(
'source'
=>
array
(
'wrongthing'
),
),
);
$result
=
self
::
processFilter
(
$config
,
$request
);
$attributes
=
$result
[
'Attributes'
];
$this
->
assertEquals
(
$attributes
[
'source'
],
array
(
'right'
));
}
/**
* Test replacing attribute value.
*/
public
function
testReplaceMatchWithTarget
()
{
$config
=
array
(
'subject'
=>
'source'
,
...
...
@@ -89,5 +161,197 @@ class Test_Core_Auth_Process_AttributeAlter extends PHPUnit_Framework_TestCase
$this
->
assertEquals
(
$attributes
[
'test'
],
array
(
'right'
));
}
/**
* Test removing attribute values.
* Note that removing a value does not renumber the attributes array.
* Also ensure unrelated attributes are not touched.
*/
public
function
testRemoveMatch
()
{
$config
=
array
(
'subject'
=>
'eduPersonAffiliation'
,
'pattern'
=>
'/^emper/'
,
'%remove'
,
);
$request
=
array
(
'Attributes'
=>
array
(
'displayName'
=>
array
(
'emperor kuzco'
),
'eduPersonAffiliation'
=>
array
(
'member'
,
'emperor'
,
'staff'
),
),
);
$result
=
self
::
processFilter
(
$config
,
$request
);
$attributes
=
$result
[
'Attributes'
];
$this
->
assertEquals
(
$attributes
[
'displayName'
],
array
(
'emperor kuzco'
));
$this
->
assertEquals
(
$attributes
[
'eduPersonAffiliation'
],
array
(
0
=>
'member'
,
2
=>
'staff'
));
}
/**
* Test removing attribute values, resulting in an empty attribute.
*/
public
function
testRemoveMatchAll
()
{
$config
=
array
(
'subject'
=>
'eduPersonAffiliation'
,
'pattern'
=>
'/^emper/'
,
'%remove'
,
);
$request
=
array
(
'Attributes'
=>
array
(
'displayName'
=>
array
(
'emperor kuzco'
),
'eduPersonAffiliation'
=>
array
(
'emperess'
,
'emperor'
),
),
);
$result
=
self
::
processFilter
(
$config
,
$request
);
$attributes
=
$result
[
'Attributes'
];
$this
->
assertArrayNotHasKey
(
'eduPersonAffiliation'
,
$attributes
);
}
/**
* Test for exception with illegal config.
*
* @expectedException Exception
*/
public
function
testWrongConfig
()
{
$config
=
array
(
'subject'
=>
'eduPersonAffiliation'
,
'pattern'
=>
'/^emper/'
,
'%dwiw'
,
);
$request
=
array
(
'Attributes'
=>
array
(
'eduPersonAffiliation'
=>
array
(
'emperess'
,
'emperor'
),
),
);
$result
=
self
::
processFilter
(
$config
,
$request
);
}
/**
* Test for exception with illegal config.
*
* @expectedException Exception
*/
public
function
testIncompleteConfig
()
{
$config
=
array
(
'subject'
=>
'eduPersonAffiliation'
,
);
$request
=
array
(
'Attributes'
=>
array
(
'eduPersonAffiliation'
=>
array
(
'emperess'
,
'emperor'
),
),
);
$result
=
self
::
processFilter
(
$config
,
$request
);
}
/**
* Test for exception with illegal config.
*
* @expectedException Exception
*/
public
function
testIncompleteConfig2
()
{
$config
=
array
(
'subject'
=>
'test'
,
'pattern'
=>
'/wrong/'
,
);
$request
=
array
(
'Attributes'
=>
array
(
'test'
=>
array
(
'somethingiswrong'
),
),
);
$request
=
array
(
'Attributes'
=>
array
(
'eduPersonAffiliation'
=>
array
(
'emperess'
,
'emperor'
),
),
);
$result
=
self
::
processFilter
(
$config
,
$request
);
}
/**
* Test for exception with illegal config.
*
* @expectedException Exception
*/
public
function
testIncompleteConfig3
()
{
$config
=
array
(
'subject'
=>
'test'
,
'pattern'
=>
'/wrong/'
,
'%replace'
,
'%remove'
,
);
$request
=
array
(
'Attributes'
=>
array
(
'test'
=>
array
(
'somethingiswrong'
),
),
);
$request
=
array
(
'Attributes'
=>
array
(
'eduPersonAffiliation'
=>
array
(
'emperess'
,
'emperor'
),
),
);
$result
=
self
::
processFilter
(
$config
,
$request
);
}
/**
* Test for exception with illegal config.
*
* @expectedException Exception
*/
public
function
testIncompleteConfig4
()
{
$config
=
array
(
'subject'
=>
'test'
,
'pattern'
=>
'/wrong/'
,
'target'
=>
'test2'
,
'%remove'
,
);
$request
=
array
(
'Attributes'
=>
array
(
'test'
=>
array
(
'somethingiswrong'
),
),
);
$request
=
array
(
'Attributes'
=>
array
(
'eduPersonAffiliation'
=>
array
(
'emperess'
,
'emperor'
),
),
);
$result
=
self
::
processFilter
(
$config
,
$request
);
}
/**
* Test for exception with illegal config.
*
* @expectedException Exception
*/
public
function
testIncompleteConfig5
()
{
$config
=
array
(
'subject'
=>
'test'
,
'pattern'
=>
'/wrong/'
,
'replacement'
=>
null
,
);
$request
=
array
(
'Attributes'
=>
array
(
'test'
=>
array
(
'somethingiswrong'
),
),
);
$request
=
array
(
'Attributes'
=>
array
(
'eduPersonAffiliation'
=>
array
(
'emperess'
,
'emperor'
),
),
);
$result
=
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