78 lines
2.9 KiB
PHP
78 lines
2.9 KiB
PHP
<?php
|
|
class ApiAuthTest extends AbstractFullApiTest
|
|
{
|
|
public function testAllAuth()
|
|
{
|
|
$this->testAuth(new AcceptUserRegistrationJob(), false);
|
|
$this->testAuth(new ActivateUserEmailJob(), false);
|
|
$this->testAuth(new AddPostJob(), false);
|
|
$this->testAuth(new AddCommentJob(), false);
|
|
$this->testAuth(new AddUserJob(), false);
|
|
$this->testAuth(new DeletePostJob(), true);
|
|
$this->testAuth(new DeleteCommentJob(), true);
|
|
$this->testAuth(new DeleteUserJob(), false);
|
|
$this->testAuth(new EditCommentJob(), true);
|
|
$this->testAuth(new EditPostJob(), false);
|
|
$this->testAuth(new EditPostContentJob(), false);
|
|
$this->testAuth(new EditPostRelationsJob(), false);
|
|
$this->testAuth(new EditPostSafetyJob(), false);
|
|
$this->testAuth(new EditPostSourceJob(), false);
|
|
$this->testAuth(new EditPostTagsJob(), false);
|
|
$this->testAuth(new EditPostThumbnailJob(), false);
|
|
$this->testAuth(new EditUserJob(), false);
|
|
$this->testAuth(new EditUserAccessRankJob(), false);
|
|
$this->testAuth(new EditUserEmailJob(), false);
|
|
$this->testAuth(new EditUserNameJob(), false);
|
|
$this->testAuth(new EditUserPasswordJob(), false);
|
|
$this->testAuth(new EditUserAvatarJob(), false);
|
|
$this->testAuth(new EditUserSettingsJob(), false);
|
|
$this->testAuth(new FeaturePostJob(), true);
|
|
$this->testAuth(new FlagPostJob(), false);
|
|
$this->testAuth(new FlagUserJob(), false);
|
|
$this->testAuth(new GetLogJob(), false);
|
|
$this->testAuth(new GetPropertyJob(), false);
|
|
$this->testAuth(new GetPostJob(), false);
|
|
$this->testAuth(new GetPostContentJob(), false);
|
|
$this->testAuth(new GetPostThumbnailJob(), false);
|
|
$this->testAuth(new GetUserJob(), false);
|
|
$this->testAuth(new GetUserSettingsJob(), false);
|
|
$this->testAuth(new ListCommentsJob(), false);
|
|
$this->testAuth(new ListLogsJob(), false);
|
|
$this->testAuth(new ListPostsJob(), false);
|
|
$this->testAuth(new ListRelatedTagsJob(), false);
|
|
$this->testAuth(new ListTagsJob(), false);
|
|
$this->testAuth(new ListUsersJob(), false);
|
|
$this->testAuth(new MergeTagsJob(), false);
|
|
$this->testAuth(new PasswordResetJob(), false);
|
|
$this->testAuth(new PreviewCommentJob(), false);
|
|
$this->testAuth(new RenameTagsJob(), false);
|
|
$this->testAuth(new ScorePostJob(), true);
|
|
$this->testAuth(new TogglePostFavoriteJob(), true);
|
|
$this->testAuth(new TogglePostTagJob(), false);
|
|
$this->testAuth(new TogglePostVisibilityJob(), false);
|
|
$this->testAuth(new ToggleUserBanJob(), false);
|
|
}
|
|
|
|
protected function testAuth($job, $expectedAuth)
|
|
{
|
|
$this->testedJobs []= $job;
|
|
$this->assert->areEqual($expectedAuth, $job->isAuthenticationRequired());
|
|
}
|
|
|
|
public function testAuthEnforcing()
|
|
{
|
|
Core::getConfig()->comments->needEmailForCommenting = false;
|
|
$this->grantAccess('addComment');
|
|
|
|
$comment = $this->commentMocker->mockSingle();
|
|
|
|
$this->assert->throws(function() use ($comment)
|
|
{
|
|
return Api::run(
|
|
new DeleteCommentJob(),
|
|
[
|
|
JobArgs::ARG_COMMENT_ID => $comment->getId(),
|
|
]);
|
|
}, 'Not logged in');
|
|
}
|
|
}
|