TestCase for the ilWACTokenTest.
More...
TestCase for the ilWACTokenTest.
- Author
- Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
- Version
- 1.0.0
disabled disabled disabled
Definition at line 43 of file ilWACTokenTest.php.
◆ getModifiedSignedPath()
ilWACTokenTest::getModifiedSignedPath |
( |
int |
$add_ttl = 0 , |
|
|
int |
$add_timestamp = 0 , |
|
|
|
$override_token = null |
|
) |
| |
|
protected |
- Parameters
-
Definition at line 340 of file ilWACTokenTest.php.
References $parts, $path, $query, $token, ILIAS\Repository\int(), ilWACSignedPath\setTokenMaxLifetimeInSeconds(), and ilWACSignedPath\signFile().
Referenced by testModifiedTimestampAddTime(), testModifiedTimestampNoMod(), testModifiedTimestampSubTime(), testModifiedToken(), testModifiedTTL(), and testModifiedTTLAndTimestamp().
345 $parts = parse_url($signed_path);
346 $path = $parts[
'path'];
348 parse_str(
$query, $query_array);
349 $token = $override_token ? $override_token : $query_array[
'il_wac_token'];
350 $ttl = (
int) $query_array[
'il_wac_ttl'];
351 $ts = (
int) $query_array[
'il_wac_ts'];
352 $path_with_token =
$path .
'?il_wac_token=' .
$token;
354 $modified_ttl = $ttl + $add_ttl;
355 $modified_ts = $ts + $add_timestamp;
357 return $path_with_token .
'&il_wac_ttl=' . $modified_ttl .
'&il_wac_ts=' . $modified_ts;
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
static setTokenMaxLifetimeInSeconds(int $token_max_lifetime_in_seconds)
static signFile(string $path_to_file)
◆ setUp()
ilWACTokenTest::setUp |
( |
| ) |
|
|
protected |
Setup.
Definition at line 94 of file ilWACTokenTest.php.
References $c, $container, $GLOBALS, ILIAS\FileDelivery\http(), and ilWACToken\setSALT().
98 $this->root = vfs\vfsStream::setup(
'ilias.de');
99 $this->file_one = vfs\vfsStream::newFile(
'data/client_name/mobs/mm_123/dummy.jpg')
100 ->at($this->root)->setContent(
'dummy');
101 $this->file_one_subfolder = vfs\vfsStream::newFile(
'data/client_name/mobs/mm_123/mobile/dummy.jpg')
102 ->at($this->root)->setContent(
'dummy');
103 $this->file_one_subfolder_two = vfs\vfsStream::newFile(
'data/client_name/mobs/mm_123/mobile/device/dummy.jpg')
104 ->at($this->root)->setContent(
'dummy');
105 $this->file_two = vfs\vfsStream::newFile(
'data/client_name/mobs/mm_123/dummy2.jpg')
106 ->at($this->root)->setContent(
'dummy2');
107 $this->file_three = vfs\vfsStream::newFile(
'data/client_name/mobs/mm_124/dummy.jpg')
108 ->at($this->root)->setContent(
'dummy');
109 $this->file_four = vfs\vfsStream::newFile(
'data/client_name/sec/ilBlog/mm_124/dummy.jpg')
110 ->at($this->root)->setContent(
'dummy');
114 $container[
'http'] = fn(
$c) => Mockery::mock(GlobalHttpState::class);
121 $this->cookieFactory = Mockery::mock(CookieFactoryImpl::class);
124 $this->cookieFactory->shouldDeferMissing();
static setSALT(string $salt)
static http()
Fetches the global http state from ILIAS.
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
◆ testCookieGeneration()
ilWACTokenTest::testCookieGeneration |
( |
| ) |
|
Definition at line 193 of file ilWACTokenTest.php.
References $response, ILIAS\FileDelivery\http(), and ilWACSignedPath\signFolderOfStartFile().
195 $this->markTestSkipped(
'unable to use http cookies at this point');
197 $cookieJar = Mockery::mock(CookieJar::class);
199 $response = Mockery::mock(ResponseInterface::class);
202 ->shouldReceive(
'response')
209 ->shouldReceive(
'with')
215 ->shouldReceive(
'with')
221 ->shouldReceive(
'with')
227 $this->
http->shouldReceive(
'cookieJar')
229 ->andReturn($cookieJar);
static http()
Fetches the global http state from ILIAS.
static signFolderOfStartFile(string $start_file_path)
◆ testFileToken()
ilWACTokenTest::testFileToken |
( |
| ) |
|
Definition at line 241 of file ilWACTokenTest.php.
References CLIENT_NAME, ilWACSignedPath\getTokenMaxLifetimeInSeconds(), ILIAS\FileDelivery\http(), ilWACSignedPath\setTokenMaxLifetimeInSeconds(), and ilWACSignedPath\signFile().
250 $this->assertTrue($ilWACSignedPath->isSignedPath());
251 $this->assertTrue($ilWACSignedPath->isSignedPathValid());
252 $this->assertEquals($ilWACSignedPath->getPathObject()->getClient(),
self::CLIENT_NAME);
253 $this->assertFalse($ilWACSignedPath->getPathObject()->isInSecFolder());
254 $this->assertTrue($ilWACSignedPath->getPathObject()->isImage());
255 $this->assertFalse($ilWACSignedPath->getPathObject()->isAudio());
256 $this->assertFalse($ilWACSignedPath->getPathObject()->isVideo());
257 $this->assertTrue($ilWACSignedPath->getPathObject()->hasTimestamp());
258 $this->assertTrue($ilWACSignedPath->getPathObject()->hasToken());
262 sleep($lifetime + self::ADDITIONAL_TIME);
264 $this->assertTrue($ilWACSignedPath->isSignedPath());
265 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static setTokenMaxLifetimeInSeconds(int $token_max_lifetime_in_seconds)
static http()
Fetches the global http state from ILIAS.
static signFile(string $path_to_file)
static getTokenMaxLifetimeInSeconds()
◆ testModifiedTimestampAddTime()
ilWACTokenTest::testModifiedTimestampAddTime |
( |
| ) |
|
Definition at line 286 of file ilWACTokenTest.php.
References getModifiedSignedPath(), and ILIAS\FileDelivery\http().
291 $this->assertTrue($ilWACSignedPath->isSignedPath());
292 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
getModifiedSignedPath(int $add_ttl=0, int $add_timestamp=0, $override_token=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
◆ testModifiedTimestampNoMod()
ilWACTokenTest::testModifiedTimestampNoMod |
( |
| ) |
|
Definition at line 273 of file ilWACTokenTest.php.
References getModifiedSignedPath(), and ILIAS\FileDelivery\http().
278 $this->assertTrue($ilWACSignedPath->isSignedPath());
279 $this->assertTrue($ilWACSignedPath->isSignedPathValid());
getModifiedSignedPath(int $add_ttl=0, int $add_timestamp=0, $override_token=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
◆ testModifiedTimestampSubTime()
ilWACTokenTest::testModifiedTimestampSubTime |
( |
| ) |
|
Definition at line 296 of file ilWACTokenTest.php.
References getModifiedSignedPath(), and ILIAS\FileDelivery\http().
301 * -1, 0),
false), $this->
http, $this->cookieFactory);
302 $this->assertTrue($ilWACSignedPath->isSignedPath());
303 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
getModifiedSignedPath(int $add_ttl=0, int $add_timestamp=0, $override_token=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
◆ testModifiedToken()
ilWACTokenTest::testModifiedToken |
( |
| ) |
|
Definition at line 327 of file ilWACTokenTest.php.
References getModifiedSignedPath(), and ILIAS\FileDelivery\http().
332 $this->assertTrue($ilWACSignedPath->isSignedPath());
333 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
getModifiedSignedPath(int $add_ttl=0, int $add_timestamp=0, $override_token=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
◆ testModifiedTTL()
ilWACTokenTest::testModifiedTTL |
( |
| ) |
|
Definition at line 307 of file ilWACTokenTest.php.
References getModifiedSignedPath(), and ILIAS\FileDelivery\http().
312 $this->assertTrue($ilWACSignedPath->isSignedPath());
313 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
getModifiedSignedPath(int $add_ttl=0, int $add_timestamp=0, $override_token=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
◆ testModifiedTTLAndTimestamp()
ilWACTokenTest::testModifiedTTLAndTimestamp |
( |
| ) |
|
Definition at line 317 of file ilWACTokenTest.php.
References getModifiedSignedPath(), and ILIAS\FileDelivery\http().
322 $this->assertTrue($ilWACSignedPath->isSignedPath());
323 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
getModifiedSignedPath(int $add_ttl=0, int $add_timestamp=0, $override_token=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
◆ testSomeBasics()
ilWACTokenTest::testSomeBasics |
( |
| ) |
|
Definition at line 162 of file ilWACTokenTest.php.
References $query, CLIENT_NAME, and ILIAS\FileDelivery\http().
166 .
$query,
false), $this->
http, $this->cookieFactory);
168 $this->assertEquals(
'dummy.jpg', $ilWACSignedPath->getPathObject()->getFileName());
169 $this->assertEquals(
$query, $ilWACSignedPath->getPathObject()->getQuery());
171 .
'/sec/ilBlog/mm_124/', $ilWACSignedPath->getPathObject()
173 $this->assertEquals(
'ilBlog', $ilWACSignedPath->getPathObject()->getSecurePathId());
174 $this->assertFalse($ilWACSignedPath->getPathObject()->isStreamable());
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
◆ testTokenGeneration()
ilWACTokenTest::testTokenGeneration |
( |
| ) |
|
Definition at line 178 of file ilWACTokenTest.php.
References CLIENT_NAME, ilWACToken\generateToken(), and ilWACToken\getSALT().
180 $ilWacPath =
new ilWacPath($this->file_four->url(),
false);
183 $this->assertEquals(
'SALT-client_name-123456-20', $ilWACToken->getRawToken());
184 $this->assertEquals(
'./data/client_name/sec/ilBlog/mm_124/dummy.jpg', $ilWACToken->getId());
188 $this->assertEquals(
'b541e2bae42ee222f9be959b7ad2ab8844cbb05b', $ilWACToken->getToken());
189 $this->assertEquals(
'e45b98f267dc891c8206c844f7df29ea', $ilWACToken->getHashedId());
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
◆ testWithoutSigning()
ilWACTokenTest::testWithoutSigning |
( |
| ) |
|
Definition at line 130 of file ilWACTokenTest.php.
References ILIAS\FileDelivery\http().
134 $cookieJar = Mockery::mock(CookieJar::class);
137 ->shouldReceive(
'getAll')
142 $this->
http->shouldReceive(
'cookieJar')
145 ->andReturn($cookieJar);
147 $request = Mockery::mock(Psr\Http\Message\RequestInterface::class);
148 $request->shouldReceive(
'getCookieParams')
151 $this->
http->shouldReceive(
'request')
153 ->andReturn($request);
155 $this->assertFalse($ilWACSignedPath->isSignedPath());
156 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
157 $this->assertFalse($ilWACSignedPath->isFolderSigned());
158 $this->assertFalse($ilWACSignedPath->isFolderTokenValid());
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
◆ $backupGlobals
ilWACTokenTest::$backupGlobals = false |
|
protected |
◆ $cookieFactory
◆ $file_four
ilWACTokenTest::$file_four |
|
protected |
◆ $file_one
ilWACTokenTest::$file_one |
|
protected |
◆ $file_one_subfolder
ilWACTokenTest::$file_one_subfolder |
|
protected |
◆ $file_one_subfolder_two
ilWACTokenTest::$file_one_subfolder_two |
|
protected |
◆ $file_three
ilWACTokenTest::$file_three |
|
protected |
◆ $file_two
ilWACTokenTest::$file_two |
|
protected |
◆ $http
◆ $root
◆ ADDITIONAL_TIME
const ilWACTokenTest::ADDITIONAL_TIME = 1 |
◆ CLIENT_NAME
const ilWACTokenTest::CLIENT_NAME = 'client_name' |
◆ LIFETIME
const ilWACTokenTest::LIFETIME = 2 |
◆ SALT
const ilWACTokenTest::SALT = 'SALT' |
The documentation for this class was generated from the following file: