user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
ed24fc1be073af311587bcc2904f4f8fb075290b blob 4148 bytes (raw)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
 
#!perl -w
# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use strict;
use Test::More;
use PublicInbox::TestCommon;
require_mods 'URI::Split';
use_ok 'PublicInbox::URIimap';

is(PublicInbox::URIimap->new('https://example.com/'), undef,
	'invalid scheme ignored');

my $uri = PublicInbox::URIimap->new('imaps://EXAMPLE.com/');
is($uri->host, 'EXAMPLE.com', 'host ok');
is($uri->canonical->host, 'example.com', 'host canonicalized');
is($uri->canonical->as_string, 'imaps://example.com/', 'URI canonicalized');
is($uri->port, 993, 'imaps port');
is($uri->auth, undef);
is($uri->user, undef);

$uri = PublicInbox::URIimap->new('imaps://foo@0/');
is("$uri", $uri->as_string, '"" overload works');
is($uri->host, '0', 'numeric host');
is($uri->user, 'foo', 'user extracted');

$uri = PublicInbox::URIimap->new('imap://0/INBOX.sub#frag')->canonical;
is($uri->as_string, 'imap://0/INBOX.sub', 'no fragment');
is($uri->scheme, 'imap');

$uri = PublicInbox::URIimap->new('imaps://;AUTH=ANONYMOUS@0/');
is($uri->auth, 'ANONYMOUS', 'AUTH=ANONYMOUS accepted');

$uri = PublicInbox::URIimap->new('imaps://bar%40example.com;AUTH=99%25@0/');
is($uri->auth, '99%', 'decoded AUTH');
is($uri->user, 'bar@example.com', 'decoded user');
is($uri->mailbox, undef, 'mailbox is undef');

$uri = PublicInbox::URIimap->new('imaps://ipv6@[::1]');
is($uri->host, '::1', 'IPv6 host');
is($uri->mailbox, undef, 'mailbox is undef');

$uri = PublicInbox::URIimap->new('imaps://0:666/INBOX');
is($uri->port, 666, 'port read');
is($uri->mailbox, 'INBOX');
$uri = PublicInbox::URIimap->new('imaps://0/INBOX.sub');
is($uri->mailbox, 'INBOX.sub');
is($uri->scheme, 'imaps');

is(PublicInbox::URIimap->new('imap://0:143/')->canonical->as_string,
	'imap://0/');
is(PublicInbox::URIimap->new('imaps://0:993/')->canonical->as_string,
	'imaps://0/');

$uri = PublicInbox::URIimap->new('imap://NSA:Hunter2@0/INBOX');
is($uri->user, 'NSA');
is($uri->password, 'Hunter2');
is($uri->uidvalidity, undef, 'no UIDVALIDITY');

$uri = PublicInbox::URIimap->new('imap://0/%');
is($uri->mailbox, '%', "RFC 2192 '%' supported");
$uri = PublicInbox::URIimap->new('imap://0/%25');
$uri = PublicInbox::URIimap->new('imap://0/*');
is($uri->mailbox, '*', "RFC 2192 '*' supported");

$uri = PublicInbox::URIimap->new('imap://0/mmm;UIDVALIDITY=1');
is($uri->mailbox, 'mmm', 'mailbox works with UIDVALIDITY');
is($uri->uidvalidity, 1, 'single-digit UIDVALIDITY');
$uri = PublicInbox::URIimap->new('imap://0/mmm;UIDVALIDITY=21');
is($uri->uidvalidity, 21, 'multi-digit UIDVALIDITY');
$uri = PublicInbox::URIimap->new('imap://0/mmm;UIDVALIDITY=bogus');
is($uri->uidvalidity, undef, 'bogus UIDVALIDITY');
is($uri->uidvalidity(2), 2, 'iuid set');
is($$uri, 'imap://0/mmm;UIDVALIDITY=2', 'bogus uidvalidity replaced');
is($uri->uidvalidity(13), 13, 'iuid set');
is($$uri, 'imap://0/mmm;UIDVALIDITY=13', 'valid uidvalidity replaced');

$uri = PublicInbox::URIimap->new('imap://0/mmm');
is($uri->uidvalidity(2), 2, 'iuid set');
is($$uri, 'imap://0/mmm;UIDVALIDITY=2', 'uidvalidity appended');
is($uri->iuid, undef, 'no iuid');

is(PublicInbox::URIimap->new('imap://0/x;uidvalidity=1')->canonical->as_string,
	'imap://0/x;UIDVALIDITY=1', 'capitalized UIDVALIDITY');

$uri = PublicInbox::URIimap->new('imap://0/mmm/;uid=8');
is($uri->canonical->as_string, 'imap://0/mmm/;UID=8', 'canonicalized UID');
is($uri->mailbox, 'mmm', 'mailbox works with iuid');
is($uri->iuid, 8, 'iuid extracted');
is($uri->iuid(9), 9, 'iuid set');
is($$uri, 'imap://0/mmm/;UID=9', 'correct iuid when stringified');
is($uri->uidvalidity(1), 1, 'set uidvalidity with iuid');
is($$uri, 'imap://0/mmm;UIDVALIDITY=1/;UID=9',
	'uidvalidity added with iuid');
is($uri->uidvalidity(4), 4, 'set uidvalidity with iuid');
is($$uri, 'imap://0/mmm;UIDVALIDITY=4/;UID=9',
	'uidvalidity replaced with iuid');
is($uri->iuid(3), 3, 'iuid set with uidvalidity');
is($$uri, 'imap://0/mmm;UIDVALIDITY=4/;UID=3', 'iuid replaced properly');

my $lc = lc($$uri);
is(PublicInbox::URIimap->new($lc)->canonical->as_string, "$$uri",
	'canonical uppercased both params');

done_testing;
debug log:

solving ed24fc1b ...
found ed24fc1b in public-inbox.git

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://public-inbox.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.mail.public-inbox.meta
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.mail.public-inbox.meta
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git