9 require_once
'PU_testcase_dcp_application.php';
16 "appRoot" => join(DIRECTORY_SEPARATOR, array(
21 "appName" =>
"TST_OPENACCESS",
23 "PU_data_dcp_openaccess.ods"
35 $user = new \Account();
37 $this->assertTrue(
$user->isAffected() , sprintf(
"Login %s not found",
$login));
38 $tokenId =
$user->getUserToken($token[
"expire"], $token[
"oneshot"], $token[
"context"],
"Tst");
39 $this->assertNotEmpty($tokenId,
"Token is empty");
41 $userToken = new \UserToken(
"", $tokenId);
44 $auth = new \openAuthenticator(
"open",
"freedom");
48 $mainAction = new \Action();
50 $mainAction->user =
$user;
51 $mainAction->auth =
$auth;
52 $mainAction->parent->permission = null;
53 setHttpVar(
"app", $mainAction->parent->name);
54 setHttpVar(
"action", $mainAction->name);
56 $granted = $auth::verifyOpenAccess($userToken);
57 $notExpired = $auth::verifyOpenExpire($userToken);
59 $this->assertEquals($granted && $notExpired, $expectedGrant,
"Wrong open access");
62 $out = $mainAction->execute();
64 $this->assertContains($error,
"",
"Error must be occur");
69 if (is_array($error)) {
70 foreach ($error as
$err) {
71 $this->assertContains($err, $e->getMessage() ,
"Incorrect error");
74 $this->assertContains($error, $e->getMessage() ,
"Incorrect error");
77 $this->assertEmpty($e->getMessage() , sprintf(
"Access must be granted : %s", $e->getMessage()));
87 "login" =>
"john.doe1",
88 "token" => [
"expire" => 200,
90 "context" => [
"app" =>
"TST_OPENACCESS"]],
91 "action" =>
"TST_OPENACCESS_ACTION_1",
97 "login" =>
"jane.doe1",
98 "token" => [
"expire" => 200,
100 "context" => [
"app" =>
"TST_OPENACCESS"]],
101 "action" =>
"TST_OPENACCESS_ACTION_2",
103 "error" =>
"CORE0012"
108 "token" => [
"expire" => 200,
110 "context" => [
"app" =>
"TST_OPENACCESS"]],
111 "action" =>
"TST_OPENACCESS_ACTION_1",
113 "error" =>
"CORE0012"
116 "login" =>
"john.doe1",
117 "token" => [
"expire" => 200,
119 "context" => [
"app" =>
"TST_OPENACCESS"]],
120 "action" =>
"TST_OPENACCESS_ACTION_OPEN1",
122 "error" => [
"CORE0006",
126 "login" =>
"jane.doe1",
127 "token" => [
"expire" => 200,
129 "context" => [
"app" =>
"CORE"]],
130 "action" =>
"TST_OPENACCESS_ACTION_OPEN1",
135 "login" =>
"jane.doe1",
136 "token" => [
"expire" => 200,
138 "context" => [
"app" =>
"TST_OPENACCESS"]],
139 "action" =>
"TST_OPENACCESS_ACTION_OPEN1",
144 "login" =>
"jane.doe1",
145 "token" => [
"expire" => 200,
147 "context" => [
"app" =>
"TST_OPENACCESS",
148 "action" =>
"TST_OPENACCESS_ACTION_OPEN1"]],
149 "action" =>
"TST_OPENACCESS_ACTION_OPEN1",
154 "login" =>
"john.doe1",
155 "token" => [
"expire" => 200,
157 "context" => [
"app" =>
"TST_OPENACCESS",
158 "action" =>
"TST_OPENACCESS_ACTION_OPEN2"]],
159 "action" =>
"TST_OPENACCESS_ACTION_OPEN2",
164 "login" =>
"john.doe1",
165 "token" => [
"expire" => 200,
167 "context" => [
"app" =>
"TST_OPENACCESS"]],
168 "action" =>
"TST_OPENACCESS_ACTION_OPEN2",
173 "login" =>
"john.doe1",
174 "token" => [
"expire" => 200,
177 "action" =>
"TST_OPENACCESS_ACTION_OPEN2",
182 "login" =>
"jane.doe1",
183 "token" => [
"expire" => 200,
186 "action" =>
"TST_OPENACCESS_ACTION_OPEN1",
191 "login" =>
"jane.doe1",
192 "token" => [
"expire" => 200,
194 "context" => [
"app" =>
"TST_OPENACCESS",
195 "action" =>
"TST_OPENACCESS_ACTION_OPEN2"]],
196 "action" =>
"TST_OPENACCESS_ACTION_OPEN1",
201 "login" =>
"john.doe1",
202 "token" => [
"expire" => 200,
204 "context" => [
"app" =>
"TST_OPENACCESS",
205 "action" =>
"TST_OPENACCESS_ACTION_OPEN1"]],
206 "action" =>
"TST_OPENACCESS_ACTION_OPEN1",
208 "error" => [
"CORE0006",
212 "login" =>
"john.doe1",
213 "token" => [
"expire" => 200,
215 "context" => [
"app" =>
"TST_OPENACCESS",
216 "action" =>
"TST_OPENACCESS_ACTION_OPEN2"]],
217 "action" =>
"TST_OPENACCESS_ACTION_OPEN1",
219 "error" => [
"CORE0006",
223 "login" =>
"jane.doe1",
224 "token" => [
"expire" => - 200,
227 "action" =>
"TST_OPENACCESS_ACTION_OPEN1",
if(ActionRouter::inMaintenance()) $auth
testApplicationToken($login, $token, $actionName, $expectedGrant, $error)
if($file) if($subject==""&&$file) if($subject=="") $err