summaryrefslogtreecommitdiff
path: root/caddytest
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2020-06-01 12:43:06 -0400
committerGitHub <noreply@github.com>2020-06-01 10:43:06 -0600
commitfdf2a77feb53cb9dd6de772f811e96a5f6b2d2c4 (patch)
tree9dc596a40de9c076519eed900c1791aabe65f52b /caddytest
parenta496308f6eb57f8dd2e1598bfb624a3e567aa4e1 (diff)
caddyfile: Add args on imports (#3423)
* caddyfile: Add support for args on imports * caddyfile: Add more import args tests
Diffstat (limited to 'caddytest')
-rw-r--r--caddytest/integration/caddyfile_adapt/import_args_file.txt49
-rw-r--r--caddytest/integration/caddyfile_adapt/import_args_snippet.txt83
-rw-r--r--caddytest/integration/testdata/import_respond.txt1
3 files changed, 133 insertions, 0 deletions
diff --git a/caddytest/integration/caddyfile_adapt/import_args_file.txt b/caddytest/integration/caddyfile_adapt/import_args_file.txt
new file mode 100644
index 0000000..6947f68
--- /dev/null
+++ b/caddytest/integration/caddyfile_adapt/import_args_file.txt
@@ -0,0 +1,49 @@
+example.com
+
+import testdata/import_respond.txt Groot Rocket
+import testdata/import_respond.txt you "the confused man"
+----------
+{
+ "apps": {
+ "http": {
+ "servers": {
+ "srv0": {
+ "listen": [
+ ":443"
+ ],
+ "routes": [
+ {
+ "match": [
+ {
+ "host": [
+ "example.com"
+ ]
+ }
+ ],
+ "handle": [
+ {
+ "handler": "subroute",
+ "routes": [
+ {
+ "handle": [
+ {
+ "body": "'I am Groot', hears Rocket",
+ "handler": "static_response"
+ },
+ {
+ "body": "'I am you', hears the confused man",
+ "handler": "static_response"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "terminal": true
+ }
+ ]
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/caddytest/integration/caddyfile_adapt/import_args_snippet.txt b/caddytest/integration/caddyfile_adapt/import_args_snippet.txt
new file mode 100644
index 0000000..8d2ff34
--- /dev/null
+++ b/caddytest/integration/caddyfile_adapt/import_args_snippet.txt
@@ -0,0 +1,83 @@
+(logging) {
+ log {
+ output file /var/log/caddy/{args.0}.access.log
+ }
+}
+
+a.example.com {
+ import logging a.example.com
+}
+
+b.example.com {
+ import logging b.example.com
+}
+----------
+{
+ "logging": {
+ "logs": {
+ "default": {
+ "exclude": [
+ "http.log.access.log0",
+ "http.log.access.log1"
+ ]
+ },
+ "log0": {
+ "writer": {
+ "filename": "/var/log/caddy/a.example.com.access.log",
+ "output": "file"
+ },
+ "include": [
+ "http.log.access.log0"
+ ]
+ },
+ "log1": {
+ "writer": {
+ "filename": "/var/log/caddy/b.example.com.access.log",
+ "output": "file"
+ },
+ "include": [
+ "http.log.access.log1"
+ ]
+ }
+ }
+ },
+ "apps": {
+ "http": {
+ "servers": {
+ "srv0": {
+ "listen": [
+ ":443"
+ ],
+ "routes": [
+ {
+ "match": [
+ {
+ "host": [
+ "a.example.com"
+ ]
+ }
+ ],
+ "terminal": true
+ },
+ {
+ "match": [
+ {
+ "host": [
+ "b.example.com"
+ ]
+ }
+ ],
+ "terminal": true
+ }
+ ],
+ "logs": {
+ "logger_names": {
+ "a.example.com": "log0",
+ "b.example.com": "log1"
+ }
+ }
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/caddytest/integration/testdata/import_respond.txt b/caddytest/integration/testdata/import_respond.txt
new file mode 100644
index 0000000..0907fbe
--- /dev/null
+++ b/caddytest/integration/testdata/import_respond.txt
@@ -0,0 +1 @@
+respond "'I am {args.0}', hears {args.1}" \ No newline at end of file