From patchwork Fri Nov 1 07:11:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 32765 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 2263B27BBEA; Fri, 1 Nov 2024 07:14:45 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 7F0DD27BBE2 for ; Fri, 1 Nov 2024 07:14:44 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6lrJ-0004Mv-3v; Fri, 01 Nov 2024 03:14:13 -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 1t6lrE-0004LI-Ly for guix-patches@gnu.org; Fri, 01 Nov 2024 03:14:08 -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 1t6lrB-0001Ca-I4 for guix-patches@gnu.org; Fri, 01 Nov 2024 03:14: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=qFi3QBVToxtiUJVjnqz3ki5qf04RYuRlBJbYPwgyI0I=; b=JwJlsH207P5bJT0uk8LtrkNsS7WIxKzm7cyetmjP3HmwbjTgUg2w30dxoViFi/XXaWLY29Lr2hNWJjI731rsYxEtUO3HrrGiB4tY8A5pFJsM9ayFJEjGAunbvoB1+39mKdHqkhQe3Wv3VcXfdM+10lN5t0TEEtVHmTkowC6ASg65bpjBPFKarZrosNL/QtPBfypvNfOs9WTet6C4+v309wbzo6y1s90/cGA3FgM1u54+RSFzUaa1yOMHW6/tZR1X5qA/CrydA21sdZWwTJcsL8eyakLuX2nvPPU5nDWWy0yLxqNTfb6U+kM9eOyfL5bnc9ze8GRhE9jySDLamCvBnw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t6lrB-0005LO-Cx; Fri, 01 Nov 2024 03:14:05 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#74151] [PATCH 7/7] 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 07:14:05 +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.173044522620475 (code B ref 74151); Fri, 01 Nov 2024 07:14:05 +0000 Received: (at 74151) by debbugs.gnu.org; 1 Nov 2024 07:13:46 +0000 Received: from localhost ([127.0.0.1]:47347 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6lqr-0005KB-E4 for submit@debbugs.gnu.org; Fri, 01 Nov 2024 03:13:45 -0400 Received: from mail-qt1-f181.google.com ([209.85.160.181]:47461) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6lqp-0005Jt-Fb for 74151@debbugs.gnu.org; Fri, 01 Nov 2024 03:13:44 -0400 Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-4609d8874b1so12439311cf.3 for <74151@debbugs.gnu.org>; Fri, 01 Nov 2024 00:13:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730445158; x=1731049958; 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=qFi3QBVToxtiUJVjnqz3ki5qf04RYuRlBJbYPwgyI0I=; b=nKue4UhMBc90OopVtiehHPp7kXXIA6TdldjxQ6EG1m9H+oZVF852hMCAdjmnCksGWx poYWb9iaPUx8uLldcTDiFjppgdpP61ghHwCS4E50FICqSN7xnwZ45x4hoK7ZJTTQqi5P x1wBKqMb3eLLdNa6jo2F/HiDtLPNXHa96oP2gJbQCg2JtK5QJVDP/pacnWiU8BVFHEuR Tyljo+PeElvm2p1iOskUthjC/U/fRQSkDU2X/VgrBOpcZNBp3gnx9GWFoBBBqlJz+GUr 4JLnVTVkdm1FsTXssViwACv1E72lOSmaf/JiRg0PmFpjrZvUSdoq/5Qlw9Z/g0ITr3Rm H+dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730445158; x=1731049958; 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=qFi3QBVToxtiUJVjnqz3ki5qf04RYuRlBJbYPwgyI0I=; b=HXEtXo7I2eCe943dZO6BCi6nG6qJaUkWwpaWY2pLx0C1CPvbzoAiPVruQgM7LphPjs g6RgwIL27h9/yvm2bd8mKUTBkePcmxfG7/WeYjnQNxnSaHnQfZcRJ5KzJ+f5a6fqPWYi C481lCCRm6SkopfmyChJJovSmBifL9m45kFOJ9P9F/NXIgv4zN05zWaC88Kl6gmLvjyi Lbyeos/Y6z3tqBt4XPTsQeqRAqcrCtBXjOGVOLqKPOQqXplhUZxOdMNcQU6dK781sbh1 AsF7W0+MqDKorLR1lrdy7RH65GzYq2ptXmxZOH/d59zZjDS7HWRDX4dg8JIBj6YdJ14T G8hA== X-Gm-Message-State: AOJu0YxuGQ+UdV1ZVbOdfbmcbIjAr7IghN1uCiEngBQ7TZqFuCHKunCR tvslH7HI2JfCxTPXadvghOhv0IeDRhQaHFnluA5l1IpeQP/z1Mh0r7kqspZf X-Google-Smtp-Source: AGHT+IHpZMJcSVV6AQ1ebuMXyUMySqHvZsRDTYDTiEzbguvEQ+z+bDiu52WRPKU2z0o2pI+d0VBYYA== X-Received: by 2002:a05:622a:198a:b0:45f:8c1:41af with SMTP id d75a77b69052e-462ab2fc97fmr77878551cf.41.1730445157556; Fri, 01 Nov 2024 00:12:37 -0700 (PDT) Received: from localhost.localdomain (vps-6234970c.vps.ovh.ca. [51.222.13.224]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-462ad1a0f59sm15646821cf.81.2024.11.01.00.12.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2024 00:12:36 -0700 (PDT) From: Maxim Cournoyer Date: Fri, 1 Nov 2024 16:11:43 +0900 Message-ID: <7c762086c432d21da2c664d4ee26c051fb54a481.1730441684.git.maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/tests/web.scm (%test-anonip): New test. (%anonip-os): New variables. (run-anonip-test): New procedure. Change-Id: Ieed210a784dbdeee8a498e74b6c0e31cb72cd9b8 --- gnu/tests/web.scm | 115 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) diff --git a/gnu/tests/web.scm b/gnu/tests/web.scm index 5c50322cef..f7a5659dc5 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,118 @@ (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/http.access.log") + (output "/var/log/anonip/http.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/http.access.log)) + marionette)) + + (test-assert "service can be restarted" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (restart-service 'anonip-/var/log/anonip/http.access.log) + (wait-for-service 'anonip-/var/log/anonip/http.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/http.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/http.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/http.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