aboutsummaryrefslogtreecommitdiff
path: root/testdata
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-10-21 17:17:13 +0700
committerShulhan <ms@kilabit.info>2023-10-21 17:17:13 +0700
commit761212298e017f58345aa948aebedc2c07b73753 (patch)
tree28c556aa99678979a4162aa0e50d036d287a96ad /testdata
parent28f9ab76a83efcfcf777e571fea826e2dfc3e28e (diff)
downloadawwan-761212298e017f58345aa948aebedc2c07b73753.tar.xz
all: implement remote "#get:" and "#put:" with owner and mode
In remote environment, using magic command "#get:" or "#put:" with owner and mode like "#get:$OWNER+$MODE" or "#put:$OWNER+MODE" will changes the file owner to $USER or $GROUP and/or permission to $MODE. The file owner will not works if user does not have permission.
Diffstat (limited to 'testdata')
-rw-r--r--testdata/play/awwanssh.test/awwan.env2
-rw-r--r--testdata/play/awwanssh.test/get.aww12
-rw-r--r--testdata/play/awwanssh.test/get_test.data20
-rw-r--r--testdata/play/awwanssh.test/plain.txt1
-rw-r--r--testdata/play/awwanssh.test/put.aww12
-rw-r--r--testdata/play/awwanssh.test/put_test.data12
6 files changed, 59 insertions, 0 deletions
diff --git a/testdata/play/awwanssh.test/awwan.env b/testdata/play/awwanssh.test/awwan.env
new file mode 100644
index 0000000..642535b
--- /dev/null
+++ b/testdata/play/awwanssh.test/awwan.env
@@ -0,0 +1,2 @@
+[host]
+name = awwanssh.test
diff --git a/testdata/play/awwanssh.test/get.aww b/testdata/play/awwanssh.test/get.aww
new file mode 100644
index 0000000..c10ae27
--- /dev/null
+++ b/testdata/play/awwanssh.test/get.aww
@@ -0,0 +1,12 @@
+## Get without read permission.
+
+#get: /etc/shadow {{.ScriptDir}}/tmp/shadow
+
+## Get and changes file permission.
+
+#get:+624 /etc/os-release {{.ScriptDir}}/tmp/get_with_mode.txt
+
+## Setting group to "bin" should be an error since current user does not have
+## privileged.
+
+#get:awwan:bin /etc/os-release {{.ScriptDir}}/tmp/get_with_owner.txt
diff --git a/testdata/play/awwanssh.test/get_test.data b/testdata/play/awwanssh.test/get_test.data
new file mode 100644
index 0000000..ad4577d
--- /dev/null
+++ b/testdata/play/awwanssh.test/get_test.data
@@ -0,0 +1,20 @@
+Test input and output for "#get".
+
+<<< WithoutPermission:error
+Play: Get: Get: permission denied
+
+<<< /etc/os-release
+NAME="Arch Linux"
+PRETTY_NAME="Arch Linux"
+ID=arch
+BUILD_ID=rolling
+ANSI_COLOR="38;2;23;147;209"
+HOME_URL="https://archlinux.org/"
+DOCUMENTATION_URL="https://wiki.archlinux.org/"
+SUPPORT_URL="https://bbs.archlinux.org/"
+BUG_REPORT_URL="https://bugs.archlinux.org/"
+PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/"
+LOGO=archlinux-logo
+
+<<< WithOwner:error
+Play: Get: chown awwan:bin "/home/awwan/src/testdata/play/awwanssh.test/tmp/get_with_owner.txt": exit status 1
diff --git a/testdata/play/awwanssh.test/plain.txt b/testdata/play/awwanssh.test/plain.txt
new file mode 100644
index 0000000..5067c47
--- /dev/null
+++ b/testdata/play/awwanssh.test/plain.txt
@@ -0,0 +1 @@
+The host name is {{.Val "host::name"}}.
diff --git a/testdata/play/awwanssh.test/put.aww b/testdata/play/awwanssh.test/put.aww
new file mode 100644
index 0000000..9779ed2
--- /dev/null
+++ b/testdata/play/awwanssh.test/put.aww
@@ -0,0 +1,12 @@
+## Put without write permission.
+
+#put: {{.ScriptDir}}/plain.txt /etc/plain.txt
+
+## Put and changes file permission.
+
+#put:+624 {{.ScriptDir}}/plain.txt put_with_mode.txt
+
+## Setting group to "bin" should be an error since current user does not have
+## privileged.
+
+#put:awwan:bin+666 {{.ScriptDir}}/plain.txt put_with_owner.txt
diff --git a/testdata/play/awwanssh.test/put_test.data b/testdata/play/awwanssh.test/put_test.data
new file mode 100644
index 0000000..61ac09c
--- /dev/null
+++ b/testdata/play/awwanssh.test/put_test.data
@@ -0,0 +1,12 @@
+Test input and output for "#put".
+
+<<< plain.txt
+The host name is awwanssh.test.
+
+
+<<< WithoutPermission:error
+Play: Put: Put: permission denied
+
+<<< WithOwner:error
+Play: Put: ssh: Run "chown awwan:bin \"put_with_owner.txt\"": Process exited with status 1
+