[Bps-public-commit] rt-extension-mailgate branch, master, created. 7d6402b1a0d620f937ba578670ccde5bb905e4a6
Chia-liang Kao
clkao at bestpractical.com
Wed Sep 1 12:19:23 EDT 2010
The branch, master has been created
at 7d6402b1a0d620f937ba578670ccde5bb905e4a6 (commit)
- Log -----------------------------------------------------------------
commit 7d6402b1a0d620f937ba578670ccde5bb905e4a6
Author: Chia-liang Kao <clkao at clkao.org>
Date: Thu Sep 2 00:20:51 2010 +0800
initial import
diff --git a/Makefile.PL b/Makefile.PL
new file mode 100644
index 0000000..5dff57e
--- /dev/null
+++ b/Makefile.PL
@@ -0,0 +1,4 @@
+use inc::Module::Install;
+RTx('RT-Extension-MailGate');
+WriteAll();
+
diff --git a/certs/server-cert.pem b/certs/server-cert.pem
new file mode 100644
index 0000000..1fa0d6c
--- /dev/null
+++ b/certs/server-cert.pem
@@ -0,0 +1,62 @@
+Certificate:
+ Data:
+ Version: 3 (0x2)
+ Serial Number:
+ c2:fa:b9:08:d7:a1:e1:a5
+ Signature Algorithm: sha1WithRSAEncryption
+ Issuer: C=US, ST=Local Host, O=Internet Widgits Pty Ltd, CN=localhost
+ Validity
+ Not Before: Feb 18 02:25:22 2007 GMT
+ Not After : Mar 20 02:25:22 2007 GMT
+ Subject: C=US, ST=Local Host, O=Internet Widgits Pty Ltd, CN=localhost
+ Subject Public Key Info:
+ Public Key Algorithm: rsaEncryption
+ RSA Public Key: (1024 bit)
+ Modulus (1024 bit):
+ 00:ab:5c:51:5d:69:66:75:22:2b:d7:4b:5c:63:d3:
+ f4:5e:ab:56:59:41:ac:41:5b:7c:89:42:8e:3b:44:
+ 88:cf:b4:0b:45:46:9e:ac:be:ab:cd:29:31:6b:6c:
+ 98:d6:67:5e:4b:7c:ec:66:6a:34:b8:20:84:21:fd:
+ 63:c5:da:f8:1c:63:68:f0:a4:2d:ca:e0:53:2d:9d:
+ 73:a7:90:88:eb:84:3e:c5:86:34:e1:4b:59:6c:f3:
+ 24:a0:4d:cb:27:85:b2:a2:f2:01:e2:e5:84:78:17:
+ 8a:45:02:41:4c:1a:43:d4:7b:b1:a7:be:b0:0c:db:
+ e4:b3:8b:fa:41:2a:b7:b0:59
+ Exponent: 65537 (0x10001)
+ X509v3 extensions:
+ X509v3 Subject Key Identifier:
+ 49:71:2C:CC:28:DA:84:6C:D7:42:E1:8C:1D:28:BD:0A:CB:4E:7D:38
+ X509v3 Authority Key Identifier:
+ keyid:49:71:2C:CC:28:DA:84:6C:D7:42:E1:8C:1D:28:BD:0A:CB:4E:7D:38
+ DirName:/C=US/ST=Local Host/O=Internet Widgits Pty Ltd/CN=localhost
+ serial:C2:FA:B9:08:D7:A1:E1:A5
+
+ X509v3 Basic Constraints:
+ CA:TRUE
+ Signature Algorithm: sha1WithRSAEncryption
+ 2b:8a:5a:04:15:2c:52:dd:09:e3:5a:2a:8e:37:29:d4:f1:fe:
+ 6d:88:fe:bf:91:84:b9:25:ba:ac:8d:ad:27:30:96:00:79:eb:
+ cb:fa:a0:df:4d:66:ee:9a:96:80:c1:81:49:db:37:86:c8:7c:
+ 16:04:8c:3d:4c:25:c4:0a:94:f5:32:f3:59:67:2c:74:8f:93:
+ f6:b0:8e:3f:d6:49:49:48:a6:49:d1:c8:e6:01:5b:ca:89:a0:
+ 5d:f3:6a:8e:2d:4a:87:31:81:93:93:4d:b2:4d:46:62:f8:35:
+ c1:03:7a:fc:2e:8f:60:59:ff:14:29:52:e2:52:5b:97:50:ab:
+ a7:24
+-----BEGIN CERTIFICATE-----
+MIIC7zCCAligAwIBAgIJAML6uQjXoeGlMA0GCSqGSIb3DQEBBQUAMFkxCzAJBgNV
+BAYTAlVTMRMwEQYDVQQIEwpMb2NhbCBIb3N0MSEwHwYDVQQKExhJbnRlcm5ldCBX
+aWRnaXRzIFB0eSBMdGQxEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0wNzAyMTgwMjI1
+MjJaFw0wNzAzMjAwMjI1MjJaMFkxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpMb2Nh
+bCBIb3N0MSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxEjAQBgNV
+BAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAq1xRXWlm
+dSIr10tcY9P0XqtWWUGsQVt8iUKOO0SIz7QLRUaerL6rzSkxa2yY1mdeS3zsZmo0
+uCCEIf1jxdr4HGNo8KQtyuBTLZ1zp5CI64Q+xYY04UtZbPMkoE3LJ4WyovIB4uWE
+eBeKRQJBTBpD1Huxp76wDNvks4v6QSq3sFkCAwEAAaOBvjCBuzAdBgNVHQ4EFgQU
+SXEszCjahGzXQuGMHSi9CstOfTgwgYsGA1UdIwSBgzCBgIAUSXEszCjahGzXQuGM
+HSi9CstOfTihXaRbMFkxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpMb2NhbCBIb3N0
+MSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxEjAQBgNVBAMTCWxv
+Y2FsaG9zdIIJAML6uQjXoeGlMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQAD
+gYEAK4paBBUsUt0J41oqjjcp1PH+bYj+v5GEuSW6rI2tJzCWAHnry/qg301m7pqW
+gMGBSds3hsh8FgSMPUwlxAqU9TLzWWcsdI+T9rCOP9ZJSUimSdHI5gFbyomgXfNq
+ji1KhzGBk5NNsk1GYvg1wQN6/C6PYFn/FClS4lJbl1CrpyQ=
+-----END CERTIFICATE-----
diff --git a/certs/server-key.pem b/certs/server-key.pem
new file mode 100644
index 0000000..ba600d2
--- /dev/null
+++ b/certs/server-key.pem
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICWwIBAAKBgQCrXFFdaWZ1IivXS1xj0/Req1ZZQaxBW3yJQo47RIjPtAtFRp6s
+vqvNKTFrbJjWZ15LfOxmajS4IIQh/WPF2vgcY2jwpC3K4FMtnXOnkIjrhD7FhjTh
+S1ls8ySgTcsnhbKi8gHi5YR4F4pFAkFMGkPUe7GnvrAM2+Szi/pBKrewWQIDAQAB
+AoGAaEez1A6yJRH4b/oSbUWs7neCAqsuck+ER9tSxsp8HznHqg7BvQoDbsRkqKTb
+lY4uGe4ZxnFXR72x6yVSNDN+zHjP29aSDNRl4Pn8mrQIfAL9hjHVwoi8rmWYjrKa
+hRsfBX+uSyVvcRwum+1xmsEXIMaDLhqI3i7Dj3aEyUIgzAECQQDWCezB/xpGLUur
+GN58deg0a9i1I0MvzTdhiduqjUFUlnrBDcp12bBITpsE5MIwF/+qpIWX7wFr2DR5
+LFBSO/dBAkEAzPR7endHbnF9JQP782g3tN+w7p80QZQY5mfJe6EPjsmAt3hVQ4bY
+A2hxGtCHErbGxjdnkU1bpqz0momlDszLGQJAO5mN5MMtRMdOH7mQEmYen6I8OMw1
+5DSnrDBgC5DD1VMFoYY+jyxryuagge9VJ2E3XwPq81CpO6d7jRZK02tBQQJAKavn
+0z2fU3BVvonx10qwUOFOayYJjO/cpDQj/jQAIssLlcIsq98l2oOIw6f0XrS086Ze
+M2fkI5502Vr1KW4wOQJASDFHxVXz3zN/2d8By93EA1ZuXe5YcX3zzPmpKkIQtO62
+dINHo+M2BYP4Ku3wME++dp4E29BNsIopoLILWHSCow==
+-----END RSA PRIVATE KEY-----
diff --git a/lib/RT/Extension/MailGate.pm b/lib/RT/Extension/MailGate.pm
new file mode 100644
index 0000000..0cf3eb7
--- /dev/null
+++ b/lib/RT/Extension/MailGate.pm
@@ -0,0 +1,7 @@
+use warnings;
+use strict;
+
+package RT::Extension::MailGate;
+our $VERSION = '0.1';
+
+1;
diff --git a/t/basic.t b/t/basic.t
new file mode 100644
index 0000000..331c8f7
--- /dev/null
+++ b/t/basic.t
@@ -0,0 +1,92 @@
+#!/usr/bin/perl -w
+use strict;
+use warnings;
+use Test::More;
+
+use Net::IMAP::Server;
+
+package Demo::IMAP::Auth;
+$INC{'Demo/IMAP/Auth.pm'} = 1;
+use base 'Net::IMAP::Server::DefaultAuth';
+
+sub auth_plain {
+ my ( $self, $user, $pass ) = @_;
+
+ # XXX DO AUTH CHECK
+ $self->user($user);
+ return 1;
+}
+
+package Demo::IMAP::Model;
+$INC{'Demo/IMAP/Model.pm'} = 1;
+use base 'Net::IMAP::Server::DefaultModel';
+
+sub init {
+ my $self = shift;
+ $self->root( Demo::IMAP::Mailbox->new() );
+ $self->root->add_child( name => "INBOX" );
+}
+
+package Demo::IMAP::Mailbox;
+use base qw/Net::IMAP::Server::Mailbox/;
+
+my $data = <<'EOF';
+From: jesse at example.com
+To: contact at example.com
+Subject: This is a test message!
+
+Hello. I am executive assistant to the director of
+Bear Stearns, a failed investment Bank. I have
+access to USD6,000,000. ...
+EOF
+
+my $msg = Net::IMAP::Server::Message->new($data);
+
+sub load_data {
+ my $self = shift;
+ $self->add_message($msg);
+}
+
+
+package main;
+
+BEGIN {
+ $ENV{LC_ALL} = $ENV{LANG} = 'en_US.UTF-8';
+ eval { require Email::Abstract; require Test::Email; 1 }
+ or plan skip_all => 'require Email::Abstract and Test::Email';
+}
+
+use RT;
+use RT::Test tests => 3;
+use RT::Test::Email;
+RT->Config->Set( LogToScreen => 'debug' );
+RT->Config->Set('Plugins',qw(RT::Extension::MailGate));
+
+use_ok('RT::Extension::MailGate');
+
+my $everyone_group = RT::Group->new( $RT::SystemUser );
+$everyone_group->LoadSystemInternalGroup( 'Everyone' );
+ok ($everyone_group->Id, "Found group 'everyone'");
+ok( RT::Test->set_rights(
+ { Principal => $everyone_group->PrincipalObj,
+ Right => [qw(CreateTicket ReplyToTicket CommentOnTicket)],
+ },
+), "Granted everybody the right to create tickets");
+
+warn start_imap();
+
+sleep 1 while 1;
+sub start_imap {
+ if (fork()) {
+ return 'localhost:1143';
+ }
+ Net::IMAP::Server->new(
+ auth_class => "Demo::IMAP::Auth",
+ model_class => "Demo::IMAP::Model",
+ log_level => 4,
+ server_key => 'certs/server-key.pem',
+ server_cert => 'certs/server-cert.pem',
+ port => 1143,
+ ssl_port => 1993
+ )->run();
+}
diff --git a/t/fdm.conf b/t/fdm.conf
new file mode 100644
index 0000000..369fcf7
--- /dev/null
+++ b/t/fdm.conf
@@ -0,0 +1,10 @@
+set lock-file "t/fdm.lock"
+account "test-acconut" imaps server "localhost"
+ port 1993 user "test-account at example.com" pass "test" folder "INBOX"
+
+match "^To:.*contact at example.com" in headers
+ action "rtmail"
+
+action "drop" drop
+action "rtmail" exec "cat"
+
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list