Skip to content
Snippets Groups Projects
Commit 0f511664 authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- fixed HINT output

parent 5d895cda
No related branches found
No related tags found
No related merge requests found
......@@ -35,7 +35,6 @@ BEGIN {
if ($config_path->is_file) {
my $config_ref = YAML::LoadFile($config_path);
if (defined $config_ref->{password}) {
warn "HINT: The password was stored in config file!";
$config_ref->{decrypted_password} = SLUB::LZA::TA::Crypt::decrypt($config_ref->{password});
}
%config = %{$config_ref};
......
......@@ -41,7 +41,7 @@ sub execute {
$config{httponly} = $opt->{httponly};
my $in_test = $ENV{TEST_ACTIVE};
local *IO::Prompt::Tiny::_is_interactive = sub {$in_test}; # fake it for testing
warn "HINT: The password will stored in config file!";
say STDERR "HINT: The password stored in config file!";
my $user = prompt('User:');
RETRY:
my $passwd1 = prompt('Password:', -echo => "*");
......@@ -50,9 +50,6 @@ RETRY:
say "you typed different passwords, retry";
goto RETRY;
}
say "user: $user";
say "pw1: $passwd1";
say "pw2: $passwd2";
$config{user} = "$user";
$config{password} = SLUB::LZA::TA::Crypt::encrypt("$passwd1");
if (defined $SLUB::LZA::TA::config_file) {
......
......@@ -14,6 +14,6 @@ my $testapp = Test::Cmd->new(
ok($testapp, "init 'ta-tool'");
$testapp->run(args =>'--help');
like($testapp->stdout, qr/Available commands:/, 'ta-tool --help, stdout');
like($testapp->stderr, qr/HINT:/, 'ta-tool --help, stderr');
like($testapp->stderr, qr/^$/, 'ta-tool --help, stderr');
is($? >> 8, 0, 'ta-tool --help, exit status');
1;
......@@ -33,7 +33,7 @@ $testapp->run(args =>'count --lzaid SLUB:LZA:goobi:1 --debug');
#say "STDOUT:",$testapp->stdout;
#say "STDERR:",$testapp->stderr;
like($testapp->stdout, qr//, 'ta-tool count by lzaid, wrong format, stdout');
like($testapp->stderr, qr/HINT:.*Error: --[a-z].* expects.*Usage/s, 'ta-tool count by lzaid, wrong format, stderr');
like($testapp->stderr, qr/Error: --[a-z].* expects.*Usage/s, 'ta-tool count by lzaid, wrong format, stderr');
isnt($? >> 8, 0, 'ta-tool count by lzaid, wrong format, exit status');
#note "elastic count non-existing lza id";
......@@ -41,13 +41,13 @@ isnt($? >> 8, 0, 'ta-tool count by lzaid, wrong format, exit status');
#say "STDOUT:",$testapp->stdout;
#say "STDERR:",$testapp->stderr;
#like($testapp->stdout, qr/must=/, 'ta-tool count by lzaid, no match, stdout');
#like($testapp->stderr, qr/HINT:/, 'ta-tool count by lzaid, no match, stderr');
#like($testapp->stderr, qr/^$/, 'ta-tool count by lzaid, no match, stderr');
#is($? >> 8, 0, 'ta-tool count by lzaid, no match, exit status');
#$testapp->run(args =>'count --lzaid SLUB:LZA:goobi:1');
#like($testapp->stdout, qr/must=/, 'ta-tool count by lzaid, no match, stdout');
#like($testapp->stderr, qr/HINT:/, 'ta-tool count by lzaid, no match, stderr');
#like($testapp->stderr, qr/^$/, 'ta-tool count by lzaid, no match, stderr');
#is($? >> 8, 0, 'ta-tool count by lzaid, no match, exit status');
note "elastic count existing lza id";
......@@ -55,14 +55,14 @@ $testapp->run(args =>'count --lzaid SLUB:LZA:testworkflow:testcases:test-sip_202
#say "STDOUT:",$testapp->stdout;
#say "STDERR:",$testapp->stderr;
like($testapp->stdout, qr/must=.*\n1\n/s, 'ta-tool count by lzaid, existing, stdout');
like($testapp->stderr, qr/HINT:/, 'ta-tool count by lzaid, existing, stderr');
like($testapp->stderr, qr/^$/, 'ta-tool count by lzaid, existing, stderr');
is($? >> 8, 0, 'ta-tool count by lzaid, no match, exit status');
$testapp->run(args =>'count --lzaid SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111');
#say "STDOUT:",$testapp->stdout;
#say "STDERR:",$testapp->stderr;
like($testapp->stdout, qr/^1$/s, 'ta-tool count by lzaid, existing, stdout');
like($testapp->stderr, qr/HINT:/, 'ta-tool count by lzaid, existing, stderr');
like($testapp->stderr, qr/^$/, 'ta-tool count by lzaid, existing, stderr');
is($? >> 8, 0, 'ta-tool count by lzaid, existing, exit status');
note "elastic count existing dc entry";
......@@ -70,7 +70,7 @@ $testapp->run(args =>'count --descriptive "Retrodigitalisierte Fotosn"');#SLUB:L
#say "STDOUT:",$testapp->stdout;
#say "STDERR:",$testapp->stderr;
like($testapp->stdout, qr/^30$/, 'ta-tool count by dc, existing, stdout');
like($testapp->stderr, qr/HINT:/, 'ta-tool count by dc, existing, stderr');
like($testapp->stderr, qr/^$/, 'ta-tool count by dc, existing, stderr');
is($? >> 8, 0, 'ta-tool count by lzaid, existing, exit status');
......
......@@ -30,7 +30,7 @@ _CFG_
note "elastic search version";
$testapp->run(args =>'info --target-version');
like($testapp->stdout, qr/^6\.\d\.\d{1,2}$/, 'ta-tool elasticsearch version, stdout');
like($testapp->stderr, qr/HINT:/, 'ta-tool elasticsearch version, stderr');
like($testapp->stderr, qr/^$/, 'ta-tool elasticsearch version, stderr');
is($? >> 8, 0, 'ta-tool elasticsearch version, exit status');
......
......@@ -32,7 +32,7 @@ $testapp->run(args =>'search --lzaid SLUB:LZA:goobi:1 --debug');
#say "STDOUT:",$testapp->stdout;
#say "STDERR:",$testapp->stderr;
like($testapp->stdout, qr//, 'ta-tool search by lzaid, wrong format, stdout');
like($testapp->stderr, qr/HINT:.*Error: --[a-z].* expects.*Usage/s, 'ta-tool search by lzaid, wrong format, stderr');
like($testapp->stderr, qr/^$.*Error: --[a-z].* expects.*Usage/s, 'ta-tool search by lzaid, wrong format, stderr');
isnt($? >> 8, 0, 'ta-tool search by lzaid, wrong format, exit status');
......@@ -41,12 +41,12 @@ $testapp->run(args =>'search --lzaid SLUB:LZA:Goobi:goobi:1 --debug');
say "STDOUT:",$testapp->stdout;
say "STDERR:",$testapp->stderr;
like($testapp->stdout, qr/must=/, 'ta-tool search by lzaid, no match, stdout');
like($testapp->stderr, qr/HINT:/, 'ta-tool search by lzaid, no match, stderr');
like($testapp->stderr, qr/^$/, 'ta-tool search by lzaid, no match, stderr');
is($? >> 8, 0, 'ta-tool search by lzaid, no match, exit status');
$testapp->run(args =>'search --lzaid SLUB:LZA:Goobi:goobi:1');
like($testapp->stdout, qr/\A\s*\Z/s, 'ta-tool search by lzaid, no match, stdout');
like($testapp->stderr, qr/HINT:/, 'ta-tool search by lzaid, no match, stderr');
like($testapp->stderr, qr/^$/, 'ta-tool search by lzaid, no match, stderr');
is($? >> 8, 0, 'ta-tool search by lzaid, no match, exit status');
note "elastic search existing lza id";
......@@ -54,14 +54,14 @@ $testapp->run(args =>'search --lzaid SLUB:LZA:testworkflow:testcases:test-sip_20
#say "STDOUT:",$testapp->stdout;
#say "STDERR:",$testapp->stderr;
like($testapp->stdout, qr/query=.*aipid\n47daf26a-02a1-4776-a8db-de04c6708bd2\Z/s, 'ta-tool search by lzaid, existing, stdout');
like($testapp->stderr, qr/HINT:/, 'ta-tool search by lzaid, existing, stderr');
like($testapp->stderr, qr/^$/, 'ta-tool search by lzaid, existing, stderr');
is($? >> 8, 0, 'ta-tool search by lzaid, no match, exit status');
$testapp->run(args =>'search --lzaid SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111');
#say "STDOUT:",$testapp->stdout;
#say "STDERR:",$testapp->stderr;
like($testapp->stdout, qr/\Aaipid\n47daf26a-02a1-4776-a8db-de04c6708bd2\Z/s, 'ta-tool search by lzaid, existing, stdout');
like($testapp->stderr, qr/HINT:/, 'ta-tool search by lzaid, existing, stderr');
like($testapp->stderr, qr/^$/, 'ta-tool search by lzaid, existing, stderr');
is($? >> 8, 0, 'ta-tool search by lzaid, existing, exit status');
note "elastic search existing dc entry";
......@@ -69,7 +69,7 @@ $testapp->run(args =>'search --descriptive "Retrodigitalisierte Fotosn"');#SLUB:
#say "STDOUT:",$testapp->stdout;
#say "STDERR:",$testapp->stderr;
like($testapp->stdout, qr/\Aaipid\n6ae5f1f0-5306-404f-8fb7-445f82416932\n9a254f9d-1c19-478a-aacb-43be3a3c7d9d\n.*4f7516e4-23c8-4750-a411-91359fb7a869\Z/s, 'ta-tool search by dc, existing, stdout');
like($testapp->stderr, qr/HINT:/, 'ta-tool search by dc, existing, stderr');
like($testapp->stderr, qr/^$/, 'ta-tool search by dc, existing, stderr');
is($? >> 8, 0, 'ta-tool search by lzaid, existing, exit status');
note "check output formats";
......@@ -77,21 +77,21 @@ $testapp->run(args =>'search --output-as-raw --lzaid SLUB:LZA:testworkflow:testc
#say "STDOUT:",$testapp->stdout;
#say "STDERR:",$testapp->stderr;
like($testapp->stdout, qr/\A\{\n\s*hits\s*\{\n\s*hits\s*\[\n/s, 'ta-tool search, raw output, stdout');
like($testapp->stderr, qr/HINT:/, 'ta-tool search, raw output, stderr');
like($testapp->stderr, qr/^$/, 'ta-tool search, raw output, stderr');
is($? >> 8, 0, 'ta-tool search, raw output, exit status');
$testapp->run(args =>'search --output-as-csv --lzaid SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111 --with-lzaid' );
#say "STDOUT:",$testapp->stdout;
#say "STDERR:",$testapp->stderr;
like($testapp->stdout, qr/\Aaipid,slubarchiv_lzaid\n47daf26a-02a1-4776-a8db-de04c6708bd2,SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111\Z/s, 'ta-tool search, CSV output, stdout');
like($testapp->stderr, qr/HINT:/, 'ta-tool search, CSV output, stderr');
like($testapp->stderr, qr/^$/, 'ta-tool search, CSV output, stderr');
is($? >> 8, 0, 'ta-tool search, CSV output, exit status');
$testapp->run(args =>'search --output-as-rsv --lzaid SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111 --with-lzaid' );
#say "STDOUT:",$testapp->stdout;
#say "STDERR:",$testapp->stderr;
like($testapp->stdout, qr/\Aaipid\x{ff}slubarchiv_lzaid\x{ff}\x{fd}47daf26a-02a1-4776-a8db-de04c6708bd2\x{ff}SLUB:LZA:testworkflow:testcases:test-sip_2023-01-01-11_11-11_11111\x{ff}\x{fd}\Z/s, 'ta-tool search, RSV output, stdout');
like($testapp->stderr, qr/HINT:/, 'ta-tool search, RSV output, stderr');
like($testapp->stderr, qr/^$/, 'ta-tool search, RSV output, stderr');
is($? >> 8, 0, 'ta-tool search, RSV output, exit status');
note "check with-options";
......@@ -122,7 +122,7 @@ foreach my $with (qw(
#say "STDOUT:",$testapp->stdout;
#say "STDERR:",$testapp->stderr;
like($testapp->stdout, qr/\Aaipid,$head\n47daf26a-02a1-4776-a8db-de04c6708bd2,[A-Za-zäöüßÄÖÜ0-9_:. -]*\Z/s, 'ta-tool search, check "'.$with_opt.'", stdout');
like($testapp->stderr, qr/HINT:/, 'ta-tool search, "'.$with_opt.'", stderr');
like($testapp->stderr, qr/^$/, 'ta-tool search, "'.$with_opt.'", stderr');
is($? >> 8, 0, 'ta-tool search, "'.$with_opt.'", exit status');
}
note "search by files";
......@@ -130,7 +130,7 @@ $testapp->run(args =>'search --pronom-id fmt/101');
#say "STDOUT:",$testapp->stdout;
#say "STDERR:",$testapp->stderr;
like($testapp->stdout, qr/\Aaipid\n9477ac73-8b3e-4939-af36-8d5dea8606fa\na636edf2-d82f-41ee-a435-f3e50e48d6cc\n9e6d4792-c5b0-4f38-8ade-8468124cc6f4\Z/s, 'ta-tool search by pronom-id, existing, stdout');
like($testapp->stderr, qr/HINT:/, 'ta-tool search by pronom-id, existing, stderr');
like($testapp->stderr, qr/^$/, 'ta-tool search by pronom-id, existing, stderr');
is($? >> 8, 0, 'ta-tool search by pronom-id, existing, exit status');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment