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 54 of file ilWACTokenTest.php.
◆ getModifiedSignedPath()
ilWACTokenTest::getModifiedSignedPath |
( |
|
$add_ttl = 0 , |
|
|
|
$add_timestamp = 0 , |
|
|
|
$override_token = null |
|
) |
| |
|
protected |
◆ setUp()
ilWACTokenTest::setUp |
( |
| ) |
|
|
protected |
Setup.
Definition at line 105 of file ilWACTokenTest.php.
References Vendor\Package\$c, $container, $GLOBALS, ILIAS\FileDelivery\http(), and ilWACToken\setSALT().
109 $this->root = vfs\vfsStream::setup(
'ilias.de');
110 $this->file_one = vfs\vfsStream::newFile(
'data/client_name/mobs/mm_123/dummy.jpg')
111 ->at($this->root)->setContent(
'dummy');
112 $this->file_one_subfolder = vfs\vfsStream::newFile(
'data/client_name/mobs/mm_123/mobile/dummy.jpg')
113 ->at($this->root)->setContent(
'dummy');
114 $this->file_one_subfolder_two = vfs\vfsStream::newFile(
'data/client_name/mobs/mm_123/mobile/device/dummy.jpg')
115 ->at($this->root)->setContent(
'dummy');
116 $this->file_two = vfs\vfsStream::newFile(
'data/client_name/mobs/mm_123/dummy2.jpg')
117 ->at($this->root)->setContent(
'dummy2');
118 $this->file_three = vfs\vfsStream::newFile(
'data/client_name/mobs/mm_124/dummy.jpg')
119 ->at($this->root)->setContent(
'dummy');
120 $this->file_four = vfs\vfsStream::newFile(
'data/client_name/sec/ilBlog/mm_124/dummy.jpg')
121 ->at($this->root)->setContent(
'dummy');
126 return Mockery::mock(GlobalHttpState::class);
134 $this->cookieFactory = Mockery::mock(CookieFactoryImpl::class);
137 $this->cookieFactory->shouldDeferMissing();
static http()
Fetches the global http state from ILIAS.
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
◆ testCookieGeneration()
ilWACTokenTest::testCookieGeneration |
( |
| ) |
|
Definition at line 206 of file ilWACTokenTest.php.
References $response, ILIAS\FileDelivery\http(), and ilWACSignedPath\signFolderOfStartFile().
208 $this->markTestSkipped(
'unable to use http cookies at this point');
209 $expected_cookies = [
210 '19ab58dae37d8d8cf931727c35514642',
211 '19ab58dae37d8d8cf931727c35514642ts',
212 '19ab58dae37d8d8cf931727c35514642ttl',
215 $cookieJar = Mockery::mock(CookieJar::class);
217 $response = Mockery::mock(ResponseInterface::class);
220 ->shouldReceive(
'response')
227 ->shouldReceive(
'with')
233 ->shouldReceive(
'with')
239 ->shouldReceive(
'with')
245 $this->
http->shouldReceive(
'cookieJar')
247 ->andReturn($cookieJar);
static signFolderOfStartFile($start_file_path)
static http()
Fetches the global http state from ILIAS.
◆ testFileToken()
ilWACTokenTest::testFileToken |
( |
| ) |
|
Definition at line 259 of file ilWACTokenTest.php.
References ilWACSignedPath\getTokenMaxLifetimeInSeconds(), ILIAS\FileDelivery\http(), ilWACSignedPath\setTokenMaxLifetimeInSeconds(), and ilWACSignedPath\signFile().
268 $this->assertTrue($ilWACSignedPath->isSignedPath());
269 $this->assertTrue($ilWACSignedPath->isSignedPathValid());
270 $this->assertEquals($ilWACSignedPath->getPathObject()->getClient(), self::CLIENT_NAME);
271 $this->assertFalse($ilWACSignedPath->getPathObject()->isInSecFolder());
272 $this->assertTrue($ilWACSignedPath->getPathObject()->isImage());
273 $this->assertFalse($ilWACSignedPath->getPathObject()->isAudio());
274 $this->assertFalse($ilWACSignedPath->getPathObject()->isVideo());
275 $this->assertTrue($ilWACSignedPath->getPathObject()->hasTimestamp());
276 $this->assertTrue($ilWACSignedPath->getPathObject()->hasToken());
280 sleep($lifetime + self::ADDITIONAL_TIME);
282 $this->assertTrue($ilWACSignedPath->isSignedPath());
283 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
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.
static signFile($path_to_file)
static setTokenMaxLifetimeInSeconds($token_max_lifetime_in_seconds)
static getTokenMaxLifetimeInSeconds()
◆ testModifiedTimestampAddTime()
ilWACTokenTest::testModifiedTimestampAddTime |
( |
| ) |
|
Definition at line 304 of file ilWACTokenTest.php.
References getModifiedSignedPath(), and ILIAS\FileDelivery\http().
309 $this->assertTrue($ilWACSignedPath->isSignedPath());
310 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
getModifiedSignedPath($add_ttl=0, $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 291 of file ilWACTokenTest.php.
References getModifiedSignedPath(), and ILIAS\FileDelivery\http().
296 $this->assertTrue($ilWACSignedPath->isSignedPath());
297 $this->assertTrue($ilWACSignedPath->isSignedPathValid());
getModifiedSignedPath($add_ttl=0, $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 314 of file ilWACTokenTest.php.
References getModifiedSignedPath(), and ILIAS\FileDelivery\http().
319 * -1, 0)), $this->
http, $this->cookieFactory);
320 $this->assertTrue($ilWACSignedPath->isSignedPath());
321 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
getModifiedSignedPath($add_ttl=0, $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 345 of file ilWACTokenTest.php.
References getModifiedSignedPath(), and ILIAS\FileDelivery\http().
350 $this->assertTrue($ilWACSignedPath->isSignedPath());
351 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
getModifiedSignedPath($add_ttl=0, $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 325 of file ilWACTokenTest.php.
References getModifiedSignedPath(), and ILIAS\FileDelivery\http().
330 $this->assertTrue($ilWACSignedPath->isSignedPath());
331 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
getModifiedSignedPath($add_ttl=0, $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 335 of file ilWACTokenTest.php.
References getModifiedSignedPath(), and ILIAS\FileDelivery\http().
340 $this->assertTrue($ilWACSignedPath->isSignedPath());
341 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
getModifiedSignedPath($add_ttl=0, $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 175 of file ilWACTokenTest.php.
References $query, and ILIAS\FileDelivery\http().
179 .
$query), $this->
http, $this->cookieFactory);
181 $this->assertEquals(
'dummy.jpg', $ilWACSignedPath->getPathObject()->getFileName());
182 $this->assertEquals(
$query, $ilWACSignedPath->getPathObject()->getQuery());
183 $this->assertEquals(
'./data/' . self::CLIENT_NAME
184 .
'/sec/ilBlog/mm_124/', $ilWACSignedPath->getPathObject()
186 $this->assertEquals(
'ilBlog', $ilWACSignedPath->getPathObject()->getSecurePathId());
187 $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 191 of file ilWACTokenTest.php.
References ilWACToken\generateToken(), and ilWACToken\getSALT().
193 $ilWacPath =
new ilWacPath($this->file_four->url());
194 $ilWACToken =
new ilWACToken($ilWacPath->getPath(), self::CLIENT_NAME, 123456, 20);
196 $this->assertEquals(
'SALT-client_name-123456-20', $ilWACToken->getRawToken());
197 $this->assertEquals(
'./data/client_name/sec/ilBlog/mm_124/dummy.jpg', $ilWACToken->getId());
200 $ilWACToken =
new ilWACToken($ilWacPath->getPath(), self::CLIENT_NAME, 123456, 20);
201 $this->assertEquals(
'b541e2bae42ee222f9be959b7ad2ab8844cbb05b', $ilWACToken->getToken());
202 $this->assertEquals(
'e45b98f267dc891c8206c844f7df29ea', $ilWACToken->getHashedId());
◆ testWithoutSigning()
ilWACTokenTest::testWithoutSigning |
( |
| ) |
|
Definition at line 143 of file ilWACTokenTest.php.
References ILIAS\FileDelivery\http().
147 $cookieJar = Mockery::mock(CookieJar::class);
150 ->shouldReceive(
'getAll')
155 $this->
http->shouldReceive(
'cookieJar')
158 ->andReturn($cookieJar);
160 $request = Mockery::mock(Psr\Http\Message\RequestInterface::class);
161 $request->shouldReceive(
'getCookieParams')
164 $this->
http->shouldReceive(
'request')
166 ->andReturn($request);
168 $this->assertFalse($ilWACSignedPath->isSignedPath());
169 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
170 $this->assertFalse($ilWACSignedPath->isFolderSigned());
171 $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: