Page MenuHomeDevCentral

D1967.id4973.diff
No OneTemporary

D1967.id4973.diff

diff --git a/PaaSDockerTest.php b/PaaSDockerTest.php
new file mode 100644
--- /dev/null
+++ b/PaaSDockerTest.php
@@ -0,0 +1,32 @@
+<?php
+
+require_once 'traits/assertHttp.php';
+require_once 'utils/OperationsConfiguration.php';
+
+use Nasqueron\Infrastructure\OperationsConfiguration;
+
+class PaaSDockerTest extends PHPUnit\Framework\TestCase {
+
+ use assertHttp;
+
+ /**
+ * @dataProvider provideDockerDomains
+ *
+ * @param string $domain A domain declared in the PaaS Docker configuration
+ * as an HTTP upstream block for a Docker container
+ */
+ public function test502Pages (string $domain) : void {
+ $url = "https://$domain/502.html";
+
+ $this->assertHttpResponseCode(200, $url, "A 502 page is missing for $domain");
+ }
+
+ public function provideDockerDomains () : iterable {
+ $domains = OperationsConfiguration::getDockerDomains();
+
+ foreach ($domains as $domain) {
+ yield [$domain];
+ }
+ }
+
+}
diff --git a/composer.json b/composer.json
--- a/composer.json
+++ b/composer.json
@@ -3,7 +3,8 @@
"description": "Tests to validate production environment",
"type": "project",
"require": {
- "phpunit/phpunit": "^7.3"
+ "phpunit/phpunit": "^7.3",
+ "ext-yaml": "*"
},
"license": "BSD-2-Clause",
"authors": [
diff --git a/utils/OperationsConfiguration.php b/utils/OperationsConfiguration.php
new file mode 100644
--- /dev/null
+++ b/utils/OperationsConfiguration.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace Nasqueron\Infrastructure;
+
+class OperationsConfiguration {
+
+ const PILLAR_BASE = "https://raw.githubusercontent.com/nasqueron/operations/master/pillar/";
+
+ public static function getDockerDomains () : array {
+ $domains = [];
+
+ $pillar = self::readPillarFile("paas/docker.sls");
+ foreach ($pillar['docker_containers'] as $instances) {
+ foreach ($instances as $containers) {
+ foreach ($containers as $instance) {
+ if (isset($instance['host'])) {
+ $domains[] = $instance['host'];
+ }
+ }
+ }
+ }
+
+ return $domains;
+ }
+
+ public static function readPillarFile ($path) : iterable {
+ $url = self::PILLAR_BASE . $path;
+ $yaml = file_get_contents($url);
+
+ return yaml_parse($yaml);
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 19:37 (21 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2262864
Default Alt Text
D1967.id4973.diff (2 KB)

Event Timeline