Skip to content

Commit

Permalink
Merge pull request #219 from Inchoo/feature/#195-enhancements-for-con…
Browse files Browse the repository at this point in the history
…fig-changes

Feature/#195 enhancements for config changes
  • Loading branch information
vvuksan authored Oct 26, 2018
2 parents ee68a84 + ff8549f commit 5694d3a
Show file tree
Hide file tree
Showing 44 changed files with 317 additions and 174 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @copyright Copyright (c) 2016 Fastly, Inc. (http://www.fastly.com)
* @license BSD, see LICENSE_FASTLY_CDN.txt
*/
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Vcl;
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Advanced;

use Fastly\Cdn\Model\Config;
use Fastly\Cdn\Model\Api;
Expand All @@ -30,7 +30,7 @@
/**
* Class CheckTlsSetting
*
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Vcl
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Advanced
*/
class CheckTlsSetting extends Action
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @copyright Copyright (c) 2016 Fastly, Inc. (http://www.fastly.com)
* @license BSD, see LICENSE_FASTLY_CDN.txt
*/
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Vcl;
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Advanced;

use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
Expand All @@ -31,7 +31,7 @@
/**
* Class ForceTls
*
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Vcl
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Advanced
*/
class ForceTls extends Action
{
Expand Down Expand Up @@ -147,6 +147,12 @@ public function execute()
}
}

$comment = ['comment' => 'Magento Module turned ON Force TLS'];
if ($checkIfReqExist) {
$comment = ['comment' => 'Magento Module turned OFF Force TLS'];
}
$this->api->addComment($clone->number, $comment);

return $result->setData(['status' => true]);
} catch (\Exception $e) {
return $result->setData([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @copyright Copyright (c) 2016 Fastly, Inc. (http://www.fastly.com)
* @license BSD, see LICENSE_FASTLY_CDN.txt
*/
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Vcl;
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Backend;

use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
Expand All @@ -31,7 +31,7 @@
/**
* Class ConfigureBackend
*
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Vcl
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Backend
*/
class ConfigureBackend extends Action
{
Expand Down Expand Up @@ -129,6 +129,9 @@ public function execute()
);
}

$comment = ['comment' => 'Magento Module updated the "'.$oldName.'" Backend Configuration'];
$this->api->addComment($clone->number, $comment);

return $result->setData([
'status' => true,
'active_version' => $clone->number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @copyright Copyright (c) 2016 Fastly, Inc. (http://www.fastly.com)
* @license BSD, see LICENSE_FASTLY_CDN.txt
*/
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Vcl;
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Backend;

use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
Expand All @@ -31,7 +31,7 @@
/**
* Class GetBackends
*
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Vcl
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Backend
*/
class GetBackends extends Action
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @copyright Copyright (c) 2016 Fastly, Inc. (http://www.fastly.com)
* @license BSD, see LICENSE_FASTLY_CDN.txt
*/
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Vcl;
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\BasicAuthentication;

use Fastly\Cdn\Model\Api;
use Fastly\Cdn\Model\Config;
Expand All @@ -29,7 +29,7 @@
/**
* Class CheckAuthDictionary
*
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Vcl
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\BasicAuthentication
*/
class CheckAuthDictionary extends Action
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @copyright Copyright (c) 2016 Fastly, Inc. (http://www.fastly.com)
* @license BSD, see LICENSE_FASTLY_CDN.txt
*/
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Vcl;
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\BasicAuthentication;

use Fastly\Cdn\Model\Config;
use Fastly\Cdn\Model\Api;
Expand All @@ -29,7 +29,7 @@
/**
* Class CheckAuthSetting
*
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Vcl
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\BasicAuthentication
*/
class CheckAuthSetting extends Action
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @copyright Copyright (c) 2016 Fastly, Inc. (http://www.fastly.com)
* @license BSD, see LICENSE_FASTLY_CDN.txt
*/
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Vcl;
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\BasicAuthentication;

use Fastly\Cdn\Model\Config;
use Fastly\Cdn\Model\Api;
Expand All @@ -29,7 +29,7 @@
/**
* Class CheckAuthUsersAvailable
*
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Vcl
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\BasicAuthentication
*/
class CheckAuthUsersAvailable extends Action
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @copyright Copyright (c) 2016 Fastly, Inc. (http://www.fastly.com)
* @license BSD, see LICENSE_FASTLY_CDN.txt
*/
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Edge\Auth;
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\BasicAuthentication;

use Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Vcl\CheckAuthSetting;
use Fastly\Cdn\Model\Api;
Expand All @@ -32,7 +32,7 @@
/**
* Class Create
*
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Edge\Auth
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\BasicAuthentication
*/
class Create extends Action
{
Expand Down Expand Up @@ -118,6 +118,9 @@ public function execute()
$this->api->activateVersion($clone->number);
}

$comment = ['comment' => 'Magento Module created the Basic Authentication dictionary'];
$this->api->addComment($clone->number, $comment);

return $result->setData([
'status' => true,
'active_version' => $clone->number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @copyright Copyright (c) 2016 Fastly, Inc. (http://www.fastly.com)
* @license BSD, see LICENSE_FASTLY_CDN.txt
*/
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Edge\Auth;
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\BasicAuthentication;

use Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Vcl\CheckAuthSetting;
use Fastly\Cdn\Model\Api;
Expand All @@ -32,7 +32,7 @@
/**
* Class Delete
*
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Edge\Auth
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\BasicAuthentication
*/
class Delete extends Action
{
Expand Down Expand Up @@ -137,6 +137,9 @@ public function execute()
$this->api->activateVersion($clone->number);
}

$comment = ['comment' => 'Magento Module deleted the Basic Authentication dictionary'];
$this->api->addComment($clone->number, $comment);

return $result->setData([
'status' => true,
'active_version' => $clone->number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @copyright Copyright (c) 2016 Fastly, Inc. (http://www.fastly.com)
* @license BSD, see LICENSE_FASTLY_CDN.txt
*/
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Vcl;
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\BasicAuthentication;

use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
Expand All @@ -33,7 +33,7 @@
/**
* Class EnableAuth
*
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Vcl
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\BasicAuthentication
*/
class EnableAuth extends Action
{
Expand Down Expand Up @@ -148,17 +148,13 @@ public function execute()
$this->api->activateVersion($clone->number);
}

if ($this->config->areWebHooksEnabled() && $this->config->canPublishConfigChanges()) {
if (!$enabled) {
$this->api->sendWebHook(
'*Basic Authentication has been turned OFF in Fastly version ' . $clone->number . '*'
);
} else {
$this->api->sendWebHook(
'*Basic Authentication has been turned ON in Fastly version '. $clone->number . '*'
);
}
$this->sendWebhook($enabled, $clone);

$comment = ['comment' => 'Magento Module turned ON Basic Authentication'];
if (!$enabled) {
$comment = ['comment' => 'Magento Module turned OFF Basic Authentication'];
}
$this->api->addComment($clone->number, $comment);

return $result->setData(['status' => true]);
} catch (\Exception $e) {
Expand All @@ -168,4 +164,19 @@ public function execute()
]);
}
}

private function sendWebhook($enabled, $clone)
{
if ($this->config->areWebHooksEnabled() && $this->config->canPublishConfigChanges()) {
if (!$enabled) {
$this->api->sendWebHook(
'*Basic Authentication has been turned OFF in Fastly version ' . $clone->number . '*'
);
} else {
$this->api->sendWebHook(
'*Basic Authentication has been turned ON in Fastly version '. $clone->number . '*'
);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @copyright Copyright (c) 2016 Fastly, Inc. (http://www.fastly.com)
* @license BSD, see LICENSE_FASTLY_CDN.txt
*/
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Edge\Auth\Item;
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\BasicAuthentication\Item;

use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
Expand All @@ -31,7 +31,7 @@
/**
* Class Create
*
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Edge\Auth\Item
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\BasicAuthentication\Item
*/
class Create extends Action
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @copyright Copyright (c) 2016 Fastly, Inc. (http://www.fastly.com)
* @license BSD, see LICENSE_FASTLY_CDN.txt
*/
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Edge\Auth\Item;
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\BasicAuthentication\Item;

use Fastly\Cdn\Model\Api;
use Magento\Backend\App\Action;
Expand All @@ -31,7 +31,7 @@
/**
* Class Delete
*
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Edge\Auth\Item
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\BasicAuthentication\Item
*/
class Delete extends Action
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @copyright Copyright (c) 2016 Fastly, Inc. (http://www.fastly.com)
* @license BSD, see LICENSE_FASTLY_CDN.txt
*/
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Edge\Auth\Item;
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\BasicAuthentication\Item;

use Fastly\Cdn\Model\Api;
use Magento\Backend\App\Action;
Expand All @@ -31,7 +31,7 @@
/**
* Class ListAll
*
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Edge\Auth\Item
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\BasicAuthentication\Item
*/
class ListAll extends Action
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @copyright Copyright (c) 2016 Fastly, Inc. (http://www.fastly.com)
* @license BSD, see LICENSE_FASTLY_CDN.txt
*/
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Vcl;
namespace Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Blocking;

use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
Expand All @@ -32,7 +32,7 @@
/**
* Class Blocking
*
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Vcl
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Blocking
*/
class Blocking extends Action
{
Expand Down Expand Up @@ -97,7 +97,6 @@ public function execute()
$service = $this->api->checkServiceDetails();
$this->vcl->checkCurrentVersionActive($service->versions, $activeVersion);
$currActiveVersion = $this->vcl->getCurrentVersion($service->versions);

$clone = $this->api->cloneVersion($currActiveVersion);

$reqName = Config::FASTLY_MAGENTO_MODULE . '_blocking';
Expand Down Expand Up @@ -170,13 +169,13 @@ public function execute()
$this->api->activateVersion($clone->number);
}

if ($this->config->areWebHooksEnabled() && $this->config->canPublishConfigChanges()) {
if ($checkIfReqExist) {
$this->api->sendWebHook('*Blocking has been turned OFF in Fastly version ' . $clone->number . '*');
} else {
$this->api->sendWebHook('*Blocking has been turned ON in Fastly version ' . $clone->number . '*');
}
$this->sendWebhook($checkIfReqExist, $clone);

$comment = ['comment' => 'Magento Module turned ON Blocking'];
if ($checkIfReqExist) {
$comment = ['comment' => 'Magento Module turned OFF Blocking'];
}
$this->api->addComment($clone->number, $comment);

return $result->setData([
'status' => true
Expand Down Expand Up @@ -228,4 +227,15 @@ private function prepareCountryCodes($blockedCountries)

return $result;
}

private function sendWebhook($checkIfReqExist, $clone)
{
if ($this->config->areWebHooksEnabled() && $this->config->canPublishConfigChanges()) {
if ($checkIfReqExist) {
$this->api->sendWebHook('*Blocking has been turned OFF in Fastly version ' . $clone->number . '*');
} else {
$this->api->sendWebHook('*Blocking has been turned ON in Fastly version ' . $clone->number . '*');
}
}
}
}
Loading

0 comments on commit 5694d3a

Please sign in to comment.