[PATCH] ipfs: Do not redirect to non-existent subdomains

  • Open
  • quality assurance status badge
Details
One participant
  • Maxime Devos
Owner
unassigned
Submitted by
Maxime Devos
Severity
normal
M
M
Maxime Devos wrote on 8 May 2021 23:04
(address . guix-patches@gnu.org)
a01e53b0d907e89f76ccaeaeffbb4d1f8b74a0a3.camel@telenet.be
Hi guix,

This patchs configures the ipfs service to allow
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.
Attachment: file
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(-)

Toggle diff (48 lines)
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
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYJb83xccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7vYFAP98kOMIwzTjoPXfT354yvH9syZ6
0Fc5nuydAivEtQxWFQD/amWsyD3yUDrJ6lUA+zvoEoPm4w4XMksKY3SYf8MgwQw=
=iOdn
-----END PGP SIGNATURE-----


?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 48299@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 48299
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch