summaryrefslogtreecommitdiffstats
path: root/test/t2700-usermaint.t
diff options
context:
space:
mode:
authorFrédéric Mangano-Tarumi <fmang@mg0.fr>2020-02-23 19:53:13 +0100
committerLukas Fleischer <lfleischer@archlinux.org>2020-02-27 16:44:36 +0100
commite374a91febe53b72ff4cb73b153348f067374c68 (patch)
tree038973590aace5ba4f4899cc256d843ef2505867 /test/t2700-usermaint.t
parent81d55e70ee0469018af86d203ceaf2fece691ea8 (diff)
downloadaur-e374a91febe53b72ff4cb73b153348f067374c68.tar.gz
aur-e374a91febe53b72ff4cb73b153348f067374c68.tar.xz
Change the extension of TAP test suites to .t
This is the common convention for TAP, and makes harnesses like prove automatically detect them. Plus, test suites don’t have to be shell scripts anymore. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'test/t2700-usermaint.t')
-rwxr-xr-xtest/t2700-usermaint.t49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/t2700-usermaint.t b/test/t2700-usermaint.t
new file mode 100755
index 00000000..4f625142
--- /dev/null
+++ b/test/t2700-usermaint.t
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+test_description='usermaint tests'
+
+. ./setup.sh
+
+test_expect_success 'Test removal of login IP addresses.' '
+ now=$(date -d now +%s) &&
+ threedaysago=$(date -d "3 days ago" +%s) &&
+ tendaysago=$(date -d "10 days ago" +%s) &&
+ cat <<-EOD | sqlite3 aur.db &&
+ UPDATE Users SET LastLogin = $threedaysago, LastLoginIPAddress = "1.2.3.4" WHERE ID = 1;
+ UPDATE Users SET LastLogin = $tendaysago, LastLoginIPAddress = "2.3.4.5" WHERE ID = 2;
+ UPDATE Users SET LastLogin = $now, LastLoginIPAddress = "3.4.5.6" WHERE ID = 3;
+ UPDATE Users SET LastLogin = 0, LastLoginIPAddress = "4.5.6.7" WHERE ID = 4;
+ UPDATE Users SET LastLogin = 0, LastLoginIPAddress = "5.6.7.8" WHERE ID = 5;
+ UPDATE Users SET LastLogin = $tendaysago, LastLoginIPAddress = "6.7.8.9" WHERE ID = 6;
+ EOD
+ "$USERMAINT" &&
+ cat <<-EOD >expected &&
+ 1.2.3.4
+ 3.4.5.6
+ EOD
+ echo "SELECT LastLoginIPAddress FROM Users WHERE LastLoginIPAddress IS NOT NULL;" | sqlite3 aur.db >actual &&
+ test_cmp actual expected
+'
+
+test_expect_success 'Test removal of SSH login IP addresses.' '
+ now=$(date -d now +%s) &&
+ threedaysago=$(date -d "3 days ago" +%s) &&
+ tendaysago=$(date -d "10 days ago" +%s) &&
+ cat <<-EOD | sqlite3 aur.db &&
+ UPDATE Users SET LastSSHLogin = $now, LastSSHLoginIPAddress = "1.2.3.4" WHERE ID = 1;
+ UPDATE Users SET LastSSHLogin = $threedaysago, LastSSHLoginIPAddress = "2.3.4.5" WHERE ID = 2;
+ UPDATE Users SET LastSSHLogin = $tendaysago, LastSSHLoginIPAddress = "3.4.5.6" WHERE ID = 3;
+ UPDATE Users SET LastSSHLogin = 0, LastSSHLoginIPAddress = "4.5.6.7" WHERE ID = 4;
+ UPDATE Users SET LastSSHLogin = 0, LastSSHLoginIPAddress = "5.6.7.8" WHERE ID = 5;
+ UPDATE Users SET LastSSHLogin = $tendaysago, LastSSHLoginIPAddress = "6.7.8.9" WHERE ID = 6;
+ EOD
+ "$USERMAINT" &&
+ cat <<-EOD >expected &&
+ 1.2.3.4
+ 2.3.4.5
+ EOD
+ echo "SELECT LastSSHLoginIPAddress FROM Users WHERE LastSSHLoginIPAddress IS NOT NULL;" | sqlite3 aur.db >actual &&
+ test_cmp actual expected
+'
+
+test_done