public function testValidate(UnitTester $I) { $data = ['host' => 'localhost', 'dbuser' => 'homestead', 'password' => 'secret', 'port' => '3306', 'database' => 'stigma']; $dbConnectionValidation = new DatabaseConnectionValidation(); $I->assertTrue($dbConnectionValidation->passes($data)); $I->expectedPdoException(function () { $data = ['host' => 'localhost', 'dbuser' => 'homestead', 'password' => 'secret2', 'port' => '3306', 'database' => 'stigma']; $dbConnectionValidation = new DatabaseConnectionValidation(); $dbConnectionValidation->passes($data); }); }
public function refresh() { $response = new \stdClass(); $response->nagios = true; $response->grafana = true; $response->influxdb = true; $response->database = true; try { $this->httpClient->get(config('nagios.host'), ['timeout' => 4]); } catch (\Exception $e) { $response->nagios = false; } $parsedData = parse_url(config('influxdb.host')); if (config('influxdb.username') != 'root') { $response->influxdb = false; } else { if (config('influxdb.password') != 'root') { $response->influxdb = false; } else { if ($parsedData['port'] != 8086) { $response->influxdb = false; } else { if (config('influxdb.database') != 'stigma') { $response->influxdb = false; } } } } try { $this->httpClient->get(config('grafana.host'), ['timeout' => 4]); } catch (\Exception $e) { $response->grafana = false; } $dbValidation = new DatabaseConnectionValidation(); $data = array(); $data['host'] = config('database.connections.mysql.host'); $data['password'] = config('database.connections.mysql.password'); $data['dbuser'] = config('database.connections.mysql.username'); $data['database'] = config('database.connections.mysql.database'); try { $ret = $dbValidation->passes($data); } catch (\Exception $e) { $response->database = false; } echo json_encode($response); }
public function refresh() { $response = new \stdClass(); $response->nagios = true; $response->grafana = true; $response->influxdb = true; $response->database = true; try { $url = 'http://' . config('nagios.host') . '/nagios'; $this->httpClient->get($url, ['auth' => [config('nagios.username'), config('nagios.password')], 'timeout' => 4]); } catch (\Exception $e) { $response->nagios = false; } try { $url = 'http://' . config('influxdb.host') . ':' . config('influxdb.port') . '/ping'; $this->httpClient->get($url, ['timeout' => 4]); } catch (\Exception $e) { $response->influxdb = false; } try { $url = 'http://' . config('grafana.username') . ':' . config('grafana.password') . '@' . config('grafana.host') . ':' . config('grafana.port') . '/api/org'; $this->httpClient->get($url, ['timeout' => 4]); } catch (\Exception $e) { $response->grafana = false; } $dbValidation = new DatabaseConnectionValidation(); $data = array(); $data['host'] = config('database.connections.mysql.host'); $data['password'] = config('database.connections.mysql.password'); $data['dbuser'] = config('database.connections.mysql.username'); $data['database'] = config('database.connections.mysql.database'); try { $ret = $dbValidation->passes($data); } catch (\Exception $e) { $response->database = false; } echo json_encode($response); }