se warnings;
use utf8;
use feature qw/state/;
use parent 'WebService::Slack::WebApi::Base';
use JSON;
sub open {
state $rule = Data::Validator->new(
dialog => { isa => 'HashRef', optional
, },
)->with('Method', 'AllowExtra');
my ($self, $args, %extra) = $rule->validate(@_);
$args->{dialog} = encode_json $args->{dialog};
return $self->request('open', { %$args, %extra });
}
1;
coded UTF-8 data as bytes, i.e. with
the internal perl UTF8 flag off, as expected by modules like JSON::XS.
=back
=head1 LMDB::Cursor
To construct a cursor you should call the C<Cursor> method of t
hannels} = join ',', @{$args->{channels}} if exists $args->{channels};
return $self->request_json('completeUploadExternal', {%$args, %extra});
}
# FIXME: maybe be broken... https://github.com/mi
package Test::Smoke::Util::LoadAJSON;
use warnings;
use strict;
our $VERSION = '0.04';
=head1 NAME
Test::Smoke::Util::LoadAJSON - A Cpanel::JSON::XS/JSON:PP/JSON::XS Factory Class
=head1 SYNOPSIS
use Test::Smoke::Util::LoadAJSON;
my $json = Test::Smoke::Util::LoadAJSON->new->utf8->pretty->encode(\%data);
=head1 DESCRIPTION
This is purely a fallback factory class that helps keep our
h a clean perl 5.14+ install that have L<JSON::PP> but not
JSON. Also people that installed L<JSON::XS> on a pre-5.14 system.
Also checks for C<$ENV{PERL_JSON_BACKEND}> to force either of the two.
=
t::Smoke;
require Test::Smoke::PostQueue;
use File::Spec::Functions;
use Test::Smoke::Util::LoadAJSON;
=head1 NAME
Test::Smoke::Poster::Base - Base class for the posters to CoreSmokeDB.
=head1 DES
Named.
=over
=item smokedb_url => $some_url
=item ddir => $smoke_directory
=item jsnfile => $json_file (mktest.jsn)
=item v => $verbosity
=back
=head3 Returns
An instance of the class.
=head
et_json()
=head3 Arguments
None.
=head3 Returns
The json string that was stored in C<< $ddir/$jsnfile >>.
=head3 Exceptions
File I/O.
=cut
sub get_json {
my $self = shift;
my $json_fi
my ($json,$jsontext,$query);
if (exists $config->{opt}->{file}
and my $fname = $config->{opt}->{file}) {
local $/ = undef;
if ($fname eq '-') {
$jsontext =
pen JSON query file '$fname': $!";
$jsontext = <$fh>;
close($fh);
}
}
else {
$jsontext = $ARGV[0];
}
$json = JSON->new();
$query = $json->de
code($jsontext);
return $query;
} # get_query();
sub initialize {
my $config = {};
my $opt = {};
GetOptions($opt, qw(
config|c=s
file|f=s
pretty!
help|
=> $self->ua_timeout) : () ),
);
return $self;
}
=head2 $poster->_post_data()
Post the json to CoreSmokeDB using HTTP::Tiny.
=cut
sub _post_data {
my $self = shift;
$self->log_in
$self->poster);
$self->log_debug("Report data: %s", my $json = $self->get_json);
my $form_data = sprintf("json=%s", uri_escape($json));
my $response = $self->ua->request(
POST =>
onse->{content});
return $response->{content};
}
=head2 $poster->_post_data_api()
Post the json to CoreSmokeDB using HTTP::Tiny, using the API-function.
=cut
sub _post_data_api {
my $self
e Data::Validate::IP qw(is_ipv4);
use Path::Tiny;
use File::XDG;
use POSIX;
use Net::OpenSSH;
use JSON::PP;
use parent 'App::ReslirpTunnel::Logger';
use App::ReslirpTunnel::Butler;
use App::ReslirpT
shell', '-Command', "Get-DnsClientServerAddress | ConvertTo-Json");
my @addrs;
eval {
for my $record (@{JSON::PP::decode_json($out)}) {
if ($record->{InterfaceAlias} eq $if
ses}};
}
}
};
unless (@addrs) {
$self->_warn("Failed to parse JSON output from DnsClientServerAddress", $@);
$self->_log(debug => "Output was", $out);
}
,
verbose => $self->v
);
return $self;
}
=head2 $poster->_post_data()
Post the json to CoreSmokeDB using L<curl(1)>.
=cut
sub _post_data {
my $self = shift;
$self->log_in
$self->poster);
$self->log_debug("Report data: %s", my $json = $self->get_json);
my $form_data = sprintf("json=%s", uri_escape($json));
my ($fh, $filename) = tempfile('curl-tsrepostXXXXXX
oreSmokeDB] %s", $response);
return $response;
}
=head2 $poster->_post_data_api()
Post the json to CoreSmokeDB API-function using L<curl(1)>.
=cut
sub _post_data_api {
my $self = shift;
('smokedb_url') >>
=back
=cut
sub run {
my $self = shift;
$self->check_for_report_and_json;
if ($self->option('mail')) {
$self->{_mailer} = Test::Smoke::Mailer->new(
}
}
=head2 $sendrpt->check_for_report_and_json()
Check for the '.rpt' and the '.jsn' file, return true if both exist.
=cut
sub check_for_report_and_json {
my $self = shift;
my $rptfile =
$self->log_info("Regenerate report and json.");
$self->regen_report_and_json();
}
return 1;
}
=head2 $sendrpt->regen_report_and_json()
Create a reporter object and generate the
1.0-or-later
use 5.014;
use warnings;
use utf8;
our $VERSION = 2.001;
use File::Spec qw();
use JSON::PP qw();
sub dist_dir {
my $class = shift;
my $dist = $class;
$dist =~ s/::/-/g;
ss->dist_dir;
my $json_file = File::Spec->catfile($dist_dir, '_alien', 'alien.json');
open my $in, '<', $json_file
or die "Cannot read $json_file";
my $json = do { local $/; <$in>
};
close $in;
my $config = JSON::PP::decode_json($json);
$config->{distdir} = $dist_dir;
if ($config->{install_type} eq 'share') {
my $inc_dir = File::Spec->catdir($dist_di
ile>: The report that is generated at the end of the run (I<mktest.rpt>).
=item
B<jsnfile>: The json that will be send to the Perl5CoreSmokeDB (I<mktest.jsn>).
=item
B<lfile>: Absolute location of
'html' => 'text/html',
'js' => 'text/javascript',
'json' => 'application/json',
'jsonld' => 'application/ld+json',
'text' => 'text/plain',
);
my %bin_types = (
'bin'
404>).
=item C<$type>
Response type. Must be a text type (C<css>, C<csv>, C<html>, C<js>, C<json>,
C<jsonld>, C<text>), image type (C<jpeg>, C<png>, C<webp>), or the generic
C<bin> binary type (maps
],
general_options => [
adir(),
commit_sha(),
jsonreport(),
max_reports(),
smokedb_url(),
],
special_options
re the JSON report in.',
);
}
sub jsonreport {
return $opt->new(
name => 'jsonreport',
option => '=s',
default => undef,
helptext => "Name of json repor
port',
option => '!',
default => $default,
helptext => "Create the report/json files.",
);
}
sub rptfile {
return $opt->new(
name => 'rptfile',
option
--sha <commit-sha> Commit SHA for the smoke (repeat for more reports)
--jsonreport <filename> The actual json-file to re-post
Override the config:
--adir <dir> Archive directory
the json files from the archive.
=cut
sub pick_reports {
my $self = shift;
if (my $jsonreport = $self->option('jsonreport')) {
die("Cannot find '$jsonreport'") unless -f $jsonrepor
t;
if ($jsonreport =~ m{^ / }x) {
$self->poster->ddir('');
}
else {
$self->poster->ddir(curdir());
}
return ($jsonreport);
}
my
pp::ReslirpTunnel::RPC;
use Socket::MsgHdr;
use IO::Socket::UNIX;
use strict;
use warnings;
use JSON::PP;
use POSIX;
sub new {
my $class = shift;
my $socket = shift;
my $self = \$socket
_bytes($len);
utf8::decode($data);
# warn "Packet received: $data\n";
my $r = JSON::PP::decode_json($data);
return $r;
}
sub _read_bytes {
my ($self, $len) = @_;
my $buf = "";
y ($self, $data) = @_;
my $json = JSON::PP::encode_json($data);
# warn "sending $json\n";
utf8::encode($json);
my $bytes = pack("N", length $json) . $json;
while (length $bytes) {
string(),
%extra_args
);
return $self;
}
=head2 $poster->_post_data()
Post the json to CoreSmokeDB using LWP::UserAgent.
=cut
sub _post_data {
my $self = shift;
$self->lo
$self->log_debug("Report data: %s", my $json = $self->get_json);
my $response = $self->ua->post(
$self->smokedb_url,
{ json => $json }
);
if ( !$response->is_success )
elf->poster);
$self->log_debug("Report data: %s", my $json = $self->get_json);
my $post_data = sprintf(qq/{"report_data": %s}/, $json);
require HTTP::Request;
require HTTP::Headers;
;
use Cwd;
use Encode qw( decode encode );
use File::Spec::Functions;
use Test::Smoke::Util::LoadAJSON;
use POSIX qw( strftime );
use System::Info;
use Test::Smoke::Util qw(
grepccmsg grepnonfatal
end_log send_out user_note/, grep m/^_/ => keys %rpt;
my $json = JSON->new->utf8(1)->pretty(1)->encode(\%rpt);
# write the json to file:
my $jsn_file = catfile($self->{ddir}, $self->{jsn
$json;
close $jsn;
$self->log_info("Write to '%s': ok", $jsn_file);
}
else {
$self->log_warn("Error creating '%s': %s", $jsn_file, $!);
}
return $self->{_json}
"Connection: keep-alive\r\n".
"\r\n"
;
my $big_request =
"POST /jsonrpc_example/json_service/ HTTP/1.1\r\n".
"Host: alx3apps.appspot.com\r\n".
"User-Agent: Mo
.
"Content-Type: application/json-rpc;charset=UTF-8\r\n".
"X-Requested-With: XMLHttpRequest\r\n".
"Referer: http://alx3apps.appspot.com/jsonrpc_example/\r\n".
"Content-
.
"Content-Type: application/json-rpc;charset=UTF-8\r\n".
"X-Requested-With: XMLHttpRequest\r\n".
"Referer: http://alx3apps.appspot.com/jsonrpc_example/\r\n".
"Content-
tring_pp($ex);
# Programmatic API
local Exception::Backtrace::decorator = sub { JSON::XS::encode_json(shift) };
my $bt3 = Exception::Backtrace::get_backtrace($@);
say $bt3->perl_trac