From patchwork Sat May 8 21:04:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: M X-Patchwork-Id: 29176 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 ED51627BC82; Sat, 8 May 2021 22:05:21 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1AC7A27BC81 for ; Sat, 8 May 2021 22:05:21 +0100 (BST) Received: from localhost ([::1]:49290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lfU8W-00004q-CV for patchwork@mira.cbaines.net; Sat, 08 May 2021 17:05:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lfU8F-0008WN-8F for guix-patches@gnu.org; Sat, 08 May 2021 17:05:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:40754) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lfU8F-000504-13 for guix-patches@gnu.org; Sat, 08 May 2021 17:05:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lfU8D-0005YZ-Qo for guix-patches@gnu.org; Sat, 08 May 2021 17:05:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#48299] [PATCH] ipfs: Do not redirect to non-existent subdomains Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 08 May 2021 21:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 48299 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 48299@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.162050788821346 (code B ref -1); Sat, 08 May 2021 21:05:01 +0000 Received: (at submit) by debbugs.gnu.org; 8 May 2021 21:04:48 +0000 Received: from localhost ([127.0.0.1]:52299 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfU7z-0005YE-IE for submit@debbugs.gnu.org; Sat, 08 May 2021 17:04:48 -0400 Received: from lists.gnu.org ([209.51.188.17]:50900) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfU7y-0005Y8-DW for submit@debbugs.gnu.org; Sat, 08 May 2021 17:04:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47930) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lfU7y-0008W7-8P for guix-patches@gnu.org; Sat, 08 May 2021 17:04:46 -0400 Received: from baptiste.telenet-ops.be ([2a02:1800:120:4::f00:13]:50854) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lfU7v-0004nH-A4 for guix-patches@gnu.org; Sat, 08 May 2021 17:04:45 -0400 Received: from butterfly.local ([213.119.233.112]) by baptiste.telenet-ops.be with bizsmtp id 2M4f250072SA7zH01M4flc; Sat, 08 May 2021 23:04:40 +0200 Message-ID: From: Maxime Devos Date: Sat, 08 May 2021 23:04:31 +0200 User-Agent: Evolution 3.34.2 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1620507880; bh=UxkmwwPr5A5YwXnCQvI5Kdhmx2N66mb+kBmIAIzMxDY=; h=Subject:From:To:Date; b=QUt0BgjXSwApgiavAvnlTBeG1IzUxFIY/y9ylYAfBdnR19SbLudXD4RiGAsvMf9em tfL/ViAePJaCBWgJ7/PsWo9ziiFc0pXZhM/xqu4jpiaE33dHdQilXsoPeKU5YIvq4U UycBgsSqplAY7ok3gs53L1kb/7saVmX+DWuqDUun0smCPB2lxRf0Rw5+9mg5v4B31W 3UW+8XscmrmJUWhcxZH5vjA8Tl7ys2tjQhKVIfy0dqjDBA0NXTUETbZ+7hdFzTO2sI AEd0PiiZAOn13PLaDHmiyN1QqYo9N4N2bjprafU1v91QiAZNvtSgCMuN8PFyL0Bci/ U05itjiY4E1uw== Received-SPF: pass client-ip=2a02:1800:120:4::f00:13; envelope-from=maximedevos@telenet.be; helo=baptiste.telenet-ops.be X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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" X-getmail-retrieved-from-mailbox: Patches 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. From ca43bd364112cf15ff5871e92890b4a0a201c817 Mon Sep 17 00:00:00 2001 From: Maxime Devos 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