File: LDAPTest.pm

package info (click to toggle)
debconf 1.5.91
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,180 kB
  • sloc: perl: 8,500; sh: 262; python: 182; makefile: 144
file content (88 lines) | stat: -rw-r--r-- 1,596 bytes parent folder | download
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
package LDAPTestSetup;  ## no critic (Modules::RequireFilenameMatchesPackage)

use warnings;
use strict;
use Test::Debconf::DbDriver::SLAPD;
use base qw(Test::Unit::Setup);

# constants
my $tmp_base_dir = "/tmp/debconf-test/debconf/dbdriver/ldap";
my $_SERVER = 'localhost';
my $_PORT = '9009';
my $_LDAPDIR = 'Test/Debconf/DbDriver/ldap';

sub set_up{
	my $self = shift();

	system("mkdir -p $tmp_base_dir") == 0
		or die "Can not create tmp data directory";

	$self->{slapd} = Test::Debconf::DbDriver::SLAPD->new('localhost',9009,$tmp_base_dir);
	$self->{slapd}->slapd_start();
}

sub tear_down{
	my $self = shift();

	$self->{slapd}->slapd_stop();
}

=head1 NAME

  Test::Debconf::DbDriver::LDAPTest - LDAP driver class test

=cut

package Test::Debconf::DbDriver::LDAPTest;
use strict;
use Debconf::DbDriver::LDAP;
use Test::Unit::TestSuite;
use FreezeThaw qw(cmpStr);
use base qw(Test::Debconf::DbDriver::CommonTest);

sub new {
	my $self = shift()->SUPER::new(@_);
	return $self;
}

sub new_driver {
	my $self = shift;

	#
	# start LDAP driver
	#

	my %params = (
		name => "ldapdb",
		server => "$_SERVER",
		port => "$_PORT",
		basedn => "cn=debconf,dc=debian,dc=org",
		binddn => "cn=admin,dc=debian,dc=org",
		bindpasswd => "debian",
	);

	$self->{driver} = Debconf::DbDriver::LDAP->new(%params);
}

sub set_up {
	my $self = shift;

	$self->new_driver();
}

sub tear_down {
	my $self = shift;

	$self->shutdown_driver();
}

sub suite {
	my $self = shift;

	my $testsuite = Test::Unit::TestSuite->new(__PACKAGE__);
	my $wrapper = LDAPTestSetup->new($testsuite);

	return $wrapper;
}

1;