From: xf0r3m Date: Thu, 3 Aug 2023 05:26:10 +0000 (+0200) Subject: Dodanie pliku testów - tests.sh X-Git-Url: https://gitweb.morketsmerke.org/?a=commitdiff_plain;h=99bdf17adb45f66e98ee8429278aa4193c930259;p=immudex-testing.git Dodanie pliku testów - tests.sh --- diff --git a/tests.sh b/tests.sh new file mode 100644 index 0000000..42b59f7 --- /dev/null +++ b/tests.sh @@ -0,0 +1,321 @@ +#!/bin/bash + +function is_in_file() { + grep -q "^${1}$" $2; + return $?; +} + +function is_file_correct() { + cmp $1 $2 > /dev/null 2>&1; + return $?; +} + +function is_running() { + ps -aux | grep "$1" | head -1 | grep -q $2; + return $?; +} + +function is_immudex_lightdm_wallpaper() { + value="background = /usr/share/images/desktop-base/lightdm_wallpaper.jpg"; + file="/etc/lightdm/lightdm-gtk-greeter.conf"; + result=$(is_in_file $value $file); + return $result; +} + +function is_immudex_lightdm_default_user_image() { + value="default-user-image = /usr/share/images/desktop-base/immudex_xfce_greeter_logo.png"; + file="/etc/lightdm/lightdm-gtk-greeter.conf"; + result=$(is_in_file $value $file); + return $result; +} + +function is_immudex_lightdm_theme() { + value="theme-name = Adwaita-dark"; + file="/etc/lightdm/lightdm-gtk-greeter.conf"; + result=$(is_in_file $value $file); + return $result; +} + +function is_immudex_default_wallpaper_set() { + value="/usr/share/images/desktop-base/d13_wallpaper.png"; + file="/usr/share/images/desktop-base/default"; + if [ -L $file ] && grep -q "${value}$"; then + return 0; + else + return 1; + fi +} + +function is_immudex_panel_whiskermenu_ok() { + value="~/immudex-testing/files/104/whiskermenu-1.rc"; + file="/home/user/.config/xfce4/panel/whiskermenu-1.rc"; + result=$(is_file_correct $value $file); + return $result; +} + +function is_immudex_panel_activator_1_ok() { + value="Name=Firefox ESR (Firejailed)"; + value1="Exec=/usr/local/bin/secured-firefox"; + file="/home/user/.config/xfce4/panel/launcher-5/16844254192.desktop"; + result=$($(is_in_file $value $file) && $(is_in_file $value1 $file)); + return $result; +} + +function is_immudex_panel_activator_2_ok() { + value="Exec=xfce4-terminal" + value1="Name=Terminal Emulator" + file="/home/user/.config/xfce4/panel/launcher-7/16844254905.desktop" + result=$($(is_in_file $value $file) && $(is_in_file $value1 $file)); + return $result; +} + +function is_immudex_panel_activatior_3_ok() { + value="Name=Padlock"; + value1="Exec=xfce4-terminal -x /usr/local/bin/padlock"; + file="/home/user/.config/xfce4/panel/launcher-14/16844255236.desktop"; + result=$($(is_in_file $value $file) && $(is_in_file $value1 $file)); + return $result; +} + +function is_immudex_widget_connky_running() { + value="conky --daemonize --pause=5"; + value1="$USER"; + result=$(is_running $value $value1); + return $result; +} + +function is_immudex_conky_file_ok() { + wget https://github.com/xf0r3m/xfcedebian/raw/d13/conkyrc -O /tmp/d13_conkyrc; + value="/tmp/d13_conkyrc"; + value1="/home/user/.conkyrc"; + result=$(is_file_correct $value $value1); + return $result; +} + +function is_immudex_keyboard_shortcut_config_ok() { + value="~/immudex-testing/files/104/xfce4-keyboard-shortcuts.xml"; + value1="/home/user/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml"; + result=$(is_file_correct $value $value1); + return $result; +} + +function is_immudex_check_terminal_config() { + value="BackgroundMode=TERMINAL_BACKGROUND_IMAGE"; + value1="MiscDefaultGeometry=100x30"; + value2="BackgroundImageFile=/usr/share/images/desktop-base/lofi_girl.jpg"; + value3="BackgroundImageStyle=TERMINAL_BACKGROUND_STYLE_FILLED"; + value4="BackgroundImageShading=0,750000"; + value5="FontName=Source Code Pro Medium 12"; + file="/home/user/.config/xfce4/terminal/terminalrc"; + result=$($(is_in_file $value $file) &&\ + $(is_in_file $value1 $file) &&\ + $(is_in_file $value2 $file) &&\ + $(is_in_file $value3 $file) &&\ + $(is_in_file $value4 $file) &&\ + $(is_in_file $value5 $file)); + return $result; +} + +function is_immudex_xfce_notes_config() { + value="~/immudex-testing/files/100/gtk-main.css"; + value1="/usr/share/xfce4-notes-plugin/gtk-3.0/gtk-main.css"; + result=$(is_file_correct $value $value1); + return $result; +} + +function is_immudex_irssi_config_file_ok() { + value="~/immudex-testing/files/100/config"; + value1="/home/user/.irssi/config"; + result=$(is_file_correct $value $value1); + return $result; +} + +function is_immudex_irssi_default_theme_ok() { + value="~/immudex-testing/files/100/default.theme"; + value1="/home/user/.irssi/default.theme"; + result=$(is_file_correct $value $value1); + return $result; +} + +function is_immudex_libreoffice_config_dir() { + [-d /home/user/.config/libreoffice ]; + return $?; +} + +function is_immudex_firejail_config_ok() { + value="~/immudex-testing/files/100/firejail.config"; + value1="/etc/firejail/firejail.config"; + result=$(is_file_correct $value $value1); + return $result; +} + +function is_immudex_notifier_distro_autostart_file_ok() { + value="~/immudex-testing/files/100/Notifier - distro.desktop"; + value1="/home/user/.config/autostart/Notifier - distro.desktop"; + result=$(is_file_correct $value $value1); + return $result; +} + +function is_immudex_notifier_packages_autostart_file_ok() { + value="~/immudex-testing/files/Notifier - packages.desktop"; + value1="/home/xf0r3m/.config/autostart/Notifier - packages.desktop"; + result=$(is_file_correct $value $value1); + return $result; +} + +function is_immudex_redshift_config_ok() { + value="~/immudex-testing/files/100/redshift.conf"; + value1="/etc/skel/.config/redshift.conf"; + result=$(is_file_correct $value $value1); + return $result; +} + +function is_immudex_redshift_autostart_file_ok() { + value="~/immudex-testing/files/100/redshift.desktop"; + value1="/etc/skel/.config/autostart/redshift.desktop"; + result=$(is_file_correct $value $value1); + return $result; +} + +function is_immudex_user_defined_mime_ok() { + value="~/immudex-testing/files/100/mimeapps.list"; + value1="/etc/skel/.config/mimeapps.list"; + result=$(is_file_correct $value $value1); + return $result; +} + +function is_immudex_sync_sh_share_dir() { + [ -d /usr/share/sync.sh ]; + return $?; +} + +function is_immudex_hostname_service_file_ok() { + value="~/immudex-tesitng/files/100/immudex_hostname.service"; + value1="/etc/systemd/system"; + result=$(is_file_correct $value $value1); + return $result; +} + +function is_immudex_right_firefox_profile() { + value="user_pref(\"extensions.lastPlatformVersion\", \"115.0.2\");"; + file="/home/user/.mozilla/firefox/l9vw01ma.default-esr/prefs.js"; + result=$(is_in_file $value $file); + return $result; +} + +function is_immudex_apply_image_ok() { + value="~/immudex-testing/images/100/apply.png"; + value1="/usr/share/icons/apply.png"; + result=$(is_file_correct $value $value1); + return $result; +} + +function is_immudex_rss_image_ok() { + value="~/immudex-testing/images/100/rss.png"; + value1="/usr/share/icons/rss.png"; + result=$(is_file_correct $value $value1); + return $result; +} + +function is_immudex_notes_background_image_ok() { + value="~/immudex-testing/images/100/notes-background.jpg"; + value1="/usr/share/images/desktop-base/notes-background.jpg"; + result=$(is_file_correct $value $value1); + return $result; +} + +function isnt_immudex_notrespass_backgroung_file() { + [ ! -f /usr/share/images/desktop-base/no_trespass_abandon.jpeg ]; + return $?; +} + +function is_immudex_hostname_service_enabled() { + systemctl status immudex_hostname.service --no-pager | grep -q 'enabled'; + return $?; +} + +function is_immudex_motd2_enabled() { + value="/usr/local/bin/motd2"; + file="/etc/bash.bashrc"; + result=$(is_in_file $value $file); + return $result; +} + +function is_immudex_chhome_alias() { + value="^alias chhome"; + file="/etc/bash.bashrc"; + result=$(is_in_file $value $file); + return $result; +} + +function is_immudex_ping_command_has_setuid() { + [ -u /usr/bin/ping ]; + return $?; +} + +function is_immudex_is_default_hostname() { + value="immudex"; + file="/etc/hostname"; + result=$(is_in_file $value $file); + return $result; +} + +function is_immudex_has_resolv_in_etc_hosts() { + value="127.0.1.1 immudex"; + file="/etc/hosts"; + result=$(is_in_file $value $file); + return $result; +} + +function is_immudex_user_is_in_sudoers_file() { + value="^user ALL=(ALL:ALL) NOPASSWD:ALL$"; + file="/etc/sudoers"; + result=$(is_in_file $value $file); + return $result; +} + +function is_immudex_xf0r3m_is_in_sudoers_file() { + value="^xf0r3m ALL=(ALL:ALL) NOPASSWD:ALL$"; + file="/etc/sudoers"; + result=$(is_in_file $value $file); + return $result; +} + +function is_immudex_dot_bashrc_user_file() { + [ -f /home/user/.bashrc ]; + return $?; +} + +function is_immudex_user_profile_image() { + value="/usr/share/image/desktop-base/immudex_xfce_greeter_logo.png"; + [ -L /home/user/.face ] && $(file /home/user/.face | grep -q "${value}$"); + return $?; +} + +function is_immudex_user_profile_image_icon() { + value=".face"; + [ -L /home/user/.face.icon ] && $(file /home/user/.face.icon | grep -q "${value}$"); + return $?; +} + +function is_immudex_user_fonts_dir() { + [ -d /home/user/.fonts ]; + return $?; +} + +function is_immudex_user_dot_profile_file() { + [ -f /home/user/.profile ]; + return $?; +} + +function is_immudex_user_dot_vimrc_file() { + [ -f /home/user/.vimrc ]; + return $?; +} + +function is_immudex_xfce4_notes_autostart() { + value="~/immudex-testing/files/autostart-x4notes.desktop"; + value1="/home/xf0r3m/.config/autostart/autostart-x4notes.desktop"; + result=$(is_file_correct $value $value1); + return $result; +}