/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('<info>Status: maintenance mode is ' . ($this->maintenanceMode->isOn() ? 'active' : 'not active') . '</info>'); $addressInfo = $this->maintenanceMode->getAddressInfo(); $addresses = implode(', ', $addressInfo); $output->writeln('<info>List of exempt IP-addresses: ' . ($addresses ? $addresses : 'none') . '</info>'); }
public function testOffSetMultipleAddresses() { $mapisExist = [[MaintenanceMode::FLAG_FILENAME, false], [MaintenanceMode::IP_FILENAME, true]]; $this->flagDir->expects($this->any())->method('isExist')->will($this->returnValueMap($mapisExist)); $this->flagDir->expects($this->any())->method('delete')->will($this->returnValueMap($mapisExist)); $this->flagDir->expects($this->any())->method('readFile')->with(MaintenanceMode::IP_FILENAME)->will($this->returnValue('address1,10.50.60.123')); $expectedArray = ['address1', '10.50.60.123']; $this->model->setAddresses('address1,10.50.60.123'); $this->assertEquals($expectedArray, $this->model->getAddressInfo()); $this->assertFalse($this->model->isOn('address1')); $this->assertFalse($this->model->isOn('address3')); }
/** * Asserts maintenance mode * * @return void * @throws \Exception */ protected function assertMaintenance() { $isExpected = $this->getIsExpected(self::PARAM_REQUIRE_MAINTENANCE, self::DEFAULT_REQUIRE_MAINTENANCE); if (null === $isExpected) { return; } $this->initObjectManager(); /** @var \Magento\Framework\App\MaintenanceMode $maintenance */ $this->maintenance = $this->objectManager->get('Magento\\Framework\\App\\MaintenanceMode'); $isOn = $this->maintenance->isOn(isset($this->server['REMOTE_ADDR']) ? $this->server['REMOTE_ADDR'] : ''); if ($isOn && !$isExpected) { $this->errorCode = self::ERR_MAINTENANCE; throw new \Exception('Unable to proceed: the maintenance mode is enabled. '); } if (!$isOn && $isExpected) { $this->errorCode = self::ERR_MAINTENANCE; throw new \Exception('Unable to proceed: the maintenance mode must be enabled first. '); } }
/** * Asserts maintenance mode * * @return void * @throws \Exception */ protected function assertMaintenance() { $isExpected = $this->getIsExpected(self::PARAM_REQUIRE_MAINTENANCE, self::DEFAULT_REQUIRE_MAINTENANCE); if (null === $isExpected) { return; } $this->init(); $isOn = $this->maintenance->isOn(isset($this->server['REMOTE_ADDR']) ? $this->server['REMOTE_ADDR'] : ''); if ($isOn && !$isExpected) { $this->errorCode = self::ERR_MAINTENANCE; throw new \Exception('Unable to proceed: the maintenance mode is enabled.'); } if (!$isOn && $isExpected) { $this->errorCode = self::ERR_MAINTENANCE; throw new \Exception('Unable to proceed: the maintenance mode must be enabled first.'); } }