27 use Symfony\Component\HttpFoundation\Session\Session;
29 $GLOBALS[
'globalSession'] =
new Session();
30 $GLOBALS[
'globalSession']->set(
't',
't');
125 $this->uploadPermissionDao = M::mock(UploadPermissionDao::class);
126 $this->uploadDao = M::mock(UploadDao::class);
127 $this->userDao = M::mock(UserDao::class);
128 $this->folderDao = M::mock(FolderDao::class);
129 $this->dbHelper = M::mock(DbHelper::class);
130 $this->authHelper = M::mock(AuthHelper::class);
131 $this->jobDao = M::mock(JobDao::class);
132 $this->showJobDao = M::mock(ShowJobsDao::class);
133 $this->session = $GLOBALS[
'globalSession'];
136 self::$functions = M::mock();
137 $this->contentMovePlugin = M::mock(
'AdminContentMove');
141 $this->authHelper->shouldReceive(
'getSession')->andReturn($this->session);
143 self::$functions->shouldReceive(
'plugin_find')
144 ->withArgs([
'content_move'])
145 ->andReturn($this->contentMovePlugin);
148 $this->uploadPermissionDao,
156 $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
165 $this->addToAssertionCount(
166 \Hamcrest\MatcherAssert::getCount() - $this->assertCountBefore);
180 $uploadContentId = 44;
182 $this->folderDao->shouldReceive(
'isFolderAccessible')
183 ->withArgs([$newFolderId, $this->userId])
186 $this->uploadPermissionDao->shouldReceive(
'isAccessible')
187 ->withArgs([$uploadId, $this->groupId])
190 $this->folderDao->shouldReceive(
'getFolderContentsId')
191 ->withArgs([$uploadId, 2])
193 ->andReturn($uploadContentId);
194 $this->contentMovePlugin->shouldReceive(
'copyContent')
195 ->withArgs([[$uploadContentId], $newFolderId, $isCopy])
199 $expected =
new Info(202,
"Upload $uploadId will be copied to folder " .
200 $newFolderId, InfoType::INFO);
201 $actual = $this->restHelper->copyUpload($uploadId, $newFolderId, $isCopy);
203 $this->assertEquals($expected, $actual);
213 $tokenExpire = strftime(
'%Y-%m-%d', strtotime(
'+3 day'));
214 $tokenName =
"myTok";
218 $this->authHelper->shouldReceive(
'getMaxTokenValidity')
219 ->andReturn($tokenValidity);
220 $this->restHelper->validateTokenRequest($tokenExpire, $tokenName,
231 $tokenExpire = strftime(
'%Y-%m-%d', strtotime(
'+10 day'));
232 $tokenName =
"myTok";
233 $tokenScope =
"read";
236 $this->authHelper->shouldReceive(
'getMaxTokenValidity')
237 ->andReturn($tokenValidity);
238 $this->expectException(HttpBadRequestException::class);
240 $this->restHelper->validateTokenRequest($tokenExpire, $tokenName,
251 $tokenExpire = strftime(
'%d-%m-%Y', strtotime(
'+10 day'));
252 $tokenName =
"myTok";
253 $tokenScope =
"read";
256 $this->authHelper->shouldReceive(
'getMaxTokenValidity')
257 ->andReturn($tokenValidity);
258 $this->expectException(HttpBadRequestException::class);
260 $this->restHelper->validateTokenRequest($tokenExpire, $tokenName,
271 $tokenExpire = strftime(
'%Y-%m-%d', strtotime(
'+10 day'));
272 $tokenName =
"myTok";
273 $tokenScope =
"rread";
276 $this->authHelper->shouldReceive(
'getMaxTokenValidity')
277 ->andReturn($tokenValidity);
278 $this->expectException(HttpBadRequestException::class);
280 $this->restHelper->validateTokenRequest($tokenExpire, $tokenName,
Contains the constants and helpers for authentication of user.
Test cases for RestHelper.
testValidateTokenRequest()
setUp()
Setup test objects.
testValidateTokenRequestInvalidScope()
tearDown()
Remove test objects.
testValidateTokenRequestMaxExpire()
testValidateTokenRequestInvalidExpire()
Provides various DAO helper functions for REST api.
Different type of infos provided by REST.
Info model to contain general error and return values.
plugin_find($x)
Mock function to get decider plugin required by BulkReuser.