about summary refs log tree commit diff
path: root/pkgs/applications/networking/cloudflared
diff options
context:
space:
mode:
authorPiper McCorkle <contact@piperswe.me>2022-09-04 19:33:21 -0500
committerPiper McCorkle <contact@piperswe.me>2022-12-13 18:31:54 -0600
commit91ccc070208d5a27df308dad2e751209e69d9aba (patch)
tree0437ae7fe0aa0c44ee2b45cf2b522deffdd61adc /pkgs/applications/networking/cloudflared
parente3e35e40579a9ac0ed8493168c2b66f5791e4bb7 (diff)
cloudflared: 2022.8.2 -> 2022.11.1, add tests and additional platforms
Diffstat (limited to 'pkgs/applications/networking/cloudflared')
-rw-r--r--pkgs/applications/networking/cloudflared/default.nix60
-rw-r--r--pkgs/applications/networking/cloudflared/tests.nix44
2 files changed, 91 insertions, 13 deletions
diff --git a/pkgs/applications/networking/cloudflared/default.nix b/pkgs/applications/networking/cloudflared/default.nix
index 0ae2d3b35884b..3930a2d4879bd 100644
--- a/pkgs/applications/networking/cloudflared/default.nix
+++ b/pkgs/applications/networking/cloudflared/default.nix
@@ -1,14 +1,14 @@
-{ lib, buildGoModule, fetchFromGitHub, stdenv }:
+{ lib, buildGoModule, fetchFromGitHub, stdenv, callPackage }:
 
 buildGoModule rec {
   pname = "cloudflared";
-  version = "2022.8.2";
+  version = "2022.11.1";
 
   src = fetchFromGitHub {
-    owner  = "cloudflare";
-    repo   = "cloudflared";
-    rev    = version;
-    hash   = "sha256-Kyt5d3KmLefTVVUmUUU23UV0lghzhLFCKLlmwTjN68I=";
+    owner = "cloudflare";
+    repo = "cloudflared";
+    rev = version;
+    hash = "sha256-aG63CEJfEL9r0SviZu9VzArtt3e4VuAbOMaYk9atSGo=";
   };
 
   vendorSha256 = null;
@@ -17,22 +17,56 @@ buildGoModule rec {
 
   preCheck = ''
     # Workaround for: sshgen_test.go:74: mkdir /homeless-shelter/.cloudflared: no such file or directory
-    export HOME="$(mktemp -d)";
+    export HOME="$(mktemp -d)"
 
     # Workaround for: protocol_test.go:11:
     #   lookup protocol-v2.argotunnel.com on [::1]:53: read udp [::1]:51876->[::1]:53: read: connection refused
-
     substituteInPlace "edgediscovery/protocol_test.go" \
       --replace "TestProtocolPercentage" "SkipProtocolPercentage"
+
+    # Workaround for: origin_icmp_proxy_test.go:46:
+    #   cannot create ICMPv4 proxy: socket: permission denied nor ICMPv6 proxy: socket: permission denied
+    substituteInPlace "ingress/origin_icmp_proxy_test.go" \
+      --replace "TestICMPRouterEcho" "SkipICMPRouterEcho"
+
+    # Workaround for: origin_icmp_proxy_test.go:110:
+    #   cannot create ICMPv4 proxy: socket: permission denied nor ICMPv6 proxy: socket: permission denied
+    substituteInPlace "ingress/origin_icmp_proxy_test.go" \
+      --replace "TestConcurrentRequestsToSameDst" "SkipConcurrentRequestsToSameDst"
+
+    # Workaround for: origin_icmp_proxy_test.go:242:
+    #   cannot create ICMPv4 proxy: socket: permission denied nor ICMPv6 proxy: socket: permission denied
+    substituteInPlace "ingress/origin_icmp_proxy_test.go" \
+      --replace "TestICMPRouterRejectNotEcho" "SkipICMPRouterRejectNotEcho"
+
+    # Workaround for: origin_icmp_proxy_test.go:108:
+    #   Received unexpected error: cannot create ICMPv4 proxy: Group ID 100 is not between ping group 65534 to 65534 nor ICMPv6 proxy: socket: permission denied
+    substituteInPlace "ingress/origin_icmp_proxy_test.go" \
+      --replace "TestTraceICMPRouterEcho" "SkipTraceICMPRouterEcho"
+
+    # Workaround for: icmp_posix_test.go:28: socket: permission denied
+    substituteInPlace "ingress/icmp_posix_test.go" \
+      --replace "TestFunnelIdleTimeout" "SkipFunnelIdleTimeout"
+
+    # Workaround for: icmp_posix_test.go:88: Received unexpected error: Group ID 100 is not between ping group 65534 to 65534
+    substituteInPlace "ingress/icmp_posix_test.go" \
+      --replace "TestReuseFunnel" "SkipReuseFunnel"
+
+    # Workaround for: supervisor_test.go:49:
+    #   Expected nil, but got: Could not lookup srv records on _us-v2-origintunneld._tcp.argotunnel.com: lookup _us-v2-origintunneld._tcp.argotunnel.com on [::1]:53: read udp [::1]:49342->[::1]:53: read: connection refused
+    substituteInPlace "supervisor/supervisor_test.go" \
+      --replace "Test_Initialize_Same_Protocol" "Skip_Initialize_Same_Protocol"
   '';
 
   doCheck = !stdenv.isDarwin;
 
+  passthru.tests.simple = callPackage ./tests.nix { inherit version; };
+
   meta = with lib; {
-    description = "CloudFlare Tunnel daemon (and DNS-over-HTTPS client)";
-    homepage    = "https://www.cloudflare.com/products/tunnel";
-    license     = licenses.asl20;
-    platforms   = platforms.unix;
-    maintainers = with maintainers; [ bbigras enorris thoughtpolice ];
+    description = "Cloudflare Tunnel daemon, Cloudflare Access toolkit, and DNS-over-HTTPS client";
+    homepage = "https://www.cloudflare.com/products/tunnel";
+    license = licenses.asl20;
+    platforms = platforms.unix ++ platforms.windows;
+    maintainers = with maintainers; [ bbigras enorris thoughtpolice piperswe ];
   };
 }
diff --git a/pkgs/applications/networking/cloudflared/tests.nix b/pkgs/applications/networking/cloudflared/tests.nix
new file mode 100644
index 0000000000000..8314e84075fd2
--- /dev/null
+++ b/pkgs/applications/networking/cloudflared/tests.nix
@@ -0,0 +1,44 @@
+{ version, lib, stdenv, pkgsCross, testers, cloudflared, runCommand, wine, wine64 }:
+
+let
+  inherit (stdenv) buildPlatform;
+in
+{
+  version = testers.testVersion {
+    package = cloudflared;
+    command = "cloudflared help";
+  };
+  refuses-to-autoupdate = runCommand "cloudflared-${version}-refuses-to-autoupdate"
+    {
+      nativeBuildInputs = [ cloudflared ];
+    } ''
+    set -e
+    cloudflared update 2>&1 | tee output.txt
+    if ! grep "cloudflared was installed by nixpkgs" output.txt
+    then
+      echo "cloudflared's output didn't contain the package manager name"
+      exit 1
+    fi
+    mkdir $out
+  '';
+} // lib.optionalAttrs (buildPlatform.isLinux && (buildPlatform.isi686 || buildPlatform.isx86_64)) {
+  runs-through-wine = runCommand "cloudflared-${version}-runs-through-wine"
+    {
+      nativeBuildInputs = [ wine ];
+      exe = "${pkgsCross.mingw32.cloudflared}/bin/cloudflared.exe";
+    } ''
+    export HOME="$(mktemp -d)"
+    wine $exe help
+    mkdir $out
+  '';
+} // lib.optionalAttrs (buildPlatform.isLinux && buildPlatform.isx86_64) {
+  runs-through-wine64 = runCommand "cloudflared-${version}-runs-through-wine64"
+    {
+      nativeBuildInputs = [ wine64 ];
+      exe = "${pkgsCross.mingwW64.cloudflared}/bin/cloudflared.exe";
+    } ''
+    export HOME="$(mktemp -d)"
+    wine64 $exe help
+    mkdir $out
+  '';
+}