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 48 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 99 of file ilWACTokenTest.php.
References $c, $container, $GLOBALS, ILIAS\FileDelivery\http(), and ilWACToken\setSALT().
103 $this->root = vfs\vfsStream::setup(
'ilias.de');
104 $this->file_one = vfs\vfsStream::newFile(
'data/client_name/mobs/mm_123/dummy.jpg')
105 ->at($this->root)->setContent(
'dummy');
106 $this->file_one_subfolder = vfs\vfsStream::newFile(
'data/client_name/mobs/mm_123/mobile/dummy.jpg')
107 ->at($this->root)->setContent(
'dummy');
108 $this->file_one_subfolder_two = vfs\vfsStream::newFile(
'data/client_name/mobs/mm_123/mobile/device/dummy.jpg')
109 ->at($this->root)->setContent(
'dummy');
110 $this->file_two = vfs\vfsStream::newFile(
'data/client_name/mobs/mm_123/dummy2.jpg')
111 ->at($this->root)->setContent(
'dummy2');
112 $this->file_three = vfs\vfsStream::newFile(
'data/client_name/mobs/mm_124/dummy.jpg')
113 ->at($this->root)->setContent(
'dummy');
114 $this->file_four = vfs\vfsStream::newFile(
'data/client_name/sec/ilBlog/mm_124/dummy.jpg')
115 ->at($this->root)->setContent(
'dummy');
120 return Mockery::mock(GlobalHttpState::class);
128 $this->cookieFactory = Mockery::mock(CookieFactoryImpl::class);
131 $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 200 of file ilWACTokenTest.php.
References $response, ILIAS\FileDelivery\http(), and ilWACSignedPath\signFolderOfStartFile().
202 $this->markTestSkipped(
'unable to use http cookies at this point');
203 $expected_cookies = [
204 '19ab58dae37d8d8cf931727c35514642',
205 '19ab58dae37d8d8cf931727c35514642ts',
206 '19ab58dae37d8d8cf931727c35514642ttl',
209 $cookieJar = Mockery::mock(CookieJar::class);
211 $response = Mockery::mock(ResponseInterface::class);
214 ->shouldReceive(
'response')
221 ->shouldReceive(
'with')
227 ->shouldReceive(
'with')
233 ->shouldReceive(
'with')
239 $this->
http->shouldReceive(
'cookieJar')
241 ->andReturn($cookieJar);
static signFolderOfStartFile($start_file_path)
static http()
Fetches the global http state from ILIAS.
◆ testFileToken()
ilWACTokenTest::testFileToken |
( |
| ) |
|
Definition at line 253 of file ilWACTokenTest.php.
References CLIENT_NAME, ilWACSignedPath\getTokenMaxLifetimeInSeconds(), ILIAS\FileDelivery\http(), ilWACSignedPath\setTokenMaxLifetimeInSeconds(), and ilWACSignedPath\signFile().
262 $this->assertTrue($ilWACSignedPath->isSignedPath());
263 $this->assertTrue($ilWACSignedPath->isSignedPathValid());
264 $this->assertEquals($ilWACSignedPath->getPathObject()->getClient(),
self::CLIENT_NAME);
265 $this->assertFalse($ilWACSignedPath->getPathObject()->isInSecFolder());
266 $this->assertTrue($ilWACSignedPath->getPathObject()->isImage());
267 $this->assertFalse($ilWACSignedPath->getPathObject()->isAudio());
268 $this->assertFalse($ilWACSignedPath->getPathObject()->isVideo());
269 $this->assertTrue($ilWACSignedPath->getPathObject()->hasTimestamp());
270 $this->assertTrue($ilWACSignedPath->getPathObject()->hasToken());
274 sleep($lifetime + self::ADDITIONAL_TIME);
276 $this->assertTrue($ilWACSignedPath->isSignedPath());
277 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
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 298 of file ilWACTokenTest.php.
References getModifiedSignedPath(), and ILIAS\FileDelivery\http().
303 $this->assertTrue($ilWACSignedPath->isSignedPath());
304 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
getModifiedSignedPath($add_ttl=0, $add_timestamp=0, $override_token=null)
static http()
Fetches the global http state from ILIAS.
◆ testModifiedTimestampNoMod()
ilWACTokenTest::testModifiedTimestampNoMod |
( |
| ) |
|
Definition at line 285 of file ilWACTokenTest.php.
References getModifiedSignedPath(), and ILIAS\FileDelivery\http().
290 $this->assertTrue($ilWACSignedPath->isSignedPath());
291 $this->assertTrue($ilWACSignedPath->isSignedPathValid());
getModifiedSignedPath($add_ttl=0, $add_timestamp=0, $override_token=null)
static http()
Fetches the global http state from ILIAS.
◆ testModifiedTimestampSubTime()
ilWACTokenTest::testModifiedTimestampSubTime |
( |
| ) |
|
Definition at line 308 of file ilWACTokenTest.php.
References getModifiedSignedPath(), and ILIAS\FileDelivery\http().
313 * -1, 0),
false), $this->
http, $this->cookieFactory);
314 $this->assertTrue($ilWACSignedPath->isSignedPath());
315 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
getModifiedSignedPath($add_ttl=0, $add_timestamp=0, $override_token=null)
static http()
Fetches the global http state from ILIAS.
◆ testModifiedToken()
ilWACTokenTest::testModifiedToken |
( |
| ) |
|
Definition at line 339 of file ilWACTokenTest.php.
References getModifiedSignedPath(), and ILIAS\FileDelivery\http().
344 $this->assertTrue($ilWACSignedPath->isSignedPath());
345 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
getModifiedSignedPath($add_ttl=0, $add_timestamp=0, $override_token=null)
static http()
Fetches the global http state from ILIAS.
◆ testModifiedTTL()
ilWACTokenTest::testModifiedTTL |
( |
| ) |
|
Definition at line 319 of file ilWACTokenTest.php.
References getModifiedSignedPath(), and ILIAS\FileDelivery\http().
324 $this->assertTrue($ilWACSignedPath->isSignedPath());
325 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
getModifiedSignedPath($add_ttl=0, $add_timestamp=0, $override_token=null)
static http()
Fetches the global http state from ILIAS.
◆ testModifiedTTLAndTimestamp()
ilWACTokenTest::testModifiedTTLAndTimestamp |
( |
| ) |
|
Definition at line 329 of file ilWACTokenTest.php.
References getModifiedSignedPath(), and ILIAS\FileDelivery\http().
334 $this->assertTrue($ilWACSignedPath->isSignedPath());
335 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
getModifiedSignedPath($add_ttl=0, $add_timestamp=0, $override_token=null)
static http()
Fetches the global http state from ILIAS.
◆ testSomeBasics()
ilWACTokenTest::testSomeBasics |
( |
| ) |
|
Definition at line 169 of file ilWACTokenTest.php.
References $query, CLIENT_NAME, and ILIAS\FileDelivery\http().
173 .
$query,
false), $this->
http, $this->cookieFactory);
175 $this->assertEquals(
'dummy.jpg', $ilWACSignedPath->getPathObject()->getFileName());
176 $this->assertEquals(
$query, $ilWACSignedPath->getPathObject()->getQuery());
178 .
'/sec/ilBlog/mm_124/', $ilWACSignedPath->getPathObject()
180 $this->assertEquals(
'ilBlog', $ilWACSignedPath->getPathObject()->getSecurePathId());
181 $this->assertFalse($ilWACSignedPath->getPathObject()->isStreamable());
static http()
Fetches the global http state from ILIAS.
◆ testTokenGeneration()
ilWACTokenTest::testTokenGeneration |
( |
| ) |
|
Definition at line 185 of file ilWACTokenTest.php.
References CLIENT_NAME, ilWACToken\generateToken(), and ilWACToken\getSALT().
187 $ilWacPath =
new ilWacPath($this->file_four->url(),
false);
190 $this->assertEquals(
'SALT-client_name-123456-20', $ilWACToken->getRawToken());
191 $this->assertEquals(
'./data/client_name/sec/ilBlog/mm_124/dummy.jpg', $ilWACToken->getId());
195 $this->assertEquals(
'b541e2bae42ee222f9be959b7ad2ab8844cbb05b', $ilWACToken->getToken());
196 $this->assertEquals(
'e45b98f267dc891c8206c844f7df29ea', $ilWACToken->getHashedId());
◆ testWithoutSigning()
ilWACTokenTest::testWithoutSigning |
( |
| ) |
|
Definition at line 137 of file ilWACTokenTest.php.
References ILIAS\FileDelivery\http().
141 $cookieJar = Mockery::mock(CookieJar::class);
144 ->shouldReceive(
'getAll')
149 $this->
http->shouldReceive(
'cookieJar')
152 ->andReturn($cookieJar);
154 $request = Mockery::mock(Psr\Http\Message\RequestInterface::class);
155 $request->shouldReceive(
'getCookieParams')
158 $this->
http->shouldReceive(
'request')
162 $this->assertFalse($ilWACSignedPath->isSignedPath());
163 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
164 $this->assertFalse($ilWACSignedPath->isFolderSigned());
165 $this->assertFalse($ilWACSignedPath->isFolderTokenValid());
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: