Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from paultcochrane/pr/avoid-echoing-password-t…
…o-term Avoid echoing password to terminal
- Loading branch information
Showing
4 changed files
with
140 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/usr/bin/env perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Test::More tests => 10; | ||
use Sub::Override; | ||
use Capture::Tiny qw( capture ); | ||
|
||
use Module::Release; | ||
|
||
BEGIN { | ||
use File::Spec; | ||
my $file = File::Spec->catfile( qw(. t lib setup_common.pl) ); | ||
require $file; | ||
} | ||
|
||
my $release = Module::Release->new; | ||
$release->{'preset_field'} = 'preset'; | ||
is( $release->get_env_var('PRESET_FIELD'), | ||
'preset', 'Preset field value returned' ); | ||
|
||
$ENV{'MOO'} = 'baa'; | ||
is( $release->get_env_var('MOO'), | ||
'baa', 'Preset environment variable value returned' ); | ||
|
||
{ | ||
my $terminal_input = | ||
Sub::Override->new( 'Module::Release::_slurp' => sub { "baa\n" } ); | ||
$ENV{'MOO'} = ''; | ||
my ( $stdout, $stderr, @result ) = capture { $release->get_env_var('MOO') }; | ||
is( | ||
$stdout, | ||
'MOO is not set. Enter it now: ', | ||
'Empty environment variable prompts for value' | ||
); | ||
is( $result[0], 'baa', 'Variable read from input' ); | ||
} | ||
|
||
{ | ||
my $terminal_input = | ||
Sub::Override->new( 'Module::Release::_slurp' => sub { "\n" } ); | ||
$ENV{'MOO'} = undef; | ||
$release->turn_debug_on; | ||
my ( $stdout, $stderr, @result ) = capture { $release->get_env_var('MOO') }; | ||
is( | ||
$stdout, | ||
'MOO is not set. Enter it now: ', | ||
'Undef environment variable prompts for value' | ||
); | ||
is( | ||
$stderr, | ||
"MOO not supplied. Aborting...\n", | ||
"Error message about missing variable shown in debug mode" | ||
); | ||
} | ||
|
||
{ | ||
my $terminal_input = | ||
Sub::Override->new( 'Module::Release::_slurp' => sub { "s3cr3t\n" } ); | ||
$ENV{'CPAN_PASS'} = undef; | ||
my ( $stdout, $stderr, @result ) = capture { $release->get_env_var('CPAN_PASS') }; | ||
is( | ||
$stdout, | ||
'CPAN_PASS is not set. Enter it now: ', | ||
'Undef CPAN_PASS variable prompts for value' | ||
); | ||
is( $result[0], 's3cr3t', 'Variable password from input' ); | ||
} | ||
|
||
# vim: expandtab shiftwidth=4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Test::More tests => 3; | ||
use File::Temp qw(:seekable); | ||
|
||
use Module::Release; | ||
|
||
BEGIN { | ||
use File::Spec; | ||
my $file = File::Spec->catfile( qw(. t lib setup_common.pl) ); | ||
require $file; | ||
} | ||
|
||
my $release = Module::Release->new; | ||
my $temp_fh = File::Temp->new; | ||
$temp_fh->write("to be or not to be\n"); | ||
$temp_fh->flush(); | ||
$temp_fh->seek( 0, SEEK_SET ); | ||
|
||
$release->{input_fh} = $temp_fh; | ||
my $input = $release->_slurp; | ||
|
||
is( | ||
$input, | ||
"to be or not to be\n", | ||
'_slurp returns content from input file handle' | ||
); | ||
|
||
# vim: expandtab shiftwidth=4 |