2 require_once(
'./libs/composer/vendor/autoload.php');
81 require_once(
'./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
82 require_once(
'./Services/WebAccessChecker/classes/class.ilWebAccessChecker.php');
83 require_once(
'./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
84 require_once(
'./Services/WebAccessChecker/classes/class.ilWACToken.php');
85 require_once(
'./Services/WebAccessChecker/test/Token/mock/class.ilWACDummyCookie.php');
86 require_once(
'./libs/composer/vendor/autoload.php');
87 $this->root = vfs\vfsStream::setup(
'ilias.de');
88 $this->file_one = vfs\vfsStream::newFile(
'data/client_name/mobs/mm_123/dummy.jpg')->at($this->root)->setContent(
'dummy');
89 $this->file_one_subfolder = vfs\vfsStream::newFile(
'data/client_name/mobs/mm_123/mobile/dummy.jpg')->at($this->root)->setContent(
'dummy');
90 $this->file_one_subfolder_two = vfs\vfsStream::newFile(
'data/client_name/mobs/mm_123/mobile/device/dummy.jpg')->at($this->root)
91 ->setContent(
'dummy');
92 $this->file_two = vfs\vfsStream::newFile(
'data/client_name/mobs/mm_123/dummy2.jpg')->at($this->root)->setContent(
'dummy2');
93 $this->file_three = vfs\vfsStream::newFile(
'data/client_name/mobs/mm_124/dummy.jpg')->at($this->root)->setContent(
'dummy');
94 $this->file_four = vfs\vfsStream::newFile(
'data/client_name/sec/ilBlog/mm_124/dummy.jpg')->at($this->root)->setContent(
'dummy');
103 $this->assertFalse($ilWACSignedPath->isSignedPath());
104 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
105 $this->assertFalse($ilWACSignedPath->isFolderSigned());
106 $this->assertFalse($ilWACSignedPath->isFolderTokenValid());
114 $this->assertEquals(
'dummy.jpg', $ilWACSignedPath->getPathObject()->getFileName());
115 $this->assertEquals(
$query, $ilWACSignedPath->getPathObject()->getQuery());
116 $this->assertEquals(
'./data/' . self::CLIENT_NAME .
'/sec/ilBlog/mm_124/', $ilWACSignedPath->getPathObject()->getSecurePath());
117 $this->assertEquals(
'ilBlog', $ilWACSignedPath->getPathObject()->getSecurePathId());
118 $this->assertFalse($ilWACSignedPath->getPathObject()->isStreamable());
129 $ilWacPath =
new ilWacPath($this->file_four->url());
130 $ilWACToken =
new ilWACToken($ilWacPath->getPath(), self::CLIENT_NAME, 123456, 20);
131 $ilWACToken->
setIp(
'127.0.0.1');
132 $ilWACToken->generateToken();
133 $this->assertEquals(
'SALT-127.0.0.1-client_name-123456-20', $ilWACToken->getRawToken());
134 $this->assertEquals(
'./data/client_name/sec/ilBlog/mm_124/dummy.jpg', $ilWACToken->getId());
137 $_SERVER[
'REMOTE_ADDR'] =
'127.0.0.1';
139 $ilWACToken =
new ilWACToken($ilWacPath->getPath(), self::CLIENT_NAME, 123456, 20);
140 $this->assertEquals(
'cd5a43304b232c785ef4f9796053b8bf5d6d829a', $ilWACToken->getToken());
141 $this->assertEquals(
'e45b98f267dc891c8206c844f7df29ea', $ilWACToken->getHashedId());
148 $_SERVER[
'REMOTE_ADDR'] =
'127.0.0.1';
151 $expected_cookies =
array(
152 '19ab58dae37d8d8cf931727c35514642',
153 '19ab58dae37d8d8cf931727c35514642ts',
154 '19ab58dae37d8d8cf931727c35514642ttl',
156 $this->assertEquals($expected_cookies, array_keys($ilWACCookieInterface->getAll()));
159 $_SERVER[
'REMOTE_ADDR'] =
'127.0.0.1';
162 $this->assertEquals($expected_cookies, array_keys($ilWACCookieInterface->getAll()));
165 $_SERVER[
'REMOTE_ADDR'] =
'127.0.0.1';
168 $this->assertEquals($expected_cookies, array_keys($ilWACCookieInterface->getAll()));
180 $this->assertTrue($ilWACSignedPath->isSignedPath());
181 $this->assertTrue($ilWACSignedPath->isSignedPathValid());
182 $this->assertEquals($ilWACSignedPath->getPathObject()->getClient(), self::CLIENT_NAME);
183 $this->assertFalse($ilWACSignedPath->getPathObject()->isInSecFolder());
184 $this->assertTrue($ilWACSignedPath->getPathObject()->isImage());
185 $this->assertFalse($ilWACSignedPath->getPathObject()->isAudio());
186 $this->assertFalse($ilWACSignedPath->getPathObject()->isVideo());
187 $this->assertTrue($ilWACSignedPath->getPathObject()->hasTimestamp());
188 $this->assertTrue($ilWACSignedPath->getPathObject()->hasToken());
192 sleep($lifetime + self::ADDITIONAL_TIME);
194 $this->assertTrue($ilWACSignedPath->isSignedPath());
195 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
204 $signed_path = $this->file_one->url();
208 $this->assertTrue($ilWACSignedPath->isFolderSigned());
209 $this->assertTrue($ilWACSignedPath->isFolderTokenValid());
210 $this->assertEquals($ilWACSignedPath->getPathObject()->getClient(), self::CLIENT_NAME);
211 $this->assertFalse($ilWACSignedPath->getPathObject()->isInSecFolder());
212 $this->assertTrue($ilWACSignedPath->getPathObject()->isImage());
213 $this->assertFalse($ilWACSignedPath->getPathObject()->isAudio());
214 $this->assertFalse($ilWACSignedPath->getPathObject()->isVideo());
215 $this->assertTrue($ilWACSignedPath->getPathObject()->hasTimestamp());
216 $this->assertTrue($ilWACSignedPath->getPathObject()->hasToken());
220 sleep($lifetime + self::ADDITIONAL_TIME);
222 $this->assertTrue($ilWACSignedPath->isFolderSigned());
223 $this->assertFalse($ilWACSignedPath->isFolderTokenValid());
226 $ilWACSignedPath->revalidatingFolderToken();
228 $this->assertTrue($ilWACSignedPath->isFolderSigned());
229 $this->assertTrue($ilWACSignedPath->isFolderTokenValid());
233 $this->assertTrue($ilWACSignedPath->isFolderSigned());
234 $this->assertTrue($ilWACSignedPath->isFolderTokenValid());
247 $this->assertTrue($ilWACSignedPath->isFolderSigned());
248 $this->assertTrue($ilWACSignedPath->isFolderTokenValid());
252 sleep($lifetime + self::ADDITIONAL_TIME);
254 $this->assertTrue($ilWACSignedPath->isFolderSigned());
255 $this->assertFalse($ilWACSignedPath->isFolderTokenValid());
258 $ilWACSignedPath->revalidatingFolderToken();
259 $this->assertTrue($ilWACSignedPath->isFolderSigned());
260 $this->assertTrue($ilWACSignedPath->isFolderTokenValid());
264 $this->assertTrue($ilWACSignedPath->isFolderSigned());
265 $this->assertTrue($ilWACSignedPath->isFolderTokenValid());
271 $this->assertTrue($ilWACSignedPath->isSignedPath());
272 $this->assertTrue($ilWACSignedPath->isSignedPathValid());
278 $this->assertTrue($ilWACSignedPath->isSignedPath());
279 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
285 $this->assertTrue($ilWACSignedPath->isSignedPath());
286 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
292 $this->assertTrue($ilWACSignedPath->isSignedPath());
293 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
299 $this->assertTrue($ilWACSignedPath->isSignedPath());
300 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
306 $this->assertTrue($ilWACSignedPath->isSignedPath());
307 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
321 $parts = parse_url($signed_path);
322 $path = $parts[
'path'];
324 parse_str(
$query, $query_array);
325 $token = $override_token ? $override_token : $query_array[
'il_wac_token'];
326 $ttl = (int)$query_array[
'il_wac_ttl'];
327 $ts = (int)$query_array[
'il_wac_ts'];
328 $path_with_token =
$path .
'?il_wac_token=' . $token;
330 $modified_ttl = $ttl + $add_ttl;
331 $modified_ts = $ts + $add_timestamp;
333 return $path_with_token .
'&il_wac_ttl=' . $modified_ttl .
'&il_wac_ts=' . $modified_ts;
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
static getCookieMaxLifetimeInSeconds()
getModifiedSignedPath($add_ttl=0, $add_timestamp=0, $override_token=null)
static signFolderOfStartFile($start_file_path, ilWACCookieInterface $ilWACCookieInterface=null)
testModifiedTimestampAddTime()
TestCase for the ilWACTokenTest.
testFolderTokenWithSecondFile()
testModifiedTimestampSubTime()
static setCookieMaxLifetimeInSeconds($cookie_max_lifetime_in_seconds)
testModifiedTTLAndTimestamp()
static signFile($path_to_file)
Create styles array
The data for the language used.
testModifiedTimestampNoMod()
static setTokenMaxLifetimeInSeconds($token_max_lifetime_in_seconds)
static getTokenMaxLifetimeInSeconds()