# Copyright (c) 2006 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: RealmMailBounce.bunit,v 1.2 2011/02/06 16:52:05 nagler Exp $ Request('initialize_fully', 'MAIL_RECEIVE_DISPATCH'); req()->set_realm('demo'); req()->set_user('demo'); my($rfid); my($email); my($uid) = req('auth_user_id'); my($compute) = sub { my($case, $params) = @_; my($m) = Bivio::Biz::Model->new(req(), 'RealmMail'); $m->create_from_rfc822(\(<<'EOF')); From: a@a.a Message-ID: Date: Sun, 1 May 2005 10:11:41 -0600 Subject: s B EOF req()->set_realm($uid); my($rmb) = class()->new(req()); $rfid = $m->get('realm_file_id'); $email = $m->new_other('Email')->load->get('email'); $rmb->new_other('MailReceiveDispatchForm')->execute(req(), { recipient => $rmb->return_path( req()->get('auth_id'), $email, $rfid, ), client_addr => '1.2.3.4', message => { name => '', content => \(<<'EOF'), From MAILER-DAEMON@bivio.biz Sun Feb 26 06:02:39 2006 Return-Path: Date: Sun, 26 Feb 2006 06:02:38 -0700 From: Mail Delivery Subsystem Message-Id: <200602261302.k1QD2cv23383@bivio.biz> To: postmaster@bivio.biz MIME-Version: 1.0 Content-Type: multipart/report; report-type=delivery-status; boundary="k1QD2cv23383.1140958958/bivio.biz" Subject: Postmaster notify: see transcript for details Auto-Submitted: auto-generated (postmaster-notification) This is a MIME-encapsulated message --k1QD2cv23383.1140958958/bivio.biz The original message was received at Sun, 26 Feb 2006 06:02:38 -0700 from localhost with id k1QD2cu23383 ----- The following addresses had permanent fatal errors ----- no-such-user@bivio.biz (reason: addressee unknown) ----- Transcript of session follows ----- Error: User Not Found 550 5.1.1 no-such-user@bivio.biz... User unknown --k1QD2cv23383.1140958958/bivio.biz Content-Type: message/delivery-status Reporting-MTA: dns; bivio.biz Arrival-Date: Sun, 26 Feb 2006 06:02:38 -0700 Final-Recipient: RFC822; no-such-user@bivio.biz Action: failed Status: 5.1.1 Diagnostic-Code: X-Unix; 67 Last-Attempt-Date: Sun, 26 Feb 2006 06:02:38 -0700 --k1QD2cv23383.1140958958/bivio.biz Content-Type: message/rfc822 Return-Path: Date: Sun, 26 Feb 2006 06:02:38 -0700 From: from-user@example.com Message-Id: <200602261302.k1QD2cu23383@bivio.biz> To: no-such-user@bivio.biz Subject: Here ya go bla --k1QD2cv23383.1140958958/bivio.biz-- EOF }, }); return [req()]; }; [{ object => sub { class(); }, } => [ execute => [ $compute => sub { assert_equals( [$rfid, $email, 'addressee unknown'], [req(class())->get(qw(realm_file_id email reason))], ); assert_equals( 1, model('RealmUser')->rows_exist({user_id => $uid}), ); return 1; }, sub { req()->set_realm('bulletin'); req()->set_user( $uid = ShellUtil_TestUser() ->create( $email = email(random_string()), ), ); ShellUtil_RealmAdmin()->join_user(qw(MAIL_RECIPIENT MEMBER)); return $compute->(); } => sub { req()->set_realm('bulletin'); assert_equals( 0, model('RealmUser')->rows_exist({user_id => $uid}), ); return 1; }, ], ]];