File: auth-netrc

package info (click to toggle)
mcds 1.9-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 556 kB
  • sloc: ansic: 1,628; perl: 217; makefile: 65; sh: 57; sed: 16
file content (62 lines) | stat: -rwxr-xr-x 1,352 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
#!/usr/bin/perl

use strict;
use FindBin;
use lib "$FindBin::Bin";
use Mcds::McdsCalypso;

my $tmp = $ENV{'AUTOPKGTEST_TMP'} // File::Temp->newdir();
File::Path::make_path($tmp);
my $mcdsrc = "$tmp/mcdsrc";

my $m = Mcds::McdsCalypso->new(
  {
    'dir' => $tmp,
    'calypso' => { },
  },
  Mcds::McdsCalypso::with_htpasswd($tmp)
);
my ($user, $password) = $m->create_random_user();
my $url = $m->go(["debian/tests/data/contacts.vcf"]);
my $results = shift;
my $reference = undef;
if (!defined $results) {
  $results="$tmp/results";
  $reference="debian/tests/data/reference-simple";
}

my $mcds_config = { '_' => {
  'url' => $url,
  'netrc' => 'yes',
}};
Config::INI::Writer->write_file($mcds_config, $mcdsrc);

# Don't overwrite user's .netrc:
$ENV{'HOME'}="$tmp";

open (my $NETRC, '>', "$ENV{'HOME'}/.netrc");
printf $NETRC <<"EOF";
machine localhost
login $user
password $password

EOF
close $NETRC;
chmod 0600, "$ENV{'HOME'}/.netrc";

printf("netrc:\n");
system("cat $ENV{'HOME'}/.netrc");

!system("mcds -c $mcdsrc King | tee $results") or die "fail";
!system("mcds -c $mcdsrc Kin2 | tee -a $results") or die "fail";

# And a diagnostic run for debugging failures:
system("mcds -v -c $mcdsrc King 2>&1");

$m->stop_server();

if (defined $reference) {
  !system("diff -u $reference $results >&2") or die "results did not match reference";
}