19 require_once(
'./libs/composer/vendor/autoload.php');
    47     public const SALT = 
'SALT';
    94     protected function setUp(): void
    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();
   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());
   164         $query = 
'myparam=1234';
   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());
   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());
   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);
   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());
   278         $this->assertTrue($ilWACSignedPath->isSignedPath());
   279         $this->assertTrue($ilWACSignedPath->isSignedPathValid());
   291         $this->assertTrue($ilWACSignedPath->isSignedPath());
   292         $this->assertFalse($ilWACSignedPath->isSignedPathValid());
   301                                                                                           * -1, 0), 
false), $this->
http, $this->cookieFactory);
   302         $this->assertTrue($ilWACSignedPath->isSignedPath());
   303         $this->assertFalse($ilWACSignedPath->isSignedPathValid());
   312         $this->assertTrue($ilWACSignedPath->isSignedPath());
   313         $this->assertFalse($ilWACSignedPath->isSignedPathValid());
   322         $this->assertTrue($ilWACSignedPath->isSignedPath());
   323         $this->assertFalse($ilWACSignedPath->isSignedPathValid());
   332         $this->assertTrue($ilWACSignedPath->isSignedPath());
   333         $this->assertFalse($ilWACSignedPath->isSignedPathValid());
   345         $parts = parse_url($signed_path);
   346         $path = $parts[
'path'];
   347         $query = $parts[
'query'];
   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;
 
static setSALT(string $salt)
 
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
 
testModifiedTimestampAddTime()
 
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 setTokenMaxLifetimeInSeconds(int $token_max_lifetime_in_seconds)
 
TestCase for the ilWACTokenTest. 
 
testModifiedTimestampSubTime()
 
static http()
Fetches the global http state from ILIAS. 
 
static signFolderOfStartFile(string $start_file_path)
 
testModifiedTTLAndTimestamp()
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
testModifiedTimestampNoMod()
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static signFile(string $path_to_file)
 
static getTokenMaxLifetimeInSeconds()