From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 1/5] xt/lei-onion-convert: test for NNTP+IMAP onions
Date: Sat, 1 May 2021 06:21:13 +0000 [thread overview]
Message-ID: <20210501062117.21617-2-e@80x24.org> (raw)
In-Reply-To: <20210501062117.21617-1-e@80x24.org>
These tests require a running Tor instance (defaulting to
127.0.0.1:9050) and Internet connectivity, but otherwise
work pretty well.
---
MANIFEST | 1 +
xt/lei-onion-convert.t | 61 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 62 insertions(+)
create mode 100644 xt/lei-onion-convert.t
diff --git a/MANIFEST b/MANIFEST
index bc2ad671..82f25735 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -516,6 +516,7 @@ xt/httpd-async-stream.t
xt/imapd-mbsync-oimap.t
xt/imapd-validate.t
xt/lei-auth-fail.t
+xt/lei-onion-convert.t
xt/mem-imapd-tls.t
xt/mem-msgview.t
xt/msgtime_cmp.t
diff --git a/xt/lei-onion-convert.t b/xt/lei-onion-convert.t
new file mode 100644
index 00000000..d38b4b16
--- /dev/null
+++ b/xt/lei-onion-convert.t
@@ -0,0 +1,61 @@
+#!perl -w
+# Copyright (C) 2021 all contributors <meta@public-inbox.org>
+# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+use strict; use v5.10; use PublicInbox::TestCommon;
+use PublicInbox::MboxReader;
+my $test_tor = $ENV{TEST_TOR};
+plan skip_all => "TEST_TOR unset" unless $test_tor;
+unless ($test_tor =~ m!\Asocks5h://!i) {
+ my $default = 'socks5h://127.0.0.1:9050';
+ diag "using $default (set TEST_TOR=socks5h://ADDR:PORT to override)";
+ $test_tor = $default;
+}
+my $onion = $ENV{TEST_ONION_HOST} //'ou63pmih66umazou.onion';
+my $ng = 'inbox.comp.mail.public-inbox.meta';
+my $nntp_url = $ENV{TEST_NNTP_ONION_URL} // "nntp://$onion/$ng";
+my $imap_url = $ENV{TEST_IMAP_ONION_URL} // "imap://$onion/$ng.0";
+my @cnv = qw(lei convert -o mboxrd:/dev/stdout);
+my @proxy_cli = ("--proxy=$test_tor");
+my $proxy_cfg = "proxy=$test_tor";
+test_lei(sub {
+ my $run = {};
+ for my $args ([$nntp_url, @proxy_cli], [$imap_url, @proxy_cli],
+ [ $nntp_url, '-c', "nntp.$proxy_cfg" ],
+ [ $imap_url, '-c', "imap.$proxy_cfg" ]) {
+ pipe(my ($r, $w)) or xbail "pipe: $!";
+ my $cmd = [@cnv, @$args];
+ my $td = start_script($cmd, undef, { 1 => $w, run_mode => 0 });
+ $args->[0] =~ s!\A(.+?://).*!$1...!;
+ my $key = "@$args";
+ ok($td, "$key running");
+ $run->{$key} = { td => $td, r => $r };
+ }
+ while (my ($key, $x) = each %$run) {
+ my ($td, $r) = delete(@$x{qw(td r)});
+ eval {
+ PublicInbox::MboxReader->mboxrd($r, sub {
+ my ($eml) = @_;
+ if ($key =~ m!\Anntps?://!i) {
+ for (qw(Xref Newsgroups Path)) {
+ $eml->header_set($_);
+ }
+ }
+ push @{$x->{eml}}, $eml;
+ close $r;
+ $td->kill('-INT');
+ die "$key done\n";
+ });
+ };
+ chomp(my $done = $@);
+ like($done, qr/\Q$key\E done/, $done);
+ $td->join;
+ }
+ my @keys = keys %$run;
+ my $first_key = shift @keys;
+ for my $key (@keys) {
+ is_deeply($run->{$key}, $run->{$first_key},
+ "`$key' matches `$first_key'");
+ }
+});
+
+done_testing;
next prev parent reply other threads:[~2021-05-01 6:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-01 6:21 [PATCH 0/5] lei: more UI/UX tweaks Eric Wong
2021-05-01 6:21 ` Eric Wong [this message]
2021-05-01 6:21 ` [PATCH 2/5] lei <q|up>: distinguish between mset and l2m counts Eric Wong
2021-05-01 6:21 ` [PATCH 3/5] lei_saved_search: fix excess indent for first lei.q entry Eric Wong
2021-05-01 6:21 ` [PATCH 4/5] lei: rename ls-sync to ls-mail-sync Eric Wong
2021-05-01 19:29 ` [PATCH 6/5] lei import: fix --mail-sync handling in LeiInput Eric Wong
2021-05-01 6:21 ` [PATCH 5/5] lei edit-search: support relocating lei.q.output Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210501062117.21617-2-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).