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 37 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 80 of file ilWACTokenTest.php.
References ilWACToken\setSALT().
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');
◆ testCookieGeneration()
ilWACTokenTest::testCookieGeneration |
( |
| ) |
|
Definition at line 145 of file ilWACTokenTest.php.
References $_SERVER, array, ilWACDummyCookie\clear(), ilWebAccessChecker\setDEBUG(), and ilWACSignedPath\signFolderOfStartFile().
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()));
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
static signFolderOfStartFile($start_file_path, ilWACCookieInterface $ilWACCookieInterface=null)
Create styles array
The data for the language used.
◆ testFileToken()
ilWACTokenTest::testFileToken |
( |
| ) |
|
Definition at line 172 of file ilWACTokenTest.php.
References ilWACSignedPath\getTokenMaxLifetimeInSeconds(), ilWACSignedPath\setTokenMaxLifetimeInSeconds(), and ilWACSignedPath\signFile().
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());
static signFile($path_to_file)
static setTokenMaxLifetimeInSeconds($token_max_lifetime_in_seconds)
static getTokenMaxLifetimeInSeconds()
◆ testFolderToken()
ilWACTokenTest::testFolderToken |
( |
| ) |
|
Definition at line 199 of file ilWACTokenTest.php.
References ilWACDummyCookie\clear(), ilWACSignedPath\getCookieMaxLifetimeInSeconds(), ilWACSignedPath\setCookieMaxLifetimeInSeconds(), and ilWACSignedPath\signFolderOfStartFile().
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());
static getCookieMaxLifetimeInSeconds()
static signFolderOfStartFile($start_file_path, ilWACCookieInterface $ilWACCookieInterface=null)
static setCookieMaxLifetimeInSeconds($cookie_max_lifetime_in_seconds)
◆ testFolderTokenWithSecondFile()
ilWACTokenTest::testFolderTokenWithSecondFile |
( |
| ) |
|
Definition at line 238 of file ilWACTokenTest.php.
References $file_two, ilWACSignedPath\getCookieMaxLifetimeInSeconds(), ilWACSignedPath\setCookieMaxLifetimeInSeconds(), and ilWACSignedPath\signFolderOfStartFile().
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());
static getCookieMaxLifetimeInSeconds()
static signFolderOfStartFile($start_file_path, ilWACCookieInterface $ilWACCookieInterface=null)
static setCookieMaxLifetimeInSeconds($cookie_max_lifetime_in_seconds)
◆ testModifiedTimestampAddTime()
ilWACTokenTest::testModifiedTimestampAddTime |
( |
| ) |
|
Definition at line 276 of file ilWACTokenTest.php.
References getModifiedSignedPath().
278 $this->assertTrue($ilWACSignedPath->isSignedPath());
279 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
getModifiedSignedPath($add_ttl=0, $add_timestamp=0, $override_token=null)
◆ testModifiedTimestampNoMod()
ilWACTokenTest::testModifiedTimestampNoMod |
( |
| ) |
|
Definition at line 269 of file ilWACTokenTest.php.
References getModifiedSignedPath().
271 $this->assertTrue($ilWACSignedPath->isSignedPath());
272 $this->assertTrue($ilWACSignedPath->isSignedPathValid());
getModifiedSignedPath($add_ttl=0, $add_timestamp=0, $override_token=null)
◆ testModifiedTimestampSubTime()
ilWACTokenTest::testModifiedTimestampSubTime |
( |
| ) |
|
Definition at line 283 of file ilWACTokenTest.php.
References getModifiedSignedPath().
285 $this->assertTrue($ilWACSignedPath->isSignedPath());
286 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
getModifiedSignedPath($add_ttl=0, $add_timestamp=0, $override_token=null)
◆ testModifiedToken()
ilWACTokenTest::testModifiedToken |
( |
| ) |
|
Definition at line 304 of file ilWACTokenTest.php.
References getModifiedSignedPath().
306 $this->assertTrue($ilWACSignedPath->isSignedPath());
307 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
getModifiedSignedPath($add_ttl=0, $add_timestamp=0, $override_token=null)
◆ testModifiedTTL()
ilWACTokenTest::testModifiedTTL |
( |
| ) |
|
Definition at line 290 of file ilWACTokenTest.php.
References getModifiedSignedPath().
292 $this->assertTrue($ilWACSignedPath->isSignedPath());
293 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
getModifiedSignedPath($add_ttl=0, $add_timestamp=0, $override_token=null)
◆ testModifiedTTLAndTimestamp()
ilWACTokenTest::testModifiedTTLAndTimestamp |
( |
| ) |
|
Definition at line 297 of file ilWACTokenTest.php.
References getModifiedSignedPath().
299 $this->assertTrue($ilWACSignedPath->isSignedPath());
300 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
getModifiedSignedPath($add_ttl=0, $add_timestamp=0, $override_token=null)
◆ testSomeBasics()
ilWACTokenTest::testSomeBasics |
( |
| ) |
|
Definition at line 110 of file ilWACTokenTest.php.
References $query, ilWACToken\DEBUG, ilWACLog\getInstance(), and ilWebAccessChecker\isDEBUG().
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());
◆ testTokenGeneration()
ilWACTokenTest::testTokenGeneration |
( |
| ) |
|
Definition at line 127 of file ilWACTokenTest.php.
References $_SERVER, ilWACToken\getSALT(), ilWebAccessChecker\setDEBUG(), and ilWACToken\setIp().
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());
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
◆ testWithoutSigning()
ilWACTokenTest::testWithoutSigning |
( |
| ) |
|
Definition at line 100 of file ilWACTokenTest.php.
103 $this->assertFalse($ilWACSignedPath->isSignedPath());
104 $this->assertFalse($ilWACSignedPath->isSignedPathValid());
105 $this->assertFalse($ilWACSignedPath->isFolderSigned());
106 $this->assertFalse($ilWACSignedPath->isFolderTokenValid());
◆ $backupGlobals
ilWACTokenTest::$backupGlobals = false |
|
protected |
◆ $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 |
◆ $root
◆ ADDITIONAL_TIME
const ilWACTokenTest::ADDITIONAL_TIME = 0.5 |
◆ CLIENT_NAME
const ilWACTokenTest::CLIENT_NAME = 'client_name' |
◆ LIFETIME
const ilWACTokenTest::LIFETIME = 1 |
◆ SALT
const ilWACTokenTest::SALT = 'SALT' |
The documentation for this class was generated from the following file: