From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id aPspNg3NJGeCnwAAe85BDQ:P1 (envelope-from ) for ; Fri, 01 Nov 2024 12:43:58 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id aPspNg3NJGeCnwAAe85BDQ (envelope-from ) for ; Fri, 01 Nov 2024 13:43:58 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=v31Go2AV; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20230601 header.b=ZunRk6dL; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1730465037; a=rsa-sha256; cv=none; b=W2hqWmURZ2CyV71JYX7fmDMqF7IIioz35AyMMuBaWxnPvAgBJtbc9KfzB85l3T443EkT9P caFdQK1fhQu+fVnsBXB/hVpxurXYQBOR1+5q/tF/vDS6ATFq0/OIpgo0FqVK2INBtnlE4a Q9JyfC36v7KLqjby7XURXR1yj3vW3CT0v6k2us+2CQ2Kh/5RIFElSvsLRCMhIh2F72UiPQ 6JA804ZAiu4uUx1cM+gFbS2A+2fy0PWx+glTpisweTMjHJDSzygUZzjZxlEjLsq+nJzFPO 7TOq6h0fRmuxBhUMNy8HjyG1OsdJ2yYbxpiZyX08K12JVyW7M79dSw3ECJRvuQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=v31Go2AV; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20230601 header.b=ZunRk6dL; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1730465037; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=4BEguu5iLHHQ7bpY++fcCdQqm2JYrV2WfguZO7GrEF4=; b=Akpa1zAgrlfMKWYZ4P+0fj5igOKgxCnVyxA0w2yQObgTRPBcIs/xxtdchnUCo3OtYaY8H/ muGrvZfYcSmR/VKesRPXoXPQbWH9MooHLEHEzhedsp4CbbzV7ha9XPRLkm6ORyTJLFTzO0 QddYR9PPn4VGDYwBs6Jqt11gntKezG4dPi6EfWBIFY1s+qEaWUe9hCuO7Dv4T4I3ss1M1w tYnFML8CLFiAtXFRAbHIE9FGLGRWS3wsXHjBezUjCxX4FrlYHp+nnPiFs0SOgj1MlU8HqK mL8q7Ine/DfIgIf+7ND9MoeGirDwu+rlaEM53m616NXBkg12CYiS6ZyxOYZmqw== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 75CC6765BB for ; Fri, 01 Nov 2024 13:43:57 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6qzc-0007hA-Rq; Fri, 01 Nov 2024 08:43:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t6qzb-0007gW-5T for guix-patches@gnu.org; Fri, 01 Nov 2024 08:43:07 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t6qza-0000Ru-PP for guix-patches@gnu.org; Fri, 01 Nov 2024 08:43:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=kMjCf3cPPZRr8OCAqtYI6tknoCszAU8a+phN/eICsWk=; b=v31Go2AVvDNHKcTn/IeDRT7e5MUkypYIXSSm63hoh5r6oQ7fN6NkTHiRo6PZ+dq1ZTHMasapkVKubqO1uf9JLkCm2uh663BCcEDNEKKbwKnFVPHL0xI3QePOV7FGaRmIAcREbc/kWtJav6o43T47JIYKXsvuSXXj34hkSgtxyKloZoStuzymRCRNac1mcy5pWnd4yMrsiHUiBaK2+jHWpqct8TR34vq4K9aAVJdYtxMpeIh6FRkole+79W34RKYrUc1mHIzNdfi1/ZzKufkLQqcbthbDgJTremHUhSvZpdukzrIxWz2GaIZhWOJdocS0pwEGf6xUjSJ0ntp7aYJWtQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t6qza-0007vw-I7; Fri, 01 Nov 2024 08:43:06 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#74151] [PATCH v2 7/9] tests: Add anonip system test. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Fri, 01 Nov 2024 12:43:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74151 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74151@debbugs.gnu.org Cc: Maxim Cournoyer , Maxim Cournoyer X-Debbugs-Original-Xcc: Maxim Cournoyer Received: via spool by 74151-submit@debbugs.gnu.org id=B74151.173046495230414 (code B ref 74151); Fri, 01 Nov 2024 12:43:06 +0000 Received: (at 74151) by debbugs.gnu.org; 1 Nov 2024 12:42:32 +0000 Received: from localhost ([127.0.0.1]:49226 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6qz1-0007uU-Hx for submit@debbugs.gnu.org; Fri, 01 Nov 2024 08:42:32 -0400 Received: from mail-pl1-f169.google.com ([209.85.214.169]:56470) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6qyy-0007tu-79 for 74151@debbugs.gnu.org; Fri, 01 Nov 2024 08:42:30 -0400 Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-20cf6eea3c0so16443585ad.0 for <74151@debbugs.gnu.org>; Fri, 01 Nov 2024 05:42:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730464882; x=1731069682; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kMjCf3cPPZRr8OCAqtYI6tknoCszAU8a+phN/eICsWk=; b=ZunRk6dLYBOp4Co2E48c78JsHeEU9J/3ppfXwNneQd6Fkn2HkwYzM4FomarDoYLc26 1NU5ler9G05v9QiIgPOSmnr4l4LGU40bClX3kGKrEGiv71FC4Qv+u6fFnB2nd3cdJgI0 YUhIRf05aWo73/T+24vmdhEvdomeP3xK9RHZP2Qv5jnKWBy7q6GBtLCzuTh/w3RB7lAq zZC480rv7tYMd81wdaeIj79N6w6bmBVrCATak9ozqX3HxfCvPjl65L3BbrioXRyJ3h34 /1D0kIQmqMOyHRcrroaegO54wsDa5L9ZVCnhSaMlf5WIObOLWvleLlxNO/OKmtf5JBpu LXuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730464882; x=1731069682; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kMjCf3cPPZRr8OCAqtYI6tknoCszAU8a+phN/eICsWk=; b=RxslGkTMu8CB4rrbXiyCXLaziVX+8tZzVoO1v4PJwxdjVMa5d75Q+/fnTDAB/pqPrC aNDMgu6EGyb5NEAoEGEfy4XKzzLEA3HedXm3arILxn95CL1886gcUJEZPMiZuH9sKTx4 QMDSaKe3Xf9a4heGQZfTI8tEgfK+rT+pezur8jJFBRX7EL8jLpJuMLnyMHaEDfY1aEqZ A0Ja2DgwuSBFUzDWbQNa9Qcgx5xH3PJmdWogpJH8uMj8JCe8/tPZrtGGV0En1WveutzQ mdYnQFWiPLJv5NYplJKWcFJZGEyqYMvxUEnopeG63g+BNyslrQ/vKcS9X9eSW9zWzo2Z BceA== X-Gm-Message-State: AOJu0YzpQiP93tdL+7ZRUvAXvoJh7JkpxARQI8vHpyKxIxLZnORPUW5Y Ye7Z2VWpb7dAnXlJN2h55R2hvVeVSNYyJXGCHjIkbPrnhfCB02uKrwOGOATV X-Google-Smtp-Source: AGHT+IHXgUlU0aGzZssVqVXOtvsA7sBwtPCwweWxoR8L7CDgpWr1n2A6xzPBgo2C68RKhGX+B/nf6g== X-Received: by 2002:a17:902:d485:b0:20c:7c09:b2ac with SMTP id d9443c01a7336-210c6c5db72mr278342325ad.52.1730464881901; Fri, 01 Nov 2024 05:41:21 -0700 (PDT) Received: from localhost.localdomain ([2405:6586:be0:0:c8ff:1707:9b9:af89]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e92fa0ea9bsm4819463a91.10.2024.11.01.05.41.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2024 05:41:21 -0700 (PDT) From: Maxim Cournoyer Date: Fri, 1 Nov 2024 21:39:27 +0900 Message-ID: X-Mailer: git-send-email 2.46.0 In-Reply-To: <281a4773768a6c271ff464f473fdbc333a58c348.1730464675.git.maxim.cournoyer@gmail.com> References: <281a4773768a6c271ff464f473fdbc333a58c348.1730464675.git.maxim.cournoyer@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: 5.56 X-Spam-Score: 5.56 X-Migadu-Queue-Id: 75CC6765BB X-Migadu-Scanner: mx10.migadu.com X-TUID: C8KT7oWhyRPk * gnu/tests/web.scm (%test-anonip): New test. (%anonip-os): New variables. (run-anonip-test): New procedure. Change-Id: Ieed210a784dbdeee8a498e74b6c0e31cb72cd9b8 --- gnu/tests/web.scm | 122 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/gnu/tests/web.scm b/gnu/tests/web.scm index 5c50322cef..6ef32138ed 100644 --- a/gnu/tests/web.scm +++ b/gnu/tests/web.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2017, 2018 Clément Lassieur ;;; Copyright © 2018 Pierre-Antoine Rouby ;;; Copyright © 2018 Marius Bakke +;;; Copyright © 2024 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -33,6 +34,7 @@ (define-module (gnu tests web) #:use-module (gnu services networking) #:use-module (gnu services shepherd) #:use-module (gnu services mail) + #:use-module (gnu packages base) #:use-module (gnu packages databases) #:use-module (gnu packages guile-xyz) #:use-module (gnu packages patchutils) @@ -52,6 +54,7 @@ (define-module (gnu tests web) %test-php-fpm %test-hpcguix-web %test-tailon + %test-anonip %test-patchwork %test-agate)) @@ -509,6 +512,125 @@ (define %test-tailon (description "Connect to a running Tailon server.") (value (run-tailon-test)))) + +;;; +;;; Anonip +;;; +(define %anonip-os + ;; Operating system under test. + (simple-operating-system + (service anonip-service-type + (anonip-configuration + (input "/var/run/anonip/access.log") + (output "/var/log/anonip/access.log") + (debug? #t))))) + +(define (run-anonip-test) + (define os + (marionette-operating-system + %anonip-os + #:imported-modules '((gnu services herd) + (guix combinators)))) + + (define vm + (virtual-machine + (operating-system os) + ;; We are interested in verifying if anonip still launches following a + ;; reboot; thus make the base image writable. + (volatile? #f))) + + (define test + (with-imported-modules '((gnu build marionette)) + #~(begin + (use-modules (ice-9 match) + (srfi srfi-64) + (gnu build marionette)) + + (define marionette + (make-marionette (list #$vm))) + + (test-runner-current (system-test-runner #$output)) + (test-begin "anonip") + + (test-assert "service is running" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (wait-for-service 'anonip-/var/log/anonip/access.log)) + marionette)) + + (test-assert "service can be restarted" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (restart-service 'anonip-/var/log/anonip/access.log) + (wait-for-service 'anonip-/var/log/anonip/access.log)) + marionette)) + + (test-assert "ip addresses are anonymized" + (marionette-eval + '(begin + (use-modules (ice-9 textual-ports)) + (call-with-output-file "/var/run/anonip/access.log" + (lambda (port) + (display "192.168.100.200 - - \ +[30/Oct/2024:14:57:44 +0100] GET /xxx.narinfo HTTP/1.1\" 200 1065 \ +\"-\" \"GNU Guile\"\n" port) + (display "2001:0db8:85a3:0000:0000:8a2e:0370:7334 - - \ +[30/Oct/2024:14:57:44 +0100] \"GET /xxx.narinfo HTTP/1.1\" 200 1065 \ +\"-\" \"GNU Guile\"\n" port))) + (#$retry-on-error + (lambda () + (call-with-input-file "/var/log/anonip/access.log" + (lambda (port) + (let ((content (get-string-all port))) + ;; The expected values are taken from anonip's test + ;; suite (see its test_module.py file). + (or (and (string-contains content "192.168.96.0") + (string-contains content "2001:db8:85a0::")) + (error "could not find expected anonymized IPs" + content)))))) + #:times 20 + #:delay 1)) + marionette)) + + (test-assert "service is running after reboot" + (begin + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (eval-there '(begin + (use-modules (shepherd system)) + (sync) ;ensure the log is fully written + (reboot)))) + marionette) + ;; Note: a distinct marionette-eval call is needed here; if + ;; included in the previous one issuing the reboot, + ;; 'wait-for-service' would apparently run before the system had + ;; rebooted (and succeed), which would defeat the test. + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (wait-for-service 'anonip-/var/log/anonip/access.log)) + marionette))) + + (test-assert "service can be stopped" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (stop-service 'anonip-/var/log/anonip/access.log)) + marionette)) + + (test-end)))) + + (gexp->derivation "anonip-test" test)) + +(define %test-anonip + (system-test + (name "anonip") + (description "Anonymize logs via Anonip") + (value (run-anonip-test)))) + ;;; ;;; Patchwork -- 2.46.0