Merge "Migration to PHP 7.x"

This commit is contained in:
Zuul 2019-01-07 23:24:18 +00:00 committed by Gerrit Code Review
commit a33f002611
93 changed files with 3027 additions and 1474 deletions

View File

@ -69,4 +69,12 @@ SSH_PRIVATE_KEY=
SCP_HOST=
SCP_REMOTE_BASE_PATH=/tmp
GOOGLE_GEO_CODING_API_KEY=
GOOGLE_GEO_CODING_API_KEY=
CLOUD_STORAGE_BASE_URL=
CLOUD_STORAGE_CONTAINER=
CLOUD_STORAGE_AUTH_URL=
CLOUD_STORAGE_USERNAME=
CLOUD_STORAGE_APIKEY=
CLOUD_STORAGE_PROJECT_NAME=
CLOUD_STORAGE_REGION=

View File

@ -12,28 +12,27 @@
* limitations under the License.
**/
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Log;
class RequestUtils {
/**
* Class RequestUtils
* @package libs\utils
*/
final class RequestUtils {
public static function getCurrentRoutePath($request)
/**
* @return bool|string
*/
public static function getCurrentRoutePath()
{
try
{
//gets routes from container and try to find the route
$router = App::make('router');
$routes = $router->getRoutes();
$route = $routes->match($request);
if (!is_null($route))
{
$route = $route->getPath();
if (strpos($route, '/') != 0)
{
$route = '/' . $route;
}
return $route;
}
$route_path = Route::getCurrentRoute()->uri();
if (strpos($route_path, '/') != 0)
$route_path = '/' . $route_path;
return $route_path;
}
catch (\Exception $ex)
{

View File

@ -13,7 +13,6 @@
**/
use Illuminate\Console\Command;
use App\Services\Model\IAdminActionsCalendarSyncProcessingService;
/**
* Class AdminActionsCalendarSyncProcessingCommand
* @package App\Console\Commands

View File

@ -11,7 +11,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Illuminate\Console\Command;
use App\Services\Model\IMemberActionsCalendarSyncProcessingService;
use models\summit\CalendarSync\CalendarSyncInfo;

View File

@ -11,14 +11,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Illuminate\Console\Command;
use libs\utils\ICacheService;
use models\summit\ISummitRepository;
use ModelSerializers\SerializerRegistry;
use services\model\ISummitService;
use Illuminate\Support\Facades\Config;
/**
* Class SummitJsonGenerator
* @package App\Console\Commands

View File

@ -11,7 +11,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Illuminate\Support\Facades\Log;
use libs\utils\ICacheService;
use Mockery\Exception;
@ -21,7 +20,6 @@ use services\model\ISummitService;
use utils\PagingResponse;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Config;
/**
* Class SummitListJsonGenerator
* @package App\Console\Commands

View File

@ -1,73 +0,0 @@
<?php namespace App\Events;
/**
* Copyright 2017 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.
**/
use Illuminate\Queue\SerializesModels;
/**
* Class FileCreated
* @package App\Events
*/
final class FileCreated extends Event
{
use SerializesModels;
/**
* @var string
*/
private $local_path;
/**
* @var string
*/
private $file_name;
/**
* @var string
*/
private $folder_name;
public function __construct($local_path, $file_name, $folder_name)
{
$this->local_path = $local_path;
$this->file_name = $file_name;
$this->folder_name = $folder_name;
}
/**
* @return string
*/
public function getLocalPath()
{
return $this->local_path;
}
/**
* @return string
*/
public function getFileName()
{
return $this->file_name;
}
/**
* @return string
*/
public function getFolderName()
{
return $this->folder_name;
}
}

View File

@ -1,34 +0,0 @@
<?php namespace App\Factories\AssetsSyncRequest;
/**
* 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.
**/
use App\Events\FileCreated;
use Illuminate\Support\Facades\Config;
use models\main\AssetsSyncRequest;
/**
* Class FileCreatedAssetSyncRequestFactory
* @package App\Factories\AssetsSyncRequest
*/
final class FileCreatedAssetSyncRequestFactory
{
public static function build(FileCreated $event){
$folder_name = $event->getFolderName();
$file_name = $event->getFileName();
$remote_base_path = Config::get('scp.scp_remote_base_path', null);
$remote_destination = sprintf("%s/%s", $remote_base_path, $file_name);
$asset_sync_request = new AssetsSyncRequest();
$asset_sync_request->setFrom($remote_destination);
$asset_sync_request->setTo(sprintf("%s/%s", $folder_name, $file_name));
$asset_sync_request->setProcessed(false);
return $asset_sync_request;
}
}

View File

@ -157,7 +157,7 @@ class CORSMiddleware
$real_method = $request->headers->get('Access-Control-Request-Method');
$request->setMethod($real_method);
$route_path = RequestUtils::getCurrentRoutePath($request);
$route_path = RequestUtils::getCurrentRoutePath();
if (!$route_path || !$this->checkEndPoint($route_path, $real_method))
{
$response = new Response();

View File

@ -1,10 +1,25 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as BaseEncrypter;
class EncryptCookies extends BaseEncrypter
<?php namespace App\Http\Middleware;
/**
* Copyright 2015 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.
**/
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
use OAuth2\Services\IPrincipalService;
use Symfony\Component\HttpFoundation\Request;
/**
* Class EncryptCookies
* @package App\Http\Middleware
*/
class EncryptCookies extends Middleware
{
/**
* The names of the cookies that should not be encrypted.
@ -12,6 +27,32 @@ class EncryptCookies extends BaseEncrypter
* @var array
*/
protected $except = [
//
];
/**
* Decrypt the cookies on the request.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @return \Symfony\Component\HttpFoundation\Request
*/
protected function decrypt(Request $request)
{
foreach ($request->cookies as $key => $cookie) {
if ($this->isDisabled($key)) {
continue;
}
try {
$request->cookies->set($key, $this->decryptCookie($key, $cookie));
} catch (DecryptException $e) {
$request->cookies->set($key, null);
}
catch(\ErrorException $e1){
$request->cookies->set($key, null);
}
}
return $request;
}
}

View File

@ -86,7 +86,7 @@ class OAuth2BearerAccessTokenRequestValidator
try {
$route = RequestUtils::getCurrentRoutePath($request);
$route = RequestUtils::getCurrentRoutePath();
if (!$route) {
throw new OAuth2ResourceServerException(
400,

View File

@ -62,7 +62,7 @@ final class RateLimitMiddleware extends ThrottleRequests
*/
public function handle($request, Closure $next, $max_attempts = 0, $decay_minutes = 0)
{
$route = RequestUtils::getCurrentRoutePath($request);
$route = RequestUtils::getCurrentRoutePath();
$method = $request->getMethod();
$endpoint = $this->endpoint_repository->getApiEndpointByUrlAndMethod($route, $method);
$key = $this->resolveRequestSignature($request);

View File

@ -0,0 +1,18 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
class TrimStrings extends Middleware
{
/**
* The names of the attributes that should not be trimmed.
*
* @var array
*/
protected $except = [
'password',
'password_confirmation',
];
}

View File

@ -0,0 +1,23 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Fideloper\Proxy\TrustProxies as Middleware;
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array
*/
protected $proxies;
/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers = Request::HEADER_X_FORWARDED_ALL;
}

View File

@ -2,9 +2,9 @@
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends BaseVerifier
class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.

View File

@ -75,6 +75,7 @@ final class CSVExporter
function cleanData(&$str)
{
if (is_null($str)) {$str = ''; return;};
if (is_array($str)) {$str = ''; return;};
$str = preg_replace("/\t/", "\\t", $str);
$str = preg_replace("/\r?\n/", "\\n", $str);
$str = preg_replace("/,/", "-", $str);

View File

@ -11,13 +11,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use App\Events\FileCreated;
use App\Services\Model\IFolderService;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use models\main\File;
use models\main\IFolderRepository;
/**
* Class FileUploader
* @package App\Http\Utils
@ -29,12 +27,18 @@ final class FileUploader
*/
private $folder_service;
/**
* @var IBucket
*/
private $bucket;
/**
* FileUploader constructor.
* @param IFolderService $folder_service
*/
public function __construct(IFolderService $folder_service){
public function __construct(IFolderService $folder_service, IBucket $bucket){
$this->folder_service = $folder_service;
$this->bucket = $bucket;
}
/**
@ -45,17 +49,27 @@ final class FileUploader
*/
public function build(UploadedFile $file, $folder_name, $is_image = false){
$attachment = new File();
$local_path = Storage::putFileAs(sprintf('/public/%s', $folder_name), $file, $file->getClientOriginalName());
$folder = $this->folder_service->findOrMake($folder_name);
try {
$attachment->setParent($folder);
$attachment->setName($file->getClientOriginalName());
$attachment->setFilename(sprintf("assets/%s/%s",$folder_name, $file->getClientOriginalName()));
$attachment->setTitle(str_replace(array('-','_'),' ', preg_replace('/\.[^.]+$/', '', $file->getClientOriginalName())));
$attachment->setShowInSearch(true);
if($is_image)
$attachment->setImage();
Event::fire(new FileCreated($local_path, $file->getClientOriginalName(), $folder_name));
$local_path = Storage::putFileAs(sprintf('/public/%s', $folder_name), $file, $file->getClientOriginalName());
$folder = $this->folder_service->findOrMake($folder_name);
$attachment->setParent($folder);
$attachment->setName($file->getClientOriginalName());
$attachment->setFilename(sprintf("assets/%s/%s", $folder_name, $file->getClientOriginalName()));
$attachment->setTitle(str_replace(array('-', '_'), ' ', preg_replace('/\.[^.]+$/', '', $file->getClientOriginalName())));
$attachment->setShowInSearch(true);
if ($is_image) $attachment->setImage();
$this->bucket->put($attachment, $local_path);
$attachment->setCloudMeta('LastPut', time());
$attachment->setCloudStatus('Live');
$attachment->setCloudSize(filesize($local_path));
}
catch (\Exception $ex){
Log::error($ex);
$attachment->setCloudStatu('Error');
}
return $attachment;
}
}

View File

@ -0,0 +1,30 @@
<?php namespace App\Http\Utils;
/**
* 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.
**/
use models\main\File;
use Exception;
/**
* Interface IBucket
* @package App\Http\Utils
*/
interface IBucket
{
/**
* @param File $f
* @param string $local_path
* @return object
* @throws Exception
*/
public function put(File $f, $local_path);
}

View File

@ -0,0 +1,82 @@
<?php namespace App\Http\Utils;
/**
* 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.
**/
use models\main\File;
use OpenStack\ObjectStore\v1\Models\StorageObject;
use OpenStack\OpenStack;
use GuzzleHttp\Psr7\Stream;
use Illuminate\Support\Facades\Config;
use Exception;
/**
* Class SwiftBucket
* @package App\Http\Utils
*/
final class SwiftBucket implements IBucket
{
/**
* @var StorageObject
*/
protected $container;
/**
* @return \OpenStack\ObjectStore\v1\Models\Container|StorageObject
*/
protected function getContainer()
{
if (!isset($this->container)) {
$openstack = new OpenStack([
'authUrl' => Config::get("cloudstorage.auth_url"),
'region' => Config::get("cloudstorage.region"),
'user' => [
'name' => Config::get("cloudstorage.user_name"),
'password' => Config::get("cloudstorage.api_key"),
'domain' => ['id' => Config::get("cloudstorage.user_domain", "default")]
],
'scope' => [
'project' => [
'name' => Config::get("cloudstorage.project_name"),
'domain' => ['id' => Config::get("cloudstorage.project_domain", "default")]
],
]
]);
$this->container = $openstack->objectStoreV1()->getContainer( Config::get("cloudstorage.container"));
}
return $this->container;
}
/**
* @param File $f
* @param string $local_path
* @return object|StorageObject
* @throws Exception
*/
public function put(File $f, $local_path)
{
$fp = fopen($local_path, 'r');
if (!$fp) {
throw new Exception("Unable to open file: " . $f->getFilename());
}
$options = [
'name' => $f->getRelativeLinkFor(),
'stream' => new Stream($fp)
];
return $this->getContainer()->createObject($options);
}
}

View File

@ -43,7 +43,7 @@ class SummitLocationImageSerializer extends SilverStripeSerializer
if($this->object->hasPicture())
{
$picture = $this->object->getPicture();
$values['image_url'] = Config::get("server.assets_base_url", 'https://www.openstack.org/'). $picture->getFilename();
$values['image_url'] = $picture->getFilename()->getUrl();
}
else
{

View File

@ -45,7 +45,7 @@ final class SummitVenueFloorSerializer extends SilverStripeSerializer
// floor image
$values['image']= ($floor->getImage() !== null) ?
Config::get("server.assets_base_url", 'https://www.openstack.org/').$floor->getImage()->getFilename()
$floor->getImage()->getUrl()
: null;
// rooms
$rooms = [];

View File

@ -11,9 +11,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use models\summit\PresentationCategoryGroup;
/**
* Class PresentationCategoryGroupSerializer
* @package ModelSerializers

View File

@ -36,7 +36,7 @@ final class PresentationSlideSerializer extends PresentationMaterialSerializer
$values = parent::serialize($expand, $fields, $relations, $params);
$slide = $this->object;
if(empty($values['link'])){
$values['link'] = $slide->hasSlide() ? Config::get("server.assets_base_url", 'https://www.openstack.org/') . $slide->getSlide()->getFilename(): null;
$values['link'] = $slide->hasSlide() ? $slide->getSlide()->getUrl(): null;
}
return $values;
}

View File

@ -11,11 +11,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use libs\utils\JsonUtils;
use Illuminate\Support\Facades\Config;
use models\summit\SummitAttendee;
/**
* Class SummitAttendeeSerializer
* @package ModelSerializers

View File

@ -31,7 +31,7 @@ final class SummitEventWithFileSerializer extends SummitEventSerializer
$values = parent::serialize($expand, $fields, $relations, $params);
$values['attachment'] = $event->hasAttachment()? Config::get("server.assets_base_url", 'https://www.openstack.org/') . $event->getAttachment()->getFilename() : null;
$values['attachment'] = $event->hasAttachment()? $event->getAttachment()->getUrl() : null;
return $values;
}

View File

@ -87,7 +87,7 @@ class SummitSerializer extends SilverStripeSerializer
}
$values['logo'] = ($summit->hasLogo()) ?
Config::get("server.assets_base_url", 'https://www.openstack.org/') . $summit->getLogo()->getFilename()
$summit->getLogo()->getUrl()
: null;
// pages info

View File

@ -16,14 +16,13 @@ use models\summit\PresentationSpeaker;
use models\summit\SpeakerAnnouncementSummitEmail;
use models\summit\SummitOwned;
use models\summit\SummitRegistrationPromoCode;
/**
* @ORM\Entity
* @ORM\Table(name="SpeakerSelectionAnnouncementEmailCreationRequest")
* Class SpeakerSelectionAnnouncementEmailCreationRequest
* @package models\main
*/
final class SpeakerSelectionAnnouncementEmailCreationRequest
class SpeakerSelectionAnnouncementEmailCreationRequest
extends EmailCreationRequest
{

View File

@ -13,6 +13,7 @@
**/
use models\utils\SilverstripeBaseModel;
use Doctrine\ORM\Mapping AS ORM;
use Illuminate\Support\Facades\Config;
/**
* @ORM\Entity(repositoryClass="repositories\main\DoctrineFolderRepository")
* @ORM\Table(name="File")
@ -52,6 +53,21 @@ class File extends SilverstripeBaseModel
*/
private $show_in_search;
/**
* @ORM\Column(name="CloudStatus", type="string")
*/
private $cloud_status;
/**
* @ORM\Column(name="CloudSize", type="int")
*/
private $cloud_size;
/**
* @ORM\Column(name="CloudMetaJson", type="string")
*/
private $cloud_metajson;
/**
* @ORM\ManyToOne(targetEntity="models\main\File")
* @ORM\JoinColumn(name="ParentID", referencedColumnName="ID")
@ -181,16 +197,119 @@ class File extends SilverstripeBaseModel
public function __construct()
{
parent::__construct();
$this->class_name = 'File';
$this->class_name = 'CloudFile';
$this->show_in_search = true;
}
public function setImage(){
$this->class_name = 'Image';
$this->class_name = 'CloudImage';
}
public function setFolder(){
$this->class_name = 'Folder';
}
/**
* @return string
*/
public function getCloudStatus()
{
return $this->cloud_status;
}
/**
* @param string $cloud_status
*/
public function setCloudStatus($cloud_status): void
{
$this->cloud_status = $cloud_status;
}
/**
* @return int
*/
public function getCloudSize()
{
return $this->cloud_size;
}
/**
* @param int $cloud_size
*/
public function setCloudSize($cloud_size): void
{
$this->cloud_size = $cloud_size;
}
/**
* @param string $cloud_metajson
*/
public function setCloudMetaJSON($cloud_metajson): void
{
$this->cloud_metajson = $cloud_metajson;
}
/**
* @return string
*/
public function getUrl()
{
$local = Config::get("server.assets_base_url", 'https://www.openstack.org/').$this->getFilename();
return $this->cloud_status == 'Live' ? $this->getCloudLink() : $local;
}
/**
* @return string
*/
public function getRelativeLinkFor()
{
$fn = $this->getFilename();
return trim(str_replace("assets", '', $fn), '/');
}
/**
* @return string
*/
public function getCloudLink()
{
return Config::get("cloudstorage.base_url") . $this->getRelativeLinkFor();
}
/**
* @param string|array $key - passing an array as the first argument replaces the meta data entirely
* @param mixed $val
* @return File - chainable
*/
public function setCloudMeta($key, $val = null)
{
if (is_array($key)) {
$data = $key;
} else {
$data = $this->getCloudMetaJSON();
$data[$key] = $val;
}
$this->cloud_metajson = json_encode($data);
return $this;
}
/**
* @param string $key [optional] - if not present returns the whole array
* @return array
*/
public function getCloudMetaJSON($key = null)
{
$data = json_decode($this->cloud_metajson, true);
if (empty($data) || !is_array($data)) {
$data = array();
}
if (!empty($key)) {
return isset($data[$key]) ? $data[$key] : null;
} else {
return $data;
}
}
}

View File

@ -20,7 +20,7 @@ use models\utils\SilverstripeBaseModel;
* Class Language
* @package App\Models\Foundation\Main
*/
final class Language extends SilverstripeBaseModel
class Language extends SilverstripeBaseModel
{
/**
* @ORM\Column(name="Name", type="string")

View File

@ -20,7 +20,7 @@ use models\summit\SummitEvent;
* Class SummitMemberSchedule
* @package models\main
*/
final class SummitMemberFavorite extends BaseEntity
class SummitMemberFavorite extends BaseEntity
{
/**

View File

@ -21,7 +21,7 @@ use models\utils\IEntity;
* Class SummitMemberSchedule
* @package models\main
*/
final class SummitMemberSchedule extends BaseEntity
class SummitMemberSchedule extends BaseEntity
{
/**

View File

@ -19,7 +19,7 @@ use models\utils\SilverstripeBaseModel;
* Class MarketPlaceReview
* @package App\Models\Foundation\Marketplace
*/
final class MarketPlaceReview extends SilverstripeBaseModel
class MarketPlaceReview extends SilverstripeBaseModel
{
/**

View File

@ -21,6 +21,12 @@ use models\main\SummitMemberSchedule;
use models\utils\SilverstripeBaseModel;
/**
* @ORM\Entity
* @ORM\AssociationOverrides({
* @ORM\AssociationOverride(
* name="summit",
* inversedBy="attendees"
* )
* })
* @ORM\Table(name="SummitAttendee")
* @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineSummitAttendeeRepository")
* Class SummitAttendee

View File

@ -11,17 +11,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Doctrine\ORM\Mapping AS ORM;
use services\utils\Facades\Encryption;
/**
* Class CalendarSyncInfoCalDav
* @ORM\Entity
* @ORM\Table(name="CalendarSyncInfoCalDav")
* @package models\summit\CalendarSync
*/
final class CalendarSyncInfoCalDav extends CalendarSyncInfo
class CalendarSyncInfoCalDav extends CalendarSyncInfo
{
/**
* @ORM\Column(name="UserName", type="string")

View File

@ -11,17 +11,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Doctrine\ORM\Mapping AS ORM;
use services\utils\Facades\Encryption;
/**
* Class CalendarSyncInfoOAuth2
* @ORM\Entity
* @ORM\Table(name="CalendarSyncInfoOAuth2")
* @package models\summit\CalendarSync
*/
final class CalendarSyncInfoOAuth2 extends CalendarSyncInfo
class CalendarSyncInfoOAuth2 extends CalendarSyncInfo
{
/**
* @ORM\Column(name="AccessToken", type="string")

View File

@ -19,7 +19,7 @@ use models\summit\SummitAbstractLocation;
* @ORM\Table(name="AdminSummitLocationActionSyncWorkRequest")
* @package models\summit\CalendarSync\WorkQueue
*/
final class AdminSummitLocationActionSyncWorkRequest
class AdminSummitLocationActionSyncWorkRequest
extends AdminScheduleSummitActionSyncWorkRequest
{
const SubType = 'ADMIN_LOCATION';

View File

@ -22,6 +22,12 @@ use Doctrine\Common\Collections\ArrayCollection;
/**
* Class PresentationCategory
* @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineSummitTrackRepository")
* @ORM\AssociationOverrides({
* @ORM\AssociationOverride(
* name="summit",
* inversedBy="presentation_categories"
* )
* })
* @ORM\Table(name="PresentationCategory")
* @package models\summit
*/

View File

@ -19,7 +19,7 @@ use Doctrine\ORM\Mapping AS ORM;
* Class TrackRadioButtonListQuestionTemplate
* @package App\Models\Foundation\Summit\Events\Presentations\TrackQuestions
*/
final class TrackRadioButtonListQuestionTemplate extends TrackMultiValueQuestionTemplate
class TrackRadioButtonListQuestionTemplate extends TrackMultiValueQuestionTemplate
{
const ClassName = 'TrackRadioButtonListQuestionTemplate';

View File

@ -18,7 +18,7 @@ use Doctrine\ORM\Mapping AS ORM;
* Class TrackTextBoxQuestionTemplate
* @package App\Models\Foundation\Summit\Events\Presentations\TrackQuestions
*/
final class TrackTextBoxQuestionTemplate extends TrackSingleValueTemplateQuestion
class TrackTextBoxQuestionTemplate extends TrackSingleValueTemplateQuestion
{
const ClassName = 'TrackTextBoxQuestionTemplate';

View File

@ -22,6 +22,12 @@ use Doctrine\ORM\Mapping AS ORM;
/**
* @ORM\Table(name="RSVPTemplate")
* @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineRSVPTemplateRepository")
* @ORM\AssociationOverrides({
* @ORM\AssociationOverride(
* name="summit",
* inversedBy="rsvp_templates"
* )
* })
* Class RSVPTemplate
* @package App\Models\Foundation\Summit\Events\RSVP
*/

View File

@ -11,14 +11,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use models\main\Member;
use models\utils\IEntity;
use models\utils\SilverstripeBaseModel;
use Doctrine\ORM\Mapping AS ORM;
/**
* @ORM\Entity
* @ORM\AssociationOverrides({
* @ORM\AssociationOverride(
* name="summit",
* inversedBy="entity_events"
* )
* })
* @ORM\Table(name="SummitEntityEvent")
* @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineSummitEntityEventRepository")
* Class SummitEntityEvent

View File

@ -30,6 +30,12 @@ use Cocur\Slugify\Slugify;
use Doctrine\ORM\Mapping AS ORM;
/**
* @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineSummitEventRepository")
* @ORM\AssociationOverrides({
* @ORM\AssociationOverride(
* name="summit",
* inversedBy="events"
* )
* })
* @ORM\Table(name="SummitEvent")
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="ClassName", type="string")

View File

@ -15,6 +15,12 @@ use models\utils\SilverstripeBaseModel;
use Doctrine\ORM\Mapping AS ORM;
/**
* @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineSummitEventTypeRepository")
* @ORM\AssociationOverrides({
* @ORM\AssociationOverride(
* name="summit",
* inversedBy="event_types"
* )
* })
* @ORM\Table(name="SummitEventType")
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="ClassName", type="string")

View File

@ -37,11 +37,12 @@ class SummitGroupEvent extends SummitEvent
*/
private $groups;
const ClassName = 'SummitGroupEvent';
/**
* @return string
*/
public function getClassName(){
return "SummitGroupEvent";
return self::ClassName;
}
public function __construct()

View File

@ -1,5 +1,4 @@
<?php namespace models\summit;
/**
* Copyright 2016 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
@ -12,18 +11,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Doctrine\ORM\Mapping AS ORM;
use models\utils\SilverstripeBaseModel;
/**
* @ORM\Entity
* @ORM\Table(name="RoomMetricSampleData")
* Class RoomMetricSampleData
* @package RoomMetricType\summit
*/
final class RoomMetricSampleData extends SilverstripeBaseModel
class RoomMetricSampleData extends SilverstripeBaseModel
{
/**

View File

@ -31,6 +31,12 @@ use Doctrine\ORM\Mapping AS ORM;
/**
* @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineSummitLocationRepository")
* @ORM\AssociationOverrides({
* @ORM\AssociationOverride(
* name="summit",
* inversedBy="locations"
* )
* })
* @ORM\Table(name="SummitAbstractLocation")
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="ClassName", type="string")

View File

@ -23,6 +23,12 @@ use models\utils\SilverstripeBaseModel;
use DateTime;
/**
* @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineSelectionPlanRepository")
* @ORM\AssociationOverrides({
* @ORM\AssociationOverride(
* name="summit",
* inversedBy="selection_plans"
* )
* })
* @ORM\Table(name="SelectionPlan")
* Class SelectionPlan
* @package App\Models\Foundation\Summit

View File

@ -17,6 +17,12 @@ use Doctrine\ORM\Mapping AS ORM;
/**
* Class PresentationSpeakerSummitAssistanceConfirmationRequest
* @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrinePresentationSpeakerSummitAssistanceConfirmationRequestRepository")
* @ORM\AssociationOverrides({
* @ORM\AssociationOverride(
* name="summit",
* inversedBy="speaker_assistances"
* )
* })
* @ORM\Table(name="PresentationSpeakerSummitAssistanceConfirmationRequest")
* @package models\summit
*/

View File

@ -45,9 +45,14 @@ final class SummitPushNotificationChannel {
return in_array($channel, self::getPublicChannels());
}
}
/**
* @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineSummitNotificationRepository")
* @ORM\AssociationOverrides({
* @ORM\AssociationOverride(
* name="summit",
* inversedBy="notifications"
* )
* })
* @ORM\Table(name="SummitPushNotification")
* Class SummitPushNotification
* @package models\summit

View File

@ -16,6 +16,12 @@ use models\utils\SilverstripeBaseModel;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineSummitTicketTypeRepository")
* @ORM\AssociationOverrides({
* @ORM\AssociationOverride(
* name="summit",
* inversedBy="ticket_types"
* )
* })
* @ORM\Table(name="SummitTicketType")
* Class SummitTicketType
* @package models\summit

View File

@ -16,6 +16,12 @@ use models\utils\SilverstripeBaseModel;
use Doctrine\ORM\Mapping AS ORM;
/**
* @ORM\Entity
* @ORM\AssociationOverrides({
* @ORM\AssociationOverride(
* name="summit",
* inversedBy="wifi_connections"
* )
* })
* @ORM\Table(name="SummitWIFIConnection")
* Class SummitWIFIConnection
* @package models\summit\SummitWIFIConnection

View File

@ -19,6 +19,12 @@ use models\utils\SilverstripeBaseModel;
use Doctrine\ORM\Mapping AS ORM;
/**
* @ORM\Entity
* @ORM\AssociationOverrides({
* @ORM\AssociationOverride(
* name="summit",
* inversedBy="track_tag_groups"
* )
* })
* @ORM\Table(name="TrackTagGroup")
* Class TrackTagGroup
* @package models\summit\TrackTagGroup

View File

@ -1,18 +1,16 @@
<?php namespace models\oauth2;
/**
* Copyright 2015 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.
**/
/**
* Copyright 2015 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.
**/
/**
* Class ResourceServerContext
* @package models\oauth2

View File

@ -12,7 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use Illuminate\Support\Facades\Config;
@ -23,7 +22,6 @@ use libs\utils\ConfigurationException;
use libs\utils\ICacheService;
use models\oauth2\AccessToken;
use Illuminate\Support\Facades\Log;
/**
* Class AccessTokenService
* @package App\Models\ResourceServer

View File

@ -23,7 +23,7 @@ use Illuminate\Support\Facades\Config;
* Class EndPointRateLimitByIP
* @package App\Models\ResourceServer
*/
final class EndPointRateLimitByIP extends ResourceServerEntity
class EndPointRateLimitByIP extends ResourceServerEntity
{
/**

View File

@ -86,8 +86,8 @@ class AppServiceProvider extends ServiceProvider
*/
public function boot()
{
$monolog = Log::getMonolog();
foreach($monolog->getHandlers() as $handler) {
$logger = Log::getLogger();
foreach($logger->getHandlers() as $handler) {
$handler->setLevel(Config::get('log.level', 'debug'));
}
@ -97,10 +97,9 @@ class AppServiceProvider extends ServiceProvider
if (!empty($to) && !empty($from)) {
$subject = 'openstackid-resource-server error';
$mono_log = Log::getMonolog();
$handler = new NativeMailerHandler($to, $subject, $from);
$handler->setLevel(Config::get('log.email_level', 'error'));
$mono_log->pushHandler($handler);
$logger->pushHandler($handler);
}
Validator::extend('int_array', function($attribute, $value, $parameters, $validator)

View File

@ -13,9 +13,7 @@
**/
use App\EntityPersisters\AdminSummitEventActionSyncWorkRequestPersister;
use App\EntityPersisters\AdminSummitLocationActionSyncWorkRequestPersister;
use App\EntityPersisters\AssetSyncRequestPersister;
use App\EntityPersisters\EntityEventPersister;
use App\Factories\AssetsSyncRequest\FileCreatedAssetSyncRequestFactory;
use App\Factories\CalendarAdminActionSyncWorkRequest\AdminSummitLocationActionSyncWorkRequestFactory;
use App\Factories\CalendarAdminActionSyncWorkRequest\SummitEventDeletedCalendarSyncWorkRequestFactory;
use App\Factories\CalendarAdminActionSyncWorkRequest\SummitEventUpdatedCalendarSyncWorkRequestFactory;
@ -40,7 +38,6 @@ use App\Factories\EntityEvents\SummitEventUpdatedEntityEventFactory;
use App\Factories\EntityEvents\SummitTicketTypeActionEntityEventFactory;
use App\Factories\EntityEvents\TrackActionEntityEventFactory;
use App\Factories\EntityEvents\TrackGroupActionActionEntityEventFactory;
use App\Services\Utils\SCPFileUploader;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
/**
@ -123,12 +120,6 @@ final class EventServiceProvider extends ServiceProvider
EntityEventPersister::persist(PresentationMaterialDeletedEntityEventFactory::build($event));
});
Event::listen(\App\Events\FileCreated::class, function($event)
{
SCPFileUploader::upload($event);
AssetSyncRequestPersister::persist(FileCreatedAssetSyncRequestFactory::build($event));
});
Event::listen(\App\Events\PresentationSpeakerCreated::class, function($event)
{
EntityEventPersister::persist_list(PresentationSpeakerCreatedEntityEventFactory::build($event));

View File

@ -27,6 +27,8 @@ use utils\PagingInfo;
use utils\PagingResponse;
use Doctrine\ORM\Query\Expr\Join;
use utils\DoctrineLeftJoinFilterMapping;
use models\summit\SummitGroupEvent;
use models\summit\Presentation;
/**
* Class DoctrineSummitEventRepository
* @package App\Repositories\Summit
@ -37,8 +39,8 @@ final class DoctrineSummitEventRepository
{
private static $forbidded_classes = [
'models\\summit\\SummitGroupEvent'
private static $forbidden_classes = [
SummitGroupEvent::ClassName,
];
/**
@ -51,17 +53,26 @@ final class DoctrineSummitEventRepository
$end_date = $event->getEndDate();
$start_date = $event->getStartDate();
return $this->getEntityManager()->createQueryBuilder()
$query = $this->getEntityManager()->createQueryBuilder()
->select("e")
->from(\models\summit\SummitEvent::class, "e")
->join('e.summit', 's', Join::WITH, " s.id = :summit_id")
->where('e.published = 1')
->andWhere('e.start_date < :end_date')
->andWhere("not e INSTANCE OF ('" . implode("','", self::$forbidded_classes) . "')")
->andWhere('e.end_date > :start_date')
->setParameter('summit_id', $summit->getId())
->setParameter('start_date', $start_date)
->setParameter('end_date', $end_date)->getQuery()->getResult();
->setParameter('end_date', $end_date);
$idx = 1;
foreach(self::$forbidden_classes as $forbidden_class){
$query = $query
->andWhere("not e INSTANCE OF :forbidden_class".$idx);
$query->setParameter("forbidden_class".$idx, $forbidden_class);
$idx++;
}
return $query->getQuery()->getResult();
}
/**
@ -212,8 +223,13 @@ final class DoctrineSummitEventRepository
$can_view_private_events = self::isCurrentMemberOnGroup(IGroup::SummitAdministrators);
if(!$can_view_private_events){
$query = $query
->andWhere("not e INSTANCE OF ('" . implode("','", self::$forbidded_classes) . "')");
$idx = 1;
foreach(self::$forbidden_classes as $forbidden_class){
$query = $query
->andWhere("not e INSTANCE OF :forbidden_class".$idx);
$query->setParameter("forbidden_class".$idx, $forbidden_class);
$idx++;
}
}
$query = $query
@ -303,8 +319,13 @@ final class DoctrineSummitEventRepository
$can_view_private_events = self::isCurrentMemberOnGroup(IGroup::SummitAdministrators);
if(!$can_view_private_events){
$query = $query
->andWhere("not e INSTANCE OF ('" . implode("','", self::$forbidded_classes) . "')");
$idx = 1;
foreach(self::$forbidden_classes as $forbidden_class){
$query = $query
->andWhere("not e INSTANCE OF :forbidden_class".$idx);
$query->setParameter("forbidden_class".$idx, $forbidden_class);
$idx++;
}
}
$query = $query

View File

@ -26,6 +26,7 @@ use utils\Filter;
use utils\Order;
use utils\PagingInfo;
use utils\PagingResponse;
use models\summit\SummitVenueRoom;
/**
* Class DoctrineSummitLocationRepository
* @package App\Repositories\Summit
@ -35,8 +36,8 @@ final class DoctrineSummitLocationRepository
implements ISummitLocationRepository
{
private static $forbidded_classes = [
'models\\summit\\SummitVenueRoom',
private static $forbidden_classes = [
SummitVenueRoom::ClassName,
];
/**
@ -109,8 +110,15 @@ final class DoctrineSummitLocationRepository
->leftJoin(SummitHotel::class, 'h', 'WITH', 'h.id = el.id')
->leftJoin(SummitAirport::class, 'ap', 'WITH', 'ap.id = el.id')
->leftJoin('al.summit', 's')
->where("s.id = :summit_id")
->andWhere("not al INSTANCE OF ('" . implode("','", self::$forbidded_classes) . "')");
->where("s.id = :summit_id");
$idx = 1;
foreach(self::$forbidden_classes as $forbidden_class){
$query = $query
->andWhere("not al INSTANCE OF :forbidden_class".$idx);
$query->setParameter("forbidden_class".$idx, $forbidden_class);
$idx++;
}
$query->setParameter("summit_id", $summit->getId());

View File

@ -570,7 +570,7 @@ final class SpeakerService
throw new ValidationException(sprintf("file exceeds max_file_size (%s MB).", ($max_file_size / 1024) / 1024));
}
$uploader = new FileUploader($this->folder_service);
$uploader = new FileUploader($this->folder_service, new SwiftBucket);
$photo = $uploader->build($file, 'profile-images', true);
$speaker->setPhoto($photo);

View File

@ -1172,7 +1172,7 @@ final class SummitLocationService
);
}
$uploader = new FileUploader($this->folder_service);
$uploader = new FileUploader($this->folder_service, new SwiftBucket);
$pic = $uploader->build($file, sprintf('summits/%s/locations/%s/maps', $location->getSummitId(), $location->getId()), true);
$map = SummitLocationImageFactory::buildMap($metadata);
$map->setPicture($pic);
@ -1276,7 +1276,7 @@ final class SummitLocationService
);
}
$uploader = new FileUploader($this->folder_service);
$uploader = new FileUploader($this->folder_service, new SwiftBucket);
$pic = $uploader->build($file, sprintf('summits/%s/locations/%s/maps', $location->getSummitId(), $location->getId()), true);
$map->setPicture($pic);
}
@ -1443,7 +1443,7 @@ final class SummitLocationService
);
}
$uploader = new FileUploader($this->folder_service);
$uploader = new FileUploader($this->folder_service, new SwiftBucket);
$pic = $uploader->build($file, sprintf('summits/%s/locations/%s/images', $location->getSummitId(), $location->getId()), true);
$image = SummitLocationImageFactory::buildImage($metadata);
$image->setPicture($pic);
@ -1547,7 +1547,7 @@ final class SummitLocationService
);
}
$uploader = new FileUploader($this->folder_service);
$uploader = new FileUploader($this->folder_service, new SwiftBucket);
$pic = $uploader->build($file, sprintf('summits/%s/locations/%s/images', $location->getSummitId(), $location->getId()), true);
$image->setPicture($pic);
}

View File

@ -18,6 +18,7 @@ use App\Events\MyScheduleRemove;
use App\Events\SummitDeleted;
use App\Events\SummitUpdated;
use App\Http\Utils\FileUploader;
use App\Http\Utils\SwiftBucket;
use App\Models\Foundation\Summit\Factories\SummitFactory;
use App\Models\Foundation\Summit\Repositories\IDefaultSummitEventTypeRepository;
use App\Models\Utils\IntervalParser;
@ -1282,7 +1283,7 @@ final class SummitService extends AbstractService implements ISummitService
throw new ValidationException(sprintf( "file exceeds max_file_size (%s MB).", ($max_file_size/1024)/1024));
}
$uploader = new FileUploader($this->folder_service);
$uploader = new FileUploader($this->folder_service, new SwiftBucket);
$attachment = $uploader->build($file, 'summit-event-attachments', true);
$event->setAttachment($attachment);

View File

@ -94,7 +94,8 @@ final class ServicesProvider extends ServiceProvider
});
// setting facade
$this->app['encryption'] = App::share(function ($app) {
App::singleton('encryption', function ($app) {
return new \services\utils\EncryptionService(
Config::get("server.ss_encrypt_key", ''),
Config::get("server.ss_encrypt_cypher", '')

View File

@ -1,47 +0,0 @@
<?php namespace App\Services\Utils;
/**
* 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.
**/
use App\Events\FileCreated;
use IDCT\Networking\Ssh\Credentials;
use IDCT\Networking\Ssh\SftpClient;
use Illuminate\Support\Facades\Config;
/**
* Class SCPFileUploader
* @package App\Services\Utils
*/
final class SCPFileUploader
{
public static function upload(FileCreated $event){
$storage_path = storage_path();
$local_path = $event->getLocalPath();
$file_name = $event->getFileName();
$remote_base_path = Config::get('scp.scp_remote_base_path', null);
$client = new SftpClient();
$host = Config::get('scp.scp_host', null);
$credentials = Credentials::withPublicKey
(
Config::get('scp.ssh_user', null),
Config::get('scp.ssh_public_key', null),
Config::get('scp.ssh_private_key', null)
);
$client->setCredentials($credentials);
$client->connect($host);
$remote_destination = sprintf("%s/%s", $remote_base_path, $file_name);
$client->scpUpload(sprintf("%s/app/%s", $storage_path, $local_path), $remote_destination);
$client->close();
}
}

29
app/User.php Normal file
View File

@ -0,0 +1,29 @@
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}

View File

@ -8,29 +8,41 @@
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.3.*",
"predis/predis": "1.0.1",
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.6.*",
"laravel/tinker": "^1.0",
"predis/predis": "1.0.*",
"ext-json":"*",
"ext-pdo":"*",
"ezyang/htmlpurifier": "4.7.0",
"glenscott/url-normalizer" : "^1.4",
"laravel-doctrine/orm":"1.2.*",
"laravel-doctrine/orm":"1.4.*",
"laravel-doctrine/extensions": "1.0.*",
"cocur/slugify": "^2.3",
"guzzlehttp/guzzle": "^6.3",
"google/apiclient": "^2.2",
"smarcet/caldavclient": "1.1.6",
"smarcet/outlook-rest-client": "dev-master",
"idct/sftp-client": "dev-master"
"idct/sftp-client": "dev-master",
"php-opencloud/openstack": "3.0.5"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"phpunit/phpunit": "~4.0",
"symfony/css-selector": "3.1.*",
"symfony/dom-crawler": "3.1.*",
"mockery/mockery": "^0.9.9"
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^2.0",
"phpunit/phpunit": "^7.0",
"laravel/browser-kit-testing": "4.0.2"
},
"suggest":{
"lib-openssl": "Required to use AES algorithms (except AES GCM)",
"ext-json":"Required to use json algorithms"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories",
"database",
"app",
"tests",
@ -41,28 +53,33 @@
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
"@php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
]
},
"config": {
"preferred-install": "dist"
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"minimum-stability":"dev"
"minimum-stability": "dev",
"prefer-stable": true
}

3130
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -99,21 +99,6 @@ return [
'cipher' => 'AES-256-CBC',
/*
|--------------------------------------------------------------------------
| Logging Configuration
|--------------------------------------------------------------------------
|
| Here you may configure the log settings for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Settings: "single", "daily", "syslog", "errorlog"
|
*/
'log' => env('APP_LOG', 'daily'),
/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers

View File

@ -67,7 +67,7 @@ return [
'providers' => [
'users' => [
'driver' => 'eloquent',
//'model' => App\User::class,
'model' => App\User::class,
],
// 'users' => [
@ -81,10 +81,6 @@ return [
| Resetting Passwords
|--------------------------------------------------------------------------
|
| Here you may set the options for resetting passwords including the view
| that is your password reset e-mail. You may also set the name of the
| table that maintains all of the reset tokens for your application.
|
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
@ -98,7 +94,6 @@ return [
'passwords' => [
'users' => [
'provider' => 'users',
'email' => 'auth.emails.password',
'table' => 'password_resets',
'expire' => 60,
],

23
config/cloudstorage.php Normal file
View File

@ -0,0 +1,23 @@
<?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.
**/
return [
'base_url' => env('CLOUD_STORAGE_BASE_URL', null),
'container' => env('CLOUD_STORAGE_CONTAINER', null),
'auth_url' => env('CLOUD_STORAGE_AUTH_URL', null),
'user_name' => env('CLOUD_STORAGE_USERNAME', null),
'api_key' => env('CLOUD_STORAGE_APIKEY', null),
'project_name' => env('CLOUD_STORAGE_PROJECT_NAME', null),
'region' => env('CLOUD_STORAGE_REGION', null),
];

View File

@ -22,7 +22,7 @@ return [
*/
'managers' => [
'default' => [
'dev' => env('APP_DEBUG'),
'dev' => env('APP_DEBUG', true),
'meta' => env('DOCTRINE_METADATA', 'annotations'),
'connection' => env('DB_CONNECTION', 'openstackid_resources'),
'namespaces' => [

52
config/hashing.php Normal file
View File

@ -0,0 +1,52 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Hash Driver
|--------------------------------------------------------------------------
|
| This option controls the default hash driver that will be used to hash
| passwords for your application. By default, the bcrypt algorithm is
| used; however, you remain free to modify this option if you wish.
|
| Supported: "bcrypt", "argon"
|
*/
'driver' => 'bcrypt',
/*
|--------------------------------------------------------------------------
| Bcrypt Options
|--------------------------------------------------------------------------
|
| Here you may specify the configuration options that should be used when
| passwords are hashed using the Bcrypt algorithm. This will allow you
| to control the amount of time it takes to hash the given password.
|
*/
'bcrypt' => [
'rounds' => env('BCRYPT_ROUNDS', 10),
],
/*
|--------------------------------------------------------------------------
| Argon Options
|--------------------------------------------------------------------------
|
| Here you may specify the configuration options that should be used when
| passwords are hashed using the Argon algorithm. These will allow you
| to control the amount of time it takes to hash the given password.
|
*/
'argon' => [
'memory' => 1024,
'threads' => 2,
'time' => 2,
],
];

81
config/logging.php Normal file
View File

@ -0,0 +1,81 @@
<?php
use Monolog\Handler\StreamHandler;
return [
/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that gets used when writing
| messages to the logs. The name specified in this option should match
| one of the channels defined in the "channels" configuration array.
|
*/
'default' => env('LOG_CHANNEL', 'stack'),
/*
|--------------------------------------------------------------------------
| Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Drivers: "single", "daily", "slack", "syslog",
| "errorlog", "monolog",
| "custom", "stack"
|
*/
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['daily'],
],
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
],
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
'days' => 7,
],
'slack' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Laravel Log',
'emoji' => ':boom:',
'level' => 'critical',
],
'stderr' => [
'driver' => 'monolog',
'handler' => StreamHandler::class,
'with' => [
'stream' => 'php://stderr',
],
],
'syslog' => [
'driver' => 'syslog',
'level' => 'debug',
],
'errorlog' => [
'driver' => 'errorlog',
'level' => 'debug',
],
],
];

View File

@ -16,6 +16,7 @@ use models\summit\ICalendarSyncInfoRepository;
use models\summit\SummitEvent;
use models\summit\CalendarSync\WorkQueue\AdminSummitEventActionSyncWorkRequest;
use models\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
use Tests\TestCase;
/**
* Class AdminActionsCalendarSyncPreProcessorTest
*/

View File

@ -12,6 +12,8 @@
* limitations under the License.
**/
use App\Services\Model\IAttendeeService;
use Tests\TestCase;
use Illuminate\Support\Facades\App;
/**
* Class AttendeeServiceTest
*/

View File

@ -0,0 +1,54 @@
<?php namespace Tests;
/**
* Copyright 2015 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.
**/
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Redis;
use Laravel\BrowserKitTesting\TestCase as BaseTestCase;
/**
* Class TestCase
* @package Tests
*/
abstract class BrowserKitTestCase extends BaseTestCase
{
use CreatesApplication;
private $redis;
/**
* The base URL to use while testing the application.
*
* @var string
*/
protected $baseUrl = 'http://localhost';
public function setUp()
{
parent::setUp(); // Don't forget this!
$this->redis = Redis::connection();
$this->redis->flushall();
$this->prepareForTests();
}
/**
* Migrates the database and set the mailer to 'pretend'.
* This will cause the tests to run quickly.
*
*/
protected function prepareForTests()
{
Artisan::call('migrate');
//Mail::pretend(true);
$this->seed('TestSeeder');
}
}

View File

@ -11,7 +11,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Tests\TestCase;
/**
* Class CountriesApiTest
*/
final class CountriesApiTest extends TestCase
{
public function testGetAllCountries()

View File

@ -0,0 +1,22 @@
<?php namespace Tests;
use Illuminate\Contracts\Console\Kernel;
/**
* Trait CreatesApplication
* @package Tests
*/
trait CreatesApplication
{
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = require __DIR__.'/../bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
return $app;
}
}

View File

@ -1,5 +1,5 @@
<?php
use Tests\TestCase;
/**
* Copyright 2016 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -0,0 +1,21 @@
<?php
namespace Tests\Feature;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testBasicTest()
{
$response = $this->get('/');
$response->assertStatus(200);
}
}

View File

@ -1,5 +1,5 @@
<?php
use Tests\TestCase;
/**
* Copyright 2015 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Tests\TestCase;
/**
* Class LanguagesApiTest
*/

View File

@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Tests\TestCase;
/**
* Class MarketplaceApiTest
*/

View File

@ -11,7 +11,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Illuminate\Support\Facades\App;
use models\summit\IAbstractCalendarSyncWorkRequestRepository;
use models\summit\ICalendarSyncInfoRepository;
@ -20,7 +19,7 @@ use models\summit\SummitEvent;
use models\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
use models\summit\CalendarSync\CalendarSyncInfo;
use models\main\Member;
use Tests\TestCase;
/**
* Class MemberActionsCalendarSyncPreProcessorTest
*/

View File

@ -12,7 +12,6 @@
* limitations under the License.
**/
use models\marketplace\ICompanyServiceRepository;
/**
* Class OAuth2PublicCloudApiTest
@ -26,14 +25,14 @@ class OAuth2PublicCloudApiTest extends ProtectedApiTest
$params = array(
'page' => 1,
'per_page' => 10,
'status' => ICompanyServiceRepository::Status_active,
'status' => 'active',
);
$headers = array("HTTP_Authorization" => " Bearer " . $this->access_token);
$response = $this->action(
"GET",
"OAuth2PublicCloudApiController@getClouds",
"PublicCloudsApiController@getAll",
$params,
array(),
array(),
@ -57,7 +56,7 @@ class OAuth2PublicCloudApiTest extends ProtectedApiTest
$headers = array("HTTP_Authorization" => " Bearer " . $this->access_token);
$response = $this->action(
"GET",
"OAuth2PublicCloudApiController@getCloud",
"PublicCloudsApiController@get",
$params,
array(),
array(),
@ -81,7 +80,7 @@ class OAuth2PublicCloudApiTest extends ProtectedApiTest
$headers = array("HTTP_Authorization" => " Bearer " . $this->access_token);
$response = $this->action(
"GET",
"OAuth2PublicCloudApiController@getCloud",
"PublicCloudsApiController@getCloud",
$params,
array(),
array(),
@ -105,7 +104,7 @@ class OAuth2PublicCloudApiTest extends ProtectedApiTest
$headers = array("HTTP_Authorization" => " Bearer " . $this->access_token);
$response = $this->action(
"GET",
"OAuth2PublicCloudApiController@getCloudDataCenters",
"PublicCloudsApiController@getCloudDataCenters",
$params,
array(),
array(),

View File

@ -153,6 +153,41 @@ final class OAuth2SummitLocationsApiTest extends ProtectedApiTest
$this->assertTrue(!is_null($locations));
}
public function testGetCurrentSummitLocationsByClassHotels($summit_id = 25)
{
$params = [
'id' => $summit_id,
'page' => 1,
'per_page' => 100,
'filter' => [
'class_name=='.\models\summit\SummitHotel::ClassName,
]
];
$headers =
[
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action
(
"GET",
"OAuth2SummitLocationsApiController@getLocations",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$locations = json_decode($content);
$this->assertTrue(!is_null($locations));
}
public function testGetCurrentSummitVenues()
{
$params = array

View File

@ -111,7 +111,6 @@ final class OAuth2TrackGroupsApiTest extends ProtectedApiTest
$track_group = json_decode($content);
$this->assertTrue(!is_null($track_group));
$this->assertResponseStatus(200);
}
/**

View File

@ -12,6 +12,9 @@
* limitations under the License.
**/
/**
* Class OAuth2TrackTagGroupsApiTest
*/
final class OAuth2TrackTagGroupsApiTest extends ProtectedApiTest
{
public function testGetTrackTagGroups($summit_id = 25)

View File

@ -11,8 +11,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Tests\TestCase;
class ParseMultiPartFormDataInputStreamTest extends TestCase
/**
* Class ParseMultiPartFormDataInputStreamTest
*/
final class ParseMultiPartFormDataInputStreamTest extends TestCase
{
public function testParse(){
$input = <<<DATA

View File

@ -125,7 +125,7 @@ class AccessTokenServiceStub2 implements IAccessTokenService
/**
* Class ProtectedApiTest
*/
abstract class ProtectedApiTest extends TestCase
abstract class ProtectedApiTest extends \Tests\BrowserKitTestCase
{
/**

View File

@ -11,13 +11,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Illuminate\Support\Facades\App;
use LaravelDoctrine\ORM\Facades\EntityManager;
use App\Models\Utils\IntervalParser;
use services\model\ISummitService;
use utils\FilterParser;
use Tests\TestCase;
/**
* Class SearchEmptySpotsTest
*/
@ -57,7 +56,7 @@ final class SearchEmptySpotsTest extends TestCase
$intervals = IntervalParser::getInterval($start_datetime, $end_datetime);
$this->assertTrue(count($intervals) == 4);
$this->assertTrue(count($intervals) == 3);
}
public function testFindSpots(){

View File

@ -1,46 +1,22 @@
<?php
use Illuminate\Support\Facades\Redis;
class TestCase extends Illuminate\Foundation\Testing\TestCase
<?php namespace Tests;
/**
* Copyright 2015 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.
**/
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
/**
* Class TestCase
* @package Tests
*/
abstract class TestCase extends BaseTestCase
{
//services
private $redis = null;
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
//putenv('DB_DEFAULT=sqlite_testing');
$app = require __DIR__.'/../bootstrap/app.php';
$instance = $app->make('Illuminate\Contracts\Console\Kernel');
$app->loadEnvironmentFrom('.env.testing');
$instance->bootstrap();
return $app;
}
public function setUp()
{
parent::setUp();
$this->redis = Redis::connection();
$this->redis->flushall();
$this->prepareForTests();
}
protected function prepareForTests()
{
Artisan::call('migrate');
$this->seed('TestSeeder');
}
public function tearDown()
{
parent::tearDown();
}
}
use CreatesApplication;
}

View File

@ -0,0 +1,19 @@
<?php
namespace Tests\Unit;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testBasicTest()
{
$this->assertTrue(true);
}
}