summaryrefslogtreecommitdiff
path: root/lib/JWebmail/Model/ReadMails/MockMaildir.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/JWebmail/Model/ReadMails/MockMaildir.pm')
-rw-r--r--lib/JWebmail/Model/ReadMails/MockMaildir.pm23
1 files changed, 7 insertions, 16 deletions
diff --git a/lib/JWebmail/Model/ReadMails/MockMaildir.pm b/lib/JWebmail/Model/ReadMails/MockMaildir.pm
index fc9cc4a..f9d530f 100644
--- a/lib/JWebmail/Model/ReadMails/MockMaildir.pm
+++ b/lib/JWebmail/Model/ReadMails/MockMaildir.pm
@@ -4,35 +4,26 @@ use Mojo::Base 'JWebmail::Model::ReadMails::QMailAuthuser';
use Mojo::JSON 'decode_json';
-use Digest::HMAC_MD5 'hmac_md5_hex';
+use JWebmail::Config 'LOGIN_SCHEME';
+if (LOGIN_SCHEME eq fc 'cram_md5') {
+ require Digest::HMAC_MD5;
+ Digest::HMAC_MD5->import('hmac_md5_hex');
+}
use constant {
VALID_USER => 'mockmaildir@example.org',
VALID_PW => '12345',
};
-has user => sub { $ENV{USER} };
-has maildir => 't/testdata/';
-has extractor => 'python';
-
-our %EXTRACTORS = (
- perl => 'script/qmauth.pl',
- python => 'script/qmauth.py',
- rust => 'bin/jwebmail-extract',
-);
-
sub new {
my $cls = shift;
my %args = @_ == 1 ? %$_[0] : @_;
my $self = bless {%args}, ref $cls || $cls;
- $self->user;
- $self->maildir;
- $self->next::method(prog => $EXTRACTORS{$self->extractor});
- return $self;
+ return $self->next::method();
}
@@ -56,7 +47,7 @@ sub start_qmauth {
my ($auth, $mode, $args) = @_;
my $mail_user = 'maildir';
- my @exec = ($EXTRACTORS{$self->extractor}, $self->maildir, $self->user, $mail_user, $mode, @$args);
+ my @exec = ($self->{prog}, $self->{mailbox_path}, $self->{virtual_user}, $mail_user, $mode, @$args);
my $pid = open(my $reader, '-|', @exec)
or die "failed to create subprocess: $!";