
* get track tag groups per summit GET /api/v1/summits/{id}/track-tag-groups params expand: allowed_tags,tag scopes %s/summits/read/all * get track tag group by id GET /api/v1/summits/{id}/track-tag-groups/{track_tag_group_id} params expand: allowed_tags,tag scopes %s/summits/read/all * seed default track tag groups on summit PUT /api/v1/summits/{id}/track-tag-groups/seed-defaults scopes %s/summits/write %s/track-tag-groups/write * add track tag groups POST /api/v1/summits/{id}/track-tag-groups payload 'name' => 'required|string|max:50', 'label' => 'required|string|max:50', 'is_mandatory' => 'required|boolean', 'allowed_tags' => 'sometimes|string_array' scopes %s/summits/write %s/track-tag-groups/write * update track tag group PUT /api/v1/summits/{id}/track-tag-groups/{track_tag_group_id} payload 'name' => 'sometimes|string|max:50', 'label' => 'sometimes|string|max:50', 'is_mandatory' => 'sometimes|boolean', 'order' => 'sometimes|integer|min:1', 'allowed_tags' => 'sometimes|string_array', scopes %s/summits/write %s/track-tag-groups/write * delete track tag group by id DELETE /api/v1/summits/{id}/track-tag-groups/{track_tag_group_id} scopes %s/summits/write %s/track-tag-groups/write Change-Id: Ieef974863c19b41655888cbbd8e29215f4724127
209 lines
6.1 KiB
PHP
209 lines
6.1 KiB
PHP
<?php
|
|
/**
|
|
* 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 OAuth2TrackTagGroupsApiTest extends ProtectedApiTest
|
|
{
|
|
public function testGetTrackTagGroups($summit_id = 25)
|
|
{
|
|
|
|
$params = [
|
|
'id' => $summit_id,
|
|
'expand' => 'allowed_tags,tag',
|
|
];
|
|
|
|
$headers = ["HTTP_Authorization" => " Bearer " . $this->access_token];
|
|
$response = $this->action(
|
|
"GET",
|
|
"OAuth2SummitTrackTagGroupsApiController@getTrackTagGroupsBySummit",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$groups = json_decode($content);
|
|
$this->assertTrue(!is_null($groups));
|
|
$this->assertResponseStatus(200);
|
|
}
|
|
|
|
/**
|
|
* @param int $summit_id
|
|
* @return mixed
|
|
*/
|
|
public function testAddTrackTagGroup($summit_id = 25){
|
|
$params = [
|
|
'id' => $summit_id,
|
|
'expand' => 'allowed_tags,tag'
|
|
];
|
|
|
|
$name = str_random(16).'_track_tag_group_name';
|
|
$label = str_random(16).'_track_tag_group_label';
|
|
$data = [
|
|
'name' => $name,
|
|
'label' => $label,
|
|
'is_mandatory' => false,
|
|
'allowed_tags' => ['101','Case Study', 'Demo'],
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"POST",
|
|
"OAuth2SummitTrackTagGroupsApiController@addTrackTagGroup",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers,
|
|
json_encode($data)
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(201);
|
|
$track_tag_group = json_decode($content);
|
|
$this->assertTrue(!is_null($track_tag_group));
|
|
return $track_tag_group;
|
|
}
|
|
|
|
/**
|
|
* @param int $summit_id
|
|
* @return mixed
|
|
*/
|
|
public function testUpdateTrackTagGroup($summit_id = 25){
|
|
$new_track_tag_group = $this->testAddTrackTagGroup($summit_id);
|
|
$params = [
|
|
'id' => $summit_id,
|
|
'track_tag_group_id' => $new_track_tag_group->id,
|
|
'expand' => 'allowed_tags,tag'
|
|
];
|
|
|
|
$name = str_random(16).'_track_tag_group_name_update';
|
|
$label = str_random(16).'_track_tag_group_label_update';
|
|
$data = [
|
|
'name' => $name,
|
|
'label' => $label,
|
|
'order' => 1,
|
|
'allowed_tags' => ['101','Case Study', 'Demo', 'Demo2'],
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"PUT",
|
|
"OAuth2SummitTrackTagGroupsApiController@updateTrackTagGroup",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers,
|
|
json_encode($data)
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(201);
|
|
$track_tag_group = json_decode($content);
|
|
$this->assertTrue(!is_null($track_tag_group));
|
|
$this->assertTrue($track_tag_group->order == 1);
|
|
return $track_tag_group;
|
|
}
|
|
|
|
public function testDeleteTrackTagGroup($summit_id = 25){
|
|
$new_track_tag_group = $this->testAddTrackTagGroup($summit_id);
|
|
$params = [
|
|
'id' => $summit_id,
|
|
'track_tag_group_id' => $new_track_tag_group->id,
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"DELETE",
|
|
"OAuth2SummitTrackTagGroupsApiController@deleteTrackTagGroup",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(204);
|
|
}
|
|
|
|
public function testGetTrackTagGroupById($summit_id = 25){
|
|
$new_track_tag_group = $this->testAddTrackTagGroup($summit_id);
|
|
$params = [
|
|
'id' => $summit_id,
|
|
'track_tag_group_id' => $new_track_tag_group->id,
|
|
'expand' => 'allowed_tags,tag'
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"GET",
|
|
"OAuth2SummitTrackTagGroupsApiController@getTrackTagGroup",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(200);
|
|
}
|
|
|
|
public function testGetTags($summit_id = 25)
|
|
{
|
|
|
|
$params = [
|
|
'id' => $summit_id,
|
|
//AND FILTER
|
|
'filter' => ['tag=@101'],
|
|
'order' => '+id',
|
|
'expand' => 'tag,track_tag_group'
|
|
];
|
|
|
|
$headers = ["HTTP_Authorization" => " Bearer " . $this->access_token];
|
|
$response = $this->action(
|
|
"GET",
|
|
"OAuth2SummitTrackTagGroupsApiController@getAllowedTags",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$tags = json_decode($content);
|
|
$this->assertTrue(!is_null($tags));
|
|
$this->assertResponseStatus(200);
|
|
}
|
|
} |