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
52849114
Commit
52849114
authored
2 years ago
by
Tim van Dijen
Browse files
Options
Downloads
Patches
Plain Diff
WIP: add test
parent
2473fc47
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/saml/lib/Controller/Metadata.php
+1
-1
1 addition, 1 deletion
modules/saml/lib/Controller/Metadata.php
tests/modules/saml/lib/Controller/MetadataTest.php
+116
-0
116 additions, 0 deletions
tests/modules/saml/lib/Controller/MetadataTest.php
with
117 additions
and
1 deletion
modules/saml/lib/Controller/Metadata.php
+
1
−
1
View file @
52849114
...
...
@@ -35,7 +35,7 @@ class Metadata
/**
* Controller constructor.
-
*
*
* It initializes the global configuration for the controllers implemented here.
*
* @param \SimpleSAML\Configuration $config The configuration to use by the controllers.
...
...
This diff is collapsed.
Click to expand it.
tests/modules/saml/lib/Controller/MetadataTest.php
0 → 100644
+
116
−
0
View file @
52849114
<?php
declare
(
strict_types
=
1
);
namespace
SimpleSAML\Test\Module\saml\Controller
;
use
PHPUnit\Framework\TestCase
;
use
SimpleSAML\Configuration
;
use
SimpleSAML\Http\RunnableResponse
;
use
SimpleSAML\Module\saml\Controller
;
use
SimpleSAML\Session
;
use
SimpleSAML\Utils
;
//use Symfony\Component\HttpFoundation\Request;
use
Symfony\Component\HttpFoundation\Response
;
/**
* Set of tests for the controllers in the "saml" module.
*
* @covers \SimpleSAML\Module\saml\Controller\Metadata
* @package SimpleSAML\Test
*/
class
MetadataTest
extends
TestCase
{
/** @var \SimpleSAML\Configuration */
protected
Configuration
$config
;
/** @var \SimpleSAML\Session */
protected
Session
$session
;
/**
* Set up for each test.
*/
protected
function
setUp
():
void
{
parent
::
setUp
();
$this
->
session
=
Session
::
getSessionFromRequest
();
$this
->
config
=
Configuration
::
loadFromArray
(
[
'module.enable'
=>
[
'saml'
=>
true
],
'enable.saml20-idp'
=>
true
,
'admin.protectmetadata'
=>
true
,
],
'[ARRAY]'
,
'simplesaml'
);
Configuration
::
setPreLoadedConfig
(
$this
->
config
,
'config.php'
);
Configuration
::
setPreLoadedConfig
(
Configuration
::
loadFromArray
(
[
'admin'
=>
[
'core:AdminPassword'
],
'phpunit'
=>
[
'saml:SP'
],
],
'[ARRAY]'
,
'simplesaml'
),
'authsources.php'
,
'simplesaml'
);
$this
->
authUtils
=
new
class
()
extends
Utils\Auth
{
public
function
requireAdmin
():
void
{
// stub
}
};
}
/**
* Test that accessing the metadata-endpoint with or without authentication
* and admin.protectmetadata set to true or false is handled properly
*
* @dataProvider provideMetadataAccess
* @param bool $protected
* @param bool $authenticated
* @return void
*/
public
function
testMetadataAccess
(
bool
$authenticated
,
bool
$protected
):
void
{
$c
=
new
Controller\ServiceProvider
(
$this
->
config
,
$this
->
session
);
if
(
$authenticated
===
true
||
$protected
===
false
)
{
// Bypass authentication - mock being authenticated
$c
->
setAuthUtils
(
$this
->
authUtils
);
}
$result
=
$c
->
metadata
(
'phpunit'
);
if
(
$authenticated
!==
false
&&
$protected
!==
true
)
{
// ($authenticated === true) or ($protected === false)
// Should lead to a Response
$this
->
assertInstanceOf
(
Response
::
class
,
$result
);
}
else
{
$this
->
assertInstanceOf
(
RunnableResponse
::
class
,
$result
);
}
}
/**
* @return array
*/
public
function
provideMetadataAccess
():
array
{
return
[
/* [authenticated, protected] */
[
false
,
false
],
[
false
,
true
],
[
true
,
false
],
[
true
,
true
],
];
}
}
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