mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-20 15:06:14 -05:00
Release 3.7.0
This commit is contained in:
39 files changed
+903
-298
No files matched your search
+11
-2
@@ -18,9 +18,13 @@ let
|
||||
'';
|
||||
binaries = unpack "gp-ci-binaries" "GP_BINARY_ARCHIVE";
|
||||
gui = unpack "gp-ci-gui" "GP_GUI_ARCHIVE";
|
||||
sourcePackage = gp.packages.${system}.fromSource.override { inherit gui; };
|
||||
nativeShellArchive = builtins.path {
|
||||
path = builtins.toPath (builtins.getEnv "GP_NSH_ARCHIVE");
|
||||
name = "gpgui-nsh.tar.xz";
|
||||
};
|
||||
sourcePackage = gp.packages.${system}.fromSource.override { inherit gui nativeShellArchive; };
|
||||
prebuiltInputs = {
|
||||
inherit binaries gui;
|
||||
inherit binaries gui nativeShellArchive;
|
||||
version = sourcePackage.version;
|
||||
};
|
||||
prebuiltPackage = gp.packages.${system}.prebuilt.override prebuiltInputs;
|
||||
@@ -52,6 +56,11 @@ in {
|
||||
package = sourcePackage;
|
||||
module = gp.nixosModules.default;
|
||||
};
|
||||
graphical-prebuilt = import ./tests/desktop-interfaces.nix {
|
||||
inherit pkgs;
|
||||
package = prebuiltPackage;
|
||||
module = gp.nixosModules.default;
|
||||
};
|
||||
runtime-prebuilt = import ./tests/native-runtime.nix {
|
||||
inherit pkgs;
|
||||
package = prebuiltPackage;
|
||||
|
||||
+5
-9
@@ -1,23 +1,19 @@
|
||||
{ pkgs, archive, checksum, binaryName, version }:
|
||||
{ pkgs, src, binaryName, version }:
|
||||
let
|
||||
nativeShell = binaryName == "gpgui-nsh";
|
||||
in
|
||||
assert builtins.elem binaryName [ "gpgui" "gpgui-nsh" ];
|
||||
assert pkgs.lib.assertMsg (!nativeShell || pkgs.lib.versionAtLeast pkgs.gtk4.version "4.14")
|
||||
"Native Shell requires GTK 4.14 or later.";
|
||||
pkgs.stdenv.mkDerivation {
|
||||
pname = binaryName;
|
||||
inherit version;
|
||||
src = builtins.path {
|
||||
path = builtins.toPath archive;
|
||||
name = "${binaryName}.tar.xz";
|
||||
recursive = false;
|
||||
sha256 = checksum;
|
||||
};
|
||||
inherit src version;
|
||||
dontBuild = true;
|
||||
nativeBuildInputs = [ pkgs.autoPatchelfHook ] ++ (
|
||||
if nativeShell then [ pkgs.wrapGAppsHook4 ] else [ pkgs.wrapGAppsHook3 ]
|
||||
);
|
||||
buildInputs = with pkgs;
|
||||
[ gnutls ] ++ (if nativeShell then [ gtk4 ] else [
|
||||
[ gnutls ] ++ (if nativeShell then [ gtk4 dbus ] else [
|
||||
gtk3 webkitgtk_4_1 libsoup_3 glib-networking libsecret
|
||||
]);
|
||||
runtimeDependencies = [ pkgs.libglvnd ] ++ pkgs.lib.optionals (!nativeShell) [
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
{ pkgs, package, module }:
|
||||
let
|
||||
testPython = pkgs.python3.withPackages (ps: [ ps.pyatspi ps.pygobject3 ]);
|
||||
typelibs = pkgs.lib.makeSearchPath "lib/girepository-1.0" [
|
||||
pkgs.at-spi2-core
|
||||
pkgs.glib.out
|
||||
pkgs.gobject-introspection
|
||||
];
|
||||
chooseTauri = pkgs.writeScript "choose-tauri" ''
|
||||
#!${testPython}/bin/python3
|
||||
import pyatspi
|
||||
import subprocess
|
||||
|
||||
desktop = pyatspi.Registry.getDesktop(0)
|
||||
target = pyatspi.findDescendant(desktop, lambda node: node.name == "Interface: Tauri")
|
||||
if target is None:
|
||||
raise SystemExit("The Tauri control is not visible yet")
|
||||
# GTK4 exposes bounds relative to the window, even on X11.
|
||||
rect = target.queryComponent().getExtents(pyatspi.WINDOW_COORDS)
|
||||
if rect.width <= 0 or rect.height <= 0:
|
||||
raise SystemExit("The Tauri control has no visible bounds")
|
||||
window = subprocess.check_output(["xdotool", "search", "--onlyvisible", "--name",
|
||||
"^GP Connect Settings$"], text=True).splitlines()[-1]
|
||||
subprocess.run(["xdotool", "mousemove", "--window", window, str(rect.x + rect.width // 2),
|
||||
str(rect.y + rect.height // 2), "click", "1"], check=True)
|
||||
'';
|
||||
in
|
||||
pkgs.testers.runNixOSTest {
|
||||
name = "gp-offline-desktop-interfaces";
|
||||
nodes.machine = {
|
||||
imports = [ module (pkgs.path + "/nixos/tests/common/x11.nix") ];
|
||||
programs.globalprotect-openconnect = { enable = true; inherit package; };
|
||||
test-support.displayManager.auto.user = "alice";
|
||||
users.users.alice = { isNormalUser = true; uid = 1000; };
|
||||
services.gnome.at-spi2-core.enable = true;
|
||||
environment.systemPackages = [ pkgs.xdotool ];
|
||||
security.polkit.extraConfig = ''
|
||||
polkit.addRule(function(action, subject) {
|
||||
if (subject.user == "alice" && action.id == "com.yuezk.gpgui.service") {
|
||||
return polkit.Result.YES;
|
||||
}
|
||||
});
|
||||
'';
|
||||
virtualisation.memorySize = 4096;
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
from datetime import timedelta
|
||||
import shlex
|
||||
|
||||
machine.start()
|
||||
machine.wait_for_unit("display-manager.service")
|
||||
def as_alice(command):
|
||||
environment = "export DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/1000 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus GTK_A11Y=atspi; "
|
||||
return "su - alice -c " + shlex.quote(environment + command)
|
||||
|
||||
accessibility_env = "GI_TYPELIB_PATH=${typelibs} "
|
||||
machine.succeed(as_alice(accessibility_env + "${testPython}/bin/python3 -c 'import pyatspi'"))
|
||||
machine.wait_until_succeeds(as_alice("xdotool getdisplaygeometry"))
|
||||
# Leave loopback available for the local privileged service.
|
||||
machine.succeed("for dev in /sys/class/net/*; do dev=$(basename \"$dev\"); [ \"$dev\" = lo ] || ip link set \"$dev\" down; done")
|
||||
|
||||
def launch():
|
||||
machine.succeed(as_alice("gpclient launch-gui > ~/gp-launch.log 2>&1 & echo $! > ~/gp-launch.pid"))
|
||||
|
||||
def wait_for_gui(name):
|
||||
# Identify the process which owns the mapped main window, including Nix's executable wrapper.
|
||||
machine.wait_until_succeeds(as_alice(
|
||||
"pid=$(xdotool search --onlyvisible --name '^GP Connect$' | tail -n 1 | xargs xdotool getwindowpid) && "
|
||||
"readlink /proc/$pid/exe | grep -E '/[.]?" + name + "(-wrapped)?$'"
|
||||
))
|
||||
|
||||
launch()
|
||||
wait_for_gui("gpgui-nsh")
|
||||
machine.succeed(as_alice("test ! -e ~/.config/gpclient/gui"))
|
||||
machine.succeed(as_alice("${pkgs.glib.bin}/bin/gapplication action com.yuezk.gpgui settings"))
|
||||
machine.wait_until_succeeds(
|
||||
as_alice("xdotool search --onlyvisible --name '^GP Connect Settings$'"),
|
||||
timeout=timedelta(seconds=60),
|
||||
)
|
||||
machine.screenshot("native-shell-settings")
|
||||
machine.wait_until_succeeds(as_alice(accessibility_env + "${chooseTauri}"), timeout=timedelta(seconds=60))
|
||||
wait_for_gui("gpgui")
|
||||
machine.succeed(as_alice("grep -Fx gpgui ~/.config/gpclient/gui"))
|
||||
machine.succeed(as_alice("kill -TERM $(cat ~/gp-launch.pid)"))
|
||||
machine.wait_until_succeeds("test ! -e /var/run/gpservice.lock")
|
||||
|
||||
launch()
|
||||
wait_for_gui("gpgui")
|
||||
machine.screenshot("tauri-relaunch")
|
||||
'';
|
||||
}
|
||||
@@ -61,6 +61,7 @@ pkgs.testers.runNixOSTest {
|
||||
return machine.succeed("su - alice -c " + shlex.quote(command))
|
||||
|
||||
# Exercise real host pkexec, private credential pipes and launcher cancellation.
|
||||
as_alice("mkdir -p ~/.config/gpclient && echo gpgui > ~/.config/gpclient/gui")
|
||||
command = "GP_GUI_BINARY=${guiProbe} " + package + "/bin/gpclient --lock-file /tmp/gp-client.lock launch-gui"
|
||||
as_alice(command + " > /tmp/gp-client-output 2>&1 & echo $! > /tmp/gp-client-pid")
|
||||
try:
|
||||
|
||||
Reference in new issue
Block a user