Rename 'redis_server' arg to 'redis'

This commit is contained in:
Jared Johnson 2015-01-23 15:13:56 -06:00
parent 4f9af75e48
commit 462a2ae367
2 changed files with 9 additions and 9 deletions

View File

@ -104,7 +104,7 @@ usable directory from the following list will be used:
=back =back
=head2 redis_server <host[:port]> =head2 redis <host[:port]>
Location of redis server where the greylisting DB will be stored. Location of redis server where the greylisting DB will be stored.
@ -179,7 +179,7 @@ my $VERSION = '0.12';
my $DENYMSG = "This mail is temporarily denied"; my $DENYMSG = "This mail is temporarily denied";
my %PERMITTED_ARGS = map { $_ => 1 } qw(per_recipient remote_ip sender my %PERMITTED_ARGS = map { $_ => 1 } qw(per_recipient remote_ip sender
recipient black_timeout white_timeout deny_late db_dir redis_server recipient black_timeout white_timeout deny_late db_dir redis
nfslock p0f reject loglevel geoip upgrade ); nfslock p0f reject loglevel geoip upgrade );
$PERMITTED_ARGS{grey_timeout} = 1; # Legacy argument now ignored $PERMITTED_ARGS{grey_timeout} = 1; # Legacy argument now ignored
@ -233,7 +233,7 @@ sub register_hooks {
sub init_db { sub init_db {
my ($self) = @_; my ($self) = @_;
return $self->init_redis if $self->{_args}{redis_server}; return $self->init_redis if $self->{_args}{redis};
return $self->init_dbm; return $self->init_dbm;
} }
@ -253,7 +253,7 @@ sub init_redis {
sub parse_redis_server { sub parse_redis_server {
my ($self) = @_; my ($self) = @_;
my $server = $self->{_args}{redis_server}; my $server = $self->{_args}{redis};
return $server if $server =~ /:/; return $server if $server =~ /:/;
return "$server:6379"; return "$server:6379";
} }

View File

@ -285,27 +285,27 @@ sub rc {
sub test_init_redis { sub test_init_redis {
my ($self) = @_; my ($self) = @_;
delete $self->{db}; delete $self->{db};
$self->{_args}{redis_server} = 'bogusserverasdfqwerty.:6379'; $self->{_args}{redis} = 'bogusserverasdfqwerty.:6379';
ok( ! $self->init_redis, 'init_redis() fails on bogus server' ); ok( ! $self->init_redis, 'init_redis() fails on bogus server' );
eval { Qpsmtpd::DB::Redis->new }; eval { Qpsmtpd::DB::Redis->new };
return if $@; return if $@;
$self->{_args}{redis_server} = 'localhost'; $self->{_args}{redis} = 'localhost';
ok( $self->init_redis, 'init_redis() succeeds when redis is up' ); ok( $self->init_redis, 'init_redis() succeeds when redis is up' );
} }
sub test_init_dbm { sub test_init_dbm {
my ($self) = @_; my ($self) = @_;
delete $self->{db}; delete $self->{db};
delete $self->{_args}{redis_server}; delete $self->{_args}{redis};
ok( $self->init_db, 'init_db() works for DBM' ); ok( $self->init_db, 'init_db() works for DBM' );
} }
sub test_parse_redis_server { sub test_parse_redis_server {
my ($self) = @_; my ($self) = @_;
$self->{_args}{redis_server} = 'asdf:1234'; $self->{_args}{redis} = 'asdf:1234';
is( $self->parse_redis_server, 'asdf:1234', is( $self->parse_redis_server, 'asdf:1234',
'parse_redis_server(): leave provided port alone' ); 'parse_redis_server(): leave provided port alone' );
$self->{_args}{redis_server} = 'qwerty'; $self->{_args}{redis} = 'qwerty';
is( $self->parse_redis_server, 'qwerty:6379', is( $self->parse_redis_server, 'qwerty:6379',
'parse_redis_server(): add default port' ); 'parse_redis_server(): add default port' );
} }