all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#72577] [PATCH 0/1] services: agate: Change variable names and add system test.
@ 2024-08-11 14:32 Rodion Goritskov
  2024-08-11 14:40 ` [bug#72577] [PATCH 1/1] " Rodion Goritskov
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Rodion Goritskov @ 2024-08-11 14:32 UTC (permalink / raw)
  To: 72577
  Cc: Rodion Goritskov, Florian Pelz, Ludovic Courtès,
	Matthew Trzcinski, Maxim Cournoyer

This is a follow up to the patchset in [1], which updated the configuration record
to make agate service work again. However, the original ticket had some improvement
suggestions, so this patch addresses them. Short option names are renamed to a long ones,
documentation is updated and system test added.

Compatibility of the service breaks again, so it is not OK now, please notify me on
deprecation policy, I will update the patchset accordingly.

1: https://issues.guix.gnu.org/71722

Rodion Goritskov (1):
  services: agate: Change variable names and add system test.

 doc/guix.texi        |   8 ++--
 gnu/services/web.scm |  38 ++++++++--------
 gnu/tests/web.scm    | 105 ++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 127 insertions(+), 24 deletions(-)


base-commit: 174ecf5b1077d29498d9de22e27b13047f314feb
-- 
2.45.2





^ permalink raw reply	[flat|nested] 12+ messages in thread

* [bug#72577] [PATCH 1/1] services: agate: Change variable names and add system test.
  2024-08-11 14:32 [bug#72577] [PATCH 0/1] services: agate: Change variable names and add system test Rodion Goritskov
@ 2024-08-11 14:40 ` Rodion Goritskov
  2024-08-12  5:31 ` [bug#72577] [PATCH v2] " Rodion Goritskov
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Rodion Goritskov @ 2024-08-11 14:40 UTC (permalink / raw)
  To: 72577
  Cc: Rodion Goritskov, Florian Pelz, Ludovic Courtès,
	Matthew Trzcinski, Maxim Cournoyer

* doc/guix.texi (Web Services): Update documentation for agate-service-type.
* gnu/services/web.scm (agate-configuration): Rename certs, addr, lang and
central-conf variables.
* gnu/tests/web.scm (%test-agate): Add system test for agate-service-type.

Change-Id: Ie14814fca1d5158acd67899da0c3fc2c5b586c72
---
 doc/guix.texi        |   8 ++--
 gnu/services/web.scm |  38 ++++++++--------
 gnu/tests/web.scm    | 105 ++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 127 insertions(+), 24 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 6e03d8bbcc..271219c4db 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -32992,10 +32992,10 @@ Web Services
 @item @code{content} (default: @file{"/srv/gemini"})
 The directory from which Agate will serve files.
 
-@item @code{certs} (default: @file{"/srv/gemini-certs"})
+@item @code{certificates} (default: @file{"/srv/gemini-certs"})
 Root of the certificate directory. Must be filled in with a value from the user.
 
-@item @code{addr} (default: @code{'("0.0.0.0:1965" "[::]:1965")})
+@item @code{addresses} (default: @code{'("[::]:1965" "0.0.0.0:1965")})
 A list of the addresses to listen on.
 
 @item @code{hostnames} (default: @code{'()})
@@ -33003,7 +33003,7 @@ Web Services
 specified, corresponding directory names should be present in the @code{content}
 directory. Optional.
 
-@item @code{lang} (default: @code{#f})
+@item @code{languages} (default: @code{#f})
 RFC 4646 language code(s) for text/gemini documents.  Optional.
 
 @item @code{only-tls13?} (default: @code{#f})
@@ -33013,7 +33013,7 @@ Web Services
 Set to @code{#t} to serve secret files (files/directories starting with
 a dot).
 
-@item @code{central-conf?} (default: @code{#f})
+@item @code{central-configuration?} (default: @code{#f})
 Set to @code{#t} to look for the .meta configuration file in the @code{content}
 root directory and will ignore @code{.meta} files in other directories
 
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index e8ddb1d987..7adb416c39 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -2186,20 +2186,20 @@ (define-record-type* <agate-configuration>
             (default agate))
   (content  agate-configuration-content
             (default "/srv/gemini"))
-  (certs     agate-configuration-certs
-             (default "/srv/gemini-certs"))
-  (addr     agate-configuration-addr
-            (default '("0.0.0.0:1965" "[::]:1965")))
-  (hostname agate-configuration-hostname
-            (default '()))
-  (lang     agate-configuration-lang
-            (default #f))
+  (certificates agate-configuration-certificatess
+                (default "/srv/gemini-certs"))
+  (addresses     agate-configuration-addresses
+                 (default '("[::]:1965" "0.0.0.0:1965")))
+  (hostnames  agate-configuration-hostnames
+              (default '()))
+  (languages     agate-configuration-languages
+                 (default #f))
   (only-tls13? agate-configuration-only-tls13
                (default #f))
   (serve-secret? agate-configuration-serve-secret
                  (default #f))
-  (central-conf? agate-configuration-central-conf
-                 (default #f))
+  (central-configuration? agate-configuration-central-configuration
+                          (default #f))
   (ed25519? agate-configuration-ed25519
             (default #f))
   (skip-port-check? agate-configuration-skip-port-check
@@ -2215,9 +2215,9 @@ (define-record-type* <agate-configuration>
 
 (define agate-shepherd-service
   (match-lambda
-    (($ <agate-configuration> package content certs addr
-                              hostname lang only-tls13?
-                              serve-secret? central-conf?
+    (($ <agate-configuration> package content certificates addresses
+                              hostnames languages only-tls13?
+                              serve-secret? central-configuration?
                               ed25519? skip-port-check?
                               log-ip? user group log-file)
      (list (shepherd-service
@@ -2228,19 +2228,19 @@ (define agate-shepherd-service
                      #~(make-forkexec-constructor
                         (list #$agate
                               "--content" #$content
-                              "--certs" #$certs
+                              "--certs" #$certificates
                               #$@(append-map
                                   (lambda x (append '("--addr") x))
-                                  addr)
+                                  addresses)
                               #$@(append-map
                                   (lambda x (append '("--hostname") x))
-                                  hostname)
-                              #$@(if lang
-                                     (list "--lang" lang)
+                                  hostnames)
+                              #$@(if languages
+                                     (list "--lang" languages)
                                      '())
                               #$@(if serve-secret? '("--serve-secret") '())
                               #$@(if only-tls13? '("--only-tls13") '())
-                              #$@(if central-conf? '("--central-conf") '())
+                              #$@(if central-configuration? '("--central-conf") '())
                               #$@(if ed25519? '("--ed25519") '())
                               #$@(if skip-port-check? '("--skip-port-check") '())
                               #$@(if log-ip? '("--log-ip") '()))
diff --git a/gnu/tests/web.scm b/gnu/tests/web.scm
index 16dc6bea49..a071e05e1d 100644
--- a/gnu/tests/web.scm
+++ b/gnu/tests/web.scm
@@ -34,8 +34,10 @@ (define-module (gnu tests web)
   #:use-module (gnu services shepherd)
   #:use-module (gnu services mail)
   #:use-module (gnu packages databases)
+  #:use-module (gnu packages guile-xyz)
   #:use-module (gnu packages patchutils)
   #:use-module (gnu packages python)
+  #:use-module (gnu packages tls)
   #:use-module (gnu packages web)
   #:use-module (guix packages)
   #:use-module (guix modules)
@@ -50,7 +52,8 @@ (define-module (gnu tests web)
             %test-php-fpm
             %test-hpcguix-web
             %test-tailon
-            %test-patchwork))
+            %test-patchwork
+            %test-agate))
 
 (define %index.html-contents
   ;; Contents of the /index.html file.
@@ -657,3 +660,103 @@ (define %test-patchwork
    (name "patchwork")
    (description "Connect to a running Patchwork service.")
    (value (run-patchwork-test patchwork))))
+
+\f
+;;;
+;;; Agate
+;;;
+
+(define %index.gmi-contents
+  ;; Contents of the /index.gmi file.
+  "Hello, guix!")
+
+(define %make-agate-root
+  ;; Create our server root in /srv.
+  #~(begin
+      (mkdir "/srv")
+      (mkdir "/srv/gemini")
+      (mkdir "/srv/gemini-certs")
+      ;; Directory should be writable for Agate user to generate certificates
+      (let ((user (getpw "agate")))
+        (chown "/srv/gemini-certs" (passwd:uid user) (passwd:gid user)))
+      (call-with-output-file (string-append "/srv/gemini/index.gmi")
+        (lambda (port)
+          (display #$%index.gmi-contents port)))))
+
+(define %agate-os
+  (simple-operating-system
+   (service dhcp-client-service-type)
+   (simple-service 'make-agate-root activation-service-type
+                   %make-agate-root)
+   (service agate-service-type
+            (agate-configuration
+             (hostnames '("localhost"))))))
+
+(define* (run-agate-test name test-os expected-content)
+  (define os
+    (marionette-operating-system
+     test-os
+     #:imported-modules '((gnu services herd)
+                          (guix combinators))
+     #:extensions (list guile-gemini guile-gnutls)))
+
+  (define forwarded-port 1965)
+
+  (define vm
+    (virtual-machine
+     (operating-system os)
+     (port-forwardings `((1965 . ,forwarded-port)))))
+
+  (define test
+    (with-imported-modules '((gnu build marionette))
+      #~(begin
+          (use-modules (srfi srfi-64)
+                       (gnu build marionette))
+
+          (define marionette
+            (make-marionette (list #$vm)))
+
+          (test-runner-current (system-test-runner #$output))
+          (test-begin #$name)
+
+          (test-assert #$(string-append name " service running")
+            (marionette-eval
+             '(begin
+                (use-modules (gnu services herd))
+                (match (start-service '#$(string->symbol name))
+                  (#f #f)
+                  (('service response-parts ...)
+                   (match (assq-ref response-parts 'running)
+                     ((#t) #t)
+                     ((pid) (number? pid))))))
+             marionette))
+
+          (test-assert "Agate TCP port ready, IPv4"
+            (wait-for-tcp-port #$forwarded-port marionette))
+
+          (test-assert "Agate TCP port ready, IPv6"
+            (wait-for-tcp-port #$forwarded-port marionette
+                               #:address
+                               '(make-socket-address
+                                 AF_INET6 (inet-pton AF_INET6 "::1") #$forwarded-port)))
+
+          (test-equal "Agate responses with the specified index.gmi"
+            #$expected-content
+            (marionette-eval '(begin
+                                (use-modules (ice-9 iconv)
+                                             (gemini client)
+                                             (gemini request)
+                                             (gemini response))
+                                (bytevector->string (gemini-response-body-bytes
+                                                     (send-gemini-request
+                                                      (build-gemini-request #:host "localhost" #:port #$forwarded-port)))
+                                                    "utf8")) marionette))
+
+          (test-end))))
+  (gexp->derivation "agate-test" test))
+
+(define %test-agate
+  (system-test
+   (name "agate")
+   (description "Connect to a running Agate service.")
+   (value (run-agate-test name %agate-os %index.gmi-contents))))
-- 
2.45.2





^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [bug#72577] [PATCH v2] services: agate: Change variable names and add system test.
  2024-08-11 14:32 [bug#72577] [PATCH 0/1] services: agate: Change variable names and add system test Rodion Goritskov
  2024-08-11 14:40 ` [bug#72577] [PATCH 1/1] " Rodion Goritskov
@ 2024-08-12  5:31 ` Rodion Goritskov
  2024-08-16 17:52 ` Christopher Howard
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Rodion Goritskov @ 2024-08-12  5:31 UTC (permalink / raw)
  To: 72577
  Cc: Rodion Goritskov, Rodion Goritskov, Florian Pelz,
	Ludovic Courtès, Matthew Trzcinski, Maxim Cournoyer

* doc/guix.texi (Web Services): Update documentation for agate-service-type.
* gnu/services/web.scm (agate-configuration): Rename certs, addr, lang and
central-conf variables.
* gnu/tests/web.scm (%test-agate): Add system test for agate-service-type.

Change-Id: Ie14814fca1d5158acd67899da0c3fc2c5b586c72
---
 doc/guix.texi        |  10 ++---
 gnu/services/web.scm |  38 ++++++++--------
 gnu/tests/web.scm    | 105 ++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 128 insertions(+), 25 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 6e03d8bbcc..8acba533c2 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -32955,7 +32955,7 @@ Web Services
 (service agate-service-type
 	 (agate-configuration
 	   (content "/srv/gemini")
-	   (certs "/srv/gemini-certs")))
+	   (certificates "/srv/gemini-certs")))
 @end lisp
 
 The example above represents the minimal tweaking necessary to get Agate
@@ -32992,10 +32992,10 @@ Web Services
 @item @code{content} (default: @file{"/srv/gemini"})
 The directory from which Agate will serve files.
 
-@item @code{certs} (default: @file{"/srv/gemini-certs"})
+@item @code{certificates} (default: @file{"/srv/gemini-certs"})
 Root of the certificate directory. Must be filled in with a value from the user.
 
-@item @code{addr} (default: @code{'("0.0.0.0:1965" "[::]:1965")})
+@item @code{addresses} (default: @code{'("[::]:1965" "0.0.0.0:1965")})
 A list of the addresses to listen on.
 
 @item @code{hostnames} (default: @code{'()})
@@ -33003,7 +33003,7 @@ Web Services
 specified, corresponding directory names should be present in the @code{content}
 directory. Optional.
 
-@item @code{lang} (default: @code{#f})
+@item @code{languages} (default: @code{#f})
 RFC 4646 language code(s) for text/gemini documents.  Optional.
 
 @item @code{only-tls13?} (default: @code{#f})
@@ -33013,7 +33013,7 @@ Web Services
 Set to @code{#t} to serve secret files (files/directories starting with
 a dot).
 
-@item @code{central-conf?} (default: @code{#f})
+@item @code{central-configuration?} (default: @code{#f})
 Set to @code{#t} to look for the .meta configuration file in the @code{content}
 root directory and will ignore @code{.meta} files in other directories
 
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index e8ddb1d987..cc6f4e6d9b 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -2186,20 +2186,20 @@ (define-record-type* <agate-configuration>
             (default agate))
   (content  agate-configuration-content
             (default "/srv/gemini"))
-  (certs     agate-configuration-certs
-             (default "/srv/gemini-certs"))
-  (addr     agate-configuration-addr
-            (default '("0.0.0.0:1965" "[::]:1965")))
-  (hostname agate-configuration-hostname
-            (default '()))
-  (lang     agate-configuration-lang
-            (default #f))
+  (certificates agate-configuration-certificates
+                (default "/srv/gemini-certs"))
+  (addresses     agate-configuration-addresses
+                 (default '("[::]:1965" "0.0.0.0:1965")))
+  (hostnames  agate-configuration-hostnames
+              (default '()))
+  (languages     agate-configuration-languages
+                 (default #f))
   (only-tls13? agate-configuration-only-tls13
                (default #f))
   (serve-secret? agate-configuration-serve-secret
                  (default #f))
-  (central-conf? agate-configuration-central-conf
-                 (default #f))
+  (central-configuration? agate-configuration-central-configuration
+                          (default #f))
   (ed25519? agate-configuration-ed25519
             (default #f))
   (skip-port-check? agate-configuration-skip-port-check
@@ -2215,9 +2215,9 @@ (define-record-type* <agate-configuration>
 
 (define agate-shepherd-service
   (match-lambda
-    (($ <agate-configuration> package content certs addr
-                              hostname lang only-tls13?
-                              serve-secret? central-conf?
+    (($ <agate-configuration> package content certificates addresses
+                              hostnames languages only-tls13?
+                              serve-secret? central-configuration?
                               ed25519? skip-port-check?
                               log-ip? user group log-file)
      (list (shepherd-service
@@ -2228,19 +2228,19 @@ (define agate-shepherd-service
                      #~(make-forkexec-constructor
                         (list #$agate
                               "--content" #$content
-                              "--certs" #$certs
+                              "--certs" #$certificates
                               #$@(append-map
                                   (lambda x (append '("--addr") x))
-                                  addr)
+                                  addresses)
                               #$@(append-map
                                   (lambda x (append '("--hostname") x))
-                                  hostname)
-                              #$@(if lang
-                                     (list "--lang" lang)
+                                  hostnames)
+                              #$@(if languages
+                                     (list "--lang" languages)
                                      '())
                               #$@(if serve-secret? '("--serve-secret") '())
                               #$@(if only-tls13? '("--only-tls13") '())
-                              #$@(if central-conf? '("--central-conf") '())
+                              #$@(if central-configuration? '("--central-conf") '())
                               #$@(if ed25519? '("--ed25519") '())
                               #$@(if skip-port-check? '("--skip-port-check") '())
                               #$@(if log-ip? '("--log-ip") '()))
diff --git a/gnu/tests/web.scm b/gnu/tests/web.scm
index 16dc6bea49..a071e05e1d 100644
--- a/gnu/tests/web.scm
+++ b/gnu/tests/web.scm
@@ -34,8 +34,10 @@ (define-module (gnu tests web)
   #:use-module (gnu services shepherd)
   #:use-module (gnu services mail)
   #:use-module (gnu packages databases)
+  #:use-module (gnu packages guile-xyz)
   #:use-module (gnu packages patchutils)
   #:use-module (gnu packages python)
+  #:use-module (gnu packages tls)
   #:use-module (gnu packages web)
   #:use-module (guix packages)
   #:use-module (guix modules)
@@ -50,7 +52,8 @@ (define-module (gnu tests web)
             %test-php-fpm
             %test-hpcguix-web
             %test-tailon
-            %test-patchwork))
+            %test-patchwork
+            %test-agate))
 
 (define %index.html-contents
   ;; Contents of the /index.html file.
@@ -657,3 +660,103 @@ (define %test-patchwork
    (name "patchwork")
    (description "Connect to a running Patchwork service.")
    (value (run-patchwork-test patchwork))))
+
+\f
+;;;
+;;; Agate
+;;;
+
+(define %index.gmi-contents
+  ;; Contents of the /index.gmi file.
+  "Hello, guix!")
+
+(define %make-agate-root
+  ;; Create our server root in /srv.
+  #~(begin
+      (mkdir "/srv")
+      (mkdir "/srv/gemini")
+      (mkdir "/srv/gemini-certs")
+      ;; Directory should be writable for Agate user to generate certificates
+      (let ((user (getpw "agate")))
+        (chown "/srv/gemini-certs" (passwd:uid user) (passwd:gid user)))
+      (call-with-output-file (string-append "/srv/gemini/index.gmi")
+        (lambda (port)
+          (display #$%index.gmi-contents port)))))
+
+(define %agate-os
+  (simple-operating-system
+   (service dhcp-client-service-type)
+   (simple-service 'make-agate-root activation-service-type
+                   %make-agate-root)
+   (service agate-service-type
+            (agate-configuration
+             (hostnames '("localhost"))))))
+
+(define* (run-agate-test name test-os expected-content)
+  (define os
+    (marionette-operating-system
+     test-os
+     #:imported-modules '((gnu services herd)
+                          (guix combinators))
+     #:extensions (list guile-gemini guile-gnutls)))
+
+  (define forwarded-port 1965)
+
+  (define vm
+    (virtual-machine
+     (operating-system os)
+     (port-forwardings `((1965 . ,forwarded-port)))))
+
+  (define test
+    (with-imported-modules '((gnu build marionette))
+      #~(begin
+          (use-modules (srfi srfi-64)
+                       (gnu build marionette))
+
+          (define marionette
+            (make-marionette (list #$vm)))
+
+          (test-runner-current (system-test-runner #$output))
+          (test-begin #$name)
+
+          (test-assert #$(string-append name " service running")
+            (marionette-eval
+             '(begin
+                (use-modules (gnu services herd))
+                (match (start-service '#$(string->symbol name))
+                  (#f #f)
+                  (('service response-parts ...)
+                   (match (assq-ref response-parts 'running)
+                     ((#t) #t)
+                     ((pid) (number? pid))))))
+             marionette))
+
+          (test-assert "Agate TCP port ready, IPv4"
+            (wait-for-tcp-port #$forwarded-port marionette))
+
+          (test-assert "Agate TCP port ready, IPv6"
+            (wait-for-tcp-port #$forwarded-port marionette
+                               #:address
+                               '(make-socket-address
+                                 AF_INET6 (inet-pton AF_INET6 "::1") #$forwarded-port)))
+
+          (test-equal "Agate responses with the specified index.gmi"
+            #$expected-content
+            (marionette-eval '(begin
+                                (use-modules (ice-9 iconv)
+                                             (gemini client)
+                                             (gemini request)
+                                             (gemini response))
+                                (bytevector->string (gemini-response-body-bytes
+                                                     (send-gemini-request
+                                                      (build-gemini-request #:host "localhost" #:port #$forwarded-port)))
+                                                    "utf8")) marionette))
+
+          (test-end))))
+  (gexp->derivation "agate-test" test))
+
+(define %test-agate
+  (system-test
+   (name "agate")
+   (description "Connect to a running Agate service.")
+   (value (run-agate-test name %agate-os %index.gmi-contents))))

base-commit: 174ecf5b1077d29498d9de22e27b13047f314feb
-- 
2.45.2





^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [bug#72577] [PATCH v2] services: agate: Change variable names and add system test.
  2024-08-11 14:32 [bug#72577] [PATCH 0/1] services: agate: Change variable names and add system test Rodion Goritskov
  2024-08-11 14:40 ` [bug#72577] [PATCH 1/1] " Rodion Goritskov
  2024-08-12  5:31 ` [bug#72577] [PATCH v2] " Rodion Goritskov
@ 2024-08-16 17:52 ` Christopher Howard
  2024-08-16 19:05   ` Rodion Goritskov
  2024-08-16 19:08 ` Christopher Howard
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 12+ messages in thread
From: Christopher Howard @ 2024-08-16 17:52 UTC (permalink / raw)
  To: Rodion Goritskov
  Cc: Ludovic Courtès, Maxim Cournoyer, 72577, Matthew Trzcinski,
	Florian Pelz

Hi, I'm testing these patches in a qemu VM. I thought I should share that, if I explicitly set the certs field, I get an error:

```
/home/user/config.scm:52:35: error: (agate-configuration (content "/srv/gemini") (certs "/srv/gemini-tls") (log-ip? #f)): extraneous field initializers (certs)
```

Here is the config file:

```
;; -*- mode: scheme; -*-
;; This is an operating system configuration template
;; for a "bare bones" setup, with no X11 display server.

(use-modules (gnu))
(use-service-modules networking ssh web)
(use-package-modules screen ssh)

(operating-system
  (host-name "guix")
  (timezone "America/Anchorage")
  (locale "en_US.utf8")

  ;; Boot in "legacy" BIOS mode, assuming /dev/sdX is the
  ;; target hard disk, and "my-root" is the label of the target
  ;; root file system.
  (bootloader (bootloader-configuration
                (bootloader grub-bootloader)
                (targets '("/dev/sda"))))
  ;; It's fitting to support the equally bare bones ‘-nographic’
  ;; QEMU option, which also nicely sidesteps forcing QWERTY.
  (kernel-arguments (list "console=ttyS0,115200"))
  (file-systems (cons (file-system
                        (device (file-system-label "my-root"))
                        (mount-point "/")
                        (type "ext4"))
                      %base-file-systems))

  ;; This is where user accounts are specified.  The "root"
  ;; account is implicit, and is initially created with the
  ;; empty password.
  (users (cons (user-account
                (name "user")
                (comment "Generic user")
                (group "users")

                ;; Adding the account to the "wheel" group
                ;; makes it a sudoer.  Adding it to "audio"
                ;; and "video" allows the user to play sound
                ;; and access the webcam.
                (supplementary-groups '("wheel"
                                        "audio" "video")))
               %base-user-accounts))

  ;; Globally-installed packages.
  (packages (cons screen %base-packages))

  ;; Add services to the baseline: a DHCP client and an SSH
  ;; server.  You may wish to add an NTP service here.
  (services (append (list (service dhcp-client-service-type)
			  (service agate-service-type
				   (agate-configuration
				    (content "/srv/gemini")
				    (certs "/srv/gemini-tls")
				    (log-ip? #f)))
                          (service openssh-service-type
                                   (openssh-configuration
                                    (openssh openssh-sans-x)
                                    (port-number 2222))))
                    %base-services)))
```

-- 
Christopher Howard




^ permalink raw reply	[flat|nested] 12+ messages in thread

* [bug#72577] [PATCH v2] services: agate: Change variable names and add system test.
  2024-08-16 17:52 ` Christopher Howard
@ 2024-08-16 19:05   ` Rodion Goritskov
  0 siblings, 0 replies; 12+ messages in thread
From: Rodion Goritskov @ 2024-08-16 19:05 UTC (permalink / raw)
  To: Christopher Howard
  Cc: Rodion Goritskov, Maxim Cournoyer, Ludovic Courtès,
	Florian Pelz, 72577, Matthew Trzcinski

Hi!

Christopher Howard <christopher@librehacker.com> writes:
>Hi, I'm testing these patches in a qemu VM. I thought I should share that, if I explicitly set the certs field, I get an error:
>
> ```
> /home/user/config.scm:52:35: error: (agate-configuration (content "/srv/gemini") (certs "/srv/gemini-tls") (log-ip? #f)): extraneous field initializers (certs)
> ```
>

This patch (intentionally) renames the field "certs" to the
"certificates", as was advised in [1].
I could maintain the compatibility here, but taking into account how
long the Agate service was broken, I thought there are not a lot of
users, so we could just rename the field.

Good to know you are interested in the Agate service too!

So, in your case you could change the configuration to something like
that:

(service agate-service-type
	 (agate-configuration
	  (content "/srv/gemini")
	  (certificates "/srv/gemini-tls")
	  (log-ip? #f)))

1: https://issues.guix.gnu.org/71722






^ permalink raw reply	[flat|nested] 12+ messages in thread

* [bug#72577] [PATCH v2] services: agate: Change variable names and add system test.
  2024-08-11 14:32 [bug#72577] [PATCH 0/1] services: agate: Change variable names and add system test Rodion Goritskov
                   ` (2 preceding siblings ...)
  2024-08-16 17:52 ` Christopher Howard
@ 2024-08-16 19:08 ` Christopher Howard
  2024-08-16 19:14   ` Rodion Goritskov
  2024-08-16 21:11 ` [bug#72577] [PATCH v3 0/1] " Rodion Goritskov
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 12+ messages in thread
From: Christopher Howard @ 2024-08-16 19:08 UTC (permalink / raw)
  To: Rodion Goritskov
  Cc: Ludovic Courtès, Florian Pelz, 72577, Maxim Cournoyer,
	Matthew Trzcinski

Another little detail perhaps worth noting: the guix documentation specifies that if no valid key and certificate is available, then Agate will try to generate them on its own. However, if you attempt to go this route, you get an error:

```
2024-08-16 10:58:21 No keys or certificates were found in the given directory.
2024-08-16 10:58:21 Specify the --hostname option to generate these automatically.
```

But there does not appear to be a hostname field available to agate-configuration, or at least it is not documented. Only the "hostnames" field for virtual hosts.

-- 
Christopher Howard




^ permalink raw reply	[flat|nested] 12+ messages in thread

* [bug#72577] [PATCH v2] services: agate: Change variable names and add system test.
  2024-08-16 19:08 ` Christopher Howard
@ 2024-08-16 19:14   ` Rodion Goritskov
  0 siblings, 0 replies; 12+ messages in thread
From: Rodion Goritskov @ 2024-08-16 19:14 UTC (permalink / raw)
  To: Christopher Howard
  Cc: Rodion Goritskov, Maxim Cournoyer, Ludovic Courtès,
	Florian Pelz, 72577, Matthew Trzcinski

Christopher Howard <christopher@librehacker.com> writes:

> Another little detail perhaps worth noting: the guix documentation
> specifies that if no valid key and certificate is available, then
> Agate will try to generate them on its own. However, if you attempt to
> go this route, you get an error:
>
> ```
> 2024-08-16 10:58:21 No keys or certificates were found in the given directory.
> 2024-08-16 10:58:21 Specify the --hostname option to generate these automatically.
> ```
>
> But there does not appear to be a hostname field available to agate-configuration, or at least it is not documented. Only the "hostnames" field for virtual hosts.

Actually, "hostnames" field in agate-configuration is a list of hostnames
that are passed as --hostname options to Agate.

I am going to update documentation pointing out that certificates are
going to be generated only if any hostnames are present in the
"hostnames" field.




^ permalink raw reply	[flat|nested] 12+ messages in thread

* [bug#72577] [PATCH v3 0/1] services: agate: Change variable names and add system test.
  2024-08-11 14:32 [bug#72577] [PATCH 0/1] services: agate: Change variable names and add system test Rodion Goritskov
                   ` (3 preceding siblings ...)
  2024-08-16 19:08 ` Christopher Howard
@ 2024-08-16 21:11 ` Rodion Goritskov
  2024-08-16 21:11   ` [bug#72577] [PATCH v3 1/1] " Rodion Goritskov
  2024-08-20 21:42 ` [bug#72577] " Christopher Howard
  2024-08-20 23:10 ` Christopher Howard
  6 siblings, 1 reply; 12+ messages in thread
From: Rodion Goritskov @ 2024-08-16 21:11 UTC (permalink / raw)
  To: 72577
  Cc: Rodion Goritskov, Rodion Goritskov, Christopher Howard,
	Florian Pelz, Ludovic Courtès, Matthew Trzcinski,
	Maxim Cournoyer

Updated version of the patch with tuned documentation.

Rodion Goritskov (1):
  services: agate: Change variable names and add system test.

 doc/guix.texi        |  21 +++++----
 gnu/services/web.scm |  38 ++++++++--------
 gnu/tests/web.scm    | 105 ++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 135 insertions(+), 29 deletions(-)


base-commit: e64960bd7edfdbd0ea99c68705526bcc778effb5
-- 
2.45.2





^ permalink raw reply	[flat|nested] 12+ messages in thread

* [bug#72577] [PATCH v3 1/1] services: agate: Change variable names and add system test.
  2024-08-16 21:11 ` [bug#72577] [PATCH v3 0/1] " Rodion Goritskov
@ 2024-08-16 21:11   ` Rodion Goritskov
  2024-08-31 17:06     ` bug#72577: " Ludovic Courtès
  0 siblings, 1 reply; 12+ messages in thread
From: Rodion Goritskov @ 2024-08-16 21:11 UTC (permalink / raw)
  To: 72577
  Cc: Rodion Goritskov, Rodion Goritskov, Christopher Howard,
	Florian Pelz, Ludovic Courtès, Matthew Trzcinski,
	Maxim Cournoyer

* doc/guix.texi (Web Services): Update documentation for agate-service-type.
* gnu/services/web.scm (agate-configuration): Rename certs, addr, lang and
central-conf variables.
* gnu/tests/web.scm (%test-agate): Add system test for agate-service-type.

Change-Id: Ie14814fca1d5158acd67899da0c3fc2c5b586c72
---
 doc/guix.texi        |  21 +++++----
 gnu/services/web.scm |  38 ++++++++--------
 gnu/tests/web.scm    | 105 ++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 135 insertions(+), 29 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 27e6f6adf3..539418e94b 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -32956,16 +32956,19 @@ Web Services
 (service agate-service-type
 	 (agate-configuration
 	   (content "/srv/gemini")
-	   (certs "/srv/gemini-certs")))
+	   (certificates "/srv/gemini-certs")))
 @end lisp
 
 The example above represents the minimal tweaking necessary to get Agate
 up and running.  Specifying the path to the certificate and key directory is
 always necessary, as the Gemini protocol requires TLS by default.
 
-If specified path is writable by Agate, and contains no valid key
-and certificate, the Agate will try to generate them on the first start.
-If specified directory is read-only - key and certificate should be pre-generated by user.
+If specified @code{certificates} path is writable by Agate, and contains no
+valid pre-generated key and certificate, the Agate will try to generate
+them on the first start. In this case you should pass at least one
+hostname using the @code{hostnames} option.
+If specified directory is read-only - key and certificate should be
+pre-generated by user.
 
 To obtain a certificate and a key in a DER format, you could, for example,
 use OpenSSL, running a commands similar to the following example:
@@ -32979,7 +32982,7 @@ Web Services
 
 Of course, you'll have to replace @i{example.com} with your own domain
 name, and then point the Agate configuration towards the path of the
-directory with the generated key and certificate using the @code{certs} option.
+directory with the generated key and certificate using the @code{certificates} option.
 
 @end defvar
 
@@ -32993,10 +32996,10 @@ Web Services
 @item @code{content} (default: @file{"/srv/gemini"})
 The directory from which Agate will serve files.
 
-@item @code{certs} (default: @file{"/srv/gemini-certs"})
+@item @code{certificates} (default: @file{"/srv/gemini-certs"})
 Root of the certificate directory. Must be filled in with a value from the user.
 
-@item @code{addr} (default: @code{'("0.0.0.0:1965" "[::]:1965")})
+@item @code{addresses} (default: @code{'("[::]:1965" "0.0.0.0:1965")})
 A list of the addresses to listen on.
 
 @item @code{hostnames} (default: @code{'()})
@@ -33004,7 +33007,7 @@ Web Services
 specified, corresponding directory names should be present in the @code{content}
 directory. Optional.
 
-@item @code{lang} (default: @code{#f})
+@item @code{languages} (default: @code{#f})
 RFC 4646 language code(s) for text/gemini documents.  Optional.
 
 @item @code{only-tls13?} (default: @code{#f})
@@ -33014,7 +33017,7 @@ Web Services
 Set to @code{#t} to serve secret files (files/directories starting with
 a dot).
 
-@item @code{central-conf?} (default: @code{#f})
+@item @code{central-configuration?} (default: @code{#f})
 Set to @code{#t} to look for the .meta configuration file in the @code{content}
 root directory and will ignore @code{.meta} files in other directories
 
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index e8ddb1d987..cc6f4e6d9b 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -2186,20 +2186,20 @@ (define-record-type* <agate-configuration>
             (default agate))
   (content  agate-configuration-content
             (default "/srv/gemini"))
-  (certs     agate-configuration-certs
-             (default "/srv/gemini-certs"))
-  (addr     agate-configuration-addr
-            (default '("0.0.0.0:1965" "[::]:1965")))
-  (hostname agate-configuration-hostname
-            (default '()))
-  (lang     agate-configuration-lang
-            (default #f))
+  (certificates agate-configuration-certificates
+                (default "/srv/gemini-certs"))
+  (addresses     agate-configuration-addresses
+                 (default '("[::]:1965" "0.0.0.0:1965")))
+  (hostnames  agate-configuration-hostnames
+              (default '()))
+  (languages     agate-configuration-languages
+                 (default #f))
   (only-tls13? agate-configuration-only-tls13
                (default #f))
   (serve-secret? agate-configuration-serve-secret
                  (default #f))
-  (central-conf? agate-configuration-central-conf
-                 (default #f))
+  (central-configuration? agate-configuration-central-configuration
+                          (default #f))
   (ed25519? agate-configuration-ed25519
             (default #f))
   (skip-port-check? agate-configuration-skip-port-check
@@ -2215,9 +2215,9 @@ (define-record-type* <agate-configuration>
 
 (define agate-shepherd-service
   (match-lambda
-    (($ <agate-configuration> package content certs addr
-                              hostname lang only-tls13?
-                              serve-secret? central-conf?
+    (($ <agate-configuration> package content certificates addresses
+                              hostnames languages only-tls13?
+                              serve-secret? central-configuration?
                               ed25519? skip-port-check?
                               log-ip? user group log-file)
      (list (shepherd-service
@@ -2228,19 +2228,19 @@ (define agate-shepherd-service
                      #~(make-forkexec-constructor
                         (list #$agate
                               "--content" #$content
-                              "--certs" #$certs
+                              "--certs" #$certificates
                               #$@(append-map
                                   (lambda x (append '("--addr") x))
-                                  addr)
+                                  addresses)
                               #$@(append-map
                                   (lambda x (append '("--hostname") x))
-                                  hostname)
-                              #$@(if lang
-                                     (list "--lang" lang)
+                                  hostnames)
+                              #$@(if languages
+                                     (list "--lang" languages)
                                      '())
                               #$@(if serve-secret? '("--serve-secret") '())
                               #$@(if only-tls13? '("--only-tls13") '())
-                              #$@(if central-conf? '("--central-conf") '())
+                              #$@(if central-configuration? '("--central-conf") '())
                               #$@(if ed25519? '("--ed25519") '())
                               #$@(if skip-port-check? '("--skip-port-check") '())
                               #$@(if log-ip? '("--log-ip") '()))
diff --git a/gnu/tests/web.scm b/gnu/tests/web.scm
index 16dc6bea49..a071e05e1d 100644
--- a/gnu/tests/web.scm
+++ b/gnu/tests/web.scm
@@ -34,8 +34,10 @@ (define-module (gnu tests web)
   #:use-module (gnu services shepherd)
   #:use-module (gnu services mail)
   #:use-module (gnu packages databases)
+  #:use-module (gnu packages guile-xyz)
   #:use-module (gnu packages patchutils)
   #:use-module (gnu packages python)
+  #:use-module (gnu packages tls)
   #:use-module (gnu packages web)
   #:use-module (guix packages)
   #:use-module (guix modules)
@@ -50,7 +52,8 @@ (define-module (gnu tests web)
             %test-php-fpm
             %test-hpcguix-web
             %test-tailon
-            %test-patchwork))
+            %test-patchwork
+            %test-agate))
 
 (define %index.html-contents
   ;; Contents of the /index.html file.
@@ -657,3 +660,103 @@ (define %test-patchwork
    (name "patchwork")
    (description "Connect to a running Patchwork service.")
    (value (run-patchwork-test patchwork))))
+
+\f
+;;;
+;;; Agate
+;;;
+
+(define %index.gmi-contents
+  ;; Contents of the /index.gmi file.
+  "Hello, guix!")
+
+(define %make-agate-root
+  ;; Create our server root in /srv.
+  #~(begin
+      (mkdir "/srv")
+      (mkdir "/srv/gemini")
+      (mkdir "/srv/gemini-certs")
+      ;; Directory should be writable for Agate user to generate certificates
+      (let ((user (getpw "agate")))
+        (chown "/srv/gemini-certs" (passwd:uid user) (passwd:gid user)))
+      (call-with-output-file (string-append "/srv/gemini/index.gmi")
+        (lambda (port)
+          (display #$%index.gmi-contents port)))))
+
+(define %agate-os
+  (simple-operating-system
+   (service dhcp-client-service-type)
+   (simple-service 'make-agate-root activation-service-type
+                   %make-agate-root)
+   (service agate-service-type
+            (agate-configuration
+             (hostnames '("localhost"))))))
+
+(define* (run-agate-test name test-os expected-content)
+  (define os
+    (marionette-operating-system
+     test-os
+     #:imported-modules '((gnu services herd)
+                          (guix combinators))
+     #:extensions (list guile-gemini guile-gnutls)))
+
+  (define forwarded-port 1965)
+
+  (define vm
+    (virtual-machine
+     (operating-system os)
+     (port-forwardings `((1965 . ,forwarded-port)))))
+
+  (define test
+    (with-imported-modules '((gnu build marionette))
+      #~(begin
+          (use-modules (srfi srfi-64)
+                       (gnu build marionette))
+
+          (define marionette
+            (make-marionette (list #$vm)))
+
+          (test-runner-current (system-test-runner #$output))
+          (test-begin #$name)
+
+          (test-assert #$(string-append name " service running")
+            (marionette-eval
+             '(begin
+                (use-modules (gnu services herd))
+                (match (start-service '#$(string->symbol name))
+                  (#f #f)
+                  (('service response-parts ...)
+                   (match (assq-ref response-parts 'running)
+                     ((#t) #t)
+                     ((pid) (number? pid))))))
+             marionette))
+
+          (test-assert "Agate TCP port ready, IPv4"
+            (wait-for-tcp-port #$forwarded-port marionette))
+
+          (test-assert "Agate TCP port ready, IPv6"
+            (wait-for-tcp-port #$forwarded-port marionette
+                               #:address
+                               '(make-socket-address
+                                 AF_INET6 (inet-pton AF_INET6 "::1") #$forwarded-port)))
+
+          (test-equal "Agate responses with the specified index.gmi"
+            #$expected-content
+            (marionette-eval '(begin
+                                (use-modules (ice-9 iconv)
+                                             (gemini client)
+                                             (gemini request)
+                                             (gemini response))
+                                (bytevector->string (gemini-response-body-bytes
+                                                     (send-gemini-request
+                                                      (build-gemini-request #:host "localhost" #:port #$forwarded-port)))
+                                                    "utf8")) marionette))
+
+          (test-end))))
+  (gexp->derivation "agate-test" test))
+
+(define %test-agate
+  (system-test
+   (name "agate")
+   (description "Connect to a running Agate service.")
+   (value (run-agate-test name %agate-os %index.gmi-contents))))
-- 
2.45.2





^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [bug#72577] [PATCH v3 1/1] services: agate: Change variable names and add system test.
  2024-08-11 14:32 [bug#72577] [PATCH 0/1] services: agate: Change variable names and add system test Rodion Goritskov
                   ` (4 preceding siblings ...)
  2024-08-16 21:11 ` [bug#72577] [PATCH v3 0/1] " Rodion Goritskov
@ 2024-08-20 21:42 ` Christopher Howard
  2024-08-20 23:10 ` Christopher Howard
  6 siblings, 0 replies; 12+ messages in thread
From: Christopher Howard @ 2024-08-20 21:42 UTC (permalink / raw)
  To: Rodion Goritskov
  Cc: Ludovic Courtès, Maxim Cournoyer, 72577, Matthew Trzcinski,
	Florian Pelz

Tested v3 patch inside qemu VM. Works correctly so far.

```
user@guix ~$ gmni gemini://localhost
# Hello World!
```

-- 
Christopher Howard




^ permalink raw reply	[flat|nested] 12+ messages in thread

* [bug#72577] [PATCH v3 1/1] services: agate: Change variable names and add system test.
  2024-08-11 14:32 [bug#72577] [PATCH 0/1] services: agate: Change variable names and add system test Rodion Goritskov
                   ` (5 preceding siblings ...)
  2024-08-20 21:42 ` [bug#72577] " Christopher Howard
@ 2024-08-20 23:10 ` Christopher Howard
  6 siblings, 0 replies; 12+ messages in thread
From: Christopher Howard @ 2024-08-20 23:10 UTC (permalink / raw)
  To: Rodion Goritskov
  Cc: Ludovic Courtès, Maxim Cournoyer, 72577, Matthew Trzcinski,
	Florian Pelz

I was finally was able to upgrade my agate production server, using the v3 patch! Capsule pages are serving out fine. Thanks! It is great to be up-to-date again.

-- 
Christopher Howard




^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#72577: [PATCH v3 1/1] services: agate: Change variable names and add system test.
  2024-08-16 21:11   ` [bug#72577] [PATCH v3 1/1] " Rodion Goritskov
@ 2024-08-31 17:06     ` Ludovic Courtès
  0 siblings, 0 replies; 12+ messages in thread
From: Ludovic Courtès @ 2024-08-31 17:06 UTC (permalink / raw)
  To: Rodion Goritskov
  Cc: Christopher Howard, Maxim Cournoyer, Florian Pelz,
	Matthew Trzcinski, 72577-done

Hi Rodion,

Rodion Goritskov <rodion.goritskov@gmail.com> skribis:

> * doc/guix.texi (Web Services): Update documentation for agate-service-type.
> * gnu/services/web.scm (agate-configuration): Rename certs, addr, lang and
> central-conf variables.
> * gnu/tests/web.scm (%test-agate): Add system test for agate-service-type.
>
> Change-Id: Ie14814fca1d5158acd67899da0c3fc2c5b586c72

Applied, thanks!

Ludo’.




^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-08-31 17:07 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-11 14:32 [bug#72577] [PATCH 0/1] services: agate: Change variable names and add system test Rodion Goritskov
2024-08-11 14:40 ` [bug#72577] [PATCH 1/1] " Rodion Goritskov
2024-08-12  5:31 ` [bug#72577] [PATCH v2] " Rodion Goritskov
2024-08-16 17:52 ` Christopher Howard
2024-08-16 19:05   ` Rodion Goritskov
2024-08-16 19:08 ` Christopher Howard
2024-08-16 19:14   ` Rodion Goritskov
2024-08-16 21:11 ` [bug#72577] [PATCH v3 0/1] " Rodion Goritskov
2024-08-16 21:11   ` [bug#72577] [PATCH v3 1/1] " Rodion Goritskov
2024-08-31 17:06     ` bug#72577: " Ludovic Courtès
2024-08-20 21:42 ` [bug#72577] " Christopher Howard
2024-08-20 23:10 ` Christopher Howard

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.