
** Get all presentations from selection Plan GET /api/v1/summits/{id}/selection-plans/{selection_plan_id}/presentations filtering 'title' => ['=@', '=='], 'abstract' => ['=@', '=='], 'social_summary' => ['=@', '=='], 'tags' => ['=@', '=='], 'level' => ['=@', '=='], 'summit_type_id' => ['=='], 'event_type_id' => ['=='], 'track_id' => ['=='], 'speaker_id' => ['=='], 'speaker' => ['=@', '=='], 'speaker_email' => ['=@', '=='], 'selection_status' => ['=='], 'id' => ['=='], 'selection_plan_id' => ['=='], 'status' => ['=='], 'is_chair_visible' => ['=='], 'is_voting_visible' => ['=='], ** for track chairs app use 'filter' => 'status==Received,is_chair_visible==1', ordering track Scopes REALM_BASE_URL/summits/read AUTHZ super-admins administrators track-chairs track-chairs-admins ** Get individual Selection List GET /api/v1/summits/{id}/tracks/{track_id}/selection-lists/individual/owner/{owner_id} Scopes REALM_BASE_URL/summits/read AUTHZ super-admins administrators track-chairs track-chairs-admins ** Add to my individual Selection List POST /api/v1/summits/{id}/tracks/{track_id}/selection-lists/individual/presentation-selections/{collection}/presentations/{presentation_id} where {collection} should be one of following: * selected * maybe * pass Scopes REALM_BASE_URL/summits/write AUTHZ super-admins administrators track-chairs track-chairs-admins ** Remove From my individual selection list DELETE /api/v1/summits/{id}/tracks/{track_id}/selection-lists/individual/presentation-selections/{collection}/presentations/{presentation_id} where {collection} should be one of following: * selected * maybe * pass Scopes REALM_BASE_URL/summits/write AUTHZ super-admins administrators track-chairs track-chairs-admins ** Get Team Selection List GET /api/v1/summits/{id}/tracks/{track_id}/selection-lists/team Scopes REALM_BASE_URL/summits/read AUTHZ super-admins administrators track-chairs track-chairs-admins ** Create team selection list POST /api/v1/summits/{id}/tracks/{track_id}/selection-lists/team Scopes REALM_BASE_URL/summits/write AUTHZ super-admins administrators track-chairs track-chairs-admins ** Reorder list PUT /api/v1/summits/{id}/tracks/{track_id}/selection-lists/{list_id}/reorder payload hash => 'required|string' collection => 'required|string|in:selected,maybe' presentations => 'required|int_array' ( presentations ids) Scopes REALM_BASE_URL/summits/write AUTHZ super-admins administrators track-chairs track-chairs-admins ** Get track chairs per Summit GET /api/v1/summits/{id}/track-chairs fitering 'member_first_name' => ['=@', '=='], 'member_last_name' => ['=@', '=='], 'member_full_name' => ['=@', '=='], 'member_email' => ['=@', '=='], 'member_id' => ['=='], 'track_id' => ['=='], 'summit_id' => ['=='] Scopes REALM_BASE_URL/summits/read AUTHZ super-admins administrators track-chairs track-chairs-admins ** Mark Presentation as viewed PUT /api/v1/summits/{id}/selection-plans/{selection_plan_id}/presentations/{presentation_id}/view Scopes REALM_BASE_URL/summits/write AUTHZ super-admins administrators track-chairs track-chairs-admins ** Add Presentation Comment POST /api/v1/summits/{id}/selection-plans/{selection_plan_id}/presentations/{presentation_id}/comments Payload 'body' => 'required|string', 'is_public' => 'required|boolean', Scopes REALM_BASE_URL/summits/write AUTHZ super-admins administrators track-chairs track-chairs-admins ** Get all Presention Category Change Request GET /api/v1/summits/{id}/selection-plans/{selection_plan_id}/presentations/all/category-change-requests filtering 'selection_plan_id' => ['=='], 'summit_id' => ['=='], 'new_category_id' => ['=='], 'old_category_id' => ['=='], 'new_category_title' => ['=@', '=='], 'old_category_title' => ['=@', '=='], 'requester_fullname' => ['=@', '=='], 'requester_email' => ['=@', '=='], 'aprover_fullname' => ['=@', '=='], 'aprover_email' => ['=@', '=='] ordering 'id', 'approval_date', 'status' Scopes REALM_BASE_URL/summits/read REALM_BASE_URL/summits/read/all AUTHZ super-admins administrators track-chairs track-chairs-admins ** Add Presentation Category change Request POST /api/v1/summits/{id}/selection-plans/{selection_plan_id}/presentations/{presentation_id}/category-change-requests payload 'new_category_id' => 'required|integer', Scopes REALM_BASE_URL/summits/write AUTHZ super-admins administrators track-chairs track-chairs-admins ** Resolve Presentation Category change Request PUT /api/v1/summits/{id}/selection-plans/{selection_plan_id}/presentations/{presentation_id}/category-change-requests/{category_change_request_id} payload 'approved' => 'required|bool', 'reason' => 'sometimes|string', Scopes REALM_BASE_URL/summits/write AUTHZ super-admins administrators track-chairs track-chairs-admins ** Add track chair POST /api/v1/summits/{id}/track-chairs Payload 'member_id' => 'required|int', 'categories' => 'required|int_array', scopes REALM_BASE_URL/summits/write AUTHZ super-admins administrators track-chairs-admins ** Update track chair PUT /api/v1/summits/{id}/track-chairs/{track_chair_id} Payload 'categories' => 'required|int_array', scopes REALM_BASE_URL/summits/write AUTHZ super-admins administrators track-chairs-admins ** Delete track chairs DELETE /api/v1/summits/{id}/track-chairs/{track_chair_id} scopes REALM_BASE_URL/summits/write AUTHZ super-admins administrators track-chairs-admins ** Get Track Chair by Id GET /api/v1/summits/{id}/track-chairs/{track_chair_id} scopes REALM_BASE_URL/summits/read AUTHZ super-admins administrators track-chairs-admins Change-Id: Iab0d77a6337a0db27c649dcafb1d90f09923df8a Signed-off-by: smarcet <smarcet@gmail.com>
567 lines
16 KiB
PHP
567 lines
16 KiB
PHP
<?php
|
|
|
|
use App\Models\Foundation\Main\IGroup;
|
|
|
|
/**
|
|
* Copyright 2018 OpenStack Foundation
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
**/
|
|
|
|
final class OAuth2SelectionPlansApiTest extends ProtectedApiTest
|
|
{
|
|
use \InsertSummitTestData;
|
|
|
|
protected function setUp()
|
|
{
|
|
$this->setCurrentGroup(IGroup::TrackChairs);
|
|
parent::setUp();
|
|
self::insertTestData();
|
|
self::$summit_permission_group->addMember(self::$member);
|
|
self::$em->persist(self::$summit);
|
|
self::$em->persist(self::$summit_permission_group);
|
|
self::$em->flush();
|
|
$track_chair = self::$summit->addTrackChair(self::$member, [ self::$defaultTrack ]);
|
|
self::$em->persist(self::$summit);
|
|
self::$em->flush();
|
|
}
|
|
|
|
protected function tearDown()
|
|
{
|
|
self::clearTestData();
|
|
parent::tearDown();
|
|
}
|
|
|
|
/**
|
|
* @param int $summit_id
|
|
* @return mixed
|
|
*/
|
|
public function testAddSelectionPlan(){
|
|
$params = [
|
|
'id' => self::$summit->getId(),
|
|
];
|
|
|
|
$name = str_random(16).'_selection_plan';
|
|
$data = [
|
|
'name' => $name,
|
|
'is_enabled' => false,
|
|
'allow_new_presentations' => false,
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"POST",
|
|
"OAuth2SummitSelectionPlansApiController@addSelectionPlan",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers,
|
|
json_encode($data)
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(201);
|
|
$selection_plan = json_decode($content);
|
|
$this->assertTrue(!is_null($selection_plan));
|
|
$this->assertEquals($name, $selection_plan->name);
|
|
return $selection_plan;
|
|
}
|
|
|
|
/**
|
|
* @param int $summit_id
|
|
* @return mixed
|
|
*/
|
|
public function testUpdateSelectionPlan(){
|
|
$params = [
|
|
'id' => self::$summit->getId(),
|
|
];
|
|
|
|
$name = str_random(16).'_selection_plan';
|
|
$data = [
|
|
'name' => $name,
|
|
'is_enabled' => false,
|
|
'allow_new_presentations' => false,
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"POST",
|
|
"OAuth2SummitSelectionPlansApiController@addSelectionPlan",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers,
|
|
json_encode($data)
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(201);
|
|
$selection_plan = json_decode($content);
|
|
|
|
$params = [
|
|
'id' => self::$summit->getId(),
|
|
'selection_plan_id' => $selection_plan->id
|
|
];
|
|
|
|
$start = new DateTime('now');
|
|
$end = new DateTime('now');
|
|
$end->add(new DateInterval('P15D'));
|
|
|
|
$data = [
|
|
'is_enabled' => false,
|
|
'submission_begin_date' => $start->getTimestamp(),
|
|
'submission_end_date' => $end->getTimestamp(),
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"PUT",
|
|
"OAuth2SummitSelectionPlansApiController@updateSelectionPlan",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers,
|
|
json_encode($data)
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(201);
|
|
$selection_plan = json_decode($content);
|
|
$this->assertTrue(!is_null($selection_plan));
|
|
$this->assertEquals(false, $selection_plan->is_enabled);
|
|
return $selection_plan;
|
|
}
|
|
|
|
|
|
public function testAddTrackGroupToSelectionPlan(){
|
|
|
|
$params = [
|
|
'id' => self::$summit->getId(),
|
|
];
|
|
|
|
$name = str_random(16).'_selection_plan';
|
|
$data = [
|
|
'name' => $name,
|
|
'is_enabled' => false,
|
|
'allow_new_presentations' => false,
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"POST",
|
|
"OAuth2SummitSelectionPlansApiController@addSelectionPlan",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers,
|
|
json_encode($data)
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(201);
|
|
$selection_plan = json_decode($content);
|
|
|
|
$params = [
|
|
'id' => self::$summit->getId(),
|
|
'selection_plan_id' => $selection_plan->id,
|
|
'track_group_id' => 1
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"PUT",
|
|
"OAuth2SummitSelectionPlansApiController@addTrackGroupToSelectionPlan",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(404);
|
|
}
|
|
|
|
/**
|
|
* @param string $status
|
|
*/
|
|
public function testGetCurrentSelectionPlanByStatus($status = 'submission'){
|
|
|
|
$params = [
|
|
'id' => self::$summit->getId(),
|
|
];
|
|
|
|
$name = str_random(16).'_selection_plan';
|
|
$data = [
|
|
'name' => $name,
|
|
'is_enabled' => false,
|
|
'allow_new_presentations' => false,
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"POST",
|
|
"OAuth2SummitSelectionPlansApiController@addSelectionPlan",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers,
|
|
json_encode($data)
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(201);
|
|
$selection_plan = json_decode($content);
|
|
|
|
$params = [
|
|
'id' => self::$summit->getId(),
|
|
'selection_plan_id' => $selection_plan->id
|
|
];
|
|
|
|
$start = new DateTime('now');
|
|
$end = new DateTime('now');
|
|
$end->add(new DateInterval('P15D'));
|
|
|
|
$data = [
|
|
'is_enabled' => false,
|
|
'submission_begin_date' => $start->getTimestamp(),
|
|
'submission_end_date' => $end->getTimestamp(),
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"PUT",
|
|
"OAuth2SummitSelectionPlansApiController@updateSelectionPlan",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers,
|
|
json_encode($data)
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(201);
|
|
|
|
$params = [
|
|
'status' => $status,
|
|
'expand' => 'track_groups,summit'
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"GET",
|
|
"OAuth2SummitSelectionPlansApiController@getCurrentSelectionPlanByStatus",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(200);
|
|
$selection_plan = json_decode($content);
|
|
$this->assertTrue(!is_null($selection_plan));
|
|
}
|
|
|
|
public function testGetPresentationsBySelectionPlan(){
|
|
|
|
$params = [
|
|
'summit' => self::$summit->getId(),
|
|
'selection_plan_id' => self::$default_selection_plan->getId(),
|
|
'filter' => 'status==Received,is_chair_visible==1',
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"GET",
|
|
"OAuth2SummitSelectionPlansApiController@getSelectionPlanPresentations",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(200);
|
|
$presentations = json_decode($content);
|
|
$this->assertTrue(!is_null($presentations));
|
|
}
|
|
|
|
public function testMarkPresentationAsViewed(){
|
|
$params = [
|
|
'summit' => self::$summit->getId(),
|
|
'selection_plan_id' => self::$default_selection_plan->getId(),
|
|
'presentation_id' => self::$presentations[0]->getId()
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"PUT",
|
|
"OAuth2SummitSelectionPlansApiController@markPresentationAsViewed",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(201);
|
|
$presentation = json_decode($content);
|
|
$this->assertTrue(!is_null($presentation));
|
|
$this->assertTrue($presentation->views_count > 0);
|
|
}
|
|
|
|
public function testAddComment(){
|
|
$params = [
|
|
'summit' => self::$summit->getId(),
|
|
'selection_plan_id' => self::$default_selection_plan->getId(),
|
|
'presentation_id' => self::$presentations[0]->getId()
|
|
];
|
|
|
|
$data = [
|
|
'is_public' => false,
|
|
'body' => 'this is a test comment',
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"POST",
|
|
"OAuth2SummitSelectionPlansApiController@addCommentToPresentation",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers,
|
|
json_encode($data)
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(201);
|
|
$comment = json_decode($content);
|
|
$this->assertTrue(!is_null($comment));
|
|
}
|
|
|
|
public function testAddCategoryChangeRequest(){
|
|
|
|
$params = [
|
|
'summit' => self::$summit->getId(),
|
|
'selection_plan_id' => self::$default_selection_plan->getId(),
|
|
'presentation_id' => self::$presentations[0]->getId(),
|
|
'expand' => 'presentation, new_category, old_category',
|
|
];
|
|
|
|
$data = [
|
|
'new_category_id' => self::$secondaryTrack->getId(),
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"POST",
|
|
"OAuth2SummitSelectionPlansApiController@createPresentationCategoryChangeRequest",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers,
|
|
json_encode($data)
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(201);
|
|
$request = json_decode($content);
|
|
$this->assertTrue(!is_null($request));
|
|
$this->assertTrue($request->status === 'Pending');
|
|
}
|
|
|
|
public function testGetAllCategoryChangeRequests(){
|
|
$params = [
|
|
'summit' => self::$summit->getId(),
|
|
'selection_plan_id' => self::$default_selection_plan->getId(),
|
|
'presentation_id' => self::$presentations[0]->getId(),
|
|
'expand' => 'presentation, new_category, old_category',
|
|
];
|
|
|
|
$data = [
|
|
'new_category_id' => self::$secondaryTrack->getId(),
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"POST",
|
|
"OAuth2SummitSelectionPlansApiController@createPresentationCategoryChangeRequest",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers,
|
|
json_encode($data)
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(201);
|
|
$request = json_decode($content);
|
|
$this->assertTrue(!is_null($request));
|
|
$this->assertTrue($request->status === 'Pending');
|
|
|
|
$params = [
|
|
'summit' => self::$summit->getId(),
|
|
'selection_plan_id' => self::$default_selection_plan->getId(),
|
|
'expand' => 'presentation, new_category, old_category',
|
|
];
|
|
|
|
$response = $this->action(
|
|
"GET",
|
|
"OAuth2SummitSelectionPlansApiController@getAllPresentationCategoryChangeRequest",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(200);
|
|
$page = json_decode($content);
|
|
|
|
$this->assertTrue(!is_null($page));
|
|
$this->assertTrue($page->total == 1);
|
|
}
|
|
|
|
public function testRejectRequest(){
|
|
$params = [
|
|
'summit' => self::$summit->getId(),
|
|
'selection_plan_id' => self::$default_selection_plan->getId(),
|
|
'presentation_id' => self::$presentations[0]->getId(),
|
|
'expand' => 'presentation, new_category, old_category',
|
|
];
|
|
|
|
$data = [
|
|
'new_category_id' => self::$secondaryTrack->getId(),
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"POST",
|
|
"OAuth2SummitSelectionPlansApiController@createPresentationCategoryChangeRequest",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers,
|
|
json_encode($data)
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(201);
|
|
$request = json_decode($content);
|
|
$this->assertTrue(!is_null($request));
|
|
$this->assertTrue($request->status === 'Pending');
|
|
|
|
|
|
$params = [
|
|
'summit' => self::$summit->getId(),
|
|
'selection_plan_id' => self::$default_selection_plan->getId(),
|
|
'presentation_id' => self::$presentations[0]->getId(),
|
|
'category_change_request_id' => $request->id,
|
|
'expand' => 'presentation, new_category, old_category',
|
|
];
|
|
|
|
$data = [
|
|
'approved' => false,
|
|
'reason' => 'TBD',
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"PUT",
|
|
"OAuth2SummitSelectionPlansApiController@resolvePresentationCategoryChangeRequest",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers,
|
|
json_encode($data)
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(201);
|
|
$request = json_decode($content);
|
|
$this->assertTrue(!is_null($request));
|
|
}
|
|
} |