-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only admins can choose a specific paper ID while saving
And add tests, and improve API messages (don't decorate).
- Loading branch information
Showing
4 changed files
with
106 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,9 @@ class PaperAPI_Tester { | |
/** @var Contact | ||
* @readonly */ | ||
public $u_estrin; | ||
/** @var Contact | ||
* @readonly */ | ||
public $u_puneet; | ||
/** @var int */ | ||
public $npid; | ||
|
||
|
@@ -29,6 +32,7 @@ function __construct(Conf $conf) { | |
$conf->refresh_settings(); | ||
$this->u_chair = $conf->checked_user_by_email("chair@_.com"); | ||
$this->u_estrin = $conf->checked_user_by_email("[email protected]"); // pc | ||
$this->u_puneet = $conf->checked_user_by_email("[email protected]"); | ||
} | ||
|
||
/** @param array<string,mixed> $args | ||
|
@@ -96,6 +100,61 @@ function test_save_submit_new_paper_zip() { | |
xassert_eqq($doc->content(), "%PDF-JAN"); | ||
} | ||
|
||
function test_submit_new_paper_pleb() { | ||
$qreq = $this->make_post_json_qreq([ | ||
"pid" => "new", "title" => "Soft Timers for Scalable Protocols", | ||
"abstract" => "The softest timers are the most scalable. So delicious, so delightful", | ||
"authors" => [["name" => "Puneet Sharma", "email" => $this->u_puneet->email]], | ||
"submission" => ["content" => "%PDF-2"], | ||
"status" => "draft" | ||
]); | ||
$jr = call_api("=paper", $this->u_puneet, $qreq); | ||
xassert_eqq($jr->ok, true); | ||
xassert_eqq($jr->paper->object, "paper"); | ||
xassert_eqq($jr->paper->title, "Soft Timers for Scalable Protocols"); | ||
} | ||
|
||
function test_update_paper_pleb() { | ||
$qreq = $this->make_post_json_qreq([ | ||
"pid" => 1, "title" => "Scalable Timers for Soft State Protocols: Taylor’s Version" | ||
]); | ||
$jr = call_api("=paper", $this->u_puneet, $qreq); | ||
xassert_eqq($jr->ok, true); | ||
xassert_eqq($jr->paper->object, "paper"); | ||
} | ||
|
||
function test_update_attack_paper_pleb() { | ||
$prow = $this->conf->checked_paper_by_id(2); | ||
xassert_eqq($this->u_puneet->can_view_paper($prow), false); | ||
$qreq = $this->make_post_json_qreq([ | ||
["pid" => 2, "title" => "Scalable Timers for Soft State Protocols: Taylor’s Version"], | ||
["pid" => 10000, "title" => "Scalable Timers for Soft State Protocols: Taylor’s Version"] | ||
]); | ||
$jr = call_api("=paper", $this->u_puneet, $qreq); | ||
xassert_eqq($jr->ok, false); | ||
xassert_eqq($jr->change_lists[0], []); | ||
xassert_eqq($jr->change_lists[1], []); | ||
xassert_eqq($jr->message_list[0]->message, "<0>You aren’t allowed to view submission #2"); | ||
xassert_eqq($jr->message_list[1]->message, "<0>You aren’t allowed to view submission #10000"); | ||
} | ||
|
||
function test_assigned_paper_id() { | ||
// Only chairs can assign papers with a specific ID | ||
$qreq = $this->make_post_json_qreq([ | ||
["pid" => 10000, "title" => "Scalable Timers for Soft State Protocols: György’s Version", | ||
"abstract" => "Hello", "authors" => [["name" => "My Name"]], | ||
"status" => "draft"] | ||
]); | ||
$jr = call_api("=paper", $this->u_estrin, $qreq); | ||
xassert_eqq($jr->ok, false); | ||
xassert_eqq($jr->change_lists[0], []); | ||
xassert_eqq($jr->message_list[0]->message, "<0>Submission #10000 does not exist"); | ||
|
||
$jr = call_api("=paper", $this->u_chair, $qreq); | ||
xassert_eqq($jr->ok, true); | ||
xassert_eqq($jr->papers[0]->pid, 10000); | ||
} | ||
|
||
function test_dry_run() { | ||
$prow = $this->conf->checked_paper_by_id($this->npid); | ||
$original_title = $prow->title; | ||
|