diff mbox series

[bug#48299] ipfs: Do not redirect to non-existent subdomains

Message ID a01e53b0d907e89f76ccaeaeffbb4d1f8b74a0a3.camel@telenet.be
State New
Headers show
Series [bug#48299] ipfs: Do not redirect to non-existent subdomains | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

M May 8, 2021, 9:04 p.m. UTC
Hi guix,

This patchs configures the ipfs service to allow
read access via http://localhost:8082/ipfs/THE-OBJECT.
Previous, it redirected to a subdomain of localhost,
but the required DNS trickery does not yet exist for
Guix System, so that redirect failed.

I added a system test for testing this functionality
(make check-system TESTS=ipfs). Not yet tested on a ‘real’ system,
though I don't expect any issues.

Greetings,
Maxime.
diff mbox series

Patch

From ca43bd364112cf15ff5871e92890b4a0a201c817 Mon Sep 17 00:00:00 2001
From: Maxime Devos <maximedevos@telenet.be>
Date: Sat, 8 May 2021 21:48:20 +0200
Subject: [PATCH 2/2] tests: networking: Test whether the gateway is usable.

The IPFS daemon listens at two endpoints.  One is called the gateway
and the other is called the API.  There are some tests for the API, but
none yet for the gateway.  Test whether data can be read from the gateway.

* gnu/tests/networking.scm
  (run-ipfs-test)[test]{read-contents/gateway}: New procedure, variant
  of 'read-contents'.
  (run-ipfs-test)[test]{can upload and download a file to/from ipfs}:
  Rename to ...
  (run-ipfs-test)[test]{can upload and download a file to/from ipfs via API}
  This.
  (run-ipfs-test)[test]{can download a file from ipfs via gateway}:
  New test.
---
 gnu/tests/networking.scm | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/gnu/tests/networking.scm b/gnu/tests/networking.scm
index 453e63f52d..6e759b7679 100644
--- a/gnu/tests/networking.scm
+++ b/gnu/tests/networking.scm
@@ -620,8 +620,21 @@  COMMIT
                 (close-port input)
                 all-input)
              marionette))
-
-          (marionette-eval '(use-modules (guix ipfs)) marionette)
+          (define (read-contents/gateway object)
+            (marionette-eval
+             `(receive (response body)
+                  (http-get (string->uri
+                             (string-append "http://localhost:8082/ipfs/"
+                                            ,object))
+                            #:decode-body? #f)
+                (list (response-code response) body))
+             marionette))
+          (marionette-eval '(use-modules (guix ipfs)
+                                         (web client)
+                                         (web response)
+                                         (web uri)
+                                         (srfi srfi-8))
+                           marionette)
           (mkdir #$output)
           (chdir #$output)
 
@@ -640,9 +653,15 @@  COMMIT
               (wait-for-tcp-port default-port marionette)))
 
           (define test-bv (string->utf8 "hello ipfs!"))
-          (test-equal "can upload and download a file to/from ipfs"
+          (define test-object (delay (add-data test-bv)))
+
+          (test-equal "can upload and download a file to/from ipfs via API"
             test-bv
-            (read-contents (add-data test-bv)))
+            (read-contents (force test-object)))
+
+          (test-equal "can download a file from ipfs via gateway"
+            (list 200 test-bv)
+            (read-contents/gateway (force test-object)))
 
           (test-end)
           (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
-- 
2.31.1