aboutsummaryrefslogtreecommitdiff
path: root/testdata
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-09-27 00:01:22 +0700
committerShulhan <ms@kilabit.info>2023-09-27 00:54:10 +0700
commitd1b393b0d4ca75c8d81d051a332597b7aa3f0ab0 (patch)
tree68adc1e0bfee5c6e2056110dc094cb520a5b969a /testdata
parent59968a1665735990187c05547faab3c5310c4be1 (diff)
downloadawwan-d1b393b0d4ca75c8d81d051a332597b7aa3f0ab0.tar.xz
all: make .Vars, .Val, and .Vals panic if values is empty
This is to prevent copying or executing command with value that are not defined or typo which make the result empty and may result in undefined behaviour. For example if we have "app_dir = /data/app" and command in the script that remove that directory recursively, sudo rm -r {{.Val "::app_dir}}/bin will result removing "/bin" entirely.
Diffstat (limited to 'testdata')
-rw-r--r--testdata/local/local.aww4
-rw-r--r--testdata/local/local.data (renamed from testdata/local/test.data)8
-rw-r--r--testdata/local/missing_val_encrypted.txt2
-rw-r--r--testdata/local/plain.txt1
-rw-r--r--testdata/local/put.aww5
-rw-r--r--testdata/local/put.data16
6 files changed, 23 insertions, 13 deletions
diff --git a/testdata/local/local.aww b/testdata/local/local.aww
index a77ec42..d9127db 100644
--- a/testdata/local/local.aww
+++ b/testdata/local/local.aww
@@ -1,5 +1 @@
echo {{.Val "secret::pass"}}
-
-#put: {{.ScriptDir}}/plain.txt {{.ScriptDir}}/tmp/plain.txt
-
-#put: {{.ScriptDir}}/encrypted.txt {{.ScriptDir}}/tmp/decrypted.txt
diff --git a/testdata/local/test.data b/testdata/local/local.data
index 330e646..9ecdb9f 100644
--- a/testdata/local/test.data
+++ b/testdata/local/local.data
@@ -7,11 +7,3 @@ this_is_a_secret
--> local: 1: echo this_is_a_secret_in_sub
this_is_a_secret_in_sub
-
-<<< tmp/plain.txt
-The host name is encrypt.
-The secret password is .
-
-<<< tmp/decrypted.txt
-The host name is encrypt.
-The secret password is this_is_a_secret.
diff --git a/testdata/local/missing_val_encrypted.txt b/testdata/local/missing_val_encrypted.txt
new file mode 100644
index 0000000..de6797e
--- /dev/null
+++ b/testdata/local/missing_val_encrypted.txt
@@ -0,0 +1,2 @@
+The host name is {{.Val "host::name"}}.
+The secret password is {{.Val "secret::pass"}}.
diff --git a/testdata/local/plain.txt b/testdata/local/plain.txt
index de6797e..5067c47 100644
--- a/testdata/local/plain.txt
+++ b/testdata/local/plain.txt
@@ -1,2 +1 @@
The host name is {{.Val "host::name"}}.
-The secret password is {{.Val "secret::pass"}}.
diff --git a/testdata/local/put.aww b/testdata/local/put.aww
new file mode 100644
index 0000000..5fd6b4d
--- /dev/null
+++ b/testdata/local/put.aww
@@ -0,0 +1,5 @@
+#put: {{.ScriptDir}}/plain.txt {{.ScriptDir}}/tmp/plain.txt
+
+#put: {{.ScriptDir}}/missing_val_encrypted.txt {{.ScriptDir}}/tmp/missing_val_encrypted.txt
+
+#put: {{.ScriptDir}}/encrypted.txt {{.ScriptDir}}/tmp/decrypted.txt
diff --git a/testdata/local/put.data b/testdata/local/put.data
new file mode 100644
index 0000000..2018f7a
--- /dev/null
+++ b/testdata/local/put.data
@@ -0,0 +1,16 @@
+<<< tmp/plain.txt
+The host name is encrypt.
+
+
+<<< missing_val_encrypted
+!!! Copy: generateFileInput: template: missing_val_encrypted.txt:2:25: executing "missing_val_encrypted.txt" at <.Val>: error calling Val: "secret::pass" is empty
+
+<<< tmp/decrypted.txt
+The host name is encrypt.
+The secret password is this_is_a_secret.
+
+<<< encrypted_empty_passphrase.stderr
+!!! Copy: generateFileInput: private key is missing or not loaded
+
+<<< encrypted_invalid_passphrase
+Local: NewSession: loadEnvFromPaths: LoadPrivateKeyInteractive: x509: decryption password incorrect