~ubuntu-branches/ubuntu/lucid/wget/lucid-security

« back to all changes in this revision

Viewing changes to tests/FTPTest.pm

  • Committer: Bazaar Package Importer
  • Author(s): Marc Deslauriers
  • Date: 2009-12-12 08:15:59 UTC
  • mfrom: (2.1.5 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091212081559-mvccl4kzdqb138y3
Tags: 1.12-1.1ubuntu1
* Merge from debian testing, remaining changes:
  - Add wget-udeb to ship wget.gnu as alternative to busybox wget
    implementation.
* Keep build dependencies in main:
  - debian/control: remove info2man build-dep
  - debian/patches/00list: disable wget-infopod_generated_manpage.dpatch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl -w
2
 
 
3
1
package FTPTest;
4
2
 
5
3
use strict;
 
4
use warnings;
6
5
 
7
6
use FTPServer;
8
7
use WgetTest;
14
13
{
15
14
    my %_attr_data = ( # DEFAULT
16
15
    );
17
 
    
 
16
 
18
17
    sub _default_for
19
18
    {
20
19
        my ($self, $attr) = @_;
22
21
        return $self->SUPER::_default_for($attr);
23
22
    }
24
23
 
25
 
    sub _standard_keys 
 
24
    sub _standard_keys
26
25
    {
27
26
        my ($self) = @_;
28
27
        ($self->SUPER::_standard_keys(), keys %_attr_data);
29
28
    }
30
29
}
31
 
    
 
30
 
32
31
 
33
32
sub _setup_server {
34
33
    my $self = shift;
35
34
 
36
 
    foreach my $url (keys %{$self->{_input}}) {
37
 
        my $filename = $url;
38
 
        $filename =~ s/^\///;
39
 
        open (FILE, ">$filename")
40
 
            or return "Test failed: cannot open input file $filename\n";
41
 
 
42
 
        print FILE $self->{_input}->{$url}->{content}
43
 
            or return "Test failed: cannot write input file $filename\n";
44
 
 
45
 
        close (FILE);
46
 
    }
 
35
    $self->{_server} = FTPServer->new (input => $self->{_input},
 
36
                                       server_behavior =>
 
37
                                           $self->{_server_behavior},
 
38
                                       LocalAddr => 'localhost',
 
39
                                       ReuseAddr => 1,
 
40
                                       rootDir => "$self->{_workdir}/$self->{_name}/input") or die "Cannot create server!!!";
47
41
}
48
42
 
49
43
 
51
45
    my $self = shift;
52
46
    my $synch_func = shift;
53
47
 
54
 
    my $server = FTPServer->new (LocalAddr => 'localhost',
55
 
                                 LocalPort => '8021',
56
 
                                 ReuseAddr => 1,
57
 
                                 rootDir => "$self->{_workdir}/$self->{_name}/input") or die "Cannot create server!!!";
58
 
    $server->run ($synch_func);
 
48
    $self->{_server}->run ($synch_func);
 
49
}
 
50
 
 
51
sub _substitute_port {
 
52
    my $self = shift;
 
53
    my $ret = shift;
 
54
    $ret =~ s/{{port}}/$self->{_server}->sockport/eg;
 
55
    return $ret;
59
56
}
60
57
 
61
58
1;