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
3f3f8dbc
Unverified
Commit
3f3f8dbc
authored
7 years ago
by
Jaime Pérez Crespo
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for the new SimpleSAML\Auth\Simple::getProcessedURL()
parent
470c69ac
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/lib/SimpleSAML/Auth/SimpleTest.php
+89
-0
89 additions, 0 deletions
tests/lib/SimpleSAML/Auth/SimpleTest.php
with
89 additions
and
0 deletions
tests/lib/SimpleSAML/Auth/SimpleTest.php
0 → 100644
+
89
−
0
View file @
3f3f8dbc
<?php
namespace
SimpleSAML\Test\Auth
;
/**
* Tests for \SimpleSAML\Auth\Simple
*
*/
class
SimpleTest
extends
\SimpleSAML\Test\Utils\ClearStateTestCase
{
/**
* @test
*/
public
function
testGetProcessedURL
()
{
$class
=
new
\ReflectionClass
(
'\SimpleSAML\Auth\Simple'
);
$method
=
$class
->
getMethod
(
'getProcessedURL'
);
$method
->
setAccessible
(
true
);
// fool the routines to make them believe we are running in a web server
$_SERVER
[
'REQUEST_URI'
]
=
'/'
;
// test merging configuration option with passed URL
\SimpleSAML_Configuration
::
loadFromArray
(
array
(
'application'
=>
array
(
'baseURL'
=>
'https://example.org'
)
),
'[ARRAY]'
,
'simplesaml'
);
$s
=
new
\SimpleSAML\Auth\Simple
(
null
);
$this
->
assertEquals
(
'https://example.org/'
,
$method
->
invokeArgs
(
$s
,
array
(
null
)));
// test a full URL passed as parameter
$this
->
assertEquals
(
'https://example.org/foo/bar?a=b#fragment'
,
$method
->
invokeArgs
(
$s
,
array
(
'http://some.overridden.host/foo/bar?a=b#fragment'
)
)
);
// test a full, current URL with no parameters
$_SERVER
[
'REQUEST_URI'
]
=
'/foo/bar?a=b#fragment'
;
$this
->
assertEquals
(
'https://example.org/foo/bar?a=b#fragment'
,
$method
->
invokeArgs
(
$s
,
array
(
null
)));
// test ports are overridden by configuration
$_SERVER
[
'SERVER_PORT'
]
=
'1234'
;
$this
->
assertEquals
(
'https://example.org/foo/bar?a=b#fragment'
,
$method
->
invokeArgs
(
$s
,
array
(
null
)));
// test config option with ending with / and port
\SimpleSAML_Configuration
::
loadFromArray
(
array
(
'application'
=>
array
(
'baseURL'
=>
'http://example.org:8080/'
)
),
'[ARRAY]'
,
'simplesaml'
);
$s
=
new
\SimpleSAML\Auth\Simple
(
null
);
$this
->
assertEquals
(
'http://example.org:8080/foo/bar?a=b#fragment'
,
$method
->
invokeArgs
(
$s
,
array
(
null
)));
// test again with a relative URL as a parameter
$this
->
assertEquals
(
'http://example.org:8080/something?foo=bar#something'
,
$method
->
invokeArgs
(
$s
,
array
(
'/something?foo=bar#something'
))
);
// now test with no configuration
$_SERVER
[
'SERVER_NAME'
]
=
'example.org'
;
\SimpleSAML_Configuration
::
loadFromArray
(
array
(),
'[ARRAY]'
,
'simplesaml'
);
$s
=
new
\SimpleSAML\Auth\Simple
(
null
);
$this
->
assertEquals
(
'http://example.org:1234/foo/bar?a=b#fragment'
,
$method
->
invokeArgs
(
$s
,
array
(
null
)));
// no configuration, https and port
$_SERVER
[
'HTTPS'
]
=
'on'
;
$this
->
assertEquals
(
'https://example.org:1234/foo/bar?a=b#fragment'
,
$method
->
invokeArgs
(
$s
,
array
(
null
)));
// no configuration and a relative URL as a parameter
$this
->
assertEquals
(
'https://example.org:1234/something?foo=bar#something'
,
$method
->
invokeArgs
(
$s
,
array
(
'/something?foo=bar#something'
))
);
// finally, no configuration and full URL as a parameter
$this
->
assertEquals
(
'https://example.org/one/two/three?foo=bar#fragment'
,
$method
->
invokeArgs
(
$s
,
array
(
'https://example.org/one/two/three?foo=bar#fragment'
))
);
}
}
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